@damiro/stylo 0.7.0 → 0.9.0
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/README.md +24 -10
- package/dist/{InPlaceView-CS1qy-Ba.js → InPlaceView-Bu91_3Ig.js} +1199 -855
- package/dist/InPlaceView-Bu91_3Ig.js.map +1 -0
- package/dist/Preview-AaGGwLQP.js +170 -0
- package/dist/Preview-AaGGwLQP.js.map +1 -0
- package/dist/SplitView.d.ts +4 -2
- package/dist/SplitView.d.ts.map +1 -1
- package/dist/Stylo.d.ts.map +1 -1
- package/dist/editor/SourceView.d.ts +4 -2
- package/dist/editor/SourceView.d.ts.map +1 -1
- package/dist/editor/extensions.d.ts +2 -2
- package/dist/editor/extensions.d.ts.map +1 -1
- package/dist/editor/useCodeMirror.d.ts +4 -2
- package/dist/editor/useCodeMirror.d.ts.map +1 -1
- package/dist/editor/wikilink-complete.d.ts +5 -3
- package/dist/editor/wikilink-complete.d.ts.map +1 -1
- package/dist/embed-B2Dfkpd_.js +124 -0
- package/dist/embed-B2Dfkpd_.js.map +1 -0
- package/dist/embed.d.ts +14 -0
- package/dist/embed.d.ts.map +1 -0
- package/dist/frontmatter-DGUkb9z-.js +39 -0
- package/dist/frontmatter-DGUkb9z-.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/inplace/InPlaceView.d.ts +11 -2
- package/dist/inplace/InPlaceView.d.ts.map +1 -1
- package/dist/inplace/config.d.ts +8 -0
- package/dist/inplace/config.d.ts.map +1 -1
- package/dist/inplace/context-menu-actions.d.ts +5 -14
- package/dist/inplace/context-menu-actions.d.ts.map +1 -1
- package/dist/inplace/context-menu-helpers.d.ts +30 -0
- package/dist/inplace/context-menu-helpers.d.ts.map +1 -0
- package/dist/inplace/context-menu-shell.d.ts +23 -0
- package/dist/inplace/context-menu-shell.d.ts.map +1 -0
- package/dist/inplace/context-menu-types.d.ts +46 -0
- package/dist/inplace/context-menu-types.d.ts.map +1 -0
- package/dist/inplace/context-menu.d.ts +2 -42
- package/dist/inplace/context-menu.d.ts.map +1 -1
- package/dist/inplace/decorate.d.ts.map +1 -1
- package/dist/inplace/edit-boundaries.d.ts +1 -25
- package/dist/inplace/edit-boundaries.d.ts.map +1 -1
- package/dist/inplace/edit-divider.d.ts +27 -0
- package/dist/inplace/edit-divider.d.ts.map +1 -0
- package/dist/inplace/embed-registry.d.ts +39 -0
- package/dist/inplace/embed-registry.d.ts.map +1 -0
- package/dist/inplace/embed.d.ts +8 -0
- package/dist/inplace/embed.d.ts.map +1 -0
- package/dist/inplace/extension.d.ts +6 -0
- package/dist/inplace/extension.d.ts.map +1 -1
- package/dist/inplace/inline-md.d.ts +6 -1
- package/dist/inplace/inline-md.d.ts.map +1 -1
- package/dist/inplace/link-row.d.ts +21 -0
- package/dist/inplace/link-row.d.ts.map +1 -0
- package/dist/inplace/math-edit.d.ts +36 -0
- package/dist/inplace/math-edit.d.ts.map +1 -0
- package/dist/inplace/math.d.ts +12 -0
- package/dist/inplace/math.d.ts.map +1 -1
- package/dist/inplace/menu-plugin.d.ts.map +1 -1
- package/dist/inplace/nodes-blocks.d.ts +14 -0
- package/dist/inplace/nodes-blocks.d.ts.map +1 -0
- package/dist/inplace/nodes-inline.d.ts +16 -0
- package/dist/inplace/nodes-inline.d.ts.map +1 -0
- package/dist/inplace/nodes.d.ts +3 -2
- package/dist/inplace/nodes.d.ts.map +1 -1
- package/dist/inplace/scan.d.ts +6 -0
- package/dist/inplace/scan.d.ts.map +1 -1
- package/dist/inplace/selection-bar-position.d.ts +31 -0
- package/dist/inplace/selection-bar-position.d.ts.map +1 -0
- package/dist/inplace/selection-bar.d.ts +0 -2
- package/dist/inplace/selection-bar.d.ts.map +1 -1
- package/dist/inplace/table-widget-caret.d.ts +11 -0
- package/dist/inplace/table-widget-caret.d.ts.map +1 -0
- package/dist/inplace/table-widget-render.d.ts +18 -0
- package/dist/inplace/table-widget-render.d.ts.map +1 -0
- package/dist/inplace/table-widget.d.ts +5 -2
- package/dist/inplace/table-widget.d.ts.map +1 -1
- package/dist/inplace/tables.d.ts.map +1 -1
- package/dist/inplace/theme-callout.d.ts +50 -0
- package/dist/inplace/theme-callout.d.ts.map +1 -0
- package/dist/inplace/theme-canvas.d.ts +166 -0
- package/dist/inplace/theme-canvas.d.ts.map +1 -0
- package/dist/inplace/theme-fonts.d.ts +4 -0
- package/dist/inplace/theme-fonts.d.ts.map +1 -0
- package/dist/inplace/theme-menu.d.ts +87 -0
- package/dist/inplace/theme-menu.d.ts.map +1 -0
- package/dist/inplace/theme-popups.d.ts +94 -0
- package/dist/inplace/theme-popups.d.ts.map +1 -0
- package/dist/inplace/theme-table-gizmos.d.ts +57 -0
- package/dist/inplace/theme-table-gizmos.d.ts.map +1 -0
- package/dist/inplace/theme-table.d.ts +30 -0
- package/dist/inplace/theme-table.d.ts.map +1 -0
- package/dist/inplace/theme.d.ts +5 -0
- package/dist/inplace/theme.d.ts.map +1 -1
- package/dist/inplace/wikilinks.d.ts.map +1 -1
- package/dist/inplace/wrap-at.d.ts +32 -0
- package/dist/inplace/wrap-at.d.ts.map +1 -0
- package/dist/{markdown-N3lRmU2n.js → markdown-BYXs9Tj8.js} +2 -2
- package/dist/{markdown-N3lRmU2n.js.map → markdown-BYXs9Tj8.js.map} +1 -1
- package/dist/render/Embed.d.ts +24 -0
- package/dist/render/Embed.d.ts.map +1 -0
- package/dist/render/Preview.d.ts +6 -2
- package/dist/render/Preview.d.ts.map +1 -1
- package/dist/render/embed-cache.d.ts +10 -0
- package/dist/render/embed-cache.d.ts.map +1 -0
- package/dist/render/remark-embed.d.ts +19 -0
- package/dist/render/remark-embed.d.ts.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/stylo.js +70 -54
- package/dist/stylo.js.map +1 -1
- package/dist/toolbar/block.d.ts +0 -26
- package/dist/toolbar/block.d.ts.map +1 -1
- package/dist/toolbar/command-helpers.d.ts +57 -0
- package/dist/toolbar/command-helpers.d.ts.map +1 -0
- package/dist/toolbar/commands.d.ts +1 -21
- package/dist/toolbar/commands.d.ts.map +1 -1
- package/dist/toolbar/frontmatter-toggle.d.ts +13 -0
- package/dist/toolbar/frontmatter-toggle.d.ts.map +1 -0
- package/dist/toolbar/heading.d.ts +10 -0
- package/dist/toolbar/heading.d.ts.map +1 -0
- package/dist/toolbar/inline-ops.d.ts +3 -53
- package/dist/toolbar/inline-ops.d.ts.map +1 -1
- package/dist/toolbar/link-ops.d.ts +22 -0
- package/dist/toolbar/link-ops.d.ts.map +1 -0
- package/dist/toolbar/rule.d.ts +11 -0
- package/dist/toolbar/rule.d.ts.map +1 -0
- package/dist/toolbar/table-position.d.ts +32 -0
- package/dist/toolbar/table-position.d.ts.map +1 -0
- package/dist/toolbar/table.d.ts +1 -16
- package/dist/toolbar/table.d.ts.map +1 -1
- package/dist/toolbar/underline-ops.d.ts +15 -0
- package/dist/toolbar/underline-ops.d.ts.map +1 -0
- package/dist/toolbar/wikilink-ops.d.ts +22 -0
- package/dist/toolbar/wikilink-ops.d.ts.map +1 -0
- package/dist/types.d.ts +48 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/{useCodeMirror-GPSkaYW6.js → useCodeMirror-DtwupFgc.js} +559 -531
- package/dist/useCodeMirror-DtwupFgc.js.map +1 -0
- package/package.json +2 -1
- package/dist/InPlaceView-CS1qy-Ba.js.map +0 -1
- package/dist/Preview-Bw0k3Mev.js +0 -93
- package/dist/Preview-Bw0k3Mev.js.map +0 -1
- package/dist/callout-oLE630ZP.js +0 -37
- package/dist/callout-oLE630ZP.js.map +0 -1
- package/dist/useCodeMirror-GPSkaYW6.js.map +0 -1
- package/dist/wikilink-CTR8IFKc.js +0 -42
- package/dist/wikilink-CTR8IFKc.js.map +0 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared machinery for `commands.ts`'s `BUILTIN_COMMANDS` registry: the
|
|
3
|
+
* `ToolbarCommand` shape, the context predicates that drive `disabled`, and
|
|
4
|
+
* the small factory functions that build a command from a mark / heading
|
|
5
|
+
* level / line-prefix spec.
|
|
6
|
+
*/
|
|
7
|
+
import type { EditorState } from "@codemirror/state";
|
|
8
|
+
import type { Command, EditorView } from "@codemirror/view";
|
|
9
|
+
import type { ToolbarCommandId } from "../types";
|
|
10
|
+
import { type LinePrefixSpec } from "./block";
|
|
11
|
+
/** Caret's line is an ATX heading (`#` … `######`). */
|
|
12
|
+
export declare const inHeading: (s: EditorState) => boolean;
|
|
13
|
+
/** Caret is inside the leading `---` YAML block. */
|
|
14
|
+
export declare const inFrontmatter: (s: EditorState) => boolean;
|
|
15
|
+
/** Contexts where inline markup is literal or would break the syntax. */
|
|
16
|
+
export declare const inLiteral: (s: EditorState) => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Inside an inline `` `code` `` or `$math$` span, no *other* mark can be added —
|
|
19
|
+
* `` `**x**` `` / `$`x`$` are not valid. The span's own mark stays live so it
|
|
20
|
+
* can be toggled off.
|
|
21
|
+
*/
|
|
22
|
+
export declare const inOtherInlineLiteral: (mark: string) => (s: EditorState) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Nothing to wrap — a collapsed caret with no word at it (a blank line, a run
|
|
25
|
+
* of spaces, punctuation). Wrapping there just drops an empty `****` / `` `` ``
|
|
26
|
+
* pair, which shows as literal marks in the seamless canvas.
|
|
27
|
+
*/
|
|
28
|
+
export declare const nothingToWrap: (s: EditorState) => boolean;
|
|
29
|
+
/** A `disabled` predicate that fires when any of `checks` matches. */
|
|
30
|
+
export declare const disabledWhen: (...checks: ((s: EditorState) => boolean)[]) => (s: EditorState) => boolean;
|
|
31
|
+
export interface ToolbarCommand {
|
|
32
|
+
id: ToolbarCommandId;
|
|
33
|
+
/** Tooltip and accessible label. */
|
|
34
|
+
title: string;
|
|
35
|
+
/** Mutate the document against the live view; returns true when handled. */
|
|
36
|
+
run: (view: EditorView) => boolean;
|
|
37
|
+
/** Reflected as the button's pressed state. */
|
|
38
|
+
isActive?: (state: EditorState) => boolean;
|
|
39
|
+
/**
|
|
40
|
+
* True when the command can't produce valid Markdown at the current selection
|
|
41
|
+
* — the button is rendered `disabled` and the shortcut is a no-op. Driven by
|
|
42
|
+
* the context predicates above (a table cell, a heading line, a frontmatter /
|
|
43
|
+
* fenced-code / `$$` block).
|
|
44
|
+
*/
|
|
45
|
+
disabled?: (state: EditorState) => boolean;
|
|
46
|
+
/** Default key bindings in CodeMirror `key` syntax. */
|
|
47
|
+
keys?: string[];
|
|
48
|
+
}
|
|
49
|
+
export declare const QUOTE: LinePrefixSpec;
|
|
50
|
+
export declare const BULLET: LinePrefixSpec;
|
|
51
|
+
export declare const ORDERED: LinePrefixSpec;
|
|
52
|
+
export declare const TASK: LinePrefixSpec;
|
|
53
|
+
export declare function history(id: "undo" | "redo", title: string, cmd: Command): ToolbarCommand;
|
|
54
|
+
export declare function wrap(id: ToolbarCommandId, title: string, mark: string, keys?: string[]): ToolbarCommand;
|
|
55
|
+
export declare function heading(level: 1 | 2 | 3): ToolbarCommand;
|
|
56
|
+
export declare function prefix(id: ToolbarCommandId, title: string, spec: LinePrefixSpec, ...extra: ((s: EditorState) => boolean)[]): ToolbarCommand;
|
|
57
|
+
//# sourceMappingURL=command-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-helpers.d.ts","sourceRoot":"","sources":["../../src/toolbar/command-helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,EAAsC,KAAK,cAAc,EAAE,MAAM,SAAS,CAAA;AAUjF,uDAAuD;AACvD,eAAO,MAAM,SAAS,MAAO,WAAW,KAAG,OAC8B,CAAA;AAEzE,oDA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AM,EAAE,GACd,cAAc,CAUhB;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,cAAc,CAUxD;AAED,wBAAgB,MAAM,CACpB,EAAE,EAAE,gBAAgB,EACpB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,cAAc,EACpB,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,EAAE,GACxC,cAAc,CAQhB"}
|
|
@@ -1,24 +1,4 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { EditorView } from "@codemirror/view";
|
|
3
|
-
import type { ToolbarCommandId } from "../types";
|
|
4
|
-
export interface ToolbarCommand {
|
|
5
|
-
id: ToolbarCommandId;
|
|
6
|
-
/** Tooltip and accessible label. */
|
|
7
|
-
title: string;
|
|
8
|
-
/** Mutate the document against the live view; returns true when handled. */
|
|
9
|
-
run: (view: EditorView) => boolean;
|
|
10
|
-
/** Reflected as the button's pressed state. */
|
|
11
|
-
isActive?: (state: EditorState) => boolean;
|
|
12
|
-
/**
|
|
13
|
-
* True when the command can't produce valid Markdown at the current selection
|
|
14
|
-
* — the button is rendered `disabled` and the shortcut is a no-op. Driven by
|
|
15
|
-
* the context predicates above (a table cell, a heading line, a frontmatter /
|
|
16
|
-
* fenced-code / `$$` block).
|
|
17
|
-
*/
|
|
18
|
-
disabled?: (state: EditorState) => boolean;
|
|
19
|
-
/** Default key bindings in CodeMirror `key` syntax. */
|
|
20
|
-
keys?: string[];
|
|
21
|
-
}
|
|
1
|
+
import { type ToolbarCommand } from "./command-helpers";
|
|
22
2
|
/** Every built-in command, in a stable order. The toolbar picks from these by id. */
|
|
23
3
|
export declare const BUILTIN_COMMANDS: ToolbarCommand[];
|
|
24
4
|
export declare const BUILTIN_BY_ID: Record<string, ToolbarCommand>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/toolbar/commands.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/toolbar/commands.ts"],"names":[],"mappings":"AAIA,OAAO,EAcL,KAAK,cAAc,EAEpB,MAAM,mBAAmB,CAAA;AAmB1B,qFAAqF;AACrF,eAAO,MAAM,gBAAgB,EAAE,cAAc,EAgI5C,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAExD,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { EditorState } from "@codemirror/state";
|
|
2
|
+
import type { EditorView } from "@codemirror/view";
|
|
3
|
+
/**
|
|
4
|
+
* Toggle the leading `---` YAML block. With none present, the top of the
|
|
5
|
+
* document — line 1 through the last selected line — is wrapped in `---` fences
|
|
6
|
+
* (so the "type it, select it, click" flow works). With one present, only the
|
|
7
|
+
* two fence lines are removed; the YAML text stays in the document. Keeping it
|
|
8
|
+
* out of rendered output is the preview pipeline's job, not this toggle's.
|
|
9
|
+
*/
|
|
10
|
+
export declare function toggleFrontmatter(view: EditorView): boolean;
|
|
11
|
+
/** True when the document has a leading `---` YAML block. */
|
|
12
|
+
export declare function frontmatterActive(state: EditorState): boolean;
|
|
13
|
+
//# sourceMappingURL=frontmatter-toggle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter-toggle.d.ts","sourceRoot":"","sources":["../../src/toolbar/frontmatter-toggle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAGlD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CA2B3D;AAED,6DAA6D;AAC7D,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAE7D"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EditorView } from "@codemirror/view";
|
|
2
|
+
/**
|
|
3
|
+
* Set, swap, or clear an ATX heading prefix on every line the selection touches.
|
|
4
|
+
* A line already at `level` is cleared; any other level (or none) is set to it.
|
|
5
|
+
*/
|
|
6
|
+
export declare function toggleHeading(view: EditorView, level: number): boolean;
|
|
7
|
+
/** Strip any ATX heading prefix from every line the selection touches — the
|
|
8
|
+
* explicit "back to body text" that toggling a heading level does obliquely. */
|
|
9
|
+
export declare function clearHeading(view: EditorView): boolean;
|
|
10
|
+
//# sourceMappingURL=heading.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["../../src/toolbar/heading.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAGlD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAmBtE;AAED;iFACiF;AACjF,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAatD"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export { linkAtIn, linkPartsIn, linkString } from "./link-ops";
|
|
2
|
+
export { underlineAtIn, underlineString } from "./underline-ops";
|
|
3
|
+
export { wikiLinkAtIn, wikiLinkPartsIn, wikiLinkString } from "./wikilink-ops";
|
|
1
4
|
/** Regex-escape a literal so it can be spliced into a pattern. */
|
|
2
5
|
export declare function esc(s: string): string;
|
|
3
6
|
/** The characters that can stack as inline marks around a span. */
|
|
@@ -45,57 +48,4 @@ export declare function markedContentAt(text: string, pos: number): {
|
|
|
45
48
|
from: number;
|
|
46
49
|
to: number;
|
|
47
50
|
} | null;
|
|
48
|
-
/** The `[text](url)` span of `text` covering `head`, or `null`. */
|
|
49
|
-
export declare function linkAtIn(text: string, head: number): {
|
|
50
|
-
from: number;
|
|
51
|
-
to: number;
|
|
52
|
-
label: string;
|
|
53
|
-
} | null;
|
|
54
|
-
/**
|
|
55
|
-
* Like {@link linkAtIn} but also breaks out the URL and its `[from, to)` span
|
|
56
|
-
* within `text`, for editing just the `(…)` part in place.
|
|
57
|
-
*/
|
|
58
|
-
export declare function linkPartsIn(text: string, head: number): {
|
|
59
|
-
from: number;
|
|
60
|
-
to: number;
|
|
61
|
-
label: string;
|
|
62
|
-
url: string;
|
|
63
|
-
urlFrom: number;
|
|
64
|
-
urlTo: number;
|
|
65
|
-
} | null;
|
|
66
|
-
/** Toggle `[text](url)` around `[from, to)` of `text` — wrap, or unlink to the label. */
|
|
67
|
-
export declare function linkString(text: string, from: number, to: number): InlineStr;
|
|
68
|
-
/** The `<u>…</u>` span of `text` covering `head` (case-insensitive), or `null`. */
|
|
69
|
-
export declare function underlineAtIn(text: string, head: number): {
|
|
70
|
-
from: number;
|
|
71
|
-
to: number;
|
|
72
|
-
inner: string;
|
|
73
|
-
} | null;
|
|
74
|
-
/**
|
|
75
|
-
* Toggle `<u>…</u>` around `[from, to)` of `text`. Markdown has no underline, so
|
|
76
|
-
* this is a raw HTML tag pair — it renders wherever the host renders inline HTML
|
|
77
|
-
* (Obsidian, GitHub). Wrap the slice, or unwrap a span the caret is already in
|
|
78
|
-
* to its inner text.
|
|
79
|
-
*/
|
|
80
|
-
export declare function underlineString(text: string, from: number, to: number): InlineStr;
|
|
81
|
-
/** The `[[target|label]]` span of `text` covering `head`, or `null`. */
|
|
82
|
-
export declare function wikiLinkAtIn(text: string, head: number): {
|
|
83
|
-
from: number;
|
|
84
|
-
to: number;
|
|
85
|
-
label: string;
|
|
86
|
-
} | null;
|
|
87
|
-
/**
|
|
88
|
-
* Like {@link wikiLinkAtIn} but also breaks out the target and its `[from, to)`
|
|
89
|
-
* span within `text`, for editing just the `[[…]]` target in place.
|
|
90
|
-
*/
|
|
91
|
-
export declare function wikiLinkPartsIn(text: string, head: number): {
|
|
92
|
-
from: number;
|
|
93
|
-
to: number;
|
|
94
|
-
target: string;
|
|
95
|
-
label: string;
|
|
96
|
-
targetFrom: number;
|
|
97
|
-
targetTo: number;
|
|
98
|
-
} | null;
|
|
99
|
-
/** Toggle `[[target]]` around `[from, to)` of `text` — wrap, or unwrap to the display text. */
|
|
100
|
-
export declare function wikiLinkString(text: string, from: number, to: number): InlineStr;
|
|
101
51
|
//# sourceMappingURL=inline-ops.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline-ops.d.ts","sourceRoot":"","sources":["../../src/toolbar/inline-ops.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"inline-ops.d.ts","sourceRoot":"","sources":["../../src/toolbar/inline-ops.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE9E,kEAAkE;AAClE,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAErC;AAED,mEAAmE;AACnE,eAAO,MAAM,UAAU,SAAS,CAAA;AAsChC,kFAAkF;AAClF,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IACvD,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;CACX;AAED,mEAAmE;AACnE,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;CACX;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,CA6DrF;AAED,kFAAkF;AAClF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,GACtD,MAAM,CAMR;AAED,mFAAmF;AACnF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,CAG1F;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAkB9F"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { InlineStr } from "./inline-ops";
|
|
2
|
+
/** The `[text](url)` span of `text` covering `head`, or `null`. */
|
|
3
|
+
export declare function linkAtIn(text: string, head: number): {
|
|
4
|
+
from: number;
|
|
5
|
+
to: number;
|
|
6
|
+
label: string;
|
|
7
|
+
} | null;
|
|
8
|
+
/**
|
|
9
|
+
* Like {@link linkAtIn} but also breaks out the URL and its `[from, to)` span
|
|
10
|
+
* within `text`, for editing just the `(…)` part in place.
|
|
11
|
+
*/
|
|
12
|
+
export declare function linkPartsIn(text: string, head: number): {
|
|
13
|
+
from: number;
|
|
14
|
+
to: number;
|
|
15
|
+
label: string;
|
|
16
|
+
url: string;
|
|
17
|
+
urlFrom: number;
|
|
18
|
+
urlTo: number;
|
|
19
|
+
} | null;
|
|
20
|
+
/** Toggle `[text](url)` around `[from, to)` of `text` — wrap, or unlink to the label. */
|
|
21
|
+
export declare function linkString(text: string, from: number, to: number): InlineStr;
|
|
22
|
+
//# sourceMappingURL=link-ops.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link-ops.d.ts","sourceRoot":"","sources":["../../src/toolbar/link-ops.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,mEAAmE;AACnE,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAQpD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAajG;AAED,yFAAyF;AACzF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,SAAS,CAgB5E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EditorState } from "@codemirror/state";
|
|
2
|
+
import type { EditorView } from "@codemirror/view";
|
|
3
|
+
/**
|
|
4
|
+
* Insert a `---` thematic break, or remove the one the caret is on. A blank line
|
|
5
|
+
* is inserted before the rule when the current line has content — otherwise
|
|
6
|
+
* CommonMark reads `text` + `---` as a setext H2, not a divider.
|
|
7
|
+
*/
|
|
8
|
+
export declare function toggleHorizontalRule(view: EditorView): boolean;
|
|
9
|
+
/** True when the primary caret's line is a thematic break. */
|
|
10
|
+
export declare function horizontalRuleActive(state: EditorState): boolean;
|
|
11
|
+
//# sourceMappingURL=rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule.d.ts","sourceRoot":"","sources":["../../src/toolbar/rule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAKlD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAyB9D;AAED,8DAA8D;AAC9D,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAEhE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pipe-table parsing and cell-position arithmetic, shared by `table.ts`'s
|
|
3
|
+
* editing commands and the in-place canvas (which needs a document position to
|
|
4
|
+
* land the caret in when a rendered table reveals its source).
|
|
5
|
+
*/
|
|
6
|
+
import type { Text } from "@codemirror/state";
|
|
7
|
+
export interface Region {
|
|
8
|
+
from: number;
|
|
9
|
+
to: number;
|
|
10
|
+
lines: string[];
|
|
11
|
+
}
|
|
12
|
+
/** The contiguous pipe-table block containing `pos`, if it parses as a table. */
|
|
13
|
+
export declare function findTable(doc: Text, pos: number): Region | null;
|
|
14
|
+
export interface CellLoc {
|
|
15
|
+
row: number;
|
|
16
|
+
col: number;
|
|
17
|
+
offset: number;
|
|
18
|
+
onDelimiter: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** The cell (and offset within it) that document position `caret` falls in,
|
|
21
|
+
* for a table whose lines start at `from`. */
|
|
22
|
+
export declare function locate(lines: string[], from: number, caret: number): CellLoc | null;
|
|
23
|
+
/** The document position `loc` resolves to, for a table's `text` starting at `from`. */
|
|
24
|
+
export declare function resolve(text: string, from: number, loc: CellLoc): number;
|
|
25
|
+
/**
|
|
26
|
+
* Document position of the start of a table cell's content, for the pipe table
|
|
27
|
+
* that contains `tableFrom`. `row` is the content-row index (header = 0, first
|
|
28
|
+
* body row = 1, …); the delimiter row is not counted. Used to land the caret in
|
|
29
|
+
* the clicked cell when a rendered in-place table reveals its source.
|
|
30
|
+
*/
|
|
31
|
+
export declare function cellSourcePos(doc: Text, tableFrom: number, row: number, col: number): number | null;
|
|
32
|
+
//# sourceMappingURL=table-position.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-position.d.ts","sourceRoot":"","sources":["../../src/toolbar/table-position.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAG7C,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,EAAE,CAAA;CAChB;AAED,iFAAiF;AACjF,wBAAgB,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAoB/D;AAED,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,OAAO,CAAA;CACrB;AAED;+CAC+C;AAC/C,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAwBnF;AAED,wFAAwF;AACxF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,CASxE;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,IAAI,EACT,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,GACV,MAAM,GAAG,IAAI,CAIf"}
|
package/dist/toolbar/table.d.ts
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
import { EditorState, type Extension
|
|
1
|
+
import { EditorState, type Extension } from "@codemirror/state";
|
|
2
2
|
import type { EditorView } from "@codemirror/view";
|
|
3
|
-
interface Region {
|
|
4
|
-
from: number;
|
|
5
|
-
to: number;
|
|
6
|
-
lines: string[];
|
|
7
|
-
}
|
|
8
|
-
/** The contiguous pipe-table block containing `pos`, if it parses as a table. */
|
|
9
|
-
export declare function findTable(doc: Text, pos: number): Region | null;
|
|
10
|
-
/**
|
|
11
|
-
* Document position of the start of a table cell's content, for the pipe table
|
|
12
|
-
* that contains `tableFrom`. `row` is the content-row index (header = 0, first
|
|
13
|
-
* body row = 1, …); the delimiter row is not counted. Used to land the caret in
|
|
14
|
-
* the clicked cell when a rendered in-place table reveals its source.
|
|
15
|
-
*/
|
|
16
|
-
export declare function cellSourcePos(doc: Text, tableFrom: number, row: number, col: number): number | null;
|
|
17
3
|
/** Insert a starter table at the cursor and select the first header cell. */
|
|
18
4
|
export declare function insertTable(view: EditorView): boolean;
|
|
19
5
|
/** True when the primary caret is inside a pipe table. */
|
|
@@ -31,5 +17,4 @@ export declare const tableKeymap: Extension;
|
|
|
31
17
|
* same transaction (one undo step). Idempotent, so it does not re-trigger.
|
|
32
18
|
*/
|
|
33
19
|
export declare const tableRealign: Extension;
|
|
34
|
-
export {};
|
|
35
20
|
//# sourceMappingURL=table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/toolbar/table.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/toolbar/table.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE3F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAyClD,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAarD;AAED,0DAA0D;AAC1D,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAEvD;AA2CD;;;;;GAKG;AACH,eAAO,MAAM,WAAW,EAAE,SAIxB,CAAA;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,SAqBzB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { InlineStr } from "./inline-ops";
|
|
2
|
+
/** The `<u>…</u>` span of `text` covering `head` (case-insensitive), or `null`. */
|
|
3
|
+
export declare function underlineAtIn(text: string, head: number): {
|
|
4
|
+
from: number;
|
|
5
|
+
to: number;
|
|
6
|
+
inner: string;
|
|
7
|
+
} | null;
|
|
8
|
+
/**
|
|
9
|
+
* Toggle `<u>…</u>` around `[from, to)` of `text`. Markdown has no underline, so
|
|
10
|
+
* this is a raw HTML tag pair — it renders wherever the host renders inline HTML
|
|
11
|
+
* (Obsidian, GitHub). Wrap the slice, or unwrap a span the caret is already in
|
|
12
|
+
* to its inner text.
|
|
13
|
+
*/
|
|
14
|
+
export declare function underlineString(text: string, from: number, to: number): InlineStr;
|
|
15
|
+
//# sourceMappingURL=underline-ops.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"underline-ops.d.ts","sourceRoot":"","sources":["../../src/toolbar/underline-ops.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,mFAAmF;AACnF,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAQpD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,SAAS,CAejF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { InlineStr } from "./inline-ops";
|
|
2
|
+
/** The `[[target|label]]` span of `text` covering `head`, or `null`. */
|
|
3
|
+
export declare function wikiLinkAtIn(text: string, head: number): {
|
|
4
|
+
from: number;
|
|
5
|
+
to: number;
|
|
6
|
+
label: string;
|
|
7
|
+
} | null;
|
|
8
|
+
/**
|
|
9
|
+
* Like {@link wikiLinkAtIn} but also breaks out the target and its `[from, to)`
|
|
10
|
+
* span within `text`, for editing just the `[[…]]` target in place.
|
|
11
|
+
*/
|
|
12
|
+
export declare function wikiLinkPartsIn(text: string, head: number): {
|
|
13
|
+
from: number;
|
|
14
|
+
to: number;
|
|
15
|
+
target: string;
|
|
16
|
+
label: string;
|
|
17
|
+
targetFrom: number;
|
|
18
|
+
targetTo: number;
|
|
19
|
+
} | null;
|
|
20
|
+
/** Toggle `[[target]]` around `[from, to)` of `text` — wrap, or unwrap to the display text. */
|
|
21
|
+
export declare function wikiLinkString(text: string, from: number, to: number): InlineStr;
|
|
22
|
+
//# sourceMappingURL=wikilink-ops.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wikilink-ops.d.ts","sourceRoot":"","sources":["../../src/toolbar/wikilink-ops.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,wEAAwE;AACxE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAOpD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;CACjB,GAAG,IAAI,CAiBP;AAED,+FAA+F;AAC/F,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,SAAS,CAehF"}
|
package/dist/types.d.ts
CHANGED
|
@@ -106,6 +106,37 @@ export interface WikiLinkCompletion {
|
|
|
106
106
|
* Affects the CodeMirror surfaces only (`source`, `split`, `in-place`).
|
|
107
107
|
*/
|
|
108
108
|
export type WikiLinkSource = (query: string) => readonly WikiLinkCompletion[] | Promise<readonly WikiLinkCompletion[]>;
|
|
109
|
+
/**
|
|
110
|
+
* Resolves an `![[ref]]` embed (transclusion) to something to render. Called
|
|
111
|
+
* with the raw reference — everything between `![[` and `]]`, trimmed, with any
|
|
112
|
+
* `#heading` / `#^blockid` / `|size` suffix left intact for the host to parse.
|
|
113
|
+
* Stylo has no vault, so it cannot resolve the reference itself; it detects the
|
|
114
|
+
* `![[…]]` and renders whatever node you return in its place. May be async (a
|
|
115
|
+
* vault lookup, a fetch). Return `null` to leave the reference as literal text.
|
|
116
|
+
*
|
|
117
|
+
* Pass it to enable embeds; omit it and `![[…]]` stays literal. Works on
|
|
118
|
+
* `preview`, `split`, and the in-place canvas (ADR-009). A `![[…]]` alone on its
|
|
119
|
+
* line renders as a **block**; one mid-sentence renders **inline** — return
|
|
120
|
+
* phrasing content (not a block element) for the inline case. `![[…]]` inside
|
|
121
|
+
* code stays literal, and inside an **in-place table cell** it stays literal too
|
|
122
|
+
* (a table cell there is for editing tabular text; `preview` / `split` do
|
|
123
|
+
* transclude in cells). Give it a stable reference — the render pipeline
|
|
124
|
+
* rebuilds when its identity changes, and the in-place canvas reads it once at
|
|
125
|
+
* mount.
|
|
126
|
+
*
|
|
127
|
+
* Results are memoised by `ref` per function identity (so a scroll or a
|
|
128
|
+
* re-render does not re-resolve). If your source's output for a given `ref` can
|
|
129
|
+
* change over time, vary the `ref` or pass a new `embedSource` to invalidate.
|
|
130
|
+
* Rejections are not cached.
|
|
131
|
+
*/
|
|
132
|
+
export type EmbedSource = (ref: string) => ReactNode | Promise<ReactNode>;
|
|
133
|
+
/** Which host resolver rejected, and the argument it was called with. */
|
|
134
|
+
export interface ResolveErrorInfo {
|
|
135
|
+
/** The prop whose function threw or returned a rejected promise. */
|
|
136
|
+
source: "embedSource" | "wikiLinkSource";
|
|
137
|
+
/** What it was asked to resolve — an `![[ref]]` reference, or the `[[` query. */
|
|
138
|
+
input: string;
|
|
139
|
+
}
|
|
109
140
|
/**
|
|
110
141
|
* Per-construct on/off switches for the in-place canvas. Each key defaults to
|
|
111
142
|
* `true`; setting one `false` leaves that construct as plain source — no
|
|
@@ -124,6 +155,8 @@ export interface InPlaceDecorationToggles {
|
|
|
124
155
|
code?: boolean;
|
|
125
156
|
frontmatter?: boolean;
|
|
126
157
|
tables?: boolean;
|
|
158
|
+
/** `![[ref]]` transclusion blocks. Needs `embedSource` set; see ADR-009. */
|
|
159
|
+
embeds?: boolean;
|
|
127
160
|
}
|
|
128
161
|
/**
|
|
129
162
|
* How the in-place canvas handles editing a table.
|
|
@@ -243,6 +276,21 @@ export interface StyloProps {
|
|
|
243
276
|
* omitted. Read once, at mount. See `WikiLinkSource`.
|
|
244
277
|
*/
|
|
245
278
|
wikiLinkSource?: WikiLinkSource;
|
|
279
|
+
/**
|
|
280
|
+
* Resolves `![[ref]]` embeds (transclusion) for `preview` and `split`. Called
|
|
281
|
+
* with the raw reference; return a node to render in its place, or `null` to
|
|
282
|
+
* leave it as literal text. May be async. Off when omitted. See
|
|
283
|
+
* {@link EmbedSource}.
|
|
284
|
+
*/
|
|
285
|
+
embedSource?: EmbedSource;
|
|
286
|
+
/**
|
|
287
|
+
* Called when `embedSource` or `wikiLinkSource` throws or returns a rejected
|
|
288
|
+
* promise. Purely for observation — logging, a toast — the resolver still
|
|
289
|
+
* falls back (literal `![[ref]]` text, or no completions) either way. A `null`
|
|
290
|
+
* return is a valid result, not an error, and does not fire this. Reactive;
|
|
291
|
+
* see {@link ResolveErrorInfo}.
|
|
292
|
+
*/
|
|
293
|
+
onResolveError?: (error: unknown, info: ResolveErrorInfo) => void;
|
|
246
294
|
/**
|
|
247
295
|
* Formatting toolbar above the editing surface (`source`, `in-place`,
|
|
248
296
|
* `split`; never `preview`). Omit or `true` for the default bar, `false` to
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAA;AAEnE;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,MAAM,CAAA;AAElD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN,MAAM,GACN,MAAM,GACN,QAAQ,GACR,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,MAAM,GACN,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,WAAW,GACX,MAAM,GACN,WAAW,GACX,MAAM,GACN,UAAU,GACV,OAAO,GACP,YAAY,GACZ,aAAa,GACb,MAAM,GACN,IAAI,GACJ,aAAa,GACb,OAAO,GACP,MAAM,GACN,WAAW,CAAA;AAEf;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAA;I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