An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Improve the format painter cursor https://github.com/siyuan-note/siyuan/issues/12732
Daniel8f4a779807f6
diff --git a/AGENTS.md b/AGENTS.mdindex 99c8d288e8..29f4912066 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -46,6 +46,8 @@ SiYuan repository guide. Module path `github.com/siyuan-note/siyuan`, license AG- For multi-step logic, write and run a temporary Node.js or Python script. On Windows, avoid PowerShell unless necessary- Do not pass non-ASCII text through shell pipelines, PowerShell here-strings, `python -c`, or `node -e`; write the text to a UTF-8 file with a file-editing tool and consume that file instead3. **Icons:** Do not hand-write SVG; use existing icons from `app/appearance/icons/litheness/icon.js` when possible+ - If no existing icon is suitable, source one from the official [Lucide icon library](https://lucide.dev/icons/) and adapt only attributes such as stroke width to match the established icon style; preserve the upstream path data+ - When adding an icon to `app/appearance/icons/litheness/icon.js`, add its preview entry to `app/appearance/icons/index.html` in the same change and keep the order aligned4. **User guide:** When editing the user guide, follow `docs/SY-FORMAT.md`- When a feature adds or changes shortcuts, update the shortcut documentation in the user guide in the same change; if the appropriate section is unclear, ask the user where it should be placed- Represent in-app UI navigation paths as segmented `kbd` text marks: use one `NodeTextMark` with `TextMarkType: "kbd"` per navigation level, and place a plain `NodeText` containing ` - ` between adjacent levelsdiff --git a/app/appearance/icons/index.html b/app/appearance/icons/index.htmlindex 4e5785f70a..d630f83a64 100644--- a/app/appearance/icons/index.html+++ b/app/appearance/icons/index.html@@ -172,6 +172,12 @@</svg>iconPaintBucket</div>+ <div>+ <svg>+ <use xlink:href="#iconPaintRoller"></use>+ </svg>+ iconPaintRoller+ </div><div><svg><use xlink:href="#iconLanguage"></use>diff --git a/app/appearance/icons/litheness/icon.js b/app/appearance/icons/litheness/icon.jsindex df8c3c7695..cdafa32ea7 100644--- a/app/appearance/icons/litheness/icon.js+++ b/app/appearance/icons/litheness/icon.js@@ -72,6 +72,9 @@ document.body.insertAdjacentHTML('afterbegin', `<svg id="iconsLitheness" style="<symbol id="iconPaintBucket" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M11 7 6 2"/><path d="M18.992 12H2.041"/><path d="M21.145 18.38A3.34 3.34 0 0 1 20 16.5a3.3 3.3 0 0 1-1.145 1.88c-.575.46-.855 1.02-.855 1.595A2 2 0 0 0 20 22a2 2 0 0 0 2-2.025c0-.58-.285-1.13-.855-1.595"/><path d="m8.5 4.5 2.148-2.148a1.205 1.205 0 0 1 1.704 0l7.296 7.296a1.205 1.205 0 0 1 0 1.704l-7.592 7.592a3.615 3.615 0 0 1-5.112 0l-3.888-3.888a3.615 3.615 0 0 1 0-5.112L5.67 7.33"/></symbol>+ <symbol id="iconPaintRoller" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">+ <rect width="16" height="6" x="2" y="2" rx="2"/><path d="M10 16v-2a2 2 0 0 1 2-2h8a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2"/><rect width="4" height="6" x="8" y="16" rx="1"/>+ </symbol><symbol id="iconLanguage" stroke-width="1.7" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></symbol>diff --git a/app/src/assets/scss/protyle/_wysiwyg.scss b/app/src/assets/scss/protyle/_wysiwyg.scssindex 5df80d2042..c9e2bccf59 100644--- a/app/src/assets/scss/protyle/_wysiwyg.scss+++ b/app/src/assets/scss/protyle/_wysiwyg.scss@@ -889,6 +889,10 @@}}+body[data-format-painter] .protyle-wysiwyg[data-readonly="false"] {+ cursor: var(--format-painter-cursor, text);+}+// 在思源中,不论只读模式还是预览点击图片都可以进行预览.protyle .img > span:nth-child(2) {cursor: pointer;diff --git a/app/src/protyle/toolbar/FormatPainter.ts b/app/src/protyle/toolbar/FormatPainter.tsindex 66da6b799e..87ce36bf31 100644--- a/app/src/protyle/toolbar/FormatPainter.ts+++ b/app/src/protyle/toolbar/FormatPainter.ts@@ -41,6 +41,26 @@ const getSegment = (textNode: Text, editableElement: Element) => {};};+const setFormatPainterCursor = () => {+ const iconElement = document.getElementById("iconPaintRoller");+ if (!iconElement) {+ return;+ }+ const svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");+ Array.from(iconElement.attributes).forEach(attribute => {+ if (attribute.name !== "id") {+ svgElement.setAttribute(attribute.name, attribute.value);+ }+ });+ svgElement.setAttribute("width", "24");+ svgElement.setAttribute("height", "24");+ svgElement.style.color = getComputedStyle(document.body).getPropertyValue("--b3-theme-on-background").trim() ||+ "#000";+ iconElement.childNodes.forEach(node => svgElement.append(node.cloneNode(true)));+ const data = encodeURIComponent(new XMLSerializer().serializeToString(svgElement));+ document.body.style.setProperty("--format-painter-cursor", `url("data:image/svg+xml,${data}") 10 21, text`);+};+export const getFormatPainterSnapshot = (rootElement: Element, range: Range) => {const segments: IFormatPainterSegment[] = [];getBlockRanges(rootElement, range, ["NodeCodeBlock", "NodeAttributeView"]).forEach(item => {@@ -88,6 +108,7 @@ class FormatPainterController {this.mode = mode;this.snapshot = snapshot;document.body.dataset.formatPainter = mode;+ setFormatPainterCursor();this.renderStatus();this.showMessage(mode === "continuous" ? window.siyuan.languages.formatPainterContinuousActive :window.siyuan.languages.formatPainterActive, 4000);@@ -118,6 +139,7 @@ class FormatPainterController {this.mode = undefined;this.snapshot = undefined;delete document.body.dataset.formatPainter;+ document.body.style.removeProperty("--format-painter-cursor");document.getElementById("statusFormatPainter")?.remove();this.showMessage(window.siyuan.languages.formatPainterInactive, 3000);return true;