|
|
@@ -269,7 +269,7 @@ export default {
|
|
|
'Arial=arial,helvetica,sans-serif;' +
|
|
|
'Times New Roman=times new roman,times,serif;' +
|
|
|
'拼音=League;',
|
|
|
- fontsize_formats: '8pt 10pt 11pt 12pt 14pt 16pt 18pt 20pt 22pt 24pt 26pt 28pt 30pt 32pt 34pt 36pt',
|
|
|
+ fontsize_formats: '8pt 10pt 12pt 14pt 16pt 18pt 20pt 22pt 24pt 26pt 28pt 30pt 32pt 34pt 36pt',
|
|
|
// 字数限制
|
|
|
ax_wordlimit_num: this.wordlimitNum,
|
|
|
ax_wordlimit_callback(editor) {
|
|
|
@@ -702,8 +702,9 @@ export default {
|
|
|
return str.replace(/<span\b[^>]*>(.*?)<\/span>/gi, '$1');
|
|
|
},
|
|
|
createParsedTextInfoPinyin(content) {
|
|
|
+ var styles = this.getFirstCharStyles();
|
|
|
let text = content.replace(/<[^>]+>/g, '');
|
|
|
- this.$emit('createParsedTextInfoPinyin', text);
|
|
|
+ this.$emit('createParsedTextInfoPinyin', text, styles);
|
|
|
},
|
|
|
handleRichTextBlur() {
|
|
|
this.$emit('handleRichTextBlur', this.itemIndex);
|
|
|
@@ -816,7 +817,7 @@ export default {
|
|
|
if (eleMathArs.length === 0) return;
|
|
|
await this.$nextTick();
|
|
|
window.MathJax.typesetPromise(eleMathArs).catch((err) =>
|
|
|
- /* eslint-disable */ console.error(...oo_tx(`483836707_818_65_818_101_11`, 'MathJax error:', err)),
|
|
|
+ /* eslint-disable */ console.error(...oo_tx(`483836707_818_65_818_101_11`, 'MathJax error:', err))
|
|
|
);
|
|
|
this.mathEleIsInit = true;
|
|
|
}
|
|
|
@@ -904,6 +905,73 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
+ getFirstCharStyles() {
|
|
|
+ const editor = tinymce.activeEditor;
|
|
|
+ if (!editor) return {};
|
|
|
+
|
|
|
+ const firstTextNode = this.findFirstTextNode(editor.getBody());
|
|
|
+ if (!firstTextNode) return {};
|
|
|
+
|
|
|
+ const styles = {};
|
|
|
+ let element = firstTextNode.parentElement;
|
|
|
+
|
|
|
+ while (element && element !== editor.getBody().parentElement) {
|
|
|
+ const computed = window.getComputedStyle(element);
|
|
|
+
|
|
|
+ if (!styles.fontFamily && computed.fontFamily && computed.fontFamily !== 'inherit') {
|
|
|
+ styles.fontFamily = computed.fontFamily;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!styles.fontSize && computed.fontSize && computed.fontSize !== 'inherit') {
|
|
|
+ const fontSize = computed.fontSize;
|
|
|
+ const pxValue = parseFloat(fontSize);
|
|
|
+ if (!isNaN(pxValue)) {
|
|
|
+ // px转pt公式:pt = px * 3/4
|
|
|
+ const ptValue = Math.round(pxValue * 0.75 * 10) / 10;
|
|
|
+ styles.fontSize = ptValue + 'pt';
|
|
|
+ } else {
|
|
|
+ styles.fontSize = fontSize;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!styles.color && computed.color && computed.color !== 'inherit') {
|
|
|
+ styles.color = computed.color;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!styles.bold && (computed.fontWeight === 'bold' || computed.fontWeight === '700')) {
|
|
|
+ styles.bold = true;
|
|
|
+ styles.fontWeight = 'bold';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!styles.underline && computed.textDecoration.includes('underline')) {
|
|
|
+ styles.underline = true;
|
|
|
+ styles.textDecoration = 'underline';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!styles.strikethrough && computed.textDecoration.includes('line-through')) {
|
|
|
+ styles.strikethrough = true;
|
|
|
+ styles.textDecoration = 'line-through';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Object.keys(styles).length >= 6) break;
|
|
|
+
|
|
|
+ element = element.parentElement;
|
|
|
+ }
|
|
|
+ return styles;
|
|
|
+ },
|
|
|
+
|
|
|
+ findFirstTextNode(element) {
|
|
|
+ const walker = document.createTreeWalker(
|
|
|
+ element,
|
|
|
+ NodeFilter.SHOW_TEXT,
|
|
|
+ {
|
|
|
+ acceptNode: (node) => (node.textContent.trim() ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT),
|
|
|
+ },
|
|
|
+ false
|
|
|
+ );
|
|
|
+ return walker.nextNode();
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|