This commit is contained in:
parent
031d2a4736
commit
8652f3b3a2
5 changed files with 35 additions and 40 deletions
|
@ -70,8 +70,6 @@ export const openMobileFileById = (id: string, action = [Constants.CB_GET_HL]) =
|
|||
// protyle 仅初始化一次,后续更新时会对 url 等再次复制
|
||||
if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly) {
|
||||
disabledProtyle(editor.protyle);
|
||||
} else {
|
||||
enableProtyle(editor.protyle);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -155,7 +155,7 @@ const initEditorName = () => {
|
|||
hideKeyboardToolbar();
|
||||
});
|
||||
inputElement.addEventListener("blur", () => {
|
||||
if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly) {
|
||||
if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly || window.siyuan.mobileEditor.protyle.disabled) {
|
||||
return;
|
||||
}
|
||||
if (!validateName(inputElement.value)) {
|
||||
|
|
|
@ -131,16 +131,13 @@ export class Gutter {
|
|||
if (buttonElement.getAttribute("disabled")) {
|
||||
return;
|
||||
}
|
||||
if (!window.siyuan.config.readonly) {
|
||||
if (!protyle.disabled) {
|
||||
gutterFold();
|
||||
}
|
||||
hideElements(["select"], protyle);
|
||||
window.siyuan.menus.menu.remove();
|
||||
return;
|
||||
}
|
||||
if (window.siyuan.config.readonly) {
|
||||
return;
|
||||
}
|
||||
if (window.siyuan.ctrlIsPressed) {
|
||||
zoomOut(protyle, id);
|
||||
} else if (window.siyuan.altIsPressed) {
|
||||
|
@ -195,7 +192,7 @@ export class Gutter {
|
|||
});
|
||||
this.element.addEventListener("contextmenu", (event: MouseEvent & { target: HTMLInputElement }) => {
|
||||
const buttonElement = hasClosestByTag(event.target, "BUTTON");
|
||||
if (!buttonElement || window.siyuan.config.readonly || buttonElement.getAttribute("data-type") === "fold") {
|
||||
if (!buttonElement || protyle.disabled || buttonElement.getAttribute("data-type") === "fold") {
|
||||
return;
|
||||
}
|
||||
if (!window.siyuan.ctrlIsPressed && !window.siyuan.altIsPressed && !window.siyuan.shiftIsPressed) {
|
||||
|
@ -408,7 +405,7 @@ export class Gutter {
|
|||
return true;
|
||||
}
|
||||
});
|
||||
if (!isList && !window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly) {
|
||||
if (!isList && !protyle.disabled) {
|
||||
const turnIntoSubmenu: IMenu[] = [];
|
||||
if (isContinue) {
|
||||
turnIntoSubmenu.push(this.turnsIntoOne({
|
||||
|
@ -587,7 +584,7 @@ export class Gutter {
|
|||
writeText(protyle.lute.BlockDOM2HTML(html));
|
||||
}
|
||||
}).element);
|
||||
if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly) {
|
||||
if (protyle.disabled) {
|
||||
return;
|
||||
}
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
|
@ -677,7 +674,7 @@ export class Gutter {
|
|||
nodeElement.classList.add("protyle-wysiwyg--select");
|
||||
countBlockWord([id], protyle.block.rootID);
|
||||
// "heading1-6", "list", "ordered-list", "check", "quote", "code", "table", "line", "math", "paragraph"
|
||||
if (type === "NodeParagraph" && !window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly) {
|
||||
if (type === "NodeParagraph" && !protyle.disabled) {
|
||||
turnIntoSubmenu.push(this.turnsIntoOne({
|
||||
icon: "iconList",
|
||||
label: window.siyuan.languages.list,
|
||||
|
@ -760,7 +757,7 @@ export class Gutter {
|
|||
level: 6,
|
||||
type: "Blocks2Hs",
|
||||
}));
|
||||
} else if (type === "NodeHeading" && !window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly) {
|
||||
} else if (type === "NodeHeading" && !protyle.disabled) {
|
||||
turnIntoSubmenu.push(this.turnsInto({
|
||||
icon: "iconParagraph",
|
||||
label: window.siyuan.languages.paragraph,
|
||||
|
@ -836,7 +833,7 @@ export class Gutter {
|
|||
type: "Blocks2Hs",
|
||||
}));
|
||||
}
|
||||
} else if (type === "NodeList" && !window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly) {
|
||||
} else if (type === "NodeList" && !protyle.disabled) {
|
||||
turnIntoSubmenu.push(this.turnsOneInto({
|
||||
icon: "iconParagraph",
|
||||
label: window.siyuan.languages.paragraph,
|
||||
|
@ -897,7 +894,7 @@ export class Gutter {
|
|||
type: "OL2TL"
|
||||
}));
|
||||
}
|
||||
} else if (type === "NodeBlockquote" && !window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly) {
|
||||
} else if (type === "NodeBlockquote" && !protyle.disabled) {
|
||||
turnIntoSubmenu.push(this.turnsOneInto({
|
||||
icon: "iconParagraph",
|
||||
label: window.siyuan.languages.paragraph,
|
||||
|
@ -907,7 +904,7 @@ export class Gutter {
|
|||
type: "CancelBlockquote"
|
||||
}));
|
||||
}
|
||||
if (turnIntoSubmenu.length > 0 && !window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly) {
|
||||
if (turnIntoSubmenu.length > 0 && !protyle.disabled) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
icon: "iconRefresh",
|
||||
label: window.siyuan.languages.turnInto,
|
||||
|
@ -951,7 +948,7 @@ export class Gutter {
|
|||
}
|
||||
}, {
|
||||
label: window.siyuan.languages.duplicate,
|
||||
disabled: window.siyuan.config.readonly || window.siyuan.config.editor.readOnly,
|
||||
disabled: protyle.disabled,
|
||||
click() {
|
||||
const tempElement = nodeElement.cloneNode(true) as HTMLElement;
|
||||
const newId = Lute.NewNodeID();
|
||||
|
@ -974,7 +971,7 @@ export class Gutter {
|
|||
}
|
||||
}])
|
||||
}).element);
|
||||
if (!window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly) {
|
||||
if (!protyle.disabled) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.cut,
|
||||
accelerator: "⌘X",
|
||||
|
@ -1008,7 +1005,7 @@ export class Gutter {
|
|||
}
|
||||
}).element);
|
||||
}
|
||||
if (type === "NodeSuperBlock" && !window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly) {
|
||||
if (type === "NodeSuperBlock" && !protyle.disabled) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.cancel + " " + window.siyuan.languages.superBlock,
|
||||
|
@ -1019,7 +1016,7 @@ export class Gutter {
|
|||
hideElements(["gutter"], protyle);
|
||||
}
|
||||
}).element);
|
||||
} else if (type === "NodeCodeBlock" && !window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly && !nodeElement.getAttribute("data-subtype")) {
|
||||
} else if (type === "NodeCodeBlock" && !protyle.disabled && !nodeElement.getAttribute("data-subtype")) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
const linewrap = nodeElement.getAttribute("linewrap");
|
||||
const ligatures = nodeElement.getAttribute("ligatures");
|
||||
|
@ -1088,7 +1085,7 @@ export class Gutter {
|
|||
}
|
||||
}]
|
||||
}).element);
|
||||
} else if (type === "NodeCodeBlock" && !window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly && ["echarts", "mindmap"].includes(nodeElement.getAttribute("data-subtype"))) {
|
||||
} else if (type === "NodeCodeBlock" && !protyle.disabled && ["echarts", "mindmap"].includes(nodeElement.getAttribute("data-subtype"))) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
const height = (nodeElement as HTMLElement).style.height;
|
||||
let html = nodeElement.outerHTML;
|
||||
|
@ -1120,7 +1117,7 @@ export class Gutter {
|
|||
}
|
||||
}]
|
||||
}).element);
|
||||
} else if (type === "NodeTable" && !window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly) {
|
||||
} else if (type === "NodeTable" && !protyle.disabled) {
|
||||
let range = getEditorRange(nodeElement);
|
||||
const tableElement = nodeElement.querySelector("table");
|
||||
if (!tableElement.contains(range.startContainer)) {
|
||||
|
@ -1136,7 +1133,7 @@ export class Gutter {
|
|||
submenu: tableMenu(protyle, nodeElement, cellElement as HTMLTableCellElement, range) as IMenu[]
|
||||
}).element);
|
||||
}
|
||||
} else if ((type === "NodeVideo" || type === "NodeAudio") && !window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly) {
|
||||
} else if ((type === "NodeVideo" || type === "NodeAudio") && !protyle.disabled) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
id: "assetSubMenu",
|
||||
|
@ -1145,7 +1142,7 @@ export class Gutter {
|
|||
label: window.siyuan.languages.assets,
|
||||
submenu: videoMenu(protyle, nodeElement, type)
|
||||
}).element);
|
||||
} else if (type === "NodeIFrame" && !window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly) {
|
||||
} else if (type === "NodeIFrame" && !protyle.disabled) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
id: "assetSubMenu",
|
||||
|
@ -1154,7 +1151,7 @@ export class Gutter {
|
|||
label: window.siyuan.languages.assets,
|
||||
submenu: iframeMenu(protyle, nodeElement)
|
||||
}).element);
|
||||
} else if (type === "NodeHTMLBlock" && !window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly) {
|
||||
} else if (type === "NodeHTMLBlock" && !protyle.disabled) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
icon: "iconHTML5",
|
||||
|
@ -1163,7 +1160,7 @@ export class Gutter {
|
|||
protyle.toolbar.showRender(protyle, nodeElement);
|
||||
}
|
||||
}).element);
|
||||
} else if (type === "NodeBlockQueryEmbed" && !window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly) {
|
||||
} else if (type === "NodeBlockQueryEmbed" && !protyle.disabled) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
const breadcrumb = nodeElement.getAttribute("breadcrumb");
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
|
@ -1226,7 +1223,7 @@ export class Gutter {
|
|||
}
|
||||
}]
|
||||
}).element);
|
||||
} else if (type === "NodeHeading" && !window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly) {
|
||||
} else if (type === "NodeHeading" && !protyle.disabled) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
const headingSubMenu = [];
|
||||
if (subType !== "h1") {
|
||||
|
@ -1327,7 +1324,7 @@ export class Gutter {
|
|||
}
|
||||
}
|
||||
}).element);
|
||||
if (!window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly) {
|
||||
if (!protyle.disabled) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
icon: "iconBefore",
|
||||
label: window.siyuan.languages["insert-before"],
|
||||
|
@ -1368,7 +1365,7 @@ export class Gutter {
|
|||
focusBlock(nodeElement);
|
||||
}
|
||||
}).element);
|
||||
if (!window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly) {
|
||||
if (!protyle.disabled) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.attr,
|
||||
accelerator: window.siyuan.config.keymap.editor.general.attr.custom + "/" + updateHotkeyTip("⇧Click"),
|
||||
|
@ -1378,7 +1375,7 @@ export class Gutter {
|
|||
}).element);
|
||||
}
|
||||
}
|
||||
if (!window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly) {
|
||||
if (!protyle.disabled) {
|
||||
const appearanceElement = new MenuItem({
|
||||
label: window.siyuan.languages.appearance,
|
||||
submenu: this.genCardStyle([nodeElement], protyle).concat(this.genFontStyle([nodeElement], protyle)).concat(this.genBGStyle([nodeElement], protyle))
|
||||
|
@ -1663,7 +1660,7 @@ export class Gutter {
|
|||
}]);
|
||||
}
|
||||
|
||||
public render(element: Element, wysiwyg: HTMLElement) {
|
||||
public render(protyle:IProtyle, element: Element, wysiwyg: HTMLElement) {
|
||||
// https://github.com/siyuan-note/siyuan/issues/4659
|
||||
const titleElement = wysiwyg.parentElement.querySelector(".protyle-title__input");
|
||||
if (titleElement && titleElement.getAttribute("data-render") !== "true") {
|
||||
|
@ -1711,7 +1708,7 @@ export class Gutter {
|
|||
}
|
||||
index += 1;
|
||||
if (isShow) {
|
||||
html = `<button ${(window.siyuan.config.readonly || window.siyuan.config.editor.readOnly) ? "" : 'draggable="true"'} data-type="${type}" data-subtype="${nodeElement.getAttribute("data-subtype")}" data-node-id="${nodeElement.getAttribute("data-node-id")}"><svg><use xlink:href="#${getIconByType(type, nodeElement.getAttribute("data-subtype"))}"></use></svg></button>` + html;
|
||||
html = `<button ${protyle.disabled ? "" : 'draggable="true"'} data-type="${type}" data-subtype="${nodeElement.getAttribute("data-subtype")}" data-node-id="${nodeElement.getAttribute("data-node-id")}"><svg><use xlink:href="#${getIconByType(type, nodeElement.getAttribute("data-subtype"))}"></use></svg></button>` + html;
|
||||
}
|
||||
let foldHTML = "";
|
||||
if (type === "NodeListItem" && nodeElement.childElementCount > 3 || type === "NodeHeading") {
|
||||
|
@ -1721,7 +1718,7 @@ export class Gutter {
|
|||
if (type === "NodeListItem" || type === "NodeList") {
|
||||
listItem = nodeElement;
|
||||
if (type === "NodeListItem" && nodeElement.childElementCount > 3) {
|
||||
html = `<button ${(window.siyuan.config.readonly || window.siyuan.config.editor.readOnly) ? "" : 'draggable="true"'} data-type="${type}" data-subtype="${nodeElement.getAttribute("data-subtype")}" data-node-id="${nodeElement.getAttribute("data-node-id")}"><svg><use xlink:href="#${getIconByType(type, nodeElement.getAttribute("data-subtype"))}"></use></svg></button>${foldHTML}`;
|
||||
html = `<button ${protyle.disabled ? "" : 'draggable="true"'} data-type="${type}" data-subtype="${nodeElement.getAttribute("data-subtype")}" data-node-id="${nodeElement.getAttribute("data-node-id")}"><svg><use xlink:href="#${getIconByType(type, nodeElement.getAttribute("data-subtype"))}"></use></svg></button>${foldHTML}`;
|
||||
}
|
||||
}
|
||||
if (type === "NodeHeading") {
|
||||
|
|
|
@ -1256,9 +1256,9 @@ export class WYSIWYG {
|
|||
if (nodeElement) {
|
||||
const embedElement = hasClosestByAttribute(nodeElement, "data-type", "NodeBlockQueryEmbed");
|
||||
if (embedElement) {
|
||||
protyle.gutter.render(embedElement, this.element);
|
||||
protyle.gutter.render(protyle, embedElement, this.element);
|
||||
} else {
|
||||
protyle.gutter.render(nodeElement, this.element);
|
||||
protyle.gutter.render(protyle, nodeElement, this.element);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -104,7 +104,7 @@ export const globalShortcut = () => {
|
|||
let findNode = false;
|
||||
allModels.editor.find(item => {
|
||||
if (item.editor.protyle.wysiwyg.element.isSameNode(eventPath0)) {
|
||||
item.editor.protyle.gutter.render(targetBlockElement, item.editor.protyle.wysiwyg.element);
|
||||
item.editor.protyle.gutter.render(item.editor.protyle, targetBlockElement, item.editor.protyle.wysiwyg.element);
|
||||
findNode = true;
|
||||
return true;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ export const globalShortcut = () => {
|
|||
window.siyuan.blockPanels.find(item => {
|
||||
item.editors.find(eItem => {
|
||||
if (eItem.protyle.wysiwyg.element.contains(eventPath0)) {
|
||||
eItem.protyle.gutter.render(targetBlockElement, eItem.protyle.wysiwyg.element);
|
||||
eItem.protyle.gutter.render(eItem.protyle, targetBlockElement, eItem.protyle.wysiwyg.element);
|
||||
findNode = true;
|
||||
return true;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ export const globalShortcut = () => {
|
|||
allModels.backlink.find(item => {
|
||||
item.editors.find(eItem => {
|
||||
if (eItem.protyle.wysiwyg.element.isSameNode(eventPath0)) {
|
||||
eItem.protyle.gutter.render(targetBlockElement, eItem.protyle.wysiwyg.element);
|
||||
eItem.protyle.gutter.render(eItem.protyle, targetBlockElement, eItem.protyle.wysiwyg.element);
|
||||
findNode = true;
|
||||
return true;
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ export const globalShortcut = () => {
|
|||
let findNode = false;
|
||||
allModels.editor.find(item => {
|
||||
if (item.editor.protyle.wysiwyg.element.contains(eventPath0)) {
|
||||
item.editor.protyle.gutter.render(targetBlockElement, item.editor.protyle.wysiwyg.element);
|
||||
item.editor.protyle.gutter.render(item.editor.protyle, targetBlockElement, item.editor.protyle.wysiwyg.element);
|
||||
findNode = true;
|
||||
return true;
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ export const globalShortcut = () => {
|
|||
window.siyuan.blockPanels.find(item => {
|
||||
item.editors.find(eItem => {
|
||||
if (eItem.protyle.wysiwyg.element.contains(eventPath0)) {
|
||||
eItem.protyle.gutter.render(targetBlockElement, eItem.protyle.wysiwyg.element);
|
||||
eItem.protyle.gutter.render(eItem.protyle, targetBlockElement, eItem.protyle.wysiwyg.element);
|
||||
findNode = true;
|
||||
return true;
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ export const globalShortcut = () => {
|
|||
allModels.backlink.find(item => {
|
||||
item.editors.find(eItem => {
|
||||
if (eItem.protyle.wysiwyg.element.contains(eventPath0)) {
|
||||
eItem.protyle.gutter.render(targetBlockElement, eItem.protyle.wysiwyg.element);
|
||||
eItem.protyle.gutter.render(eItem.protyle, targetBlockElement, eItem.protyle.wysiwyg.element);
|
||||
findNode = true;
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue