|
|
@@ -1399,6 +1399,45 @@ export default {
|
|
|
});
|
|
|
return walker.nextNode();
|
|
|
},
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取富文本body元素的初始样式信息
|
|
|
+ * @returns {object} 包含字体、字号、颜色等body初始样式属性的对象
|
|
|
+ */
|
|
|
+ getBodyInitialStyles() {
|
|
|
+ const editor = tinymce.activeEditor;
|
|
|
+ if (!editor) return {};
|
|
|
+
|
|
|
+ const body = editor.getBody();
|
|
|
+ if (!body) return {};
|
|
|
+
|
|
|
+ const computed = window.getComputedStyle(body);
|
|
|
+ const styles = {};
|
|
|
+
|
|
|
+ // 获取字体家族
|
|
|
+ if (computed.fontFamily && computed.fontFamily !== 'inherit') {
|
|
|
+ styles.fontFamily = computed.fontFamily;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取字体大小(px转pt)
|
|
|
+ if (computed.fontSize && computed.fontSize !== 'inherit') {
|
|
|
+ const fontSize = computed.fontSize;
|
|
|
+ const pxValue = parseFloat(fontSize);
|
|
|
+ if (!isNaN(pxValue)) {
|
|
|
+ const ptValue = Math.round(pxValue * 0.75 * 10) / 10;
|
|
|
+ styles.fontSize = `${ptValue}pt`;
|
|
|
+ } else {
|
|
|
+ styles.fontSize = fontSize;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取字体颜色
|
|
|
+ if (computed.color && computed.color !== 'inherit' && computed.color !== 'rgb(0, 0, 0)') {
|
|
|
+ styles.color = computed.color;
|
|
|
+ }
|
|
|
+
|
|
|
+ return styles;
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|