Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/8554 link

Vanessa5c53a543896d
diff --git a/app/src/assets/scss/protyle/_toolbar.scss b/app/src/assets/scss/protyle/_toolbar.scss
index a588d6bd8b..bebb830b60 100644
--- a/app/src/assets/scss/protyle/_toolbar.scss
+++ b/app/src/assets/scss/protyle/_toolbar.scss
@@ -34,7 +34,11 @@
color: var(--b3-theme-primary);
}
- &:hover {
+ &:disabled {
+ opacity: .38;
+ }
+
+ &:hover:not(:disabled) {
background-color: var(--b3-list-hover);
}
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts
index 40185176ec..544f8c0710 100644
--- a/app/src/menus/protyle.ts
+++ b/app/src/menus/protyle.ts
@@ -1473,21 +1473,13 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
}
};
-export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText = false,
- linkElements = [linkElement], oldHTMLs?: Map<string, string>) => {
+export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText = false) => {
window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_INLINE_A);
const nodeElement = hasClosestBlock(linkElement);
if (!nodeElement) {
return;
}
- const linkBlockElements: Element[] = [];
- linkElements.forEach(item => {
- const blockElement = hasClosestBlock(item);
- if (blockElement && !linkBlockElements.includes(blockElement)) {
- linkBlockElements.push(blockElement);
- }
- });
hideTooltip();
hideElements(["util", "toolbar", "hint"], protyle);
let html = nodeElement.outerHTML;
@@ -1743,18 +1735,16 @@ style="margin:4px 0;width: ${isMobile() ? "100%" : "360px"}" class="b3-text-fiel
window.siyuan.menus.menu.removeCB = () => {
const title = Lute.EscapeHTMLStr(inputElements[2].value.replace(/\n|\r\n|\r|\u2028|\u2029/g, ""));
const href = Lute.EscapeHTMLStr(inputElements[0].value.replace(/\n|\r\n|\r|\u2028|\u2029/g, ""));
- linkElements.forEach(item => {
- if (title) {
- item.setAttribute("data-title", title);
- } else {
- item.removeAttribute("data-title");
- }
- if (item.getAttribute("data-type").indexOf("a") > -1) {
- item.setAttribute("data-href", href);
- } else {
- item.removeAttribute("data-href");
- }
- });
+ if (title) {
+ linkElement.setAttribute("data-title", title);
+ } else {
+ linkElement.removeAttribute("data-title");
+ }
+ if (linkElement.getAttribute("data-type").indexOf("a") > -1) {
+ linkElement.setAttribute("data-href", href);
+ } else {
+ linkElement.removeAttribute("data-href");
+ }
if (!inputElements[1].value && (inputElements[0].value || inputElements[2].value)) {
linkElement.textContent = "*";
}
@@ -1765,24 +1755,9 @@ style="margin:4px 0;width: ${isMobile() ? "100%" : "360px"}" class="b3-text-fiel
focusByRange(protyle.toolbar.range);
}
if (!inputElements[1].value && !inputElements[0].value && !inputElements[2].value) {
- linkElements.forEach(item => item.remove());
- }
- if (oldHTMLs) {
- const operations: IOperation[] = [];
- const undoOperations: IOperation[] = [];
- linkBlockElements.forEach(item => {
- const id = item.getAttribute("data-node-id");
- const oldHTML = oldHTMLs.get(id);
- if (oldHTML && item.outerHTML !== oldHTML) {
- item.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
- operations.push({action: "update", id, data: item.outerHTML});
- undoOperations.push({action: "update", id, data: oldHTML});
- }
- });
- if (operations.length > 0) {
- transaction(protyle, operations, undoOperations);
- }
- } else if (html !== nodeElement.outerHTML) {
+ linkElement.remove();
+ }
+ if (html !== nodeElement.outerHTML) {
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
updateTransaction(protyle, nodeElement, html);
}