An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: Support block alias drag sorting and improve spacing https://github.com/siyuan-note/siyuan/issues/19735
Danielb897a070af45
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-6yi0dv5/20210613191509-cbkxcbz.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-6yi0dv5/20210613191509-cbkxcbz.syindex d8a47bdd2f..168a3cd8f0 100644--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-6yi0dv5/20210613191509-cbkxcbz.sy+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-6yi0dv5/20210613191509-cbkxcbz.sy@@ -6,7 +6,7 @@"id": "20210613191509-cbkxcbz","title": "Content Block Attribute","type": "doc",- "updated": "20260922145800"+ "updated": "20260922175346"},"Children": [{@@ -44,7 +44,7 @@"HeadingLevel": 2,"Properties": {"id": "20210613191548-ckua3q3",- "updated": "20260922145800"+ "updated": "20260922175346"},"Children": [{@@ -62,7 +62,7 @@],"Properties": {"id": "20210613191548-n6dt4hc",- "updated": "20260922145800"+ "updated": "20260922175346"},"Children": [{@@ -165,6 +165,19 @@{"Type": "NodeText","Data": " to cancel the current input. Leading and trailing whitespace, empty entries and exact duplicates are removed from new input."+ },+ {+ "Type": "NodeText",+ "Data": " Drag aliases to reorder them; the order is saved when you release. Touchscreens also support dragging. Press "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Esc"+ },+ {+ "Type": "NodeText",+ "Data": " while dragging to cancel the reorder."}]}diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-fqgskfj/20210612224500-ywcms1m.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-fqgskfj/20210612224500-ywcms1m.syindex 81e29d4e84..13d489c46b 100644--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-fqgskfj/20210612224500-ywcms1m.sy+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-fqgskfj/20210612224500-ywcms1m.sy@@ -6,7 +6,7 @@"id": "20210612224500-ywcms1m","title": "内容块属性","type": "doc",- "updated": "20260922145800"+ "updated": "20260922175346"},"Children": [{@@ -44,7 +44,7 @@"HeadingLevel": 2,"Properties": {"id": "20210613004126-79loyta",- "updated": "20260922145800"+ "updated": "20260922175346"},"Children": [{@@ -62,7 +62,7 @@],"Properties": {"id": "20210613004249-56e0c6r",- "updated": "20260922145800"+ "updated": "20260922175346"},"Children": [{@@ -165,6 +165,19 @@{"Type": "NodeText","Data": " 取消本次输入。新输入会去除首尾空白、过滤空项和完全相同的重复项。"+ },+ {+ "Type": "NodeText",+ "Data": "拖动别名可调整顺序,松开后保存;触屏也支持拖动。拖动时按 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Esc"+ },+ {+ "Type": "NodeText",+ "Data": " 可取消排序。"}]}diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226115825-mhcslw2/20211226120802-77aj0is.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226115825-mhcslw2/20211226120802-77aj0is.syindex 5183546197..f12f5c906c 100644--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226115825-mhcslw2/20211226120802-77aj0is.sy+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226115825-mhcslw2/20211226120802-77aj0is.sy@@ -6,7 +6,7 @@"id": "20211226120802-77aj0is","title": "内容區塊屬性","type": "doc",- "updated": "20260922145800"+ "updated": "20260922175346"},"Children": [{@@ -44,7 +44,7 @@"HeadingLevel": 2,"Properties": {"id": "20211226120833-wzobna4",- "updated": "20260922145800"+ "updated": "20260922175346"},"Children": [{@@ -63,7 +63,7 @@"Properties": {"colgroup": "|","id": "20211226120833-5n4ui6o",- "updated": "20260922145800"+ "updated": "20260922175346"},"Children": [{@@ -166,6 +166,19 @@{"Type": "NodeText","Data": " 取消本次輸入。新輸入會移除前後空白、過濾空項和完全相同的重複項。"+ },+ {+ "Type": "NodeText",+ "Data": "拖曳別名可調整順序,放開後儲存;觸控螢幕也支援拖曳。拖曳時按 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Esc"+ },+ {+ "Type": "NodeText",+ "Data": " 可取消排序。"}]}diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-gvtksyj/20240530101000-875snki.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-gvtksyj/20240530101000-875snki.syindex 42590f2344..6cff89d09e 100644--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-gvtksyj/20240530101000-875snki.sy+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-gvtksyj/20240530101000-875snki.sy@@ -7,7 +7,7 @@"id": "20240530101000-875snki","title": "コンテンツブロックの属性","type": "doc",- "updated": "20260922145800"+ "updated": "20260922175346"},"Children": [{@@ -48,7 +48,7 @@"Properties": {"ID": "20240530101000-9eowlvm","id": "20240530101000-enq56zt",- "updated": "20260922145800"+ "updated": "20260922175346"},"Children": [{@@ -68,7 +68,7 @@"ID": "20240530101000-ue0r5sh","colgroup": "|","id": "20240530101000-essns4c",- "updated": "20260922145800"+ "updated": "20260922175346"},"Children": [{@@ -171,6 +171,19 @@{"Type": "NodeText","Data": " キーで今回の入力を取り消せます。新しい入力では、前後の空白、空の項目、完全に一致する重複項目が除去されます。"+ },+ {+ "Type": "NodeText",+ "Data": "エイリアスをドラッグして順序を変更でき、離すと保存されます。タッチスクリーンでもドラッグできます。ドラッグ中に "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Esc"+ },+ {+ "Type": "NodeText",+ "Data": " キーを押すと並べ替えを取り消せます。"}]}diff --git a/app/src/assets/scss/business/_custom.scss b/app/src/assets/scss/business/_custom.scssindex beef2025e6..ebc7b2c642 100644--- a/app/src/assets/scss/business/_custom.scss+++ b/app/src/assets/scss/business/_custom.scss@@ -1,16 +1,5 @@.custom-attr {- &__aliases {- .b3-chip {- max-width: 100%;- }-- .b3-chip > span {- min-width: 0;- overflow-wrap: anywhere;- }- }-&__avbacklinks {border-bottom: 1px solid var(--b3-border-color);padding: 4px 8px 8px 36px;@@ -245,6 +234,22 @@margin: 1px 2px;}+ &__aliases {+ padding: 0;++ .b3-chip {+ max-width: 100%;+ margin: 0 8px 8px 0;+ }++ .b3-chip > span {+ min-width: 0;+ overflow-wrap: anywhere;+ touch-action: none;+ user-select: none;+ }+ }+.av__cellassetimg {max-height: 24px;}diff --git a/app/src/menus/aliasInput.ts b/app/src/menus/aliasInput.tsindex 0a534b3d50..6633deeaf8 100644--- a/app/src/menus/aliasInput.ts+++ b/app/src/menus/aliasInput.ts@@ -12,13 +12,17 @@ export const bindAliasInput = (element: HTMLElement, initialValue: string, optioremoveLabel: string,placeholder: string,spellcheck: boolean,+ dragThreshold?: number,save: (value: string) => Promise<boolean>,}) => {let aliases = parseAliases(initialValue);let editing = -1;let pending: Promise<boolean>;let actions = Promise.resolve();- element.innerHTML = `<div class="b3-chips b3-chips__doctag custom-attr__aliases"></div>+ let activeActions = 0;+ let cancelDrag: () => void;+ let suppressClick = false;+ element.innerHTML = `<div class="b3-chips custom-attr__aliases"></div><button type="button" class="b3-button b3-button--cancel"><svg><use xlink:href="#iconAdd"></use></svg><span></span></button><input class="b3-text-field fn__block fn__none">`;const list = element.querySelector<HTMLElement>(".b3-chips");@@ -28,11 +32,126 @@ export const bindAliasInput = (element: HTMLElement, initialValue: string, optioinput.placeholder = options.placeholder;input.setAttribute("aria-label", options.placeholder);input.spellcheck = options.spellcheck;+ list.addEventListener("click", event => {+ if (suppressClick && event.detail !== 0) {+ event.preventDefault();+ event.stopImmediatePropagation();+ }+ }, true);+ list.addEventListener("touchstart", event => {+ // 别名上的触摸由排序处理,避免同时触发移动端面板的下拉关闭。+ if ((event.target as Element).closest(".b3-chip")) {+ event.stopPropagation();+ }+ }, {passive: true});list.addEventListener("pointerdown", event => {+ suppressClick = false;// 点击标签时由点击处理器先提交草稿,避免失焦重绘移除正在点击的元素。if (document.activeElement === input) {event.preventDefault();}+ const chip = (event.target as Element).closest<HTMLElement>(".b3-chip");+ if (!chip || event.button !== 0 || !event.isPrimary || pending || activeActions || cancelDrag ||+ !input.classList.contains("fn__none") || (event.target as Element).closest(".b3-chip__close")) {+ return;+ }+ const rect = chip.getBoundingClientRect();+ const offsetX = event.clientX - rect.left;+ const offsetY = event.clientY - rect.top;+ let clone: HTMLElement;+ const cleanup = () => {+ document.removeEventListener("pointermove", move);+ document.removeEventListener("pointerup", drop);+ document.removeEventListener("pointercancel", cancel);+ document.removeEventListener("keydown", escape, true);+ window.removeEventListener("blur", cancel);+ list.removeEventListener("lostpointercapture", lostCapture);+ if (list.hasPointerCapture(event.pointerId)) {+ list.releasePointerCapture(event.pointerId);+ }+ clone?.remove();+ chip.classList.remove("b3-chip--dragging");+ cancelDrag = undefined;+ };+ const cancel = () => {+ cleanup();+ if (clone) {+ render();+ }+ };+ const lostCapture = (captureEvent: PointerEvent) => {+ if (captureEvent.target === list && captureEvent.pointerId === event.pointerId) {+ cancel();+ }+ };+ const escape = (keyEvent: KeyboardEvent) => {+ if (keyEvent.key === "Escape") {+ keyEvent.preventDefault();+ keyEvent.stopPropagation();+ cancel();+ }+ };+ const move = (moveEvent: PointerEvent) => {+ if (moveEvent.pointerId !== event.pointerId) {+ return;+ }+ if (!clone) {+ if (Math.abs(moveEvent.clientX - event.clientX) < (options.dragThreshold ?? 5) &&+ Math.abs(moveEvent.clientY - event.clientY) < (options.dragThreshold ?? 5)) {+ return;+ }+ suppressClick = true;+ clone = chip.cloneNode(true) as HTMLElement;+ clone.classList.add("b3-chip--dragclone");+ clone.setAttribute("aria-hidden", "true");+ clone.querySelectorAll("[tabindex]").forEach(item => item.removeAttribute("tabindex"));+ Object.assign(clone.style, {+ position: "fixed", width: `${rect.width}px`, height: `${rect.height}px`,+ margin: "0", zIndex: "9999", pointerEvents: "none", transition: "none",+ });+ document.body.append(clone);+ chip.classList.add("b3-chip--dragging");+ list.setPointerCapture(event.pointerId);+ }+ moveEvent.preventDefault();+ clone.style.left = `${moveEvent.clientX - offsetX}px`;+ clone.style.top = `${moveEvent.clientY - offsetY}px`;+ const target = document.elementFromPoint(moveEvent.clientX, moveEvent.clientY)+ ?.closest<HTMLElement>(".b3-chip");+ if (target && target !== chip && target.parentElement === list) {+ const targetRect = target.getBoundingClientRect();+ if (moveEvent.clientX > targetRect.left + targetRect.width / 2) {+ target.after(chip);+ } else {+ target.before(chip);+ }+ }+ };+ const drop = (upEvent: PointerEvent) => {+ if (upEvent.pointerId !== event.pointerId) {+ return;+ }+ const next = Array.from(list.children).map(item => item.querySelector("span").textContent);+ cleanup();+ if (!clone) {+ return;+ }+ upEvent.preventDefault();+ if (next.some((alias, index) => alias !== aliases[index])) {+ activate(async () => {+ if (!await persist(next, false)) {+ render();+ }+ });+ }+ };+ cancelDrag = cancel;+ document.addEventListener("pointermove", move, {passive: false});+ document.addEventListener("pointerup", drop);+ document.addEventListener("pointercancel", cancel);+ document.addEventListener("keydown", escape, true);+ window.addEventListener("blur", cancel);+ list.addEventListener("lostpointercapture", lostCapture);});const finish = () => {editing = -1;@@ -124,10 +243,13 @@ export const bindAliasInput = (element: HTMLElement, initialValue: string, optio};const activate = (action: () => Promise<void>) => {// 标签操作依次提交,避免失焦保存和连续删除互相覆盖。+ activeActions++;actions = actions.then(async () => {if (await commit()) {await action();}+ }).finally(() => {+ activeActions--;});};add.addEventListener("click", open);@@ -151,9 +273,11 @@ export const bindAliasInput = (element: HTMLElement, initialValue: string, optiorender();return {commit: async () => {+ cancelDrag?.();await actions;return commit();},focus: open,+ destroy: () => cancelDrag?.(),};};diff --git a/app/src/menus/commonMenuItem.ts b/app/src/menus/commonMenuItem.tsindex 197b1e092d..411a580951 100644--- a/app/src/menus/commonMenuItem.ts+++ b/app/src/menus/commonMenuItem.ts@@ -288,6 +288,7 @@ export const openFileAttr = (attrs: Record<string, string>, focusName = "bookmar</div></div>`,destroyCallback() {+ aliasInput.destroy();/// #if MOBILEdisposeSheet();/// #else@@ -315,6 +316,7 @@ export const openFileAttr = (attrs: Record<string, string>, focusName = "bookmar(dialog.element.querySelector('.b3-text-field[data-name="name"]') as HTMLInputElement).value = attrs.name || "";const aliasInput = bindAliasInput(dialog.element.querySelector("[data-alias-input]"), attrs.alias || "", {addLabel: window.siyuan.languages.addAlias,+ dragThreshold: Constants.SIZE_DRAG_THRESHOLD,removeLabel: window.siyuan.languages.remove,placeholder: window.siyuan.languages.attrAliasTip,spellcheck: window.siyuan.config.editor.spellcheck,