mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
🚨
This commit is contained in:
parent
a3c33565df
commit
30cb2390ae
3 changed files with 18 additions and 18 deletions
|
|
@ -180,7 +180,7 @@ export const initWindow = () => {
|
||||||
|
|
||||||
const winOnBlur = () => {
|
const winOnBlur = () => {
|
||||||
document.body.classList.add("body--blur");
|
document.body.classList.add("body--blur");
|
||||||
}
|
};
|
||||||
|
|
||||||
const winOnClose = (currentWindow: Electron.BrowserWindow, close = false) => {
|
const winOnClose = (currentWindow: Electron.BrowserWindow, close = false) => {
|
||||||
exportLayout(false, () => {
|
exportLayout(false, () => {
|
||||||
|
|
@ -224,7 +224,7 @@ export const initWindow = () => {
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("toolbar").style.paddingLeft = "0";
|
document.getElementById("toolbar").style.paddingLeft = "0";
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const winOnLeaveFullscreen = () => {
|
const winOnLeaveFullscreen = () => {
|
||||||
if (isWindow()) {
|
if (isWindow()) {
|
||||||
|
|
@ -232,7 +232,7 @@ export const initWindow = () => {
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("toolbar").setAttribute("style", "");
|
document.getElementById("toolbar").setAttribute("style", "");
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const currentWindow = getCurrentWindow();
|
const currentWindow = getCurrentWindow();
|
||||||
currentWindow.on("focus", winOnFocus);
|
currentWindow.on("focus", winOnFocus);
|
||||||
|
|
|
||||||
|
|
@ -205,10 +205,10 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range:
|
||||||
protyle.hint.render(protyle);
|
protyle.hint.render(protyle);
|
||||||
}
|
}
|
||||||
hideElements(["gutter"], protyle);
|
hideElements(["gutter"], protyle);
|
||||||
updateInput(html, protyle, id, type);
|
updateInput(html, protyle, id);
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateInput = (html: string, protyle: IProtyle, id: string, type: string) => {
|
const updateInput = (html: string, protyle: IProtyle, id: string) => {
|
||||||
const tempElement = document.createElement("template");
|
const tempElement = document.createElement("template");
|
||||||
tempElement.innerHTML = html;
|
tempElement.innerHTML = html;
|
||||||
const doOperations: IOperation[] = [];
|
const doOperations: IOperation[] = [];
|
||||||
|
|
|
||||||
|
|
@ -26,15 +26,15 @@ export const turnIntoTaskList = (protyle: IProtyle, type: string, blockElement:
|
||||||
if (isDone) {
|
if (isDone) {
|
||||||
blockElement.parentElement.classList.add("protyle-task--done");
|
blockElement.parentElement.classList.add("protyle-task--done");
|
||||||
}
|
}
|
||||||
blockElement.previousElementSibling.outerHTML = `<div class="protyle-action protyle-action--task" draggable="true"><svg><use xlink:href="#icon${isDone ? "C" : "Unc"}heck"></use></svg></div>`
|
blockElement.previousElementSibling.outerHTML = `<div class="protyle-action protyle-action--task" draggable="true"><svg><use xlink:href="#icon${isDone ? "C" : "Unc"}heck"></use></svg></div>`;
|
||||||
editElement.innerHTML = editElement.innerHTML.substring(contextStartIndex);
|
editElement.innerHTML = editElement.innerHTML.substring(contextStartIndex);
|
||||||
updateTransaction(protyle, liElement.getAttribute("data-node-id"), liElement.outerHTML, oldHTML);
|
updateTransaction(protyle, liElement.getAttribute("data-node-id"), liElement.outerHTML, oldHTML);
|
||||||
focusByWbr(protyle.wysiwyg.element, range)
|
focusByWbr(protyle.wysiwyg.element, range);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
const id = blockElement.getAttribute("data-node-id")
|
const id = blockElement.getAttribute("data-node-id");
|
||||||
const newId = Lute.NewNodeID();
|
const newId = Lute.NewNodeID();
|
||||||
const emptyId = Lute.NewNodeID();
|
const emptyId = Lute.NewNodeID();
|
||||||
const liItemId = Lute.NewNodeID();
|
const liItemId = Lute.NewNodeID();
|
||||||
|
|
@ -68,18 +68,18 @@ export const turnIntoTaskList = (protyle: IProtyle, type: string, blockElement:
|
||||||
action: "delete",
|
action: "delete",
|
||||||
id: newId
|
id: newId
|
||||||
}]);
|
}]);
|
||||||
blockElement.outerHTML = `<div data-subtype="t" data-node-id="${newId}" data-type="NodeList" class="list" updated="${newId.split("-")[0]}"><div data-marker="*" data-subtype="t" data-node-id="${liItemId}" data-type="NodeListItem" class="li${isDone ? " protyle-task--done" : ""}" updated="${liItemId.split("-")[0]}"><div class="protyle-action protyle-action--task" draggable="true"><svg><use xlink:href="#icon${isDone ? "C" : "Unc"}heck"></use></svg></div>${blockElement.outerHTML}<div class="protyle-attr" contenteditable="false"></div></div><div class="protyle-attr" contenteditable="false"></div></div>`
|
blockElement.outerHTML = `<div data-subtype="t" data-node-id="${newId}" data-type="NodeList" class="list" updated="${newId.split("-")[0]}"><div data-marker="*" data-subtype="t" data-node-id="${liItemId}" data-type="NodeListItem" class="li${isDone ? " protyle-task--done" : ""}" updated="${liItemId.split("-")[0]}"><div class="protyle-action protyle-action--task" draggable="true"><svg><use xlink:href="#icon${isDone ? "C" : "Unc"}heck"></use></svg></div>${blockElement.outerHTML}<div class="protyle-attr" contenteditable="false"></div></div><div class="protyle-attr" contenteditable="false"></div></div>`;
|
||||||
focusByWbr(protyle.wysiwyg.element, range)
|
focusByWbr(protyle.wysiwyg.element, range);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false;
|
||||||
}
|
};
|
||||||
|
|
||||||
export const headingTurnIntoList = (protyle: IProtyle, type: string, blockElement: HTMLElement, editElement: HTMLElement, range: Range) => {
|
export const headingTurnIntoList = (protyle: IProtyle, type: string, blockElement: HTMLElement, editElement: HTMLElement, range: Range) => {
|
||||||
if (type === "NodeHeading" && ["* ", "- "].includes(editElement.innerHTML.substring(0, 2)) &&
|
if (type === "NodeHeading" && ["* ", "- "].includes(editElement.innerHTML.substring(0, 2)) &&
|
||||||
blockElement.parentElement.getAttribute("data-type") !== "NodeListItem") {
|
blockElement.parentElement.getAttribute("data-type") !== "NodeListItem") {
|
||||||
const id = blockElement.getAttribute("data-node-id")
|
const id = blockElement.getAttribute("data-node-id");
|
||||||
const newId = Lute.NewNodeID();
|
const newId = Lute.NewNodeID();
|
||||||
const emptyId = Lute.NewNodeID();
|
const emptyId = Lute.NewNodeID();
|
||||||
const liItemId = Lute.NewNodeID();
|
const liItemId = Lute.NewNodeID();
|
||||||
|
|
@ -113,9 +113,9 @@ export const headingTurnIntoList = (protyle: IProtyle, type: string, blockElemen
|
||||||
action: "delete",
|
action: "delete",
|
||||||
id: newId
|
id: newId
|
||||||
}]);
|
}]);
|
||||||
blockElement.outerHTML = `<div data-subtype="u" data-node-id="${newId}" data-type="NodeList" class="list" updated="${newId.split("-")[0]}"><div data-marker="${editElement.innerHTML.substring(0, 1)}" data-subtype="u" data-node-id="${liItemId}" data-type="NodeListItem" class="li" updated="${liItemId.split("-")[0]}"><div class="protyle-action" draggable="true"><svg><use xlink:href="#iconDot"></use></svg></div>${blockElement.outerHTML}<div class="protyle-attr" contenteditable="false"></div></div><div class="protyle-attr" contenteditable="false"></div></div>`
|
blockElement.outerHTML = `<div data-subtype="u" data-node-id="${newId}" data-type="NodeList" class="list" updated="${newId.split("-")[0]}"><div data-marker="${editElement.innerHTML.substring(0, 1)}" data-subtype="u" data-node-id="${liItemId}" data-type="NodeListItem" class="li" updated="${liItemId.split("-")[0]}"><div class="protyle-action" draggable="true"><svg><use xlink:href="#iconDot"></use></svg></div>${blockElement.outerHTML}<div class="protyle-attr" contenteditable="false"></div></div><div class="protyle-attr" contenteditable="false"></div></div>`;
|
||||||
focusByWbr(protyle.wysiwyg.element, range)
|
focusByWbr(protyle.wysiwyg.element, range);
|
||||||
return true
|
return true;
|
||||||
}
|
}
|
||||||
return false
|
return false;
|
||||||
}
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue