@threadlabs/looma 0.53.13 → 0.53.14

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/docs/catalog.json CHANGED
@@ -780,7 +780,7 @@
780
780
  ],
781
781
  "schemaVersion": 1,
782
782
  "package": "@threadlabs/looma",
783
- "version": "0.53.13",
783
+ "version": "0.53.14",
784
784
  "groups": [
785
785
  {
786
786
  "id": "layout",
@@ -1,5 +1,6 @@
1
1
  import { Extension, Mark, Node, markInputRule, markPasteRule, mergeAttributes } from "@tiptap/core";
2
2
  import { Plugin } from "@tiptap/pm/state";
3
+ import { DOMParser } from "@tiptap/pm/model";
3
4
  import { closeHistory, history, redo, undo } from "@tiptap/pm/history";
4
5
  //#region src/editor/extensions/input-rule-history.ts
5
6
  /**
@@ -45,6 +46,23 @@ var LoomaInputRuleHistory = Extension.create({
45
46
  }
46
47
  });
47
48
  //#endregion
49
+ //#region src/editor/extensions/dom-readback.ts
50
+ var EditorDOMParser = class extends DOMParser {
51
+ parse(node, options) {
52
+ return super.parse(node, options?.preserveWhitespace === true ? {
53
+ ...options,
54
+ preserveWhitespace: "full"
55
+ } : options);
56
+ }
57
+ };
58
+ var LoomaDOMReadback = Extension.create({
59
+ name: "loomaDOMReadback",
60
+ addProseMirrorPlugins() {
61
+ const { schema, rules } = DOMParser.fromSchema(this.editor.schema);
62
+ return [new Plugin({ props: { domParser: new EditorDOMParser(schema, rules) } })];
63
+ }
64
+ });
65
+ //#endregion
48
66
  //#region ../../node_modules/.pnpm/@tiptap+extension-document@2.27.2_@tiptap+core@2.27.2_@tiptap+pm@2.27.2_/node_modules/@tiptap/extension-document/dist/index.js
49
67
  /**
50
68
  * The default document node which represents the top level node of the editor.
@@ -435,4 +453,4 @@ var Code = Mark.create({
435
453
  }
436
454
  });
437
455
  //#endregion
438
- export { Bold as a, Document as c, Italic as i, LoomaInputRuleHistory as l, History as n, Text as o, HardBreak as r, Paragraph as s, Code as t };
456
+ export { Bold as a, Document as c, Italic as i, LoomaDOMReadback as l, History as n, Text as o, HardBreak as r, Paragraph as s, Code as t, LoomaInputRuleHistory as u };
@@ -11586,6 +11586,13 @@ function customHeadings(headings) {
11586
11586
  marked.add(next);
11587
11587
  }
11588
11588
  }
11589
+ function softLineBreaks(node) {
11590
+ if (node.type !== "text" || !node.value?.includes("\n")) return [node];
11591
+ return node.value.split(/((?<!\n)\n(?!\n))/).filter(Boolean).map((value) => value === "\n" ? { type: "softBreak" } : {
11592
+ type: "text",
11593
+ value
11594
+ });
11595
+ }
11589
11596
  function toNode(node, path, context) {
11590
11597
  let result = toBareNode(node, path, context);
11591
11598
  if (!node.marks?.length) return result;
@@ -11616,7 +11623,7 @@ function toNode(node, path, context) {
11616
11623
  const definition = typeof attrs.reference === "string" ? context.definitions.get(referenceKey(attrs.reference)) : void 0;
11617
11624
  if (definition && definition.attrs?.href === attrs.href && string(definition.attrs?.title) === string(attrs.title) && !attrs.class) {
11618
11625
  const referenceType = (attrs.referenceType === "collapsed" || attrs.referenceType === "shortcut") && referenceKey(text(result)) !== referenceKey(attrs.reference) ? "full" : string(attrs.referenceType, "full");
11619
- result = compact("linkReference", [result], {
11626
+ result = compact("linkReference", softLineBreaks(result), {
11620
11627
  label: attrs.reference,
11621
11628
  referenceType
11622
11629
  });
@@ -11628,7 +11635,7 @@ function toNode(node, path, context) {
11628
11635
  "rel",
11629
11636
  "class"
11630
11637
  ]) if (attrs[key] !== LINK_DEFAULTS[key]) has(attributes, key, attrs[key]);
11631
- result = compact(type, [result], {
11638
+ result = compact(type, softLineBreaks(result), {
11632
11639
  url: string(attrs.href),
11633
11640
  ...attrs.title ? { title: string(attrs.title) } : {},
11634
11641
  ...Object.keys(attributes).length ? { attributes } : {}
@@ -11639,7 +11646,7 @@ function toNode(node, path, context) {
11639
11646
  type,
11640
11647
  value: result.value ?? ""
11641
11648
  };
11642
- } else result = compact(type, [result], mark.attrs?.color ? { attributes: { color: string(mark.attrs.color) } } : {});
11649
+ } else result = compact(type, softLineBreaks(result), mark.attrs?.color ? { attributes: { color: string(mark.attrs.color) } } : {});
11643
11650
  }
11644
11651
  return result;
11645
11652
  }
@@ -11653,7 +11660,9 @@ function toBareNode(node, path, context) {
11653
11660
  } : child);
11654
11661
  const plain = (type, keys = [], extra = {}) => {
11655
11662
  fields(node, keys, path);
11656
- return compact(type, children(), extra);
11663
+ const result = compact(type, children(), extra);
11664
+ if ((type === "paragraph" || type === "heading") && result.children) result.children = result.children.flatMap(softLineBreaks);
11665
+ return result;
11657
11666
  };
11658
11667
  const block = (type, keys = [], extra = {}) => {
11659
11668
  fields(node, keys, path);
@@ -1,6 +1,6 @@
1
1
  import { C as assignLoomaHeadingIds, D as splitLoomaFrontmatter, E as normalizeLoomaChipTone, S as LOOMA_CHIP_TONES, T as normalizeLoomaCalloutTone, d as readPictureHtml, f as isHeadingAlignment, g as referenceDisplay, h as getReferenceDisplay, m as LoomaReferencePresentation, o as markdownToEditorDocument, p as LoomaReference, s as imageHtmlSpec, u as normalizeImageSources, v as LoomaFileAttachment, w as loomaHeadingSlug } from "./expressmark.js";
2
2
  import { i as TABLE_CELL_BACKGROUND_PRESETS, n as resolveTableCellAt } from "./table-overlay.js";
3
- import { a as Bold, c as Document, i as Italic, l as LoomaInputRuleHistory, n as History, o as Text$1, r as HardBreak, s as Paragraph, t as Code } from "./dist.js";
3
+ import { a as Bold, c as Document, i as Italic, l as LoomaDOMReadback, n as History, o as Text$1, r as HardBreak, s as Paragraph, t as Code, u as LoomaInputRuleHistory } from "./dist.js";
4
4
  import { Extension, InputRule, Mark, Node as Node$1, PasteRule, callOrReturn, canInsertNode, combineTransactionSteps, escapeForRegEx, findChildren, findChildrenInRange, findParentNodeClosestToPos, getAttributes, getChangedRanges, getExtensionField, getMarksBetween, getText, getTextSerializersFromSchema, isNodeEmpty, isNodeSelection, markInputRule, markPasteRule, mergeAttributes, nodeInputRule, textInputRule, textblockTypeInputRule, wrappingInputRule } from "@tiptap/core";
5
5
  import { NodeSelection, Plugin, PluginKey, Selection, TextSelection } from "@tiptap/pm/state";
6
6
  import { Decoration, DecorationSet } from "@tiptap/pm/view";
@@ -10479,6 +10479,7 @@ function getDefaultEditorExtensions(options = {}) {
10479
10479
  HardBreak,
10480
10480
  History,
10481
10481
  LoomaInputRuleHistory,
10482
+ LoomaDOMReadback,
10482
10483
  Dropcursor,
10483
10484
  Gapcursor,
10484
10485
  Link.configure({
package/editor/compact.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as Bold, c as Document, i as Italic, l as LoomaInputRuleHistory, n as History, o as Text, r as HardBreak, s as Paragraph, t as Code } from "./chunks/dist.js";
1
+ import { a as Bold, c as Document, i as Italic, l as LoomaDOMReadback, n as History, o as Text, r as HardBreak, s as Paragraph, t as Code, u as LoomaInputRuleHistory } from "./chunks/dist.js";
2
2
  import { t as createEditorSession } from "./chunks/session.js";
3
3
  //#region src/editor/compact-extensions.ts
4
4
  /** Minimal short-form schema; additional consumer extensions are opt-in. */
@@ -12,7 +12,8 @@ function getCompactEditorExtensions() {
12
12
  Code,
13
13
  HardBreak,
14
14
  History,
15
- LoomaInputRuleHistory
15
+ LoomaInputRuleHistory,
16
+ LoomaDOMReadback
16
17
  ];
17
18
  }
18
19
  //#endregion
@@ -0,0 +1,2 @@
1
+ import { Extension } from "@tiptap/core";
2
+ export declare const LoomaDOMReadback: Extension<any, any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threadlabs/looma",
3
- "version": "0.53.13",
3
+ "version": "0.53.14",
4
4
  "type": "module",
5
5
  "description": "HTML Next UI components, native DOM support and design tokens.",
6
6
  "license": "MIT",