mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
🚨
This commit is contained in:
parent
5727f1b91a
commit
e7a45d4026
3 changed files with 28 additions and 28 deletions
|
|
@ -3,7 +3,7 @@ import {Constants} from "../constants";
|
||||||
import {shell} from "electron";
|
import {shell} from "electron";
|
||||||
import {dialog} from "@electron/remote";
|
import {dialog} from "@electron/remote";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {isBrowser, isMobile} from "../util/functions";
|
import {isBrowser} from "../util/functions";
|
||||||
import {fetchPost} from "../util/fetch";
|
import {fetchPost} from "../util/fetch";
|
||||||
import {setAccessAuthCode} from "./util";
|
import {setAccessAuthCode} from "./util";
|
||||||
import {exportLayout} from "../layout/util";
|
import {exportLayout} from "../layout/util";
|
||||||
|
|
@ -214,7 +214,7 @@ export const about = {
|
||||||
<button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
|
<button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
|
||||||
<button class="b3-button b3-button--text">${window.siyuan.languages.confirm}</button>
|
<button class="b3-button b3-button--text">${window.siyuan.languages.confirm}</button>
|
||||||
</div>`,
|
</div>`,
|
||||||
width: isMobile() ? "80vw" : "520px",
|
width: "520px",
|
||||||
});
|
});
|
||||||
const textAreaElement = passwordDialog.element.querySelector("textarea");
|
const textAreaElement = passwordDialog.element.querySelector("textarea");
|
||||||
textAreaElement.focus();
|
textAreaElement.focus();
|
||||||
|
|
|
||||||
|
|
@ -396,13 +396,13 @@ export const layoutToJSON = (layout: Layout | Wnd | Tab | Model, json: any) => {
|
||||||
|
|
||||||
export const resizeDrag = () => {
|
export const resizeDrag = () => {
|
||||||
const dragElement = document.getElementById("drag");
|
const dragElement = document.getElementById("drag");
|
||||||
const right = dragElement.getBoundingClientRect().left - document.querySelector("#windowControls").clientWidth
|
const right = dragElement.getBoundingClientRect().left - document.querySelector("#windowControls").clientWidth;
|
||||||
if (right < dragElement.clientWidth) {
|
if (right < dragElement.clientWidth) {
|
||||||
dragElement.style.paddingRight = right + "px";
|
dragElement.style.paddingRight = right + "px";
|
||||||
} else {
|
} else {
|
||||||
dragElement.style.paddingRight = "";
|
dragElement.style.paddingRight = "";
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
export const resizeTabs = () => {
|
export const resizeTabs = () => {
|
||||||
const models = getAllModels();
|
const models = getAllModels();
|
||||||
|
|
|
||||||
|
|
@ -176,55 +176,55 @@ export const listIndent = (protyle: IProtyle, liItemElements: Element[], range:
|
||||||
};
|
};
|
||||||
|
|
||||||
export const breakList = (protyle: IProtyle, blockElement: Element, range: Range) => {
|
export const breakList = (protyle: IProtyle, blockElement: Element, range: Range) => {
|
||||||
const listItemElement = blockElement.parentElement
|
const listItemElement = blockElement.parentElement;
|
||||||
const listItemId = listItemElement.getAttribute("data-node-id")
|
const listItemId = listItemElement.getAttribute("data-node-id");
|
||||||
const doOperations: IOperation[] = [];
|
const doOperations: IOperation[] = [];
|
||||||
const undoOperations: IOperation[] = [];
|
const undoOperations: IOperation[] = [];
|
||||||
|
|
||||||
range.insertNode(document.createElement("wbr"))
|
range.insertNode(document.createElement("wbr"));
|
||||||
const newListId = Lute.NewNodeID()
|
const newListId = Lute.NewNodeID();
|
||||||
let newListHTML = ''
|
let newListHTML = "";
|
||||||
let hasFind = 0
|
let hasFind = 0;
|
||||||
Array.from(listItemElement.parentElement.children).forEach(item => {
|
Array.from(listItemElement.parentElement.children).forEach(item => {
|
||||||
if (!hasFind && item.isSameNode(listItemElement)) {
|
if (!hasFind && item.isSameNode(listItemElement)) {
|
||||||
hasFind = 1
|
hasFind = 1;
|
||||||
} else if (hasFind && !item.classList.contains("protyle-attr")) {
|
} else if (hasFind && !item.classList.contains("protyle-attr")) {
|
||||||
undoOperations.push({
|
undoOperations.push({
|
||||||
id: item.getAttribute("data-node-id"),
|
id: item.getAttribute("data-node-id"),
|
||||||
action: "move",
|
action: "move",
|
||||||
previousID: listItemId,
|
previousID: listItemId,
|
||||||
})
|
});
|
||||||
doOperations.push({
|
doOperations.push({
|
||||||
id: item.getAttribute("data-node-id"),
|
id: item.getAttribute("data-node-id"),
|
||||||
action: "delete",
|
action: "delete",
|
||||||
})
|
});
|
||||||
if (item.getAttribute("data-subtype") === "o") {
|
if (item.getAttribute("data-subtype") === "o") {
|
||||||
undoOperations.push({
|
undoOperations.push({
|
||||||
id: item.getAttribute("data-node-id"),
|
id: item.getAttribute("data-node-id"),
|
||||||
action: "update",
|
action: "update",
|
||||||
data: item.outerHTML,
|
data: item.outerHTML,
|
||||||
})
|
});
|
||||||
item.setAttribute("data-marker", hasFind + ".")
|
item.setAttribute("data-marker", hasFind + ".");
|
||||||
item.firstElementChild.innerHTML = hasFind + "."
|
item.firstElementChild.innerHTML = hasFind + ".";
|
||||||
}
|
}
|
||||||
newListHTML += item.outerHTML
|
newListHTML += item.outerHTML;
|
||||||
item.remove();
|
item.remove();
|
||||||
hasFind++;
|
hasFind++;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
undoOperations.reverse();
|
undoOperations.reverse();
|
||||||
newListHTML = `<div data-subtype="${listItemElement.getAttribute("data-subtype")}" data-node-id="${newListId}" data-type="NodeList" class="list" updated="${dayjs().format("YYYYMMDDHHmmss")}">${newListHTML}<div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div></div>`
|
newListHTML = `<div data-subtype="${listItemElement.getAttribute("data-subtype")}" data-node-id="${newListId}" data-type="NodeList" class="list" updated="${dayjs().format("YYYYMMDDHHmmss")}">${newListHTML}<div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div></div>`;
|
||||||
listItemElement.parentElement.insertAdjacentHTML("afterend", newListHTML);
|
listItemElement.parentElement.insertAdjacentHTML("afterend", newListHTML);
|
||||||
doOperations.push({
|
doOperations.push({
|
||||||
id: newListId,
|
id: newListId,
|
||||||
action: "insert",
|
action: "insert",
|
||||||
previousID: listItemElement.parentElement.getAttribute("data-node-id"),
|
previousID: listItemElement.parentElement.getAttribute("data-node-id"),
|
||||||
data: newListHTML
|
data: newListHTML
|
||||||
})
|
});
|
||||||
undoOperations.push({
|
undoOperations.push({
|
||||||
id: newListId,
|
id: newListId,
|
||||||
action: "delete"
|
action: "delete"
|
||||||
})
|
});
|
||||||
|
|
||||||
Array.from(listItemElement.children).reverse().forEach((item) => {
|
Array.from(listItemElement.children).reverse().forEach((item) => {
|
||||||
if (!item.classList.contains("protyle-action") && !item.classList.contains("protyle-attr")) {
|
if (!item.classList.contains("protyle-action") && !item.classList.contains("protyle-attr")) {
|
||||||
|
|
@ -232,30 +232,30 @@ export const breakList = (protyle: IProtyle, blockElement: Element, range: Range
|
||||||
id: item.getAttribute("data-node-id"),
|
id: item.getAttribute("data-node-id"),
|
||||||
action: "move",
|
action: "move",
|
||||||
previousID: listItemElement.parentElement.getAttribute("data-node-id")
|
previousID: listItemElement.parentElement.getAttribute("data-node-id")
|
||||||
})
|
});
|
||||||
undoOperations.push({
|
undoOperations.push({
|
||||||
id: item.getAttribute("data-node-id"),
|
id: item.getAttribute("data-node-id"),
|
||||||
action: "move",
|
action: "move",
|
||||||
parentID: listItemId
|
parentID: listItemId
|
||||||
})
|
});
|
||||||
listItemElement.parentElement.after(item);
|
listItemElement.parentElement.after(item);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
undoOperations.splice(0, 0, {
|
undoOperations.splice(0, 0, {
|
||||||
id: listItemId,
|
id: listItemId,
|
||||||
action: "insert",
|
action: "insert",
|
||||||
data: listItemElement.outerHTML,
|
data: listItemElement.outerHTML,
|
||||||
previousID: listItemElement.previousElementSibling.getAttribute("data-node-id"),
|
previousID: listItemElement.previousElementSibling.getAttribute("data-node-id"),
|
||||||
parentID: listItemElement.parentElement.getAttribute("data-node-id")
|
parentID: listItemElement.parentElement.getAttribute("data-node-id")
|
||||||
})
|
});
|
||||||
listItemElement.remove()
|
listItemElement.remove();
|
||||||
doOperations.push({
|
doOperations.push({
|
||||||
id: listItemId,
|
id: listItemId,
|
||||||
action: "delete",
|
action: "delete",
|
||||||
})
|
});
|
||||||
transaction(protyle, doOperations, undoOperations);
|
transaction(protyle, doOperations, undoOperations);
|
||||||
focusByWbr(protyle.wysiwyg.element, range);
|
focusByWbr(protyle.wysiwyg.element, range);
|
||||||
}
|
};
|
||||||
|
|
||||||
export const listOutdent = (protyle: IProtyle, liItemElements: Element[], range: Range) => {
|
export const listOutdent = (protyle: IProtyle, liItemElements: Element[], range: Range) => {
|
||||||
const liElement = liItemElements[0].parentElement;
|
const liElement = liItemElements[0].parentElement;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue