mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 01:20:12 +01:00
🚨
This commit is contained in:
parent
cc5003549c
commit
5d051d0c64
10 changed files with 26 additions and 26 deletions
|
|
@ -428,7 +428,7 @@ export const keymap = {
|
||||||
keys[1] = "headings";
|
keys[1] = "headings";
|
||||||
}
|
}
|
||||||
let hasConflict = false;
|
let hasConflict = false;
|
||||||
const isAssistKey = ["⌘", "⇧", "⌥", "⌃"].includes(keymapStr.substr(keymapStr.length - 1, 1))
|
const isAssistKey = ["⌘", "⇧", "⌥", "⌃"].includes(keymapStr.substr(keymapStr.length - 1, 1));
|
||||||
if (isAssistKey ||
|
if (isAssistKey ||
|
||||||
["⌘A", "⌘X", "⌘C", "⌘V", "⌘-", "⌘=", "⌘0", "⇧⌘V", "⌘/", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⌃D", "⇧⌘→", "⇧⌘←", "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦", "Escape"].includes(keymapStr) ||
|
["⌘A", "⌘X", "⌘C", "⌘V", "⌘-", "⌘=", "⌘0", "⇧⌘V", "⌘/", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⌃D", "⇧⌘→", "⇧⌘←", "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦", "Escape"].includes(keymapStr) ||
|
||||||
// 跳转到下/上一个编辑页签不能包含 ctrl, 否则不能监听到 keyup
|
// 跳转到下/上一个编辑页签不能包含 ctrl, 否则不能监听到 keyup
|
||||||
|
|
|
||||||
|
|
@ -210,4 +210,4 @@ export const publish = {
|
||||||
}</ul>`;
|
}</ul>`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
|
|
|
||||||
|
|
@ -705,7 +705,7 @@ export class Files extends Model {
|
||||||
public init(init = true) {
|
public init(init = true) {
|
||||||
let html = "";
|
let html = "";
|
||||||
let closeHtml = "";
|
let closeHtml = "";
|
||||||
let closeCounter = 0
|
let closeCounter = 0;
|
||||||
window.siyuan.notebooks.forEach((item) => {
|
window.siyuan.notebooks.forEach((item) => {
|
||||||
if (item.closed) {
|
if (item.closed) {
|
||||||
closeCounter++;
|
closeCounter++;
|
||||||
|
|
@ -716,8 +716,8 @@ export class Files extends Model {
|
||||||
});
|
});
|
||||||
this.element.innerHTML = html;
|
this.element.innerHTML = html;
|
||||||
this.closeElement.lastElementChild.innerHTML = closeHtml;
|
this.closeElement.lastElementChild.innerHTML = closeHtml;
|
||||||
const counterElement = this.closeElement.querySelector(".counter")
|
const counterElement = this.closeElement.querySelector(".counter");
|
||||||
counterElement.textContent = closeCounter.toString()
|
counterElement.textContent = closeCounter.toString();
|
||||||
if (closeCounter) {
|
if (closeCounter) {
|
||||||
counterElement.classList.remove("fn__none");
|
counterElement.classList.remove("fn__none");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -752,7 +752,7 @@ export class Files extends Model {
|
||||||
this.closeElement.lastElementChild.innerHTML = closeHTML;
|
this.closeElement.lastElementChild.innerHTML = closeHTML;
|
||||||
const counterElement = this.closeElement.querySelector(".counter");
|
const counterElement = this.closeElement.querySelector(".counter");
|
||||||
counterElement.textContent = (parseInt(counterElement.textContent) + 1).toString();
|
counterElement.textContent = (parseInt(counterElement.textContent) + 1).toString();
|
||||||
counterElement.classList.remove("fn__none")
|
counterElement.classList.remove("fn__none");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -797,10 +797,10 @@ export class Files extends Model {
|
||||||
}
|
}
|
||||||
const liElement = this.closeElement.querySelector(`li[data-url="${data.data.box.id}"]`) as HTMLElement;
|
const liElement = this.closeElement.querySelector(`li[data-url="${data.data.box.id}"]`) as HTMLElement;
|
||||||
if (liElement) {
|
if (liElement) {
|
||||||
const counterElement = this.closeElement.querySelector(".counter")
|
const counterElement = this.closeElement.querySelector(".counter");
|
||||||
counterElement.textContent = (parseInt(counterElement.textContent) - 1).toString()
|
counterElement.textContent = (parseInt(counterElement.textContent) - 1).toString();
|
||||||
if (counterElement.textContent === "0") {
|
if (counterElement.textContent === "0") {
|
||||||
counterElement.classList.add("fn__none")
|
counterElement.classList.add("fn__none");
|
||||||
}
|
}
|
||||||
liElement.remove();
|
liElement.remove();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1019,7 +1019,7 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
|
||||||
fetchPost("/api/asset/getImageOCRText", {
|
fetchPost("/api/asset/getImageOCRText", {
|
||||||
path: imgElement.getAttribute("src")
|
path: imgElement.getAttribute("src")
|
||||||
}, (response) => {
|
}, (response) => {
|
||||||
const textarea =element.querySelector("textarea")
|
const textarea =element.querySelector("textarea");
|
||||||
textarea.value = response.data.text;
|
textarea.value = response.data.text;
|
||||||
textarea.dataset.ocrText = response.data.text;
|
textarea.dataset.ocrText = response.data.text;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -304,8 +304,8 @@ export class MobileFiles extends Model {
|
||||||
});
|
});
|
||||||
this.element.innerHTML = html;
|
this.element.innerHTML = html;
|
||||||
this.closeElement.lastElementChild.innerHTML = closeHtml;
|
this.closeElement.lastElementChild.innerHTML = closeHtml;
|
||||||
const counterElement = this.closeElement.querySelector(".counter")
|
const counterElement = this.closeElement.querySelector(".counter");
|
||||||
counterElement.textContent = closeCounter.toString()
|
counterElement.textContent = closeCounter.toString();
|
||||||
if (closeCounter) {
|
if (closeCounter) {
|
||||||
counterElement.classList.remove("fn__none");
|
counterElement.classList.remove("fn__none");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -419,7 +419,7 @@ export class MobileFiles extends Model {
|
||||||
this.closeElement.lastElementChild.innerHTML = closeHTML;
|
this.closeElement.lastElementChild.innerHTML = closeHTML;
|
||||||
const counterElement = this.closeElement.querySelector(".counter");
|
const counterElement = this.closeElement.querySelector(".counter");
|
||||||
counterElement.textContent = (parseInt(counterElement.textContent) + 1).toString();
|
counterElement.textContent = (parseInt(counterElement.textContent) + 1).toString();
|
||||||
counterElement.classList.remove("fn__none")
|
counterElement.classList.remove("fn__none");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -474,10 +474,10 @@ export class MobileFiles extends Model {
|
||||||
const liElement = this.closeElement.querySelector(`li[data-url="${data.data.box.id}"]`) as HTMLElement;
|
const liElement = this.closeElement.querySelector(`li[data-url="${data.data.box.id}"]`) as HTMLElement;
|
||||||
if (liElement) {
|
if (liElement) {
|
||||||
liElement.remove();
|
liElement.remove();
|
||||||
const counterElement = this.closeElement.querySelector(".counter")
|
const counterElement = this.closeElement.querySelector(".counter");
|
||||||
counterElement.textContent = (parseInt(counterElement.textContent) - 1).toString()
|
counterElement.textContent = (parseInt(counterElement.textContent) - 1).toString();
|
||||||
if (counterElement.textContent === "0") {
|
if (counterElement.textContent === "0") {
|
||||||
counterElement.classList.add("fn__none")
|
counterElement.classList.add("fn__none");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setNoteBook((notebooks: INotebook[]) => {
|
setNoteBook((notebooks: INotebook[]) => {
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ export class Gutter {
|
||||||
selectElements.push(item);
|
selectElements.push(item);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
protyle.wysiwyg.element.querySelector(`[data-node-id="${buttonElement.getAttribute("data-node-id")}"]`)?.classList.add("protyle-wysiwyg--select")
|
protyle.wysiwyg.element.querySelector(`[data-node-id="${buttonElement.getAttribute("data-node-id")}"]`)?.classList.add("protyle-wysiwyg--select");
|
||||||
selectElements = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));
|
selectElements = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));
|
||||||
selectElements.forEach(item => {
|
selectElements.forEach(item => {
|
||||||
selectIds.push(item.getAttribute("data-node-id"));
|
selectIds.push(item.getAttribute("data-node-id"));
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ export class Title {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.key === "ArrowDown") {
|
if (event.key === "ArrowDown") {
|
||||||
const rects = getSelection().getRangeAt(0).getClientRects()
|
const rects = getSelection().getRangeAt(0).getClientRects();
|
||||||
// https://github.com/siyuan-note/siyuan/issues/11729
|
// https://github.com/siyuan-note/siyuan/issues/11729
|
||||||
if (this.editElement.getBoundingClientRect().bottom - rects[rects.length - 1].bottom < 25) {
|
if (this.editElement.getBoundingClientRect().bottom - rects[rects.length - 1].bottom < 25) {
|
||||||
const noContainerElement = getNoContainerElement(protyle.wysiwyg.element.firstElementChild);
|
const noContainerElement = getNoContainerElement(protyle.wysiwyg.element.firstElementChild);
|
||||||
|
|
|
||||||
|
|
@ -527,7 +527,7 @@ const dragSb = async (protyle: IProtyle, sourceElements: Element[], targetElemen
|
||||||
item.protyle.undo.clear();
|
item.protyle.undo.clear();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
/// #endif
|
/// #endif
|
||||||
}
|
}
|
||||||
|
|
@ -711,7 +711,7 @@ const dragSame = async (protyle: IProtyle, sourceElements: Element[], targetElem
|
||||||
item.protyle.undo.clear();
|
item.protyle.undo.clear();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
/// #endif
|
/// #endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -338,9 +338,9 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let lastElement: Element;
|
let lastElement: Element;
|
||||||
let insertBefore = false
|
let insertBefore = false;
|
||||||
if (!range.toString() && insertByCursor) {
|
if (!range.toString() && insertByCursor) {
|
||||||
const positon = getSelectionOffset(blockElement, protyle.wysiwyg.element, range)
|
const positon = getSelectionOffset(blockElement, protyle.wysiwyg.element, range);
|
||||||
if (positon.start === 0 && editableElement.textContent !== "") {
|
if (positon.start === 0 && editableElement.textContent !== "") {
|
||||||
insertBefore = true;
|
insertBefore = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,9 +93,9 @@ export const upSelect = (options: {
|
||||||
} else {
|
} else {
|
||||||
const tdElement = hasClosestByMatchTag(options.range.startContainer, "TD") || hasClosestByMatchTag(options.range.startContainer, "TH");
|
const tdElement = hasClosestByMatchTag(options.range.startContainer, "TD") || hasClosestByMatchTag(options.range.startContainer, "TH");
|
||||||
const nodeEditableElement = (tdElement || getContenteditableElement(options.nodeElement) || options.nodeElement) as HTMLElement;
|
const nodeEditableElement = (tdElement || getContenteditableElement(options.nodeElement) || options.nodeElement) as HTMLElement;
|
||||||
const startIndex = getSelectionOffset(nodeEditableElement, options.editorElement, options.range).start
|
const startIndex = getSelectionOffset(nodeEditableElement, options.editorElement, options.range).start;
|
||||||
const innerText = nodeEditableElement.innerText;
|
const innerText = nodeEditableElement.innerText;
|
||||||
const isExpandUp = matchHotKey(window.siyuan.config.keymap.editor.general.expandUp.custom, options.event)
|
const isExpandUp = matchHotKey(window.siyuan.config.keymap.editor.general.expandUp.custom, options.event);
|
||||||
if (!isMac() && isExpandUp) {
|
if (!isMac() && isExpandUp) {
|
||||||
// Windows 中 ⌥⇧↑ 默认无选中功能会导致 https://ld246.com/article/1716635371149
|
// Windows 中 ⌥⇧↑ 默认无选中功能会导致 https://ld246.com/article/1716635371149
|
||||||
} else if (startIndex > 0) {
|
} else if (startIndex > 0) {
|
||||||
|
|
@ -141,9 +141,9 @@ export const downSelect = (options: {
|
||||||
} else {
|
} else {
|
||||||
const tdElement = hasClosestByMatchTag(options.range.startContainer, "TD") || hasClosestByMatchTag(options.range.startContainer, "TH");
|
const tdElement = hasClosestByMatchTag(options.range.startContainer, "TD") || hasClosestByMatchTag(options.range.startContainer, "TH");
|
||||||
const nodeEditableElement = (tdElement || getContenteditableElement(options.nodeElement) || options.nodeElement) as HTMLElement;
|
const nodeEditableElement = (tdElement || getContenteditableElement(options.nodeElement) || options.nodeElement) as HTMLElement;
|
||||||
const endIndex = getSelectionOffset(nodeEditableElement, options.editorElement, options.range).end
|
const endIndex = getSelectionOffset(nodeEditableElement, options.editorElement, options.range).end;
|
||||||
const innerText = nodeEditableElement.innerText;
|
const innerText = nodeEditableElement.innerText;
|
||||||
const isExpandDown = matchHotKey(window.siyuan.config.keymap.editor.general.expandDown.custom, options.event)
|
const isExpandDown = matchHotKey(window.siyuan.config.keymap.editor.general.expandDown.custom, options.event);
|
||||||
if (!isMac() && isExpandDown) {
|
if (!isMac() && isExpandDown) {
|
||||||
// Windows 中 ⌥⇧↓ 默认无选中功能会导致 https://ld246.com/article/1716635371149
|
// Windows 中 ⌥⇧↓ 默认无选中功能会导致 https://ld246.com/article/1716635371149
|
||||||
} else if (endIndex < innerText.length) {
|
} else if (endIndex < innerText.length) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue