Fix: make sure Edit buttons work even for Lua expressions and code

widgets whose bodies appear multiple times in the same page (previously
always jumped to first).
This commit is contained in:
Zef Hemel
2026-03-12 14:13:18 +01:00
parent 1f7a4d7d66
commit dbcef9e8aa
5 changed files with 33 additions and 24 deletions
+6 -2
View File
@@ -10,7 +10,7 @@ import { extendedMarkdownLanguage } from "../markdown_parser/parser.ts";
import { renderToText } from "@silverbulletmd/silverbullet/lib/tree";
import {
attachWidgetEventHandlers,
moveCursorIntoText,
moveCursorToWidgetStart,
} from "./widget_util.ts";
import { expandMarkdown } from "../markdown_renderer/inline.ts";
import {
@@ -366,7 +366,11 @@ export class LuaWidget extends WidgetType {
icon: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-edit"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path></svg>',
listener: (e) => {
e.stopPropagation();
moveCursorIntoText(this.opts.client, this.opts.codeText!);
moveCursorToWidgetStart(
this.opts.client,
this.dom!,
this.opts.codeText,
);
},
}),
);