@damiro/stylo 0.4.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/LICENSE +21 -0
- package/README.md +144 -0
- package/dist/InPlaceView-Ba7JCZ2Y.js +2346 -0
- package/dist/InPlaceView-Ba7JCZ2Y.js.map +1 -0
- package/dist/Preview-Dxb9zPVv.js +93 -0
- package/dist/Preview-Dxb9zPVv.js.map +1 -0
- package/dist/SplitView.d.ts +23 -0
- package/dist/SplitView.d.ts.map +1 -0
- package/dist/Stylo.d.ts +15 -0
- package/dist/Stylo.d.ts.map +1 -0
- package/dist/callout-oLE630ZP.js +37 -0
- package/dist/callout-oLE630ZP.js.map +1 -0
- package/dist/callout.d.ts +18 -0
- package/dist/callout.d.ts.map +1 -0
- package/dist/config-DTBxVhtH.js +101 -0
- package/dist/config-DTBxVhtH.js.map +1 -0
- package/dist/editor/SourceView.d.ts +17 -0
- package/dist/editor/SourceView.d.ts.map +1 -0
- package/dist/editor/extensions.d.ts +20 -0
- package/dist/editor/extensions.d.ts.map +1 -0
- package/dist/editor/highlight.d.ts +19 -0
- package/dist/editor/highlight.d.ts.map +1 -0
- package/dist/editor/save.d.ts +12 -0
- package/dist/editor/save.d.ts.map +1 -0
- package/dist/editor/theme.d.ts +3 -0
- package/dist/editor/theme.d.ts.map +1 -0
- package/dist/editor/useCodeMirror.d.ts +26 -0
- package/dist/editor/useCodeMirror.d.ts.map +1 -0
- package/dist/frontmatter.d.ts +21 -0
- package/dist/frontmatter.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/inplace/InPlaceView.d.ts +30 -0
- package/dist/inplace/InPlaceView.d.ts.map +1 -0
- package/dist/inplace/autoformat.d.ts +23 -0
- package/dist/inplace/autoformat.d.ts.map +1 -0
- package/dist/inplace/config.d.ts +57 -0
- package/dist/inplace/config.d.ts.map +1 -0
- package/dist/inplace/context-menu-actions.d.ts +53 -0
- package/dist/inplace/context-menu-actions.d.ts.map +1 -0
- package/dist/inplace/context-menu.d.ts +50 -0
- package/dist/inplace/context-menu.d.ts.map +1 -0
- package/dist/inplace/decorate.d.ts +17 -0
- package/dist/inplace/decorate.d.ts.map +1 -0
- package/dist/inplace/edit-boundaries.d.ts +59 -0
- package/dist/inplace/edit-boundaries.d.ts.map +1 -0
- package/dist/inplace/edit-insert-assoc.d.ts +17 -0
- package/dist/inplace/edit-insert-assoc.d.ts.map +1 -0
- package/dist/inplace/edit-line-prefix.d.ts +23 -0
- package/dist/inplace/edit-line-prefix.d.ts.map +1 -0
- package/dist/inplace/extension.d.ts +21 -0
- package/dist/inplace/extension.d.ts.map +1 -0
- package/dist/inplace/frontmatter.d.ts +13 -0
- package/dist/inplace/frontmatter.d.ts.map +1 -0
- package/dist/inplace/inline-md.d.ts +13 -0
- package/dist/inplace/inline-md.d.ts.map +1 -0
- package/dist/inplace/lazyInPlace.d.ts +7 -0
- package/dist/inplace/lazyInPlace.d.ts.map +1 -0
- package/dist/inplace/link-click.d.ts +24 -0
- package/dist/inplace/link-click.d.ts.map +1 -0
- package/dist/inplace/link-hover.d.ts +11 -0
- package/dist/inplace/link-hover.d.ts.map +1 -0
- package/dist/inplace/list-guides.d.ts +16 -0
- package/dist/inplace/list-guides.d.ts.map +1 -0
- package/dist/inplace/long-press.d.ts +39 -0
- package/dist/inplace/long-press.d.ts.map +1 -0
- package/dist/inplace/math.d.ts +16 -0
- package/dist/inplace/math.d.ts.map +1 -0
- package/dist/inplace/menu-plugin.d.ts +30 -0
- package/dist/inplace/menu-plugin.d.ts.map +1 -0
- package/dist/inplace/nodes.d.ts +24 -0
- package/dist/inplace/nodes.d.ts.map +1 -0
- package/dist/inplace/plugin.d.ts +21 -0
- package/dist/inplace/plugin.d.ts.map +1 -0
- package/dist/inplace/reveal.d.ts +8 -0
- package/dist/inplace/reveal.d.ts.map +1 -0
- package/dist/inplace/scan.d.ts +11 -0
- package/dist/inplace/scan.d.ts.map +1 -0
- package/dist/inplace/selection-bar.d.ts +38 -0
- package/dist/inplace/selection-bar.d.ts.map +1 -0
- package/dist/inplace/table-cell-dom.d.ts +30 -0
- package/dist/inplace/table-cell-dom.d.ts.map +1 -0
- package/dist/inplace/table-enter.d.ts +22 -0
- package/dist/inplace/table-enter.d.ts.map +1 -0
- package/dist/inplace/table-gizmos.d.ts +55 -0
- package/dist/inplace/table-gizmos.d.ts.map +1 -0
- package/dist/inplace/table-structure.d.ts +23 -0
- package/dist/inplace/table-structure.d.ts.map +1 -0
- package/dist/inplace/table-widget.d.ts +81 -0
- package/dist/inplace/table-widget.d.ts.map +1 -0
- package/dist/inplace/tables.d.ts +8 -0
- package/dist/inplace/tables.d.ts.map +1 -0
- package/dist/inplace/theme.d.ts +14 -0
- package/dist/inplace/theme.d.ts.map +1 -0
- package/dist/inplace/widgets.d.ts +25 -0
- package/dist/inplace/widgets.d.ts.map +1 -0
- package/dist/inplace/wikilinks.d.ts +10 -0
- package/dist/inplace/wikilinks.d.ts.map +1 -0
- package/dist/katex-BfiLlqfN.js +21979 -0
- package/dist/katex-BfiLlqfN.js.map +1 -0
- package/dist/katex.css +3 -0
- package/dist/markdown-N3lRmU2n.js +8524 -0
- package/dist/markdown-N3lRmU2n.js.map +1 -0
- package/dist/render/Preview.d.ts +10 -0
- package/dist/render/Preview.d.ts.map +1 -0
- package/dist/render/lazyPreview.d.ts +8 -0
- package/dist/render/lazyPreview.d.ts.map +1 -0
- package/dist/render/remark-callout.d.ts +10 -0
- package/dist/render/remark-callout.d.ts.map +1 -0
- package/dist/render/remark-wikilink.d.ts +8 -0
- package/dist/render/remark-wikilink.d.ts.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/stylo.js +293 -0
- package/dist/stylo.js.map +1 -0
- package/dist/toolbar/Toolbar.d.ts +28 -0
- package/dist/toolbar/Toolbar.d.ts.map +1 -0
- package/dist/toolbar/block.d.ts +56 -0
- package/dist/toolbar/block.d.ts.map +1 -0
- package/dist/toolbar/cell-inline.d.ts +16 -0
- package/dist/toolbar/cell-inline.d.ts.map +1 -0
- package/dist/toolbar/commands.d.ts +25 -0
- package/dist/toolbar/commands.d.ts.map +1 -0
- package/dist/toolbar/config.d.ts +21 -0
- package/dist/toolbar/config.d.ts.map +1 -0
- package/dist/toolbar/fence.d.ts +28 -0
- package/dist/toolbar/fence.d.ts.map +1 -0
- package/dist/toolbar/floating-watchdog.d.ts +18 -0
- package/dist/toolbar/floating-watchdog.d.ts.map +1 -0
- package/dist/toolbar/icon-paths.d.ts +10 -0
- package/dist/toolbar/icon-paths.d.ts.map +1 -0
- package/dist/toolbar/icons.d.ts +10 -0
- package/dist/toolbar/icons.d.ts.map +1 -0
- package/dist/toolbar/inline-ops.d.ts +101 -0
- package/dist/toolbar/inline-ops.d.ts.map +1 -0
- package/dist/toolbar/inline.d.ts +38 -0
- package/dist/toolbar/inline.d.ts.map +1 -0
- package/dist/toolbar/keyboard-inset.d.ts +10 -0
- package/dist/toolbar/keyboard-inset.d.ts.map +1 -0
- package/dist/toolbar/keymap.d.ts +8 -0
- package/dist/toolbar/keymap.d.ts.map +1 -0
- package/dist/toolbar/labels.d.ts +16 -0
- package/dist/toolbar/labels.d.ts.map +1 -0
- package/dist/toolbar/table-grid.d.ts +23 -0
- package/dist/toolbar/table-grid.d.ts.map +1 -0
- package/dist/toolbar/table.d.ts +35 -0
- package/dist/toolbar/table.d.ts.map +1 -0
- package/dist/toolbar-settings/SortableRow.d.ts +15 -0
- package/dist/toolbar-settings/SortableRow.d.ts.map +1 -0
- package/dist/toolbar-settings/StyloToolbarSettings.d.ts +29 -0
- package/dist/toolbar-settings/StyloToolbarSettings.d.ts.map +1 -0
- package/dist/toolbar-settings/index.d.ts +3 -0
- package/dist/toolbar-settings/index.d.ts.map +1 -0
- package/dist/toolbar-settings/items.d.ts +24 -0
- package/dist/toolbar-settings/items.d.ts.map +1 -0
- package/dist/toolbar-settings.js +269 -0
- package/dist/toolbar-settings.js.map +1 -0
- package/dist/types.d.ts +264 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/useCodeMirror-YnIFkvKn.js +1361 -0
- package/dist/useCodeMirror-YnIFkvKn.js.map +1 -0
- package/dist/wikilink-BFpTehto.js +42 -0
- package/dist/wikilink-BFpTehto.js.map +1 -0
- package/dist/wikilink.d.ts +11 -0
- package/dist/wikilink.d.ts.map +1 -0
- package/package.json +122 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reveal.d.ts","sourceRoot":"","sources":["../../src/inplace/reveal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEpD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAQ7D"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Tree } from "@lezer/common";
|
|
2
|
+
import type { Text } from "@codemirror/state";
|
|
3
|
+
export type { Tree };
|
|
4
|
+
/**
|
|
5
|
+
* Is `pos` inside a code span or code block? Regex-scanned syntax (`[[…]]`,
|
|
6
|
+
* `$…$`) is left literal in those contexts.
|
|
7
|
+
*/
|
|
8
|
+
export declare function inCodeContext(tree: Tree, pos: number): boolean;
|
|
9
|
+
/** Does any line spanned by `[from, to]` currently hold part of a selection? */
|
|
10
|
+
export declare function rangeRevealed(revealed: Set<number>, doc: Text, from: number, to: number): boolean;
|
|
11
|
+
//# sourceMappingURL=scan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../src/inplace/scan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAE7C,YAAY,EAAE,IAAI,EAAE,CAAA;AAIpB;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAQ9D;AAED,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAKjG"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A floating inline-formatting bar that follows a non-empty selection in the
|
|
3
|
+
* in-place canvas, Notion style. Inline marks only — bold, italic,
|
|
4
|
+
* strikethrough, inline code, link, wikilink, inline math; block and insert
|
|
5
|
+
* actions live on the right-click menu.
|
|
6
|
+
*
|
|
7
|
+
* It follows an editor selection (`state.selection`) and also a text selection
|
|
8
|
+
* inside an editable table cell (a DOM selection — the widget is atomic, so it
|
|
9
|
+
* never reaches `state.selection`). In a cell the mark buttons route through
|
|
10
|
+
* `runInlineInCell`; the link / wikilink field editors do not apply there, so
|
|
11
|
+
* those buttons fall back to the plain toggle.
|
|
12
|
+
*/
|
|
13
|
+
import { ViewPlugin, type EditorView, type PluginValue, type ViewUpdate } from "@codemirror/view";
|
|
14
|
+
declare class SelectionBar implements PluginValue {
|
|
15
|
+
private view;
|
|
16
|
+
private bar;
|
|
17
|
+
private ids;
|
|
18
|
+
private buttons;
|
|
19
|
+
private linkMenu;
|
|
20
|
+
private onScroll;
|
|
21
|
+
private onSelectionChange;
|
|
22
|
+
constructor(view: EditorView);
|
|
23
|
+
update(u: ViewUpdate): void;
|
|
24
|
+
/**
|
|
25
|
+
* Layout reads (`coordsAtPos`, `getBoundingClientRect`) are illegal inside an
|
|
26
|
+
* `update`, so the placement is computed in a measure phase and applied in the
|
|
27
|
+
* write phase. `key: this` collapses repeats within one cycle.
|
|
28
|
+
*/
|
|
29
|
+
private schedule;
|
|
30
|
+
/** The screen box of the current text selection — editor or table cell. */
|
|
31
|
+
private selectionBox;
|
|
32
|
+
private measure;
|
|
33
|
+
private apply;
|
|
34
|
+
destroy(): void;
|
|
35
|
+
}
|
|
36
|
+
export declare const selectionBar: ViewPlugin<SelectionBar, undefined>;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=selection-bar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection-bar.d.ts","sourceRoot":"","sources":["../../src/inplace/selection-bar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAgBjG,cAAM,YAAa,YAAW,WAAW;IAe3B,OAAO,CAAC,IAAI;IAdxB,OAAO,CAAC,GAAG,CAAa;IACxB,OAAO,CAAC,GAAG,CAAoB;IAC/B,OAAO,CAAC,OAAO,CAAiD;IAChE,OAAO,CAAC,QAAQ,CAAa;IAG7B,OAAO,CAAC,QAAQ,CAEf;IAED,OAAO,CAAC,iBAAiB,CAExB;IAED,YAAoB,IAAI,EAAE,UAAU,EAiDnC;IAED,MAAM,CAAC,CAAC,EAAE,UAAU,QAInB;IAED;;;;OAIG;IACH,OAAO,CAAC,QAAQ;IAQhB,2EAA2E;IAC3E,OAAO,CAAC,YAAY;IAwBpB,OAAO,CAAC,OAAO;IAsCf,OAAO,CAAC,KAAK;IAcb,OAAO,SAMN;CACF;AASD,eAAO,MAAM,YAAY,qCAAqC,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ParsedTable } from "./table-widget";
|
|
2
|
+
/** `[head, ...body]` as raw cell strings — the editable widget's source of truth. */
|
|
3
|
+
export declare const gridOf: (t: ParsedTable) => string[][];
|
|
4
|
+
export declare const trimGrid: (rows: string[][]) => string[][];
|
|
5
|
+
/** A GFM cell escapes a literal pipe as `\|`; unescape before inline parsing. */
|
|
6
|
+
export declare const unescapePipe: (s: string) => string;
|
|
7
|
+
/** Char offset of the DOM selection within `cell`'s rendered text. */
|
|
8
|
+
export declare function renderedCaretOffset(cell: HTMLElement): number;
|
|
9
|
+
/** `[from, to]` char offsets of the DOM selection within `cell`'s text. */
|
|
10
|
+
export declare function selectionOffsets(cell: HTMLElement): {
|
|
11
|
+
from: number;
|
|
12
|
+
to: number;
|
|
13
|
+
};
|
|
14
|
+
/** Char offset within `cell`'s rendered text at a screen point, `0` if unresolved. */
|
|
15
|
+
export declare function offsetFromPoint(cell: HTMLElement, x: number, y: number): number;
|
|
16
|
+
/**
|
|
17
|
+
* Select the word at a screen point in `cell`'s raw text — the cell equivalent
|
|
18
|
+
* of the canvas's "right-click selects the word under the pointer". A point
|
|
19
|
+
* inside a marked run (`**bold phrase**`, `[a link](url)`, …) selects the whole
|
|
20
|
+
* run's text instead, so a Format toggle covers all of it. Returns `false`
|
|
21
|
+
* (leaving any caret / selection untouched) when the point is on whitespace or
|
|
22
|
+
* punctuation, so a menu opened there still has a target.
|
|
23
|
+
*/
|
|
24
|
+
export declare function selectWordAtPoint(cell: HTMLElement, x: number, y: number): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Select `cell`'s first text node from char `offset` to char `head` (both
|
|
27
|
+
* clamped). With `head` omitted or equal, the caret is simply parked at `offset`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function placeCaret(cell: HTMLElement, offset: number, head?: number): void;
|
|
30
|
+
//# sourceMappingURL=table-cell-dom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-cell-dom.d.ts","sourceRoot":"","sources":["../../src/inplace/table-cell-dom.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAEjD,qFAAqF;AACrF,eAAO,MAAM,MAAM,MAAO,WAAW,KAAG,MAAM,EAAE,EAA4C,CAAA;AAE5F,eAAO,MAAM,QAAQ,SAAU,MAAM,EAAE,EAAE,KAAG,MAAM,EAAE,EAA6C,CAAA;AAEjG,iFAAiF;AACjF,eAAO,MAAM,YAAY,MAAO,MAAM,KAAG,MAAiC,CAAA;AAa1E,sEAAsE;AACtE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAM7D;AAED,2EAA2E;AAC3E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAYhF;AAMD,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAa/E;AAID;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAelF;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,SAAS,QAgB1E"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keyboard entry into a table.
|
|
3
|
+
*
|
|
4
|
+
* A GFM table renders as one block widget spanning every table line, registered
|
|
5
|
+
* as a single atomic range — so stock vertical cursor motion skips the whole
|
|
6
|
+
* construct and ArrowDown from the line above lands *below* the table, never in
|
|
7
|
+
* it.
|
|
8
|
+
*
|
|
9
|
+
* Here ArrowDown on the line directly above a table (ArrowUp directly below)
|
|
10
|
+
* steps in instead. In `table: "cells"` it focuses the near edge cell; in
|
|
11
|
+
* `source` it drops the caret on the adjacent table source line, which reveals
|
|
12
|
+
* the raw pipe syntax the same way a blockquote or fenced block reveals on
|
|
13
|
+
* caret entry.
|
|
14
|
+
*/
|
|
15
|
+
import { type Extension } from "@codemirror/state";
|
|
16
|
+
import { type Command } from "@codemirror/view";
|
|
17
|
+
/** ArrowDown that steps into a table on the line below. */
|
|
18
|
+
export declare const enterTableFromAbove: Command;
|
|
19
|
+
/** ArrowUp that steps into a table on the line above. */
|
|
20
|
+
export declare const enterTableFromBelow: Command;
|
|
21
|
+
export declare const inPlaceTableEnter: Extension;
|
|
22
|
+
//# sourceMappingURL=table-enter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-enter.d.ts","sourceRoot":"","sources":["../../src/inplace/table-enter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,EAAE,KAAK,OAAO,EAA4C,MAAM,kBAAkB,CAAA;AA4CzF,2DAA2D;AAC3D,eAAO,MAAM,mBAAmB,EAAE,OAA8B,CAAA;AAChE,yDAAyD;AACzD,eAAO,MAAM,mBAAmB,EAAE,OAA+B,CAAA;AAEjE,eAAO,MAAM,iBAAiB,EAAE,SAK/B,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Align } from "../toolbar/table-grid";
|
|
2
|
+
import { type MenuRow } from "./context-menu";
|
|
3
|
+
/** A structural edit requested from an edge `+` or the cell context menu. */
|
|
4
|
+
export type StructOp = {
|
|
5
|
+
kind: "insertColumn";
|
|
6
|
+
at: number;
|
|
7
|
+
focus: [number, number];
|
|
8
|
+
} | {
|
|
9
|
+
kind: "deleteColumn";
|
|
10
|
+
at: number;
|
|
11
|
+
focus: [number, number];
|
|
12
|
+
} | {
|
|
13
|
+
kind: "insertRow";
|
|
14
|
+
at: number;
|
|
15
|
+
focus: [number, number];
|
|
16
|
+
} | {
|
|
17
|
+
kind: "deleteRow";
|
|
18
|
+
at: number;
|
|
19
|
+
focus: [number, number];
|
|
20
|
+
} | {
|
|
21
|
+
kind: "align";
|
|
22
|
+
at: number;
|
|
23
|
+
value: Align;
|
|
24
|
+
};
|
|
25
|
+
export interface GizmoHost {
|
|
26
|
+
/** Current grid shape, read when the menu opens. */
|
|
27
|
+
dims: () => {
|
|
28
|
+
cols: number;
|
|
29
|
+
rows: number;
|
|
30
|
+
alignAt: (c: number) => Align;
|
|
31
|
+
};
|
|
32
|
+
/** Apply a structural edit to the model and reserialise. */
|
|
33
|
+
run: (op: StructOp) => void;
|
|
34
|
+
}
|
|
35
|
+
export interface TableGizmos {
|
|
36
|
+
/** Overlay to append inside the positioned table wrapper. */
|
|
37
|
+
el: HTMLElement;
|
|
38
|
+
/** Re-place the edge `+` buttons against the current `<table>` layout. */
|
|
39
|
+
layout: (table: HTMLTableElement) => void;
|
|
40
|
+
/** Open the structural menu for `cell` at a screen point. `extra` rows (the
|
|
41
|
+
* Format group for a cell selection) are appended below the structural set. */
|
|
42
|
+
openFor: (cell: HTMLElement, x: number, y: number, extra?: MenuRow[]) => void;
|
|
43
|
+
/** Drop the document-level menu listeners. */
|
|
44
|
+
destroy: () => void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Editable-table affordances, Obsidian style: a `+` on the right edge (append
|
|
48
|
+
* column) and the bottom edge (append row), shown on hover, plus a right-click /
|
|
49
|
+
* long-press context menu on any cell for the full structural set. No persistent
|
|
50
|
+
* per-row / per-column chrome — the menu is contextual to the clicked cell, so it
|
|
51
|
+
* stays in reach on a table of any height. The menu reuses the canvas's shared
|
|
52
|
+
* `ContextMenu` shell (`context-menu.ts`); only the edge strips are bespoke.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createTableGizmos(doc: Document, host: GizmoHost): TableGizmos;
|
|
55
|
+
//# sourceMappingURL=table-gizmos.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-gizmos.d.ts","sourceRoot":"","sources":["../../src/inplace/table-gizmos.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAuC,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAElF,6EAA6E;AAC7E,MAAM,MAAM,QAAQ,GAChB;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAC1D;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAC1D;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAA;AAE/C,MAAM,WAAW,SAAS;IACxB,oDAAoD;IACpD,IAAI,EAAE,MAAM;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,KAAK,CAAA;KAAE,CAAA;IACzE,4DAA4D;IAC5D,GAAG,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,IAAI,CAAA;CAC5B;AAED,MAAM,WAAW,WAAW;IAC1B,6DAA6D;IAC7D,EAAE,EAAE,WAAW,CAAA;IACf,0EAA0E;IAC1E,MAAM,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAA;IACzC;oFACgF;IAChF,OAAO,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;IAC7E,8CAA8C;IAC9C,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,GAAG,WAAW,CAmG7E"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Align } from "../toolbar/table-grid";
|
|
2
|
+
/**
|
|
3
|
+
* The editable table's grid model: `rows` is `[header, ...body]` as raw cell
|
|
4
|
+
* strings, `aligns` is one entry per column. Every operation here mutates both
|
|
5
|
+
* in place and keeps them dimensionally consistent, so the widget can hand the
|
|
6
|
+
* result straight to `serializeGrid`. The guards keep the table well-formed —
|
|
7
|
+
* always a header, at least one body row, at least one column.
|
|
8
|
+
*/
|
|
9
|
+
export interface GridModel {
|
|
10
|
+
rows: string[][];
|
|
11
|
+
aligns: Align[];
|
|
12
|
+
}
|
|
13
|
+
/** Insert a blank column before index `at` (`at === cols` appends). */
|
|
14
|
+
export declare function insertColumn(g: GridModel, at: number): void;
|
|
15
|
+
/** Remove column `at`, unless it is the only one. */
|
|
16
|
+
export declare function deleteColumn(g: GridModel, at: number): void;
|
|
17
|
+
/** Insert a blank body row before index `at` (`at === rows.length` appends). */
|
|
18
|
+
export declare function insertRow(g: GridModel, at: number): void;
|
|
19
|
+
/** Remove row `at`, unless it is the header or the last remaining body row. */
|
|
20
|
+
export declare function deleteRow(g: GridModel, at: number): void;
|
|
21
|
+
/** Set column `c`'s alignment (`""` clears it back to default). */
|
|
22
|
+
export declare function setAlign(g: GridModel, c: number, align: Align): void;
|
|
23
|
+
//# sourceMappingURL=table-structure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-structure.d.ts","sourceRoot":"","sources":["../../src/inplace/table-structure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAElD;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,EAAE,EAAE,CAAA;IAChB,MAAM,EAAE,KAAK,EAAE,CAAA;CAChB;AAID,uEAAuE;AACvE,wBAAgB,YAAY,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAI3D;AAED,qDAAqD;AACrD,wBAAgB,YAAY,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAI3D;AAED,gFAAgF;AAChF,wBAAgB,SAAS,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAGxD;AAED,+EAA+E;AAC/E,wBAAgB,SAAS,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAGxD;AAED,mEAAmE;AACnE,wBAAgB,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAEpE"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { EditorView, WidgetType } from "@codemirror/view";
|
|
2
|
+
import { type Align } from "../toolbar/table-grid";
|
|
3
|
+
/** Marks a transaction that came from an editable table widget's own DOM. */
|
|
4
|
+
export declare const fromTableWidget: import("@codemirror/state").AnnotationType<boolean>;
|
|
5
|
+
export interface ParsedTable {
|
|
6
|
+
head: string[];
|
|
7
|
+
body: string[][];
|
|
8
|
+
aligns: Align[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A GFM table rendered as an editable `<table>` (`inPlace.table === "cells"`).
|
|
12
|
+
* The widget owns its DOM while mounted and keeps `rows` — the raw cell strings —
|
|
13
|
+
* as its source of truth. A cell shows its Markdown **rendered** (`renderInline`)
|
|
14
|
+
* while unfocused and swaps to the **raw source** as a plain text node while it
|
|
15
|
+
* has focus, mirroring the per-line reveal on the main canvas. Every edit
|
|
16
|
+
* re-serializes `rows` into the document with the `fromTableWidget` annotation
|
|
17
|
+
* so `tableField` remaps rather than rebuilds and DOM focus survives.
|
|
18
|
+
*
|
|
19
|
+
* The widget never stores its document range — a serialize dispatch shifts it —
|
|
20
|
+
* so `bounds()` re-derives it from `posAtDOM` plus a scan of contiguous pipe
|
|
21
|
+
* lines every time it is needed.
|
|
22
|
+
*/
|
|
23
|
+
export declare class EditableTableWidget extends WidgetType {
|
|
24
|
+
readonly data: ParsedTable;
|
|
25
|
+
private table;
|
|
26
|
+
private rows;
|
|
27
|
+
private editing;
|
|
28
|
+
private syncing;
|
|
29
|
+
/** Rendered-text offset from the mousedown that is bringing a cell into edit. */
|
|
30
|
+
private pendingOffset;
|
|
31
|
+
private current;
|
|
32
|
+
private gizmos;
|
|
33
|
+
private longPress;
|
|
34
|
+
/** When a long-press last opened the structural menu; a `contextmenu` the
|
|
35
|
+
* browser synthesises from the same gesture and lands within the window is
|
|
36
|
+
* swallowed rather than re-opening it. */
|
|
37
|
+
private longPressAt;
|
|
38
|
+
constructor(data: ParsedTable);
|
|
39
|
+
eq(other: EditableTableWidget): boolean;
|
|
40
|
+
ignoreEvent(): boolean;
|
|
41
|
+
private cols;
|
|
42
|
+
/**
|
|
43
|
+
* The table's current `[from, to]` in the document, derived from the DOM.
|
|
44
|
+
* `posAtDOM` may land on any line of the widget, so the scan grows the span in
|
|
45
|
+
* both directions across contiguous non-blank pipe lines.
|
|
46
|
+
*/
|
|
47
|
+
private bounds;
|
|
48
|
+
private cellAt;
|
|
49
|
+
private coords;
|
|
50
|
+
/** Draw `cell` from `rows[r][c]` — raw text when `raw`, rendered otherwise. */
|
|
51
|
+
private paint;
|
|
52
|
+
private mkCell;
|
|
53
|
+
/** Rebuild `<thead>` / `<tbody>` from the current grid model. */
|
|
54
|
+
private renderCells;
|
|
55
|
+
private appendRow;
|
|
56
|
+
private model;
|
|
57
|
+
/** Apply a structural edit from a gizmo, rebuild, restore focus, reserialize. */
|
|
58
|
+
private runOp;
|
|
59
|
+
/** Commit `cell`'s edited text into `rows` and, unless it keeps focus, re-render it. */
|
|
60
|
+
private finish;
|
|
61
|
+
private onFocusIn;
|
|
62
|
+
private onFocusOut;
|
|
63
|
+
/** The selection as (row, col, anchor offset, head offset) within the editing cell. */
|
|
64
|
+
private readCaret;
|
|
65
|
+
private writeCaret;
|
|
66
|
+
/** Serialize `rows` into the document. */
|
|
67
|
+
private sync;
|
|
68
|
+
private onKey;
|
|
69
|
+
/**
|
|
70
|
+
* Focus the first (top-left) or last (bottom-right) cell — keyboard entry into
|
|
71
|
+
* the table from the line above or below. Returns `false` when the DOM isn't
|
|
72
|
+
* mounted, so the caller can fall back to stock cursor motion.
|
|
73
|
+
*/
|
|
74
|
+
focusEdge(edge: "first" | "last"): boolean;
|
|
75
|
+
/** Open the structural menu for the cell at a screen point, from a right-click
|
|
76
|
+
* or a long-press. */
|
|
77
|
+
private openCellMenuAt;
|
|
78
|
+
toDOM(view: EditorView): HTMLDivElement;
|
|
79
|
+
destroy(): void;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=table-widget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-widget.d.ts","sourceRoot":"","sources":["../../src/inplace/table-widget.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAEzD,OAAO,EAAE,KAAK,KAAK,EAAiB,MAAM,uBAAuB,CAAA;AAuBjE,6EAA6E;AAC7E,eAAO,MAAM,eAAe,qDAA+B,CAAA;AAE3D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,IAAI,EAAE,MAAM,EAAE,EAAE,CAAA;IAChB,MAAM,EAAE,KAAK,EAAE,CAAA;CAChB;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,mBAAoB,SAAQ,UAAU;IAerC,QAAQ,CAAC,IAAI,EAAE,WAAW;IAdtC,OAAO,CAAC,KAAK,CAAgC;IAC7C,OAAO,CAAC,IAAI,CAAY;IACxB,OAAO,CAAC,OAAO,CAAoC;IACnD,OAAO,CAAC,OAAO,CAAQ;IACvB,iFAAiF;IACjF,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,SAAS,CAA+B;IAChD;;+CAE2C;IAC3C,OAAO,CAAC,WAAW,CAAI;IAEvB,YAAqB,IAAI,EAAE,WAAW,EAIrC;IAEQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,WAQrC;IAEQ,WAAW,YAEnB;IAED,OAAO,CAAC,IAAI;IAIZ;;;;OAIG;IACH,OAAO,CAAC,MAAM;IAad,OAAO,CAAC,MAAM;IAMd,OAAO,CAAC,MAAM;IAId,+EAA+E;IAC/E,OAAO,CAAC,KAAK;IAQb,OAAO,CAAC,MAAM;IAed,iEAAiE;IACjE,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,KAAK;IAIb,iFAAiF;IACjF,OAAO,CAAC,KAAK;IAsBb,wFAAwF;IACxF,OAAO,CAAC,MAAM;IAMd,OAAO,CAAC,SAAS;IAajB,OAAO,CAAC,UAAU;IAQlB,uFAAuF;IACvF,OAAO,CAAC,SAAS;IAWjB,OAAO,CAAC,UAAU;IAKlB,0CAA0C;IAC1C,OAAO,CAAC,IAAI;IA0BZ,OAAO,CAAC,KAAK;IAuFb;;;;OAIG;IACH,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CASzC;IAED;2BACuB;IACvB,OAAO,CAAC,cAAc;IAetB,KAAK,CAAC,IAAI,EAAE,UAAU,kBA2ErB;IAEQ,OAAO,SAOf;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { StateField } from "@codemirror/state";
|
|
2
|
+
import { type DecorationSet } from "@codemirror/view";
|
|
3
|
+
/**
|
|
4
|
+
* Renders GFM tables in place. A state field, not the view plugin, because the
|
|
5
|
+
* replacement spans line breaks. The whole document is scanned — tables are few.
|
|
6
|
+
*/
|
|
7
|
+
export declare const tableField: StateField<DecorationSet>;
|
|
8
|
+
//# sourceMappingURL=tables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tables.d.ts","sourceRoot":"","sources":["../../src/inplace/tables.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,UAAU,EAAa,MAAM,mBAAmB,CAAA;AACvF,OAAO,EAAc,KAAK,aAAa,EAA0B,MAAM,kBAAkB,CAAA;AAqHzF;;;GAGG;AACH,eAAO,MAAM,UAAU,2BAuBrB,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display styling for the in-place canvas. Scoped to editors that include this
|
|
3
|
+
* extension (via `EditorView.theme`), so `source` mode is untouched. Sizes are
|
|
4
|
+
* relative to the editor font so they track the host's type scale; colour stays
|
|
5
|
+
* inherited from the `--stylo-*` tokens.
|
|
6
|
+
*
|
|
7
|
+
* Vertical rhythm mirrors the `preview` surface, which follows Tailwind's
|
|
8
|
+
* `prose` scale (reference only, no plugin). The match is approximate here: a
|
|
9
|
+
* `.cm-line` cannot take a `margin` without drifting click-to-position (see the
|
|
10
|
+
* 2026-09-02 click-mapping note), and a blank source line already supplies most
|
|
11
|
+
* of the inter-block gap, so heading `padding-top` is trimmed accordingly.
|
|
12
|
+
*/
|
|
13
|
+
export declare const inPlaceTheme: import("@codemirror/state").Extension;
|
|
14
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/inplace/theme.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,uCAyavB,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type EditorView, WidgetType } from "@codemirror/view";
|
|
2
|
+
/** Rendered `<hr>` replacing a `---` / `***` / `___` line. */
|
|
3
|
+
export declare class HrWidget extends WidgetType {
|
|
4
|
+
eq(): boolean;
|
|
5
|
+
toDOM(): HTMLHRElement;
|
|
6
|
+
ignoreEvent(): boolean;
|
|
7
|
+
}
|
|
8
|
+
/** `•` glyph replacing a `-` / `*` / `+` list marker. */
|
|
9
|
+
export declare class BulletWidget extends WidgetType {
|
|
10
|
+
eq(): boolean;
|
|
11
|
+
toDOM(): HTMLSpanElement;
|
|
12
|
+
ignoreEvent(): boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Interactive checkbox replacing a `[ ]` / `[x]` task marker. Toggling it
|
|
16
|
+
* dispatches a one-character change to the source (`" "` ⇄ `"x"`).
|
|
17
|
+
*/
|
|
18
|
+
export declare class CheckboxWidget extends WidgetType {
|
|
19
|
+
readonly checked: boolean;
|
|
20
|
+
constructor(checked: boolean);
|
|
21
|
+
eq(other: CheckboxWidget): boolean;
|
|
22
|
+
toDOM(view: EditorView): HTMLInputElement;
|
|
23
|
+
ignoreEvent(): boolean;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=widgets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widgets.d.ts","sourceRoot":"","sources":["../../src/inplace/widgets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE9D,8DAA8D;AAC9D,qBAAa,QAAS,SAAQ,UAAU;IAC7B,EAAE,YAEV;IAED,KAAK,kBAIJ;IAEQ,WAAW,YAEnB;CACF;AAED,yDAAyD;AACzD,qBAAa,YAAa,SAAQ,UAAU;IACjC,EAAE,YAEV;IAED,KAAK,oBAKJ;IAEQ,WAAW,YAEnB;CACF;AAED;;;GAGG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO;IAArC,YAAqB,OAAO,EAAE,OAAO,EAEpC;IAEQ,EAAE,CAAC,KAAK,EAAE,cAAc,WAEhC;IAED,KAAK,CAAC,IAAI,EAAE,UAAU,oBAWrB;IAEQ,WAAW,YAEnB;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Range } from "@codemirror/state";
|
|
2
|
+
import { Decoration, type EditorView } from "@codemirror/view";
|
|
3
|
+
import { type Tree } from "./scan";
|
|
4
|
+
/**
|
|
5
|
+
* Regex pass for `[[wikilinks]]` — the CodeMirror grammar has no node for them.
|
|
6
|
+
* Collapses each match to its label and tags it with `data-stylo-wikilink`
|
|
7
|
+
* (the delegated click handler in `inPlaceExtension` reads that attribute).
|
|
8
|
+
*/
|
|
9
|
+
export declare function scanWikilinks(view: EditorView, from: number, to: number, revealed: Set<number>, tree: Tree, out: Range<Decoration>[]): void;
|
|
10
|
+
//# sourceMappingURL=wikilinks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wikilinks.d.ts","sourceRoot":"","sources":["../../src/inplace/wikilinks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE9D,OAAO,EAAiB,KAAK,IAAI,EAAE,MAAM,QAAQ,CAAA;AAEjD;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,EACrB,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,KAAK,CAAC,UAAU,CAAC,EAAE,GACvB,IAAI,CAyBN"}
|