|
|
@@ -398,6 +398,8 @@ Vue.component('spaceEditor', {
|
|
|
_emitEditorHtmlTimer: undefined,
|
|
|
_enhancePdfTimer: undefined,
|
|
|
_pdfEnhancing: false,
|
|
|
+ defaultEditorFontFamily: "'仿宋_GB2312', 'FangSong_GB2312', FangSong, serif",
|
|
|
+ defaultEditorFontSize: "20pt",
|
|
|
}
|
|
|
},
|
|
|
name: "spaceEditor",
|
|
|
@@ -2477,7 +2479,7 @@ Vue.component('spaceEditor', {
|
|
|
if (result.messages && result.messages.length) {
|
|
|
wordUi.showMessage('warning', 'Word 已导入,少量复杂格式可能需要人工检查。');
|
|
|
} else {
|
|
|
- wordUi.showMessage('success', 'Word 文件已导入正文,并尽量保留原文档格式。');
|
|
|
+ wordUi.showMessage('success', 'Word 文件已导入正文,原有字体和字号已尽量保留;未指定格式的文字使用仿宋_GB2312、20pt。');
|
|
|
}
|
|
|
}.bind(this))
|
|
|
.catch(function (error) {
|
|
|
@@ -2580,10 +2582,22 @@ Vue.component('spaceEditor', {
|
|
|
return;
|
|
|
}
|
|
|
var computed = window.getComputedStyle(parent);
|
|
|
+ var explicitFontFamily = "";
|
|
|
+ var explicitFontSize = "";
|
|
|
+ var fontNode = parent;
|
|
|
+ while (fontNode && fontNode != wrapper) {
|
|
|
+ if (!explicitFontFamily && fontNode.style && fontNode.style.fontFamily) {
|
|
|
+ explicitFontFamily = fontNode.style.fontFamily;
|
|
|
+ }
|
|
|
+ if (!explicitFontSize && fontNode.style && fontNode.style.fontSize) {
|
|
|
+ explicitFontSize = fontNode.style.fontSize;
|
|
|
+ }
|
|
|
+ fontNode = fontNode.parentElement;
|
|
|
+ }
|
|
|
var formattedSpan = document.createElement('span');
|
|
|
formattedSpan.setAttribute('data-word-format', 'true');
|
|
|
- formattedSpan.style.fontFamily = computed.fontFamily;
|
|
|
- formattedSpan.style.fontSize = computed.fontSize;
|
|
|
+ formattedSpan.style.fontFamily = explicitFontFamily || this.defaultEditorFontFamily;
|
|
|
+ formattedSpan.style.fontSize = explicitFontSize || this.defaultEditorFontSize;
|
|
|
formattedSpan.style.color = computed.color;
|
|
|
if (computed.fontWeight && computed.fontWeight !== '400' && computed.fontWeight !== 'normal') {
|
|
|
formattedSpan.style.fontWeight = computed.fontWeight;
|
|
|
@@ -2599,7 +2613,7 @@ Vue.component('spaceEditor', {
|
|
|
}
|
|
|
formattedSpan.appendChild(textNode.cloneNode(true));
|
|
|
textNode.parentNode.replaceChild(formattedSpan, textNode);
|
|
|
- });
|
|
|
+ }.bind(this));
|
|
|
|
|
|
var inlineNodes = wrapper.querySelectorAll('span, font, b, strong, i, em, u, s, strike, sub, sup');
|
|
|
for (var inlineIndex = inlineNodes.length - 1; inlineIndex >= 0; inlineIndex--) {
|
|
|
@@ -2621,6 +2635,22 @@ Vue.component('spaceEditor', {
|
|
|
this.$emit('input', this.getEditorSaveHtml());
|
|
|
this.deferSyncEditorPlayableVideos();
|
|
|
},
|
|
|
+ applyDefaultEditorTypography: function (editor) {
|
|
|
+ if (!editor || !editor.model || !editor.model.document) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ var root = editor.model.document.getRoot();
|
|
|
+ var firstBlock = root.getChild(0);
|
|
|
+ editor.model.change(function (writer) {
|
|
|
+ if (!firstBlock) {
|
|
|
+ firstBlock = writer.appendElement('paragraph', root);
|
|
|
+ }
|
|
|
+ writer.setSelection(firstBlock, 'in');
|
|
|
+ });
|
|
|
+ editor.execute('fontFamily', { value: this.defaultEditorFontFamily });
|
|
|
+ editor.execute('fontSize', { value: this.defaultEditorFontSize });
|
|
|
+ },
|
|
|
convertWordWithServer: function (file) {
|
|
|
var formData = new FormData();
|
|
|
var convertUrl = this.wordconverturl;
|
|
|
@@ -3567,6 +3597,9 @@ Vue.component('spaceEditor', {
|
|
|
|
|
|
if (_this.htmlContent != undefined) {
|
|
|
_this.editor.setData(_this.normalizeVideoHtmlForEditor(_this.htmlContent));
|
|
|
+ if (!String(_this.htmlContent || '').trim()) {
|
|
|
+ _this.applyDefaultEditorTypography(_this.editor);
|
|
|
+ }
|
|
|
_this.upgradePdfLinksToViewers();
|
|
|
_this.deferSyncEditorPlayableVideos();
|
|
|
_this.enhanceEditorPdfViewers();
|