mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 00:38:49 +01:00
This commit is contained in:
parent
ab1c3669c4
commit
a8944e19be
3 changed files with 34 additions and 3 deletions
|
|
@ -15,7 +15,7 @@ export const initConfigSearch = (element: HTMLElement) => {
|
|||
"editor", "md2", "md3", "md12", "md16", "md27", "md28", "md29", "md30", "md31", "md32", "md33", "md34",
|
||||
"md39", "md40", "fontSizeTip", "fontSize", "font", "font1", "generateHistory", "generateHistoryInterval",
|
||||
"historyRetentionDays", "historyRetentionDaysTip", "clearHistory", "katexMacros", "katexMacrosTip",
|
||||
"editReadonly", "editReadonlyTip"
|
||||
"editReadonly", "editReadonlyTip", "embedBlockBreadcrumb", "embedBlockBreadcrumbTip"
|
||||
]),
|
||||
|
||||
// 文档树
|
||||
|
|
|
|||
|
|
@ -1165,6 +1165,7 @@ export class Gutter {
|
|||
}).element);
|
||||
} else if (type === "NodeBlockQueryEmbed" && !window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
const breadcrumb = nodeElement.getAttribute("breadcrumb");
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
id: "assetSubMenu",
|
||||
type: "submenu",
|
||||
|
|
@ -1183,6 +1184,25 @@ export class Gutter {
|
|||
click() {
|
||||
protyle.toolbar.showRender(protyle, nodeElement);
|
||||
}
|
||||
}, {
|
||||
label: `<div class="fn__flex" style="margin-bottom: 4px"><span>${window.siyuan.languages.embedBlockBreadcrumb}</span><span class="fn__space fn__flex-1"></span>
|
||||
<input type="checkbox" class="b3-switch fn__flex-center"${breadcrumb === "true" ? " checked" : ((window.siyuan.config.editor.embedBlockBreadcrumb && breadcrumb !== "false") ? " checked" : "")}></div>`,
|
||||
bind(element) {
|
||||
element.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {
|
||||
const inputElement = element.querySelector("input");
|
||||
if (event.target.tagName !== "INPUT") {
|
||||
inputElement.checked = !inputElement.checked;
|
||||
}
|
||||
nodeElement.setAttribute("breadcrumb", inputElement.checked.toString());
|
||||
fetchPost("/api/attr/setBlockAttrs", {
|
||||
id,
|
||||
attrs: {breadcrumb: inputElement.checked.toString()}
|
||||
});
|
||||
nodeElement.removeAttribute("data-render")
|
||||
blockRender(protyle, nodeElement);
|
||||
window.siyuan.menus.menu.remove();
|
||||
});
|
||||
}
|
||||
}]
|
||||
}).element);
|
||||
} else if (type === "NodeHeading" && !window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly) {
|
||||
|
|
|
|||
|
|
@ -26,10 +26,17 @@ export const blockRender = (protyle: IProtyle, element: Element) => {
|
|||
<span class="protyle-icon protyle-action__menu protyle-icon--last"><svg><use xlink:href="#iconMore"></use></svg></span>
|
||||
</div>${item.lastElementChild.outerHTML}`;
|
||||
const content = Lute.UnEscapeHTMLStr(item.getAttribute("data-content"));
|
||||
let breadcrumb: boolean | string = item.getAttribute("breadcrumb");
|
||||
if (breadcrumb) {
|
||||
breadcrumb = breadcrumb === "true"
|
||||
} else {
|
||||
breadcrumb = window.siyuan.config.editor.embedBlockBreadcrumb
|
||||
}
|
||||
fetchPost("/api/search/searchEmbedBlock", {
|
||||
stmt: content,
|
||||
headingMode: item.getAttribute("custom-heading-mode") === "1" ? 1 : 0,
|
||||
excludeIDs: [item.getAttribute("data-node-id"), protyle.block.rootID]
|
||||
excludeIDs: [item.getAttribute("data-node-id"), protyle.block.rootID],
|
||||
breadcrumb
|
||||
}, (response) => {
|
||||
const rotateElement = item.querySelector(".fn__rotate");
|
||||
if (rotateElement) {
|
||||
|
|
@ -37,7 +44,11 @@ export const blockRender = (protyle: IProtyle, element: Element) => {
|
|||
}
|
||||
let html = "";
|
||||
response.data.blocks.forEach((blocksItem: { block: IBlock, blockPaths: IBreadcrumb[] }) => {
|
||||
html += `<div class="protyle-wysiwyg__embed" data-id="${blocksItem.block.id}">${genBreadcrumb(blocksItem.blockPaths, true)}${blocksItem.block.content}</div>`;
|
||||
let breadcrumbHTML = "";
|
||||
if (blocksItem.blockPaths.length !== 0) {
|
||||
breadcrumbHTML = genBreadcrumb(blocksItem.blockPaths, true);
|
||||
}
|
||||
html += `<div class="protyle-wysiwyg__embed" data-id="${blocksItem.block.id}">${breadcrumbHTML}${blocksItem.block.content}</div>`;
|
||||
});
|
||||
item.setAttribute("data-render", "true");
|
||||
if (response.data.blocks.length > 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue