inplan 0.1.23 → 0.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/app/main/index.cjs
CHANGED
|
@@ -735,12 +735,14 @@ function setStatusSession(file, session2) {
|
|
|
735
735
|
}
|
|
736
736
|
}
|
|
737
737
|
function registerPluginScheme() {
|
|
738
|
-
electron.protocol.registerSchemesAsPrivileged([{ scheme: SCHEME, privileges: { standard: true, secure: true, supportFetchAPI: true } }]);
|
|
738
|
+
electron.protocol.registerSchemesAsPrivileged([{ scheme: SCHEME, privileges: { standard: true, secure: true, supportFetchAPI: true, corsEnabled: true } }]);
|
|
739
739
|
}
|
|
740
740
|
function handlePluginScheme() {
|
|
741
741
|
electron.protocol.handle(SCHEME, () => {
|
|
742
742
|
if (!state) return new Response("", { status: 404 });
|
|
743
|
-
return new Response(node_fs.readFileSync(state.rendererPath), {
|
|
743
|
+
return new Response(node_fs.readFileSync(state.rendererPath), {
|
|
744
|
+
headers: { "content-type": "text/javascript", "access-control-allow-origin": "*" }
|
|
745
|
+
});
|
|
744
746
|
});
|
|
745
747
|
}
|
|
746
748
|
function pluginInfo() {
|
|
@@ -1219,6 +1221,24 @@ ${body.replace(/\s*$/, "")}
|
|
|
1219
1221
|
}
|
|
1220
1222
|
return { linkTarget: toPosix(node_path.relative(node_path.dirname(session.paths.file), abs)) };
|
|
1221
1223
|
});
|
|
1224
|
+
electron.ipcMain.handle("asset:save", (_e, bytes, ext) => {
|
|
1225
|
+
if (!session) return null;
|
|
1226
|
+
const docDir = node_path.dirname(session.paths.file);
|
|
1227
|
+
const assetsDir = node_path.join(docDir, `${node_path.basename(session.paths.file).replace(/\.md$/i, "")}.assets`);
|
|
1228
|
+
const safeExt = /^[a-z0-9]{1,5}$/i.test(ext) ? ext.toLowerCase() : "png";
|
|
1229
|
+
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[^0-9]/g, "").slice(0, 14);
|
|
1230
|
+
let abs = node_path.join(assetsDir, `image-${stamp}.${safeExt}`);
|
|
1231
|
+
for (let n = 1; node_fs.existsSync(abs); n++) abs = node_path.join(assetsDir, `image-${stamp}-${n}.${safeExt}`);
|
|
1232
|
+
try {
|
|
1233
|
+
node_fs.mkdirSync(assetsDir, { recursive: true });
|
|
1234
|
+
node_fs.writeFileSync(abs, Buffer.from(bytes));
|
|
1235
|
+
} catch (e) {
|
|
1236
|
+
process.stderr.write(`[inplan] asset:save failed: ${e.message}
|
|
1237
|
+
`);
|
|
1238
|
+
return null;
|
|
1239
|
+
}
|
|
1240
|
+
return { relPath: toPosix(node_path.relative(docDir, abs)) };
|
|
1241
|
+
});
|
|
1222
1242
|
electron.ipcMain.handle("doc:open", (_e, target) => {
|
|
1223
1243
|
const abs = node_path.resolve("/", target);
|
|
1224
1244
|
if (!abs.endsWith(".md") || !node_fs.existsSync(abs)) {
|
package/app/preload/index.mjs
CHANGED
|
@@ -105,6 +105,7 @@ const api = {
|
|
|
105
105
|
create: (path, content) => ipcRenderer.invoke("newdoc:create", path, content),
|
|
106
106
|
append: (path, body, comments) => ipcRenderer.invoke("newdoc:append", path, body, comments)
|
|
107
107
|
},
|
|
108
|
+
saveAsset: (bytes, ext) => ipcRenderer.invoke("asset:save", bytes, ext),
|
|
108
109
|
navigate: (dir) => ipcRenderer.invoke("nav:go", dir),
|
|
109
110
|
onNavState: (cb) => {
|
|
110
111
|
let active = true;
|
|
@@ -43520,6 +43520,28 @@ var EN = {
|
|
|
43520
43520
|
// pane tabs + splitter
|
|
43521
43521
|
"tabs.comments": "Comments",
|
|
43522
43522
|
"tabs.source": "Source",
|
|
43523
|
+
// source pane — formatting toolbar
|
|
43524
|
+
"source.heading": "H",
|
|
43525
|
+
"source.headingTitle": "Heading",
|
|
43526
|
+
"source.paragraph": "Paragraph",
|
|
43527
|
+
"source.h1": "Heading 1",
|
|
43528
|
+
"source.h2": "Heading 2",
|
|
43529
|
+
"source.h3": "Heading 3",
|
|
43530
|
+
"source.h4": "Heading 4",
|
|
43531
|
+
"source.h5": "Heading 5",
|
|
43532
|
+
"source.h6": "Heading 6",
|
|
43533
|
+
"source.bold": "Bold",
|
|
43534
|
+
"source.italic": "Italic",
|
|
43535
|
+
"source.strikethrough": "Strikethrough",
|
|
43536
|
+
"source.hr": "Horizontal rule",
|
|
43537
|
+
"source.quote": "Quote",
|
|
43538
|
+
"source.bulletList": "Bullet list",
|
|
43539
|
+
"source.orderedList": "Numbered list",
|
|
43540
|
+
"source.checklist": "Checklist",
|
|
43541
|
+
"source.link": "Link",
|
|
43542
|
+
"source.inlineCode": "Inline code",
|
|
43543
|
+
"source.codeBlock": "Code block",
|
|
43544
|
+
"source.image": "Image",
|
|
43523
43545
|
"splitter.resize": "Drag to resize",
|
|
43524
43546
|
// profile menu
|
|
43525
43547
|
"profile.account": "Account menu",
|
|
@@ -43546,6 +43568,7 @@ var EN = {
|
|
|
43546
43568
|
"msg.turnFinished": "turn finished — waiting for agent",
|
|
43547
43569
|
"msg.unsavedAnswer": "You have an unsaved answer — click “Answer” to save it, or Send again to skip.",
|
|
43548
43570
|
"msg.cantAnchor": "Comments can't be anchored to this selection",
|
|
43571
|
+
"msg.imagePasteFailed": "couldn't paste image",
|
|
43549
43572
|
// status bar
|
|
43550
43573
|
"status.ready": "ready",
|
|
43551
43574
|
"status.thinking": "Agent is thinking",
|
|
@@ -43763,6 +43786,21 @@ function NewDocModal({
|
|
|
43763
43786
|
] })
|
|
43764
43787
|
] }) });
|
|
43765
43788
|
}
|
|
43789
|
+
function isInternalDocLink(href) {
|
|
43790
|
+
if (!href || /^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith("//") || href.startsWith("#")) return false;
|
|
43791
|
+
return /\.md(\?[^#]*)?(#.*)?$/i.test(href);
|
|
43792
|
+
}
|
|
43793
|
+
function resolveDocPath(basePath, href) {
|
|
43794
|
+
const cleanHref = href.replace(/[?#].*$/, "");
|
|
43795
|
+
const baseDir = basePath.includes("/") ? basePath.slice(0, basePath.lastIndexOf("/")) : "";
|
|
43796
|
+
const out = cleanHref.startsWith("/") ? [] : baseDir.split("/").filter(Boolean);
|
|
43797
|
+
for (const seg of cleanHref.split("/")) {
|
|
43798
|
+
if (seg === "" || seg === ".") continue;
|
|
43799
|
+
if (seg === "..") out.pop();
|
|
43800
|
+
else out.push(seg);
|
|
43801
|
+
}
|
|
43802
|
+
return out.join("/");
|
|
43803
|
+
}
|
|
43766
43804
|
var md = new MarkdownIt({ html: true, linkify: true });
|
|
43767
43805
|
var isHtmlComment = (html2) => /^\s*<!--[\s\S]*-->\s*$/.test(html2);
|
|
43768
43806
|
var renderHtmlToken = (tokens, idx) => {
|
|
@@ -43797,12 +43835,30 @@ md.renderer.rules.link_close = (tokens, idx, opts, env, self2) => {
|
|
|
43797
43835
|
if (!show) return "";
|
|
43798
43836
|
return defaultLinkClose(tokens, idx, opts, env, self2);
|
|
43799
43837
|
};
|
|
43838
|
+
var defaultImage = md.renderer.rules.image ?? ((tokens, idx, opts, _env, self2) => self2.renderToken(tokens, idx, opts));
|
|
43839
|
+
md.renderer.rules.image = (tokens, idx, opts, env, self2) => {
|
|
43840
|
+
const docPath = env.docPath;
|
|
43841
|
+
const src = tokens[idx].attrGet("src") ?? "";
|
|
43842
|
+
if (docPath && src && !/^[a-z][a-z0-9+.-]*:/i.test(src) && !src.startsWith("//") && !src.startsWith("/")) {
|
|
43843
|
+
const normalizedDocPath = docPath.replace(/\\/g, "/");
|
|
43844
|
+
if (/^([a-z]:)?\//i.test(normalizedDocPath)) {
|
|
43845
|
+
const decodedSrc = decodeURI(src);
|
|
43846
|
+
const abs = resolveDocPath(normalizedDocPath, decodedSrc);
|
|
43847
|
+
const withLeadingSlash = `/${abs.replace(/^\/+/, "")}`;
|
|
43848
|
+
tokens[idx].attrSet("src", `file://${encodeURI(withLeadingSlash)}`);
|
|
43849
|
+
}
|
|
43850
|
+
}
|
|
43851
|
+
return defaultImage(tokens, idx, opts, env, self2);
|
|
43852
|
+
};
|
|
43800
43853
|
var BLOCK_RULES = ["paragraph_open", "heading_open", "blockquote_open", "bullet_list_open", "ordered_list_open", "list_item_open", "table_open", "tr_open", "hr"];
|
|
43801
43854
|
for (const name2 of BLOCK_RULES) {
|
|
43802
43855
|
const orig = md.renderer.rules[name2];
|
|
43803
43856
|
md.renderer.rules[name2] = (tokens, idx, options, env, self2) => {
|
|
43804
43857
|
const tok = tokens[idx];
|
|
43805
|
-
if (tok.map)
|
|
43858
|
+
if (tok.map) {
|
|
43859
|
+
tok.attrSet("data-line", String(tok.map[0]));
|
|
43860
|
+
tok.attrSet("data-end-line", String(tok.map[1] - 1));
|
|
43861
|
+
}
|
|
43806
43862
|
return orig ? orig(tokens, idx, options, env, self2) : self2.renderToken(tokens, idx, options);
|
|
43807
43863
|
};
|
|
43808
43864
|
}
|
|
@@ -43814,23 +43870,8 @@ for (const name2 of ["fence", "code_block"]) {
|
|
|
43814
43870
|
return tok.map ? html2.replace(/^<pre/, `<pre data-line="${tok.map[0]}"`) : html2;
|
|
43815
43871
|
};
|
|
43816
43872
|
}
|
|
43817
|
-
function renderMarkdown(body, showAnchor) {
|
|
43818
|
-
return md.render(body, { showAnchor });
|
|
43819
|
-
}
|
|
43820
|
-
function isInternalDocLink(href) {
|
|
43821
|
-
if (!href || /^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith("//") || href.startsWith("#")) return false;
|
|
43822
|
-
return /\.md(\?[^#]*)?(#.*)?$/i.test(href);
|
|
43823
|
-
}
|
|
43824
|
-
function resolveDocPath(basePath, href) {
|
|
43825
|
-
const cleanHref = href.replace(/[?#].*$/, "");
|
|
43826
|
-
const baseDir = basePath.includes("/") ? basePath.slice(0, basePath.lastIndexOf("/")) : "";
|
|
43827
|
-
const out = cleanHref.startsWith("/") ? [] : baseDir.split("/").filter(Boolean);
|
|
43828
|
-
for (const seg of cleanHref.split("/")) {
|
|
43829
|
-
if (seg === "" || seg === ".") continue;
|
|
43830
|
-
if (seg === "..") out.pop();
|
|
43831
|
-
else out.push(seg);
|
|
43832
|
-
}
|
|
43833
|
-
return out.join("/");
|
|
43873
|
+
function renderMarkdown(body, showAnchor, docPath) {
|
|
43874
|
+
return md.render(body, { showAnchor, docPath });
|
|
43834
43875
|
}
|
|
43835
43876
|
var ua = typeof navigator !== "undefined" && (navigator.userAgent || navigator.platform) || "";
|
|
43836
43877
|
var MOD_KEY = /mac/i.test(ua) ? "⌘" : "Ctrl";
|
|
@@ -43885,6 +43926,51 @@ var IconPencil = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children:
|
|
|
43885
43926
|
/* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M12 20h9" }),
|
|
43886
43927
|
/* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z" })
|
|
43887
43928
|
] });
|
|
43929
|
+
var IconBold = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
|
|
43930
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M6 4h8a4 4 0 0 1 0 8H6z" }),
|
|
43931
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M6 12h9a4 4 0 0 1 0 8H6z" })
|
|
43932
|
+
] });
|
|
43933
|
+
var IconItalic = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
|
|
43934
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "19", y1: "4", x2: "10", y2: "4" }),
|
|
43935
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "14", y1: "20", x2: "5", y2: "20" }),
|
|
43936
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "15", y1: "4", x2: "9", y2: "20" })
|
|
43937
|
+
] });
|
|
43938
|
+
var IconStrikethrough = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
|
|
43939
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M16 4H9a3 3 0 0 0-2.83 4" }),
|
|
43940
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M14 12a4 4 0 0 1 0 8H6" }),
|
|
43941
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "4", y1: "12", x2: "20", y2: "12" })
|
|
43942
|
+
] });
|
|
43943
|
+
var IconHorizontalRule = () => /* @__PURE__ */ jsxRuntimeExports.jsx(Glyph, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "4", y1: "12", x2: "20", y2: "12" }) });
|
|
43944
|
+
var IconQuote = () => /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { viewBox: "0 0 24 24", fill: "currentColor", stroke: "none", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M9 6c-2.5 0-4.5 2-4.5 4.5S6.5 15 9 15c-.3 2.5-2 4-4.5 4v2c3.5 0 6.5-2.5 6.5-6.5V6H9zm10 0c-2.5 0-4.5 2-4.5 4.5s2 4.5 4.5 4.5c-.3 2.5-2 4-4.5 4v2c3.5 0 6.5-2.5 6.5-6.5V6h-2z" }) });
|
|
43945
|
+
var IconBulletList = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
|
|
43946
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "9", y1: "6", x2: "20", y2: "6" }),
|
|
43947
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "9", y1: "12", x2: "20", y2: "12" }),
|
|
43948
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "9", y1: "18", x2: "20", y2: "18" }),
|
|
43949
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("circle", { cx: "4.5", cy: "6", r: "1.2", fill: "currentColor", stroke: "none" }),
|
|
43950
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("circle", { cx: "4.5", cy: "12", r: "1.2", fill: "currentColor", stroke: "none" }),
|
|
43951
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("circle", { cx: "4.5", cy: "18", r: "1.2", fill: "currentColor", stroke: "none" })
|
|
43952
|
+
] });
|
|
43953
|
+
var IconChecklist = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
|
|
43954
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M9 11l3 3L22 4" }),
|
|
43955
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11" })
|
|
43956
|
+
] });
|
|
43957
|
+
var IconLink = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
|
|
43958
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }),
|
|
43959
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })
|
|
43960
|
+
] });
|
|
43961
|
+
var IconInlineCode = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
|
|
43962
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("polyline", { points: "16 6 22 12 16 18" }),
|
|
43963
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("polyline", { points: "8 6 2 12 8 18" })
|
|
43964
|
+
] });
|
|
43965
|
+
var IconCodeBlock = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
|
|
43966
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M8 3a2 2 0 0 0-2 2v3a2 2 0 0 1-2 2 2 2 0 0 1 2 2v3a2 2 0 0 0 2 2" }),
|
|
43967
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M16 3a2 2 0 0 1 2 2v3a2 2 0 0 0 2 2 2 2 0 0 0-2 2v3a2 2 0 0 1-2 2" })
|
|
43968
|
+
] });
|
|
43969
|
+
var IconImage = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
|
|
43970
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
|
|
43971
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("circle", { cx: "8.5", cy: "8.5", r: "1.5" }),
|
|
43972
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("polyline", { points: "21 15 16 10 5 21" })
|
|
43973
|
+
] });
|
|
43888
43974
|
function ComposerPopover({
|
|
43889
43975
|
target,
|
|
43890
43976
|
pos,
|
|
@@ -44158,6 +44244,109 @@ function QuestionChips({
|
|
|
44158
44244
|
)
|
|
44159
44245
|
] });
|
|
44160
44246
|
}
|
|
44247
|
+
var ATX = /^(#{1,6})\s+/;
|
|
44248
|
+
function lineBounds(text2, from, to) {
|
|
44249
|
+
const start = text2.lastIndexOf("\n", from - 1) + 1;
|
|
44250
|
+
let end = text2.indexOf("\n", Math.max(to - 1, start));
|
|
44251
|
+
if (end === -1) end = text2.length;
|
|
44252
|
+
return { start, end };
|
|
44253
|
+
}
|
|
44254
|
+
function headingEdit(text2, pos, level) {
|
|
44255
|
+
const { start, end } = lineBounds(text2, pos, pos);
|
|
44256
|
+
const line = text2.slice(start, end);
|
|
44257
|
+
const m2 = ATX.exec(line);
|
|
44258
|
+
const currentLevel = m2?.[1]?.length ?? 0;
|
|
44259
|
+
const rest = m2 ? line.slice(m2[0].length) : line;
|
|
44260
|
+
const nextLevel = currentLevel === level ? 0 : level;
|
|
44261
|
+
const prefix = nextLevel > 0 ? "#".repeat(nextLevel) + " " : "";
|
|
44262
|
+
const insert2 = prefix + rest;
|
|
44263
|
+
return { changes: { from: start, to: end, insert: insert2 }, selection: { anchor: start + insert2.length } };
|
|
44264
|
+
}
|
|
44265
|
+
function wrapEdit(text2, from, to, open, close = open) {
|
|
44266
|
+
if (from === to) {
|
|
44267
|
+
return { changes: { from, to, insert: open + close }, selection: { anchor: from + open.length } };
|
|
44268
|
+
}
|
|
44269
|
+
const selected = text2.slice(from, to);
|
|
44270
|
+
if (selected.startsWith(open) && selected.endsWith(close) && selected.length >= open.length + close.length) {
|
|
44271
|
+
const inner = selected.slice(open.length, selected.length - close.length);
|
|
44272
|
+
return { changes: { from, to, insert: inner }, selection: { anchor: from, head: from + inner.length } };
|
|
44273
|
+
}
|
|
44274
|
+
const before = text2.slice(Math.max(0, from - open.length), from);
|
|
44275
|
+
const after = text2.slice(to, to + close.length);
|
|
44276
|
+
if (before === open && after === close) {
|
|
44277
|
+
return { changes: { from: from - open.length, to: to + close.length, insert: selected }, selection: { anchor: from - open.length, head: from - open.length + selected.length } };
|
|
44278
|
+
}
|
|
44279
|
+
return { changes: { from, to, insert: open + selected + close }, selection: { anchor: from + open.length, head: from + open.length + selected.length } };
|
|
44280
|
+
}
|
|
44281
|
+
function linePrefixEdit(text2, from, to, prefix, prefixPattern) {
|
|
44282
|
+
const { start, end } = lineBounds(text2, from, to);
|
|
44283
|
+
const lines = text2.slice(start, end).split("\n");
|
|
44284
|
+
const skipBlank = lines.length > 1;
|
|
44285
|
+
const targetable = lines.filter((l2) => !(skipBlank && l2.length === 0));
|
|
44286
|
+
const matchLen = (l2) => {
|
|
44287
|
+
if (prefixPattern) {
|
|
44288
|
+
const m2 = prefixPattern.exec(l2);
|
|
44289
|
+
return m2 ? m2[0].length : null;
|
|
44290
|
+
}
|
|
44291
|
+
return l2.startsWith(prefix) ? prefix.length : null;
|
|
44292
|
+
};
|
|
44293
|
+
const allPrefixed = targetable.length > 0 && targetable.every((l2) => matchLen(l2) !== null);
|
|
44294
|
+
const insert2 = lines.map((l2) => {
|
|
44295
|
+
if (skipBlank && l2.length === 0) return l2;
|
|
44296
|
+
const len = matchLen(l2);
|
|
44297
|
+
if (allPrefixed) return len !== null ? l2.slice(len) : l2;
|
|
44298
|
+
return len !== null ? l2 : prefix + l2;
|
|
44299
|
+
}).join("\n");
|
|
44300
|
+
return { changes: { from: start, to: end, insert: insert2 }, selection: { anchor: start + insert2.length } };
|
|
44301
|
+
}
|
|
44302
|
+
function orderedListEdit(text2, from, to) {
|
|
44303
|
+
const { start, end } = lineBounds(text2, from, to);
|
|
44304
|
+
const lines = text2.slice(start, end).split("\n");
|
|
44305
|
+
const skipBlank = lines.length > 1;
|
|
44306
|
+
const targetable = lines.filter((l2) => !(skipBlank && l2.length === 0));
|
|
44307
|
+
const allNumbered = targetable.length > 0 && targetable.every((l2) => /^\d+\.\s/.test(l2));
|
|
44308
|
+
let n2 = 1;
|
|
44309
|
+
const insert2 = lines.map((l2) => {
|
|
44310
|
+
if (skipBlank && l2.length === 0) return l2;
|
|
44311
|
+
if (allNumbered) return l2.replace(/^\d+\.\s/, "");
|
|
44312
|
+
return `${n2++}. ${l2.replace(/^\d+\.\s/, "")}`;
|
|
44313
|
+
}).join("\n");
|
|
44314
|
+
return { changes: { from: start, to: end, insert: insert2 }, selection: { anchor: start + insert2.length } };
|
|
44315
|
+
}
|
|
44316
|
+
function codeBlockEdit(text2, from, to) {
|
|
44317
|
+
const fence2 = "```";
|
|
44318
|
+
const selected = text2.slice(from, to);
|
|
44319
|
+
if (selected.startsWith(fence2 + "\n") && selected.endsWith("\n" + fence2)) {
|
|
44320
|
+
const inner = selected.slice(fence2.length + 1, selected.length - fence2.length - 1);
|
|
44321
|
+
return { changes: { from, to, insert: inner }, selection: { anchor: from, head: from + inner.length } };
|
|
44322
|
+
}
|
|
44323
|
+
if (from === to) {
|
|
44324
|
+
return { changes: { from, to, insert: `${fence2}
|
|
44325
|
+
|
|
44326
|
+
${fence2}` }, selection: { anchor: from + fence2.length + 1 } };
|
|
44327
|
+
}
|
|
44328
|
+
return {
|
|
44329
|
+
changes: { from, to, insert: `${fence2}
|
|
44330
|
+
${selected}
|
|
44331
|
+
${fence2}` },
|
|
44332
|
+
selection: { anchor: from + fence2.length + 1, head: from + fence2.length + 1 + selected.length }
|
|
44333
|
+
};
|
|
44334
|
+
}
|
|
44335
|
+
function horizontalRuleEdit(text2, from, to) {
|
|
44336
|
+
const insert2 = "\n\n---\n\n";
|
|
44337
|
+
return { changes: { from, to, insert: insert2 }, selection: { anchor: from + insert2.length } };
|
|
44338
|
+
}
|
|
44339
|
+
function linkEdit(text2, from, to) {
|
|
44340
|
+
const label = from === to ? "text" : text2.slice(from, to);
|
|
44341
|
+
const url = "url";
|
|
44342
|
+
const insert2 = `[${label}](${url})`;
|
|
44343
|
+
const urlStart = from + 1 + label.length + 2;
|
|
44344
|
+
return { changes: { from, to, insert: insert2 }, selection: { anchor: urlStart, head: urlStart + url.length } };
|
|
44345
|
+
}
|
|
44346
|
+
function imageEdit(text2, from, to, relPath) {
|
|
44347
|
+
const insert2 = ``;
|
|
44348
|
+
return { changes: { from, to, insert: insert2 }, selection: { anchor: from + insert2.length } };
|
|
44349
|
+
}
|
|
44161
44350
|
var setFind = StateEffect.define();
|
|
44162
44351
|
function findDeco(doc2, query, ci2) {
|
|
44163
44352
|
if (!query) return Decoration.none;
|
|
@@ -44183,7 +44372,7 @@ var findField = StateField.define({
|
|
|
44183
44372
|
},
|
|
44184
44373
|
provide: (f2) => EditorView.decorations.from(f2, (v2) => v2.deco)
|
|
44185
44374
|
});
|
|
44186
|
-
var SourceEditor = reactExports.forwardRef(function SourceEditor2({ value, editable: editable2, onChange, onCursorLine, onFind, find: find2, binding, commentsForCopy, onCutComments, onPasteComments }, ref) {
|
|
44375
|
+
var SourceEditor = reactExports.forwardRef(function SourceEditor2({ value, editable: editable2, onChange, onCursorLine, onFind, find: find2, binding, commentsForCopy, onCutComments, onPasteComments, onPasteImage }, ref) {
|
|
44187
44376
|
const host = reactExports.useRef(null);
|
|
44188
44377
|
const view = reactExports.useRef(null);
|
|
44189
44378
|
const editableComp = reactExports.useRef(new Compartment());
|
|
@@ -44201,6 +44390,8 @@ var SourceEditor = reactExports.forwardRef(function SourceEditor2({ value, edita
|
|
|
44201
44390
|
onCutCommentsRef.current = onCutComments;
|
|
44202
44391
|
const onPasteCommentsRef = reactExports.useRef(onPasteComments);
|
|
44203
44392
|
onPasteCommentsRef.current = onPasteComments;
|
|
44393
|
+
const onPasteImageRef = reactExports.useRef(onPasteImage);
|
|
44394
|
+
onPasteImageRef.current = onPasteImage;
|
|
44204
44395
|
reactExports.useImperativeHandle(ref, () => ({
|
|
44205
44396
|
scrollToLine(line) {
|
|
44206
44397
|
const v2 = view.current;
|
|
@@ -44216,8 +44407,55 @@ var SourceEditor = reactExports.forwardRef(function SourceEditor2({ value, edita
|
|
|
44216
44407
|
const f2 = Math.max(0, Math.min(from, len));
|
|
44217
44408
|
const t2 = Math.max(0, Math.min(to, len));
|
|
44218
44409
|
v2.dispatch({ selection: { anchor: f2, head: t2 }, effects: EditorView.scrollIntoView(f2, { y: "center" }) });
|
|
44410
|
+
},
|
|
44411
|
+
setHeading(level) {
|
|
44412
|
+
withSelection((text2, from) => headingEdit(text2, from, level));
|
|
44413
|
+
},
|
|
44414
|
+
toggleBold() {
|
|
44415
|
+
withSelection((text2, from, to) => wrapEdit(text2, from, to, "**"));
|
|
44416
|
+
},
|
|
44417
|
+
toggleItalic() {
|
|
44418
|
+
withSelection((text2, from, to) => wrapEdit(text2, from, to, "_"));
|
|
44419
|
+
},
|
|
44420
|
+
toggleStrikethrough() {
|
|
44421
|
+
withSelection((text2, from, to) => wrapEdit(text2, from, to, "~~"));
|
|
44422
|
+
},
|
|
44423
|
+
toggleInlineCode() {
|
|
44424
|
+
withSelection((text2, from, to) => wrapEdit(text2, from, to, "`"));
|
|
44425
|
+
},
|
|
44426
|
+
toggleCodeBlock() {
|
|
44427
|
+
withSelection(codeBlockEdit);
|
|
44428
|
+
},
|
|
44429
|
+
toggleBlockquote() {
|
|
44430
|
+
withSelection((text2, from, to) => linePrefixEdit(text2, from, to, "> "));
|
|
44431
|
+
},
|
|
44432
|
+
toggleBulletList() {
|
|
44433
|
+
withSelection((text2, from, to) => linePrefixEdit(text2, from, to, "- "));
|
|
44434
|
+
},
|
|
44435
|
+
toggleOrderedList() {
|
|
44436
|
+
withSelection(orderedListEdit);
|
|
44437
|
+
},
|
|
44438
|
+
toggleChecklist() {
|
|
44439
|
+
withSelection((text2, from, to) => linePrefixEdit(text2, from, to, "- [ ] ", /^-\s\[[ xX]\]\s/));
|
|
44440
|
+
},
|
|
44441
|
+
insertLink() {
|
|
44442
|
+
withSelection(linkEdit);
|
|
44443
|
+
},
|
|
44444
|
+
insertHorizontalRule() {
|
|
44445
|
+
withSelection(horizontalRuleEdit);
|
|
44446
|
+
},
|
|
44447
|
+
insertImage(relPath) {
|
|
44448
|
+
withSelection((text2, from, to) => imageEdit(text2, from, to, relPath));
|
|
44219
44449
|
}
|
|
44220
44450
|
}));
|
|
44451
|
+
function withSelection(fn) {
|
|
44452
|
+
const v2 = view.current;
|
|
44453
|
+
if (!v2 || !editable2) return;
|
|
44454
|
+
const { from, to } = v2.state.selection.main;
|
|
44455
|
+
const edit = fn(v2.state.doc.toString(), from, to);
|
|
44456
|
+
v2.dispatch(edit);
|
|
44457
|
+
v2.focus();
|
|
44458
|
+
}
|
|
44221
44459
|
reactExports.useEffect(() => {
|
|
44222
44460
|
if (!host.current) return;
|
|
44223
44461
|
const handleCopyCut = (e, v22, cut) => {
|
|
@@ -44239,7 +44477,13 @@ var SourceEditor = reactExports.forwardRef(function SourceEditor2({ value, edita
|
|
|
44239
44477
|
// With a plugin binding, it owns the content; otherwise the controlled value.
|
|
44240
44478
|
doc: binding ? binding.getText() : value,
|
|
44241
44479
|
extensions: [
|
|
44242
|
-
// ⌘F should open the app's find bar, not CodeMirror's own search panel.
|
|
44480
|
+
// ⌘F should open the app's find bar, not CodeMirror's own search panel. Also
|
|
44481
|
+
// overrides @codemirror/lang-markdown's own default Enter binding (still Prec.high,
|
|
44482
|
+
// so ours must outrank it): its default only exits a 2-item TIGHT list on the
|
|
44483
|
+
// SECOND Enter on an empty item — the first just loosens the list (CommonMark's
|
|
44484
|
+
// tight/loose distinction), inserting a blank line most people read as a stray
|
|
44485
|
+
// glitch rather than an intentional format change. `nonTightLists: false` skips
|
|
44486
|
+
// that step, so Enter on an empty list item always exits immediately.
|
|
44243
44487
|
Prec.highest(
|
|
44244
44488
|
keymap.of([
|
|
44245
44489
|
{
|
|
@@ -44248,7 +44492,8 @@ var SourceEditor = reactExports.forwardRef(function SourceEditor2({ value, edita
|
|
|
44248
44492
|
onFindRef.current?.();
|
|
44249
44493
|
return true;
|
|
44250
44494
|
}
|
|
44251
|
-
}
|
|
44495
|
+
},
|
|
44496
|
+
{ key: "Enter", run: insertNewlineContinueMarkupCommand({ nonTightLists: false }) }
|
|
44252
44497
|
])
|
|
44253
44498
|
),
|
|
44254
44499
|
basicSetup,
|
|
@@ -44269,6 +44514,19 @@ var SourceEditor = reactExports.forwardRef(function SourceEditor2({ value, edita
|
|
|
44269
44514
|
copy: (e, v22) => handleCopyCut(e, v22, false),
|
|
44270
44515
|
cut: (e, v22) => handleCopyCut(e, v22, true),
|
|
44271
44516
|
paste: (e, v22) => {
|
|
44517
|
+
const imgFile = [...e.clipboardData?.files ?? []].find((f2) => f2.type.startsWith("image/"));
|
|
44518
|
+
if (imgFile && onPasteImageRef.current) {
|
|
44519
|
+
e.preventDefault();
|
|
44520
|
+
const onPasteImage2 = onPasteImageRef.current;
|
|
44521
|
+
void imgFile.arrayBuffer().then(async (bytes) => {
|
|
44522
|
+
const relPath = await onPasteImage2(bytes, imgFile.type);
|
|
44523
|
+
if (!relPath) return;
|
|
44524
|
+
const pos = v22.state.selection.main.from;
|
|
44525
|
+
v22.dispatch(imageEdit(v22.state.doc.toString(), pos, pos, relPath));
|
|
44526
|
+
}).catch(() => {
|
|
44527
|
+
});
|
|
44528
|
+
return true;
|
|
44529
|
+
}
|
|
44272
44530
|
if (!onPasteCommentsRef.current) return false;
|
|
44273
44531
|
const html2 = e.clipboardData?.getData("text/html") ?? "";
|
|
44274
44532
|
const payload = html2 ? readClipHtml(html2) : null;
|
|
@@ -44306,6 +44564,72 @@ var SourceEditor = reactExports.forwardRef(function SourceEditor2({ value, edita
|
|
|
44306
44564
|
}, [find2?.query, find2?.ci]);
|
|
44307
44565
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-source", ref: host });
|
|
44308
44566
|
});
|
|
44567
|
+
function SourceToolbar({
|
|
44568
|
+
editorRef,
|
|
44569
|
+
body,
|
|
44570
|
+
activeLine,
|
|
44571
|
+
disabled,
|
|
44572
|
+
onPickImage
|
|
44573
|
+
}) {
|
|
44574
|
+
const t2 = useT();
|
|
44575
|
+
const headingBtnRef = reactExports.useRef(null);
|
|
44576
|
+
const fileInputRef = reactExports.useRef(null);
|
|
44577
|
+
const [headingMenuOpen, setHeadingMenuOpen] = reactExports.useState(false);
|
|
44578
|
+
const pickImage = async (e) => {
|
|
44579
|
+
const file = e.target.files?.[0];
|
|
44580
|
+
e.target.value = "";
|
|
44581
|
+
if (!file || !onPickImage) return;
|
|
44582
|
+
const bytes = await file.arrayBuffer();
|
|
44583
|
+
const relPath = await onPickImage(bytes, file.type);
|
|
44584
|
+
if (relPath) editorRef.current?.insertImage(relPath);
|
|
44585
|
+
};
|
|
44586
|
+
const line = activeLine != null ? body.split("\n")[activeLine] ?? "" : "";
|
|
44587
|
+
const currentLevel = ATX.exec(line)?.[1]?.length ?? 0;
|
|
44588
|
+
const headingItems = [
|
|
44589
|
+
{ level: 0, label: t2("source.paragraph") },
|
|
44590
|
+
{ level: 1, label: t2("source.h1") },
|
|
44591
|
+
{ level: 2, label: t2("source.h2") },
|
|
44592
|
+
{ level: 3, label: t2("source.h3") },
|
|
44593
|
+
{ level: 4, label: t2("source.h4") },
|
|
44594
|
+
{ level: 5, label: t2("source.h5") },
|
|
44595
|
+
{ level: 6, label: t2("source.h6") }
|
|
44596
|
+
].map(({ level, label }) => ({
|
|
44597
|
+
label: currentLevel === level ? `✓ ${label}` : label,
|
|
44598
|
+
onSelect: () => editorRef.current?.setHeading(level)
|
|
44599
|
+
}));
|
|
44600
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-src-toolbar", children: [
|
|
44601
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-seg", children: /* @__PURE__ */ jsxRuntimeExports.jsx("button", { ref: headingBtnRef, className: currentLevel > 0 ? "active" : "", disabled, title: t2("source.headingTitle"), onClick: () => setHeadingMenuOpen((o) => !o), children: currentLevel > 0 ? `${t2("source.heading")}${currentLevel}` : t2("source.heading") }) }),
|
|
44602
|
+
headingMenuOpen && headingBtnRef.current && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
44603
|
+
ContextMenu,
|
|
44604
|
+
{
|
|
44605
|
+
pos: { x: headingBtnRef.current.getBoundingClientRect().left, y: headingBtnRef.current.getBoundingClientRect().bottom + 4 },
|
|
44606
|
+
items: headingItems,
|
|
44607
|
+
onClose: () => setHeadingMenuOpen(false)
|
|
44608
|
+
}
|
|
44609
|
+
),
|
|
44610
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-seg", children: [
|
|
44611
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { disabled, title: t2("source.bold"), "aria-label": t2("source.bold"), onClick: () => editorRef.current?.toggleBold(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconBold, {}) }),
|
|
44612
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { disabled, title: t2("source.italic"), "aria-label": t2("source.italic"), onClick: () => editorRef.current?.toggleItalic(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconItalic, {}) }),
|
|
44613
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { disabled, title: t2("source.strikethrough"), "aria-label": t2("source.strikethrough"), onClick: () => editorRef.current?.toggleStrikethrough(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconStrikethrough, {}) })
|
|
44614
|
+
] }),
|
|
44615
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-seg", children: [
|
|
44616
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { disabled, title: t2("source.hr"), "aria-label": t2("source.hr"), onClick: () => editorRef.current?.insertHorizontalRule(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconHorizontalRule, {}) }),
|
|
44617
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { disabled, title: t2("source.quote"), "aria-label": t2("source.quote"), onClick: () => editorRef.current?.toggleBlockquote(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconQuote, {}) })
|
|
44618
|
+
] }),
|
|
44619
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-seg", children: [
|
|
44620
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { disabled, title: t2("source.bulletList"), "aria-label": t2("source.bulletList"), onClick: () => editorRef.current?.toggleBulletList(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconBulletList, {}) }),
|
|
44621
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { disabled, title: t2("source.orderedList"), onClick: () => editorRef.current?.toggleOrderedList(), children: "1." }),
|
|
44622
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { disabled, title: t2("source.checklist"), "aria-label": t2("source.checklist"), onClick: () => editorRef.current?.toggleChecklist(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconChecklist, {}) })
|
|
44623
|
+
] }),
|
|
44624
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-seg", children: [
|
|
44625
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { disabled, title: t2("source.link"), "aria-label": t2("source.link"), onClick: () => editorRef.current?.insertLink(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconLink, {}) }),
|
|
44626
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { disabled, title: t2("source.inlineCode"), "aria-label": t2("source.inlineCode"), onClick: () => editorRef.current?.toggleInlineCode(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconInlineCode, {}) }),
|
|
44627
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { disabled, title: t2("source.codeBlock"), "aria-label": t2("source.codeBlock"), onClick: () => editorRef.current?.toggleCodeBlock(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconCodeBlock, {}) }),
|
|
44628
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { disabled: disabled || !onPickImage, title: t2("source.image"), "aria-label": t2("source.image"), onClick: () => fileInputRef.current?.click(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconImage, {}) })
|
|
44629
|
+
] }),
|
|
44630
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("input", { ref: fileInputRef, type: "file", accept: "image/*", hidden: true, onChange: pickImage })
|
|
44631
|
+
] });
|
|
44632
|
+
}
|
|
44309
44633
|
dayjs.extend(relativeTime);
|
|
44310
44634
|
var REFRESH_MS = 3e4;
|
|
44311
44635
|
function RelativeTime({ iso, className }) {
|
|
@@ -45195,6 +45519,14 @@ function applySegments(segs, accepted) {
|
|
|
45195
45519
|
}
|
|
45196
45520
|
var USER_AUTHOR = "You";
|
|
45197
45521
|
var EMPTY = { body: "", comments: [] };
|
|
45522
|
+
var IMAGE_EXT_BY_MIME = {
|
|
45523
|
+
"image/png": "png",
|
|
45524
|
+
"image/jpeg": "jpg",
|
|
45525
|
+
"image/gif": "gif",
|
|
45526
|
+
"image/webp": "webp",
|
|
45527
|
+
"image/avif": "avif",
|
|
45528
|
+
"image/svg+xml": "svg"
|
|
45529
|
+
};
|
|
45198
45530
|
var ZOOM_MIN = 0.6;
|
|
45199
45531
|
var ZOOM_MAX = 1.8;
|
|
45200
45532
|
function anchoredText(body, id2) {
|
|
@@ -45206,6 +45538,18 @@ function anchorLine(body, id2) {
|
|
|
45206
45538
|
if (idx < 0) return null;
|
|
45207
45539
|
return body.slice(0, idx).split("\n").length - 1;
|
|
45208
45540
|
}
|
|
45541
|
+
function closestPreviewBlock(root, line) {
|
|
45542
|
+
let best = null;
|
|
45543
|
+
let bestLine = -1;
|
|
45544
|
+
root?.querySelectorAll("[data-line]").forEach((el2) => {
|
|
45545
|
+
const l2 = Number(el2.getAttribute("data-line") ?? -1);
|
|
45546
|
+
if (l2 <= line && l2 >= bestLine) {
|
|
45547
|
+
bestLine = l2;
|
|
45548
|
+
best = el2;
|
|
45549
|
+
}
|
|
45550
|
+
});
|
|
45551
|
+
return best;
|
|
45552
|
+
}
|
|
45209
45553
|
function flashEl(el2, cls) {
|
|
45210
45554
|
if (!el2) return;
|
|
45211
45555
|
el2.classList.remove(cls);
|
|
@@ -45418,6 +45762,7 @@ function App(props = {}) {
|
|
|
45418
45762
|
setAgentThinking(false);
|
|
45419
45763
|
setAgentDone(false);
|
|
45420
45764
|
setAgentMessages([]);
|
|
45765
|
+
setActivePreviewLine(null);
|
|
45421
45766
|
setStatus(`opened ${path.split("/").pop() ?? path}`);
|
|
45422
45767
|
void hostApi().getProposal().then((parked) => parked != null && showProposal(parked));
|
|
45423
45768
|
}),
|
|
@@ -45565,15 +45910,7 @@ function App(props = {}) {
|
|
|
45565
45910
|
if (!root) return;
|
|
45566
45911
|
root.querySelectorAll(".ap-active-line").forEach((el2) => el2.classList.remove("ap-active-line"));
|
|
45567
45912
|
if (activePreviewLine == null) return;
|
|
45568
|
-
|
|
45569
|
-
let bestLine = -1;
|
|
45570
|
-
root.querySelectorAll("[data-line]").forEach((el2) => {
|
|
45571
|
-
const l2 = Number(el2.getAttribute("data-line") ?? -1);
|
|
45572
|
-
if (l2 <= activePreviewLine && l2 >= bestLine) {
|
|
45573
|
-
bestLine = l2;
|
|
45574
|
-
best = el2;
|
|
45575
|
-
}
|
|
45576
|
-
});
|
|
45913
|
+
const best = closestPreviewBlock(root, activePreviewLine);
|
|
45577
45914
|
if (best) {
|
|
45578
45915
|
best.classList.add("ap-active-line");
|
|
45579
45916
|
if (!skipPreviewScroll.current) best.scrollIntoView({ block: "center" });
|
|
@@ -45634,6 +45971,43 @@ function App(props = {}) {
|
|
|
45634
45971
|
},
|
|
45635
45972
|
[apply]
|
|
45636
45973
|
);
|
|
45974
|
+
const onPickImage = reactExports.useCallback(async (bytes, mime) => {
|
|
45975
|
+
const saveAsset = hostApi().saveAsset;
|
|
45976
|
+
if (!saveAsset) return null;
|
|
45977
|
+
const ext = IMAGE_EXT_BY_MIME[mime] ?? "png";
|
|
45978
|
+
const saved = await saveAsset(bytes, ext);
|
|
45979
|
+
return saved?.relPath ?? null;
|
|
45980
|
+
}, []);
|
|
45981
|
+
const onPreviewPasteImage = reactExports.useCallback(
|
|
45982
|
+
async (e) => {
|
|
45983
|
+
if (editingLocked) return;
|
|
45984
|
+
const file = [...e.clipboardData?.files ?? []].find((f2) => f2.type.startsWith("image/"));
|
|
45985
|
+
if (!file) return;
|
|
45986
|
+
e.preventDefault();
|
|
45987
|
+
const pasteDocPath = docPathRef.current;
|
|
45988
|
+
let relPath;
|
|
45989
|
+
try {
|
|
45990
|
+
const bytes = await file.arrayBuffer();
|
|
45991
|
+
relPath = await onPickImage(bytes, file.type);
|
|
45992
|
+
} catch {
|
|
45993
|
+
setStatus(t2("msg.imagePasteFailed"));
|
|
45994
|
+
return;
|
|
45995
|
+
}
|
|
45996
|
+
if (!relPath || docPathRef.current !== pasteDocPath) return;
|
|
45997
|
+
const cur2 = docRef.current;
|
|
45998
|
+
const lines = cur2.body.split("\n");
|
|
45999
|
+
let insertAfter = lines.length - 1;
|
|
46000
|
+
if (activePreviewLine != null) {
|
|
46001
|
+
const blockEl = closestPreviewBlock(previewRef.current, activePreviewLine);
|
|
46002
|
+
const endLine = blockEl?.getAttribute("data-end-line");
|
|
46003
|
+
insertAfter = endLine != null ? Number(endLine) : activePreviewLine;
|
|
46004
|
+
}
|
|
46005
|
+
insertAfter = Math.min(Math.max(insertAfter, 0), lines.length - 1);
|
|
46006
|
+
lines.splice(insertAfter + 1, 0, "", ``);
|
|
46007
|
+
apply({ ...cur2, body: lines.join("\n") }, { type: "image_pasted", payload: {} });
|
|
46008
|
+
},
|
|
46009
|
+
[editingLocked, onPickImage, activePreviewLine, apply]
|
|
46010
|
+
);
|
|
45637
46011
|
reactExports.useEffect(() => {
|
|
45638
46012
|
if (!autoResolve || !loaded) return;
|
|
45639
46013
|
const next = autoResolveSuggested(docRef.current, autoResolvedRef.current);
|
|
@@ -46151,7 +46525,7 @@ function App(props = {}) {
|
|
|
46151
46525
|
tryAddCommentRef.current = tryAddComment;
|
|
46152
46526
|
const resolvedIds = reactExports.useMemo(() => new Set(doc2.comments.filter((c) => c.resolved).map((c) => c.id)), [doc2.comments]);
|
|
46153
46527
|
const previewHtml = reactExports.useMemo(
|
|
46154
|
-
() => renderMarkdown(doc2.body, (id2) => showResolvedOrphaned || !resolvedIds.has(id2)),
|
|
46528
|
+
() => renderMarkdown(doc2.body, (id2) => showResolvedOrphaned || !resolvedIds.has(id2), docPathRef.current),
|
|
46155
46529
|
[doc2.body, resolvedIds, showResolvedOrphaned]
|
|
46156
46530
|
);
|
|
46157
46531
|
reactExports.useEffect(() => {
|
|
@@ -46518,7 +46892,9 @@ function App(props = {}) {
|
|
|
46518
46892
|
"div",
|
|
46519
46893
|
{
|
|
46520
46894
|
className: "ap-rendered",
|
|
46895
|
+
tabIndex: -1,
|
|
46521
46896
|
dangerouslySetInnerHTML: { __html: previewHtml },
|
|
46897
|
+
onPaste: onPreviewPasteImage,
|
|
46522
46898
|
onClick: (e) => {
|
|
46523
46899
|
const target = e.target;
|
|
46524
46900
|
const a = target.closest("a");
|
|
@@ -46548,26 +46924,30 @@ function App(props = {}) {
|
|
|
46548
46924
|
/* @__PURE__ */ jsxRuntimeExports.jsx(VSplitter, { width: srcW, setWidth: setSrcW }),
|
|
46549
46925
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("section", { className: "ap-pane", style: { width: srcW }, "data-onboard": "source", children: [
|
|
46550
46926
|
panes === 2 && /* @__PURE__ */ jsxRuntimeExports.jsx(PaneTabs, { tab: rightTab, onTab: setRightTab }),
|
|
46551
|
-
proposal && reviewOpen ? /* @__PURE__ */ jsxRuntimeExports.jsx(DiffSource, { segs: editedSegs, accepted, focused: reviewCursor, onToggle: toggleHunk }) : /* @__PURE__ */ jsxRuntimeExports.
|
|
46552
|
-
|
|
46553
|
-
|
|
46554
|
-
|
|
46555
|
-
|
|
46556
|
-
|
|
46557
|
-
|
|
46558
|
-
|
|
46559
|
-
|
|
46560
|
-
|
|
46561
|
-
|
|
46562
|
-
|
|
46563
|
-
|
|
46564
|
-
|
|
46565
|
-
|
|
46566
|
-
|
|
46567
|
-
|
|
46568
|
-
|
|
46569
|
-
|
|
46570
|
-
|
|
46927
|
+
proposal && reviewOpen ? /* @__PURE__ */ jsxRuntimeExports.jsx(DiffSource, { segs: editedSegs, accepted, focused: reviewCursor, onToggle: toggleHunk }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(EditorErrorBoundary, { label: "The source editor", children: [
|
|
46928
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SourceToolbar, { editorRef, body: doc2.body, activeLine: activePreviewLine, disabled: editingLocked, onPickImage: hostApi().saveAsset ? onPickImage : void 0 }),
|
|
46929
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
46930
|
+
SourceEditor,
|
|
46931
|
+
{
|
|
46932
|
+
ref: editorRef,
|
|
46933
|
+
binding: hostApi().binding ?? null,
|
|
46934
|
+
value: doc2.body,
|
|
46935
|
+
editable: !editingLocked,
|
|
46936
|
+
onChange: (body) => {
|
|
46937
|
+
setDoc((d) => ({ ...d, body }));
|
|
46938
|
+
if (props.onboarding) setOnboardSourceEdits((n2) => n2 + 1);
|
|
46939
|
+
if (!hostApi().binding?.setText) setDirty(serialize({ ...docRef.current, body }) !== savedRef.current);
|
|
46940
|
+
},
|
|
46941
|
+
onCursorLine: (line) => setActivePreviewLine(line),
|
|
46942
|
+
onFind: () => setFindOpen(true),
|
|
46943
|
+
find: findOpen && findOpts.inEditor && findOpts.query ? { query: findOpts.query, ci: findOpts.ci } : null,
|
|
46944
|
+
commentsForCopy,
|
|
46945
|
+
onCutComments: editingLocked ? void 0 : onCutComments,
|
|
46946
|
+
onPasteComments: editingLocked ? void 0 : onPasteComments,
|
|
46947
|
+
onPasteImage: editingLocked || !hostApi().saveAsset ? void 0 : onPickImage
|
|
46948
|
+
}
|
|
46949
|
+
)
|
|
46950
|
+
] })
|
|
46571
46951
|
] })
|
|
46572
46952
|
] }),
|
|
46573
46953
|
showComments && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
@@ -223,6 +223,8 @@ body {
|
|
|
223
223
|
@media (prefers-reduced-motion: reduce) { .ap-sidepanel, .ap-sidepanel.ap-sidepanel--closing { animation: none; } }
|
|
224
224
|
.ap-preview { flex: 1; min-width: 0; overflow: auto; padding: 28px 36px; border-right: 1px solid var(--line); background: var(--bg); }
|
|
225
225
|
.ap-rendered { max-width: 760px; }
|
|
226
|
+
.ap-rendered img { max-width: 100%; height: auto; } /* a pasted/picked image is embedded at its native pixel size otherwise */
|
|
227
|
+
.ap-rendered:focus { outline: none; } /* tabIndex={-1}: click-focusable (to receive a native paste event) but not Tab-reachable, so there's no keyboard focus ring to suppress here */
|
|
226
228
|
.ap-rendered h1, .ap-rendered h2, .ap-rendered h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -0.01em; line-height: 1.15; }
|
|
227
229
|
.ap-rendered .ap-anchor { background: var(--anchor); border-bottom: 2px solid var(--amber); color: inherit; text-decoration: none; cursor: pointer; border-radius: 2px; }
|
|
228
230
|
/* Click-to-focus flash: anchored comment pulses darker yellow then fades to normal (1s). */
|
|
@@ -238,6 +240,12 @@ body {
|
|
|
238
240
|
.ap-vsplit:hover, .ap-vsplit:active { background: var(--accent); }
|
|
239
241
|
.ap-pane:last-child { border-right: 0; }
|
|
240
242
|
.ap-source { flex: 1; overflow: auto; }
|
|
243
|
+
.ap-src-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--bg); flex: 0 0 auto; }
|
|
244
|
+
.ap-src-toolbar .ap-seg button {
|
|
245
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
246
|
+
min-width: 28px; height: 26px; padding: 0 8px; font-size: 13px; font-weight: 500;
|
|
247
|
+
}
|
|
248
|
+
.ap-src-toolbar svg { width: 15px; height: 15px; display: block; }
|
|
241
249
|
|
|
242
250
|
.ap-tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--bg); }
|
|
243
251
|
.ap-tabs button { flex: 1; border: 0; background: transparent; padding: 8px; cursor: pointer; color: var(--muted); }
|
package/app/renderer/index.html
CHANGED
|
@@ -5,14 +5,24 @@
|
|
|
5
5
|
<!-- A runtime plugin (when entitled): the renderer imports the verified bundle main serves over
|
|
6
6
|
the privileged inplan-plugin: scheme (script-src), and the plugin may connect to an
|
|
7
7
|
editor-hosted loopback endpoint (connect-src ws://127.0.0.1). Both are inert on the base /
|
|
8
|
-
no-plugin path (main exposes nothing to import + runs no plugin).
|
|
8
|
+
no-plugin path (main exposes nothing to import + runs no plugin).
|
|
9
|
+
img-src adds file: so a Markdown image (pasted/picked, saved as a sibling
|
|
10
|
+
`<docname>.assets/*` file and embedded as a `file://` URL by renderMarkdown — see
|
|
11
|
+
markdown.ts) can actually load; the plan doc lives outside the app's own bundle
|
|
12
|
+
directory, so 'self' alone can't cover it. https: (not http:) lets a Markdown image
|
|
13
|
+
whose destination is a plain remote URL (typed directly, e.g. ) load
|
|
14
|
+
too — markdown.ts already leaves absolute URLs untouched, so this was the only thing
|
|
15
|
+
blocking them. http: is deliberately NOT included: any doc (agent-authored, shared via
|
|
16
|
+
a repo) can embed a remote image as a tracking pixel that leaks the viewer's IP the
|
|
17
|
+
moment the doc merely renders, and plaintext http adds an on-path tampering risk on top
|
|
18
|
+
of that with no offsetting benefit. -->
|
|
9
19
|
<meta
|
|
10
20
|
http-equiv="Content-Security-Policy"
|
|
11
|
-
content="default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' inplan-plugin:; connect-src 'self' inplan-plugin: ws://127.0.0.1:* ws://localhost:*; frame-src https://inplan.ai http://127.0.0.1:* http://localhost:*"
|
|
21
|
+
content="default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' inplan-plugin:; img-src 'self' file: https:; connect-src 'self' inplan-plugin: ws://127.0.0.1:* ws://localhost:*; frame-src https://inplan.ai http://127.0.0.1:* http://localhost:*"
|
|
12
22
|
/>
|
|
13
23
|
<title>inplan</title>
|
|
14
|
-
<script type="module" crossorigin src="./assets/index-
|
|
15
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
24
|
+
<script type="module" crossorigin src="./assets/index-K0WqENF0.js"></script>
|
|
25
|
+
<link rel="stylesheet" crossorigin href="./assets/index-i6zzDOQL.css">
|
|
16
26
|
</head>
|
|
17
27
|
<body>
|
|
18
28
|
<div id="root"></div>
|