mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-19 02:21:38 +08:00
This commit is contained in:
parent
40868a50f9
commit
bab9a27cac
@ -234,6 +234,10 @@ export class Toolbar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public setInlineMark(protyle: IProtyle, type: string, action: "range" | "toolbar", textObj?: ITextOption) {
|
public setInlineMark(protyle: IProtyle, type: string, action: "range" | "toolbar", textObj?: ITextOption) {
|
||||||
|
if (["text", "a", "block-ref", "inline-math", "inline-memo"].includes(type)) {
|
||||||
|
protyle.toolbar.element.querySelector(`[data-type="${type}"]`).dispatchEvent(new CustomEvent("block-ref" === type ? getEventName() : "click"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
const nodeElement = hasClosestBlock(this.range.startContainer);
|
const nodeElement = hasClosestBlock(this.range.startContainer);
|
||||||
if (!nodeElement) {
|
if (!nodeElement) {
|
||||||
return;
|
return;
|
||||||
|
@ -112,11 +112,12 @@ export class WYSIWYG {
|
|||||||
const inputData = event.data;
|
const inputData = event.data;
|
||||||
protyle.toolbar.range = range;
|
protyle.toolbar.range = range;
|
||||||
const inlineElement = range.startContainer.parentElement;
|
const inlineElement = range.startContainer.parentElement;
|
||||||
const currentTypes = protyle.toolbar.getCurrentType();
|
const currentTypes = protyle.toolbar.getCurrentType();
|
||||||
if (// 表格行内公式之前无法插入文字 https://github.com/siyuan-note/siyuan/issues/3908
|
if (// 表格行内公式之前无法插入文字 https://github.com/siyuan-note/siyuan/issues/3908
|
||||||
inlineElement.tagName==="SPAN" &&
|
inlineElement.tagName === "SPAN" &&
|
||||||
|
inlineElement.textContent.replace(Constants.ZWSP, "") !== inputData &&
|
||||||
range.toString() === "" && range.startContainer.nodeType === 3 &&
|
range.toString() === "" && range.startContainer.nodeType === 3 &&
|
||||||
(currentTypes.includes("inline-memo") || currentTypes.includes("text") || currentTypes.includes("block-ref")|| currentTypes.includes("file-annotation-ref")|| currentTypes.includes("a")) &&
|
(currentTypes.includes("inline-memo") || currentTypes.includes("text") || currentTypes.includes("block-ref") || currentTypes.includes("file-annotation-ref") || currentTypes.includes("a")) &&
|
||||||
!hasNextSibling(range.startContainer) && range.startContainer.textContent.length === range.startOffset &&
|
!hasNextSibling(range.startContainer) && range.startContainer.textContent.length === range.startOffset &&
|
||||||
inlineElement.textContent.replace(Constants.ZWSP, "").length >= inputData.length // 为空的时候需要等于
|
inlineElement.textContent.replace(Constants.ZWSP, "").length >= inputData.length // 为空的时候需要等于
|
||||||
) {
|
) {
|
||||||
|
@ -1183,11 +1183,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||||||
}
|
}
|
||||||
if (matchHotKey(menuItem.hotkey, event)) {
|
if (matchHotKey(menuItem.hotkey, event)) {
|
||||||
protyle.toolbar.range = getEditorRange(protyle.wysiwyg.element);
|
protyle.toolbar.range = getEditorRange(protyle.wysiwyg.element);
|
||||||
if (["text", "a", "block-ref", "inline-math", "inline-memo"].includes(menuItem.name)) {
|
protyle.toolbar.setInlineMark(protyle, menuItem.name, "range");
|
||||||
protyle.toolbar.element.querySelector(`[data-type="${menuItem.name}"]`).dispatchEvent(new CustomEvent("block-ref" === menuItem.name ? getEventName() : "click"));
|
|
||||||
} else {
|
|
||||||
protyle.toolbar.setInlineMark(protyle, menuItem.name, "range");
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user