This commit is contained in:
Vanessa 2022-07-28 21:36:18 +08:00
parent bb82261522
commit 811c95a91e
2 changed files with 4 additions and 7 deletions

View file

@ -197,9 +197,9 @@ export const editor = {
item.editor.reload(); item.editor.reload();
setPadding(item.editor.protyle); setPadding(item.editor.protyle);
if (window.siyuan.config.editor.fullWidth) { if (window.siyuan.config.editor.fullWidth) {
item.editor.protyle.wysiwyg.element.setAttribute("data-fullwidth", "true"); item.editor.protyle.contentElement.setAttribute("data-fullwidth", "true");
} else { } else {
item.editor.protyle.wysiwyg.element.removeAttribute("data-fullwidth"); item.editor.protyle.contentElement.removeAttribute("data-fullwidth");
} }
}); });
setInlineStyle(); setInlineStyle();

View file

@ -78,9 +78,6 @@ export class WYSIWYG {
if (window.siyuan.config.editor.displayBookmarkIcon) { if (window.siyuan.config.editor.displayBookmarkIcon) {
this.element.classList.add("protyle-wysiwyg--attr"); this.element.classList.add("protyle-wysiwyg--attr");
} }
if (window.siyuan.config.editor.fullWidth) {
this.element.setAttribute("data-fullwidth", "true");
}
this.bindEvent(protyle); this.bindEvent(protyle);
keydown(protyle, this.element); keydown(protyle, this.element);
dropEvent(protyle, this.element); dropEvent(protyle, this.element);
@ -90,14 +87,14 @@ export class WYSIWYG {
const ialKeys = Object.keys(ial); const ialKeys = Object.keys(ial);
for (let i = 0; i < this.element.attributes.length; i++) { for (let i = 0; i < this.element.attributes.length; i++) {
const oldKey = this.element.attributes[i].nodeName; const oldKey = this.element.attributes[i].nodeName;
if (!["type", "class", "spellcheck", "contenteditable", "data-doc-type", "data-fullwidth", "style"].includes(oldKey) && if (!["type", "class", "spellcheck", "contenteditable", "data-doc-type", "style"].includes(oldKey) &&
!ialKeys.includes(oldKey)) { !ialKeys.includes(oldKey)) {
this.element.removeAttribute(oldKey); this.element.removeAttribute(oldKey);
i--; i--;
} }
} }
ialKeys.forEach((key: string) => { ialKeys.forEach((key: string) => {
if (!["title-img", "title", "updated", "icon", "id", "type", "class", "spellcheck", "contenteditable", "data-doc-type", "data-fullwidth", "style"].includes(key)) { if (!["title-img", "title", "updated", "icon", "id", "type", "class", "spellcheck", "contenteditable", "data-doc-type", "style"].includes(key)) {
this.element.setAttribute(key, ial[key]); this.element.setAttribute(key, ial[key]);
} }
}); });