@threadlabs/looma 0.7.1 → 0.7.2

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.
@@ -1,14 +1,79 @@
1
1
  import { n as TABLE_CELL_BACKGROUND_PRESETS } from "./table-backgrounds.js";
2
2
  import { Extension, Mark, Node, callOrReturn, canInsertNode, combineTransactionSteps, escapeForRegEx, findChildren, findChildrenInRange, findParentNodeClosestToPos, getAttributes, getChangedRanges, getExtensionField, getMarksBetween, isNodeEmpty, isNodeSelection, markInputRule, markPasteRule, mergeAttributes, nodeInputRule, textInputRule, textblockTypeInputRule, wrappingInputRule } from "@tiptap/core";
3
3
  import { NodeSelection, Plugin, PluginKey, Selection, TextSelection } from "@tiptap/pm/state";
4
+ import { Decoration, DecorationSet } from "@tiptap/pm/view";
4
5
  import { history, redo, undo } from "@tiptap/pm/history";
5
6
  import { dropCursor } from "@tiptap/pm/dropcursor";
6
7
  import { gapCursor } from "@tiptap/pm/gapcursor";
7
- import { Decoration, DecorationSet } from "@tiptap/pm/view";
8
8
  import { common, createLowlight } from "lowlight";
9
9
  import { DOMParser, Node as Node$1 } from "@tiptap/pm/model";
10
10
  import MarkdownIt from "markdown-it";
11
11
  import { CellSelection, TableMap, addColumn, addColumnAfter, addColumnBefore, addRow, addRowAfter, addRowBefore, cellAround, columnResizing, deleteCellSelection, deleteColumn, deleteRow, deleteTable, fixTables, goToNextCell, mergeCells, setCellAttr, splitCell, tableEditing, toggleHeader, toggleHeaderCell } from "@tiptap/pm/tables";
12
+ //#region src/editor/extensions/active-block.ts
13
+ /**
14
+ * Marks the top-level block holding the caret so a stylesheet can show where
15
+ * editing is happening without drawing chrome inside the reading column.
16
+ *
17
+ * The decoration lands on the document's direct child, not on the textblock the
18
+ * caret sits in: a marker that tracked the caret's own line would move on every
19
+ * wrap and every arrow key, and one that tracked a nested list item would step
20
+ * in and out of the list's inset. The outermost block is the stable answer to
21
+ * "where am I", which is the question the marker exists to answer.
22
+ */
23
+ /** Class applied to the decorated block; `looma-editor.css` owns its appearance. */
24
+ var LOOMA_ACTIVE_BLOCK_CLASS = "looma-active-block";
25
+ /** Plugin state is the editor's focus, so the marker is absent while reading. */
26
+ var LoomaActiveBlockPluginKey = new PluginKey("loomaActiveBlock");
27
+ /**
28
+ * Decorates the outermost block containing the selection head while the editor
29
+ * has focus.
30
+ *
31
+ * @contract Adds `LOOMA_ACTIVE_BLOCK_CLASS` to at most one top-level block, and
32
+ * nothing at all when the editor is unfocused or not editable. The document is
33
+ * never modified.
34
+ * @invariant Focus is tracked in plugin state rather than read from the editor,
35
+ * so the decoration recomputes on focus and blur even when neither changes the
36
+ * selection.
37
+ * @ownership The consuming stylesheet owns every visual property; this extension
38
+ * owns only which block carries the class.
39
+ */
40
+ var LoomaActiveBlock = Extension.create({
41
+ name: "loomaActiveBlock",
42
+ addProseMirrorPlugins() {
43
+ return [new Plugin({
44
+ key: LoomaActiveBlockPluginKey,
45
+ state: {
46
+ init: () => false,
47
+ apply: (transaction, focused) => {
48
+ const next = transaction.getMeta(LoomaActiveBlockPluginKey);
49
+ return typeof next === "boolean" ? next : focused;
50
+ }
51
+ },
52
+ props: {
53
+ handleDOMEvents: {
54
+ focus: (view) => {
55
+ view.dispatch(view.state.tr.setMeta(LoomaActiveBlockPluginKey, true));
56
+ return false;
57
+ },
58
+ blur: (view) => {
59
+ view.dispatch(view.state.tr.setMeta(LoomaActiveBlockPluginKey, false));
60
+ return false;
61
+ }
62
+ },
63
+ decorations: (state) => {
64
+ if (!LoomaActiveBlockPluginKey.getState(state)) return null;
65
+ const { $head } = state.selection;
66
+ if ($head.depth === 0) return null;
67
+ const from = $head.before(1);
68
+ const block = state.doc.nodeAt(from);
69
+ if (!block) return null;
70
+ return DecorationSet.create(state.doc, [Decoration.node(from, from + block.nodeSize, { class: LOOMA_ACTIVE_BLOCK_CLASS })]);
71
+ }
72
+ }
73
+ })];
74
+ }
75
+ });
76
+ //#endregion
12
77
  //#region src/editor/extensions/callout.ts
13
78
  /** Canonical tone values that may be persisted in a Looma callout node. */
14
79
  var LOOMA_CALLOUT_TONES = [
@@ -6631,7 +6696,8 @@ function getDefaultEditorExtensions(options = {}) {
6631
6696
  }),
6632
6697
  ...mention ? [mention] : [],
6633
6698
  LoomaTableKit,
6634
- LoomaListBehavior
6699
+ LoomaListBehavior,
6700
+ LoomaActiveBlock
6635
6701
  ];
6636
6702
  }
6637
6703
  //#endregion
@@ -7264,4 +7330,4 @@ function createLoomaSlashCommandExtension(options = {}) {
7264
7330
  });
7265
7331
  }
7266
7332
  //#endregion
7267
- export { DEFAULT_MENTION_RESULT_LIMIT as C, LOOMA_CALLOUT_TONES as D, normalizeMentionResultLimit as E, LoomaCallout as O, createLoomaMentionExtension as S, filterLoomaMentionItems as T, getActiveTableCellBackground as _, handleTableAction as a, LoomaSmartPaste as b, normalizeActiveTableColumnWidths as c, getDefaultEditorExtensions as d, getLoomaTableExtensions as f, getActiveTableCellAlignment as g, LoomaTableHeader as h, getActiveTableUiState as i, shouldShowTextFormattingToolbar as l, LoomaTableCell as m, createLoomaSlashCommandExtension as n, handleTableOverlayAction as o, LoomaTable as p, getDefaultSlashCommands as r, insertTableAtRange as s, LoomaSlashCommand as t, LoomaTableKit as u, setActiveTableCellAlignment as v, MAX_MENTION_RESULT_LIMIT as w, LoomaMentionSuggestionPluginKey as x, setActiveTableCellBackground as y };
7333
+ export { LoomaActiveBlock as A, DEFAULT_MENTION_RESULT_LIMIT as C, LOOMA_CALLOUT_TONES as D, normalizeMentionResultLimit as E, LoomaCallout as O, createLoomaMentionExtension as S, filterLoomaMentionItems as T, getActiveTableCellBackground as _, handleTableAction as a, LoomaSmartPaste as b, normalizeActiveTableColumnWidths as c, getDefaultEditorExtensions as d, getLoomaTableExtensions as f, getActiveTableCellAlignment as g, LoomaTableHeader as h, getActiveTableUiState as i, LoomaActiveBlockPluginKey as j, LOOMA_ACTIVE_BLOCK_CLASS as k, shouldShowTextFormattingToolbar as l, LoomaTableCell as m, createLoomaSlashCommandExtension as n, handleTableOverlayAction as o, LoomaTable as p, getDefaultSlashCommands as r, insertTableAtRange as s, LoomaSlashCommand as t, LoomaTableKit as u, setActiveTableCellAlignment as v, MAX_MENTION_RESULT_LIMIT as w, LoomaMentionSuggestionPluginKey as x, setActiveTableCellBackground as y };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Marks the top-level block holding the caret so a stylesheet can show where
3
+ * editing is happening without drawing chrome inside the reading column.
4
+ *
5
+ * The decoration lands on the document's direct child, not on the textblock the
6
+ * caret sits in: a marker that tracked the caret's own line would move on every
7
+ * wrap and every arrow key, and one that tracked a nested list item would step
8
+ * in and out of the list's inset. The outermost block is the stable answer to
9
+ * "where am I", which is the question the marker exists to answer.
10
+ */
11
+ import { Extension } from "@tiptap/core";
12
+ import { PluginKey } from "@tiptap/pm/state";
13
+ /** Class applied to the decorated block; `looma-editor.css` owns its appearance. */
14
+ export declare const LOOMA_ACTIVE_BLOCK_CLASS = "looma-active-block";
15
+ /** Plugin state is the editor's focus, so the marker is absent while reading. */
16
+ export declare const LoomaActiveBlockPluginKey: PluginKey<boolean>;
17
+ /**
18
+ * Decorates the outermost block containing the selection head while the editor
19
+ * has focus.
20
+ *
21
+ * @contract Adds `LOOMA_ACTIVE_BLOCK_CLASS` to at most one top-level block, and
22
+ * nothing at all when the editor is unfocused or not editable. The document is
23
+ * never modified.
24
+ * @invariant Focus is tracked in plugin state rather than read from the editor,
25
+ * so the decoration recomputes on focus and blur even when neither changes the
26
+ * selection.
27
+ * @ownership The consuming stylesheet owns every visual property; this extension
28
+ * owns only which block carries the class.
29
+ */
30
+ export declare const LoomaActiveBlock: Extension<any, any>;
@@ -6,6 +6,7 @@
6
6
  * application owns wiring and editor-instance lifetime. Tiptap remains a peer
7
7
  * dependency so Looma and the host execute against the same editor runtime.
8
8
  */
9
+ export { LOOMA_ACTIVE_BLOCK_CLASS, LoomaActiveBlock, LoomaActiveBlockPluginKey, } from "./active-block.js";
9
10
  export { LoomaCallout, LOOMA_CALLOUT_TONES, type LoomaCalloutTone, } from "./callout.js";
10
11
  export { getDefaultEditorExtensions, getLoomaTableExtensions, LoomaTableKit, type DefaultEditorExtensionsOptions, } from "./preset.js";
11
12
  export { LoomaSmartPaste } from "./smart-paste.js";
@@ -1,3 +1,3 @@
1
1
  import { n as TABLE_CELL_BACKGROUND_PRESETS } from "../chunks/table-backgrounds.js";
2
- import { C as DEFAULT_MENTION_RESULT_LIMIT, D as LOOMA_CALLOUT_TONES, E as normalizeMentionResultLimit, O as LoomaCallout, S as createLoomaMentionExtension, T as filterLoomaMentionItems, _ as getActiveTableCellBackground, a as handleTableAction, b as LoomaSmartPaste, c as normalizeActiveTableColumnWidths, d as getDefaultEditorExtensions, f as getLoomaTableExtensions, g as getActiveTableCellAlignment, h as LoomaTableHeader, i as getActiveTableUiState, l as shouldShowTextFormattingToolbar, m as LoomaTableCell, n as createLoomaSlashCommandExtension, o as handleTableOverlayAction, p as LoomaTable, r as getDefaultSlashCommands, s as insertTableAtRange, t as LoomaSlashCommand, u as LoomaTableKit, v as setActiveTableCellAlignment, w as MAX_MENTION_RESULT_LIMIT, x as LoomaMentionSuggestionPluginKey, y as setActiveTableCellBackground } from "../chunks/extensions.js";
3
- export { DEFAULT_MENTION_RESULT_LIMIT, LOOMA_CALLOUT_TONES, LoomaCallout, LoomaMentionSuggestionPluginKey, LoomaSlashCommand, LoomaSmartPaste, LoomaTable, LoomaTableCell, LoomaTableHeader, LoomaTableKit, MAX_MENTION_RESULT_LIMIT, TABLE_CELL_BACKGROUND_PRESETS, createLoomaMentionExtension, createLoomaSlashCommandExtension, filterLoomaMentionItems, getActiveTableCellAlignment, getActiveTableCellBackground, getActiveTableUiState, getDefaultEditorExtensions, getDefaultSlashCommands, getLoomaTableExtensions, handleTableAction, handleTableOverlayAction, insertTableAtRange, normalizeActiveTableColumnWidths, normalizeMentionResultLimit, setActiveTableCellAlignment, setActiveTableCellBackground, shouldShowTextFormattingToolbar };
2
+ import { A as LoomaActiveBlock, C as DEFAULT_MENTION_RESULT_LIMIT, D as LOOMA_CALLOUT_TONES, E as normalizeMentionResultLimit, O as LoomaCallout, S as createLoomaMentionExtension, T as filterLoomaMentionItems, _ as getActiveTableCellBackground, a as handleTableAction, b as LoomaSmartPaste, c as normalizeActiveTableColumnWidths, d as getDefaultEditorExtensions, f as getLoomaTableExtensions, g as getActiveTableCellAlignment, h as LoomaTableHeader, i as getActiveTableUiState, j as LoomaActiveBlockPluginKey, k as LOOMA_ACTIVE_BLOCK_CLASS, l as shouldShowTextFormattingToolbar, m as LoomaTableCell, n as createLoomaSlashCommandExtension, o as handleTableOverlayAction, p as LoomaTable, r as getDefaultSlashCommands, s as insertTableAtRange, t as LoomaSlashCommand, u as LoomaTableKit, v as setActiveTableCellAlignment, w as MAX_MENTION_RESULT_LIMIT, x as LoomaMentionSuggestionPluginKey, y as setActiveTableCellBackground } from "../chunks/extensions.js";
3
+ export { DEFAULT_MENTION_RESULT_LIMIT, LOOMA_ACTIVE_BLOCK_CLASS, LOOMA_CALLOUT_TONES, LoomaActiveBlock, LoomaActiveBlockPluginKey, LoomaCallout, LoomaMentionSuggestionPluginKey, LoomaSlashCommand, LoomaSmartPaste, LoomaTable, LoomaTableCell, LoomaTableHeader, LoomaTableKit, MAX_MENTION_RESULT_LIMIT, TABLE_CELL_BACKGROUND_PRESETS, createLoomaMentionExtension, createLoomaSlashCommandExtension, filterLoomaMentionItems, getActiveTableCellAlignment, getActiveTableCellBackground, getActiveTableUiState, getDefaultEditorExtensions, getDefaultSlashCommands, getLoomaTableExtensions, handleTableAction, handleTableOverlayAction, insertTableAtRange, normalizeActiveTableColumnWidths, normalizeMentionResultLimit, setActiveTableCellAlignment, setActiveTableCellBackground, shouldShowTextFormattingToolbar };
package/editor/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { n as TABLE_CELL_BACKGROUND_PRESETS, t as TABLE_CELL_BACKGROUND_OPTIONS } from "./chunks/table-backgrounds.js";
2
2
  import { n as resolveTableCellAt, t as measureTableOverlayGeometry } from "./chunks/ui.js";
3
- import { C as DEFAULT_MENTION_RESULT_LIMIT, D as LOOMA_CALLOUT_TONES, E as normalizeMentionResultLimit, O as LoomaCallout, S as createLoomaMentionExtension, T as filterLoomaMentionItems, _ as getActiveTableCellBackground, a as handleTableAction, b as LoomaSmartPaste, c as normalizeActiveTableColumnWidths, d as getDefaultEditorExtensions, f as getLoomaTableExtensions, g as getActiveTableCellAlignment, h as LoomaTableHeader, i as getActiveTableUiState, l as shouldShowTextFormattingToolbar, m as LoomaTableCell, n as createLoomaSlashCommandExtension, o as handleTableOverlayAction, p as LoomaTable, r as getDefaultSlashCommands, s as insertTableAtRange, t as LoomaSlashCommand, u as LoomaTableKit, v as setActiveTableCellAlignment, w as MAX_MENTION_RESULT_LIMIT, x as LoomaMentionSuggestionPluginKey, y as setActiveTableCellBackground } from "./chunks/extensions.js";
3
+ import { A as LoomaActiveBlock, C as DEFAULT_MENTION_RESULT_LIMIT, D as LOOMA_CALLOUT_TONES, E as normalizeMentionResultLimit, O as LoomaCallout, S as createLoomaMentionExtension, T as filterLoomaMentionItems, _ as getActiveTableCellBackground, a as handleTableAction, b as LoomaSmartPaste, c as normalizeActiveTableColumnWidths, d as getDefaultEditorExtensions, f as getLoomaTableExtensions, g as getActiveTableCellAlignment, h as LoomaTableHeader, i as getActiveTableUiState, j as LoomaActiveBlockPluginKey, k as LOOMA_ACTIVE_BLOCK_CLASS, l as shouldShowTextFormattingToolbar, m as LoomaTableCell, n as createLoomaSlashCommandExtension, o as handleTableOverlayAction, p as LoomaTable, r as getDefaultSlashCommands, s as insertTableAtRange, t as LoomaSlashCommand, u as LoomaTableKit, v as setActiveTableCellAlignment, w as MAX_MENTION_RESULT_LIMIT, x as LoomaMentionSuggestionPluginKey, y as setActiveTableCellBackground } from "./chunks/extensions.js";
4
4
  import { AlignCenter, AlignLeft, AlignRight, Bold, Braces, ChevronDown, ChevronLeft, CircleCheck, CircleX, CodeXml, Columns3, Ellipsis, Eraser, GripHorizontal, GripVertical, Heading1, Heading2, Heading3, Highlighter, Image, Info, Italic, List, ListOrdered, ListTodo, Merge, Minus, NotebookPen, PaintBucket, PanelBottom, PanelLeft, PanelRight, PanelTop, Pilcrow, Plus, Quote, Redo2, Rows3, Split, Strikethrough, Table2, Trash2, TriangleAlert, Underline, Undo2 } from "lucide";
5
5
  //#region src/editor/icons.ts
6
6
  /** The opinionated Lucide set used by Looma's shipped interaction surfaces. */
@@ -94,4 +94,4 @@ function getVisualViewportRect(owner = window) {
94
94
  };
95
95
  }
96
96
  //#endregion
97
- export { DEFAULT_MENTION_RESULT_LIMIT, LOOMA_CALLOUT_TONES, LOOMA_ICONS, LoomaCallout, LoomaMentionSuggestionPluginKey, LoomaSlashCommand, LoomaSmartPaste, LoomaTable, LoomaTableCell, LoomaTableHeader, LoomaTableKit, MAX_MENTION_RESULT_LIMIT, TABLE_CELL_BACKGROUND_OPTIONS, TABLE_CELL_BACKGROUND_PRESETS, createLoomaMentionExtension, createLoomaSlashCommandExtension, filterLoomaMentionItems, getActiveTableCellAlignment, getActiveTableCellBackground, getActiveTableUiState, getDefaultEditorExtensions, getDefaultSlashCommands, getLoomaTableExtensions, getVisualViewportRect, handleTableAction, handleTableOverlayAction, insertTableAtRange, loomaIconMarkup, measureTableOverlayGeometry, normalizeActiveTableColumnWidths, normalizeMentionResultLimit, resolveTableCellAt, setActiveTableCellAlignment, setActiveTableCellBackground, shouldShowTextFormattingToolbar };
97
+ export { DEFAULT_MENTION_RESULT_LIMIT, LOOMA_ACTIVE_BLOCK_CLASS, LOOMA_CALLOUT_TONES, LOOMA_ICONS, LoomaActiveBlock, LoomaActiveBlockPluginKey, LoomaCallout, LoomaMentionSuggestionPluginKey, LoomaSlashCommand, LoomaSmartPaste, LoomaTable, LoomaTableCell, LoomaTableHeader, LoomaTableKit, MAX_MENTION_RESULT_LIMIT, TABLE_CELL_BACKGROUND_OPTIONS, TABLE_CELL_BACKGROUND_PRESETS, createLoomaMentionExtension, createLoomaSlashCommandExtension, filterLoomaMentionItems, getActiveTableCellAlignment, getActiveTableCellBackground, getActiveTableUiState, getDefaultEditorExtensions, getDefaultSlashCommands, getLoomaTableExtensions, getVisualViewportRect, handleTableAction, handleTableOverlayAction, insertTableAtRange, loomaIconMarkup, measureTableOverlayGeometry, normalizeActiveTableColumnWidths, normalizeMentionResultLimit, resolveTableCellAt, setActiveTableCellAlignment, setActiveTableCellBackground, shouldShowTextFormattingToolbar };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threadlabs/looma",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "type": "module",
5
5
  "description": "Looma components as HTML, Vue, and plain DOM, with design tokens.",
6
6
  "license": "MIT",
@@ -4372,6 +4372,28 @@ html[data-ui-input-modality="touch"] [data-component~="ui-tree-item"] .drag-hand
4372
4372
  }
4373
4373
  }
4374
4374
 
4375
+ /*
4376
+ * Marker for the block being edited, drawn in the gutter beside the text rather
4377
+ * than around it: a border or fill on the reading column reads as a form field.
4378
+ * The bar sits outside the content box, so a consumer that zeroes
4379
+ * --ui-editor-content-padding-inline must leave room on its own wrapper.
4380
+ */
4381
+ .looma-editor .ProseMirror > .looma-active-block {
4382
+ position: relative;
4383
+ }
4384
+
4385
+ .looma-editor .ProseMirror > .looma-active-block::before {
4386
+ position: absolute;
4387
+ z-index: 1;
4388
+ inset-block: 0;
4389
+ inset-inline-start: calc(-1 * var(--ui-editor-active-block-offset, var(--ui-space-3)));
4390
+ inline-size: var(--ui-editor-active-block-width, 2px);
4391
+ border-radius: var(--ui-radius-round);
4392
+ background: var(--ui-editor-active-block-color, var(--ui-border-strong));
4393
+ content: "";
4394
+ pointer-events: none;
4395
+ }
4396
+
4375
4397
  .looma-editor .ProseMirror p {
4376
4398
  margin: 0 0 var(--ui-editor-paragraph-gap, var(--ui-space-3));
4377
4399
  }