|
@@ -208,8 +208,8 @@ export default {
|
|
'Arial=arial,helvetica,sans-serif;' +
|
|
'Arial=arial,helvetica,sans-serif;' +
|
|
'Times New Roman=times new roman,times,serif;' +
|
|
'Times New Roman=times new roman,times,serif;' +
|
|
'拼音=League;',
|
|
'拼音=League;',
|
|
- // 字数限制
|
|
|
|
fontsize_formats: '8pt 10pt 11pt 12pt 14pt 16pt 18pt 20pt 22pt 24pt 26pt 28pt 30pt 32pt 34pt 36pt',
|
|
fontsize_formats: '8pt 10pt 11pt 12pt 14pt 16pt 18pt 20pt 22pt 24pt 26pt 28pt 30pt 32pt 34pt 36pt',
|
|
|
|
+ // 字数限制
|
|
ax_wordlimit_num: this.wordlimitNum,
|
|
ax_wordlimit_num: this.wordlimitNum,
|
|
ax_wordlimit_callback(editor) {
|
|
ax_wordlimit_callback(editor) {
|
|
editor.execCommand('undo');
|
|
editor.execCommand('undo');
|
|
@@ -283,6 +283,56 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
/**
|
|
/**
|
|
|
|
+ * 判断内容是否全部加粗
|
|
|
|
+ */
|
|
|
|
+ isAllBold() {
|
|
|
|
+ let editor = tinymce.get(this.id);
|
|
|
|
+ let body = editor.getBody();
|
|
|
|
+ function getTextNodes(node) {
|
|
|
|
+ let textNodes = [];
|
|
|
|
+ if (node.nodeType === 3 && node.nodeValue.trim() !== '') {
|
|
|
|
+ textNodes.push(node);
|
|
|
|
+ } else {
|
|
|
|
+ for (let child of node.childNodes) {
|
|
|
|
+ textNodes = textNodes.concat(getTextNodes(child));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return textNodes;
|
|
|
|
+ }
|
|
|
|
+ let textNodes = getTextNodes(body);
|
|
|
|
+ if (textNodes.length === 0) return false;
|
|
|
|
+ return textNodes.every((node) => {
|
|
|
|
+ let el = node.parentElement;
|
|
|
|
+ while (el && el !== body) {
|
|
|
|
+ const tag = el.tagName.toLowerCase();
|
|
|
|
+ const fontWeight = window.getComputedStyle(el).fontWeight;
|
|
|
|
+ if (tag === 'b' || tag === 'strong' || fontWeight === 'bold' || parseInt(fontWeight) >= 600) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ el = el.parentElement;
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ /**
|
|
|
|
+ * 设置整体富文本格式
|
|
|
|
+ * @param {string} text 格式名称
|
|
|
|
+ */
|
|
|
|
+ setRichFormat(text) {
|
|
|
|
+ let editor = tinymce.get(this.id);
|
|
|
|
+ editor.execCommand('SelectAll');
|
|
|
|
+ if (text === 'bold') {
|
|
|
|
+ if (this.isAllBold()) {
|
|
|
|
+ editor.formatter.remove('bold');
|
|
|
|
+ } else {
|
|
|
|
+ editor.formatter.apply('bold');
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ editor.formatter.toggle(text);
|
|
|
|
+ }
|
|
|
|
+ editor.selection.collapse(false);
|
|
|
|
+ },
|
|
|
|
+ /**
|
|
* 图片上传自定义逻辑函数
|
|
* 图片上传自定义逻辑函数
|
|
* @param {object} blobInfo 文件数据
|
|
* @param {object} blobInfo 文件数据
|
|
* @param {Function} success 成功回调函数
|
|
* @param {Function} success 成功回调函数
|
|
@@ -502,9 +552,7 @@ export default {
|
|
.map((item) => {
|
|
.map((item) => {
|
|
if (/<[^>]+>/g.test(item)) return item;
|
|
if (/<[^>]+>/g.test(item)) return item;
|
|
return item
|
|
return item
|
|
- .map((li) =>
|
|
|
|
- li.map(({ number, con }) => (number && con ? addTone(Number(number), con) : number || con || '')),
|
|
|
|
- )
|
|
|
|
|
|
+ .map(({ number, con }) => (number && con ? addTone(Number(number), con) : number || con || ''))
|
|
.flat();
|
|
.flat();
|
|
})
|
|
})
|
|
// 如果是数组,将数组字符串每两个之间加一个空格
|
|
// 如果是数组,将数组字符串每两个之间加一个空格
|
|
@@ -541,7 +589,7 @@ export default {
|
|
this.isShow = true;
|
|
this.isShow = true;
|
|
this.contentmenu = {
|
|
this.contentmenu = {
|
|
left: `${pixelsFromLeft + 14}px`,
|
|
left: `${pixelsFromLeft + 14}px`,
|
|
- top: `${pixelsFromTop - 18}px`,
|
|
|
|
|
|
+ top: `${pixelsFromTop + 22}px`,
|
|
};
|
|
};
|
|
},
|
|
},
|
|
|
|
|