mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 01:20:12 +01:00
This commit is contained in:
parent
f69cad6349
commit
85efea75bc
1 changed files with 23 additions and 5 deletions
|
|
@ -24,6 +24,8 @@ import {openAssetNewWindow} from "../window/openNewWindow";
|
||||||
import {escapeHtml} from "../util/escape";
|
import {escapeHtml} from "../util/escape";
|
||||||
import {copyTextByType} from "../protyle/toolbar/util";
|
import {copyTextByType} from "../protyle/toolbar/util";
|
||||||
import {hideElements} from "../protyle/ui/hideElements";
|
import {hideElements} from "../protyle/ui/hideElements";
|
||||||
|
import {Protyle} from "../protyle";
|
||||||
|
import {getAllEditor} from "../layout/getAll";
|
||||||
|
|
||||||
const bindAttrInput = (inputElement: HTMLInputElement, id: string) => {
|
const bindAttrInput = (inputElement: HTMLInputElement, id: string) => {
|
||||||
inputElement.addEventListener("change", () => {
|
inputElement.addEventListener("change", () => {
|
||||||
|
|
@ -160,6 +162,20 @@ export const openFileAttr = (attrs: IObject, focusName = "bookmark", protyle?: I
|
||||||
let notifyHTML = "";
|
let notifyHTML = "";
|
||||||
let hasAV = false;
|
let hasAV = false;
|
||||||
const range = getSelection().rangeCount > 0 ? getSelection().getRangeAt(0) : null;
|
const range = getSelection().rangeCount > 0 ? getSelection().getRangeAt(0) : null;
|
||||||
|
let ghostProtyle: Protyle;
|
||||||
|
if (!protyle) {
|
||||||
|
getAllEditor().find(item => {
|
||||||
|
if (attrs.id === item.protyle.block.rootID) {
|
||||||
|
protyle = item.protyle;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!protyle) {
|
||||||
|
ghostProtyle = new Protyle(window.siyuan.ws.app, document.createElement('div'), {
|
||||||
|
blockId: attrs.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Object.keys(attrs).forEach(item => {
|
Object.keys(attrs).forEach(item => {
|
||||||
if (Constants.CUSTOM_RIFF_DECKS === item || item.startsWith("custom-sy-")) {
|
if (Constants.CUSTOM_RIFF_DECKS === item || item.startsWith("custom-sy-")) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -247,6 +263,8 @@ export const openFileAttr = (attrs: IObject, focusName = "bookmark", protyle?: I
|
||||||
focusByRange(range);
|
focusByRange(range);
|
||||||
if (protyle) {
|
if (protyle) {
|
||||||
hideElements(["select"], protyle);
|
hideElements(["select"], protyle);
|
||||||
|
} else {
|
||||||
|
ghostProtyle.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -266,8 +284,8 @@ export const openFileAttr = (attrs: IObject, focusName = "bookmark", protyle?: I
|
||||||
target.classList.add("item--focus");
|
target.classList.add("item--focus");
|
||||||
dialog.element.querySelectorAll(".custom-attr").forEach((item: HTMLElement) => {
|
dialog.element.querySelectorAll(".custom-attr").forEach((item: HTMLElement) => {
|
||||||
if (item.dataset.type === target.dataset.type) {
|
if (item.dataset.type === target.dataset.type) {
|
||||||
if (item.dataset.type === "NodeAttributeView" && item.innerHTML === "" && protyle) {
|
if (item.dataset.type === "NodeAttributeView" && item.innerHTML === "") {
|
||||||
renderAVAttribute(item, attrs.id, protyle);
|
renderAVAttribute(item, attrs.id, protyle || ghostProtyle.protyle);
|
||||||
}
|
}
|
||||||
item.classList.remove("fn__none");
|
item.classList.remove("fn__none");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -370,7 +388,7 @@ export const openFileAttr = (attrs: IObject, focusName = "bookmark", protyle?: I
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const openAttr = (nodeElement: Element, focusName = "bookmark", protyle?: IProtyle) => {
|
export const openAttr = (nodeElement: Element, focusName = "bookmark", protyle: IProtyle) => {
|
||||||
if (nodeElement.getAttribute("data-type") === "NodeThematicBreak") {
|
if (nodeElement.getAttribute("data-type") === "NodeThematicBreak") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue