Merge branch 'master' of https://git.nuttyreading.com/wangjinlei/tougao_web into Editorial-Board
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="tinymce-container">
|
<div class="tinymce-container">
|
||||||
|
|
||||||
|
<i class="el-icon-copy-document" @click="handleCopy" v-if="displayValue&&readonly" style="margin-top: -30px;float: right;margin-bottom: 10px;cursor: pointer;"></i>
|
||||||
|
<div style="clear: both;"></div>
|
||||||
<div v-if="readonly" v-html="displayValue" class="readonly-content">
|
<div v-if="readonly" v-html="displayValue" class="readonly-content">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -96,6 +97,41 @@ beforeDestroy() {
|
|||||||
|
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
handleCopy() {
|
||||||
|
|
||||||
|
|
||||||
|
if (this.displayValue) {
|
||||||
|
// 1. 使用正则匹配 <wmath ... data-latex="内容" ...>...</wmath>
|
||||||
|
// 这里的正则会精准提取 data-latex 属性中的值
|
||||||
|
const cleanValue = this.displayValue.replace(/<wmath[^>]*data-latex="([^"]*)"[^>]*>[\s\S]*?<\/wmath>/g, '$1');
|
||||||
|
|
||||||
|
// 2. 如果你还想顺便把 <br> 转换成换行符,可以加上这一行:
|
||||||
|
const finalValue = cleanValue.replace(/<br\s*\/?>/gi, '\n');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 3. 执行复制到剪贴板的操作
|
||||||
|
this.copyToClipboard(finalValue);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
copyToClipboard(text) {
|
||||||
|
// 兼容性较好的复制方法
|
||||||
|
const textArea = document.createElement("textarea");
|
||||||
|
textArea.value = text;
|
||||||
|
document.body.appendChild(textArea);
|
||||||
|
textArea.select();
|
||||||
|
try {
|
||||||
|
document.execCommand('copy');
|
||||||
|
this.$message({
|
||||||
|
message: 'Successfully copied to clipboard!',
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error('无法复制', err);
|
||||||
|
}
|
||||||
|
document.body.removeChild(textArea);
|
||||||
|
},
|
||||||
destroyTinymce() {
|
destroyTinymce() {
|
||||||
this.displayValue=null
|
this.displayValue=null
|
||||||
// 通过 window.tinymce 获取全局对象,根据 id 找到并销毁
|
// 通过 window.tinymce 获取全局对象,根据 id 找到并销毁
|
||||||
|
|||||||
Reference in New Issue
Block a user