@threadlabs/looma 0.53.8 → 0.53.9

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.8",
783
+ "version": "0.53.9",
784
784
  "groups": [
785
785
  {
786
786
  "id": "layout",
@@ -336,6 +336,12 @@ var LoomaReferencePresentation = Extension.create({
336
336
  }
337
337
  });
338
338
  //#endregion
339
+ //#region src/editor/heading-alignment.ts
340
+ /** Native HTML heading alignment shared by the editor schema and portable conversion. */
341
+ function isHeadingAlignment(value) {
342
+ return typeof value === "string" && /^(left|center|right|justify)$/.test(value);
343
+ }
344
+ //#endregion
339
345
  //#region ../../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/decode-codepoint.js
340
346
  /**
341
347
  * True for NUL, UTF-16 surrogates, and values past U+10FFFF.
@@ -4944,7 +4950,7 @@ for (const proto of [RunResultRecord.prototype, RunResultWithRootTrivia.prototyp
4944
4950
  var ESC = "\x1B";
4945
4951
  `${ESC}`, `${ESC}`, `${ESC}`, `${ESC}`, `${ESC}`, `${ESC}`;
4946
4952
  //#endregion
4947
- //#region ../../node_modules/.pnpm/expressmark@0.6.1/node_modules/expressmark/dist/types.js
4953
+ //#region ../../node_modules/.pnpm/expressmark@0.6.4/node_modules/expressmark/dist/types.js
4948
4954
  var ConversionError = class extends Error {
4949
4955
  code;
4950
4956
  constructor(code, message) {
@@ -4980,7 +4986,7 @@ function plainText(node) {
4980
4986
  return node.value ?? (node.children ?? node.body ?? []).map(plainText).join("");
4981
4987
  }
4982
4988
  //#endregion
4983
- //#region ../../node_modules/.pnpm/expressmark@0.6.1/node_modules/expressmark/dist/anchors.js
4989
+ //#region ../../node_modules/.pnpm/expressmark@0.6.4/node_modules/expressmark/dist/anchors.js
4984
4990
  /** The specification's readable anchor for a heading or title text. */
4985
4991
  function anchorText(text) {
4986
4992
  return text.normalize("NFC").toLowerCase().replace(/[^\p{L}\p{N}\p{M}]+/gu, "-").replace(/^-+|-+$/g, "") || "section";
@@ -9146,7 +9152,7 @@ var require_launder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9146
9152
  module.exports.naughtyHref = naughtyHref;
9147
9153
  }));
9148
9154
  //#endregion
9149
- //#region ../../node_modules/.pnpm/expressmark@0.6.1/node_modules/expressmark/dist/html.js
9155
+ //#region ../../node_modules/.pnpm/expressmark@0.6.4/node_modules/expressmark/dist/html.js
9150
9156
  var import_sanitize_html = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
9151
9157
  var htmlparser = (init_dist(), __toCommonJS(dist_exports));
9152
9158
  var escapeStringRegexp = require_escape_string_regexp();
@@ -10215,6 +10221,22 @@ var policy = {
10215
10221
  details: ["open"],
10216
10222
  ol: ["start"],
10217
10223
  li: ["value"],
10224
+ ...Object.fromEntries([
10225
+ "h1",
10226
+ "h2",
10227
+ "h3",
10228
+ "h4",
10229
+ "h5",
10230
+ "h6"
10231
+ ].map((tag) => [tag, [{
10232
+ name: "align",
10233
+ values: [
10234
+ "left",
10235
+ "center",
10236
+ "right",
10237
+ "justify"
10238
+ ]
10239
+ }]])),
10218
10240
  td: [
10219
10241
  "colspan",
10220
10242
  "rowspan",
@@ -10631,7 +10653,7 @@ function readStartTag(source, start, limit = source.length) {
10631
10653
  }
10632
10654
  }
10633
10655
  //#endregion
10634
- //#region ../../node_modules/.pnpm/expressmark@0.6.1/node_modules/expressmark/dist/references.js
10656
+ //#region ../../node_modules/.pnpm/expressmark@0.6.4/node_modules/expressmark/dist/references.js
10635
10657
  function walk(node, visit, skipNotes, active = /* @__PURE__ */ new Set()) {
10636
10658
  if (!node || typeof node !== "object" || active.has(node)) return;
10637
10659
  if (skipNotes && node.type === "footnoteDefinition") return;
@@ -10680,7 +10702,7 @@ function linkDefinitions(document) {
10680
10702
  return definitions;
10681
10703
  }
10682
10704
  //#endregion
10683
- //#region ../../node_modules/.pnpm/expressmark@0.6.1/node_modules/expressmark/dist/render.js
10705
+ //#region ../../node_modules/.pnpm/expressmark@0.6.4/node_modules/expressmark/dist/render.js
10684
10706
  init_dist();
10685
10707
  function isAlignment(value) {
10686
10708
  return value === "start" || value === "center" || value === "end";
@@ -10777,7 +10799,7 @@ function renderHtml(document, options = {}) {
10777
10799
  return Object.entries(values).map(([key, value]) => {
10778
10800
  let name = sourceKey(key);
10779
10801
  if (!/^[a-zA-Z][\w:-]*$/.test(name) || value === false) return "";
10780
- if (!nativeAttributes.has(name) && !name.startsWith("data-") && !name.startsWith("aria-")) name = `data-${name}`;
10802
+ if (!nativeAttributes.has(name) && !(node.type === "heading" && name === "align") && !name.startsWith("data-") && !name.startsWith("aria-")) name = `data-${name}`;
10781
10803
  return value === true ? ` ${name}` : ` ${name}="${escapeHtml(String(value))}"`;
10782
10804
  }).join("");
10783
10805
  }
@@ -11525,10 +11547,17 @@ function toBareNode(node, path, context) {
11525
11547
  };
11526
11548
  case "paragraph": return plain("paragraph");
11527
11549
  case "loomaLineBlock": return plain("lineBlock");
11528
- case "heading": return plain("heading", ["level", "id"], {
11529
- level: Number(attrs.level ?? 1),
11530
- ...context.headingIds.has(node) ? { id: context.headingIds.get(node) } : context.custom.has(node) ? { id: string(attrs.id) } : {}
11531
- });
11550
+ case "heading":
11551
+ if (attrs.align != null && !isHeadingAlignment(attrs.align)) fail(path, "unsupported heading alignment");
11552
+ return plain("heading", [
11553
+ "level",
11554
+ "id",
11555
+ "align"
11556
+ ], {
11557
+ level: Number(attrs.level ?? 1),
11558
+ ...attrs.align != null ? { attributes: { align: attrs.align } } : {},
11559
+ ...context.headingIds.has(node) ? { id: context.headingIds.get(node) } : context.custom.has(node) ? { id: string(attrs.id) } : {}
11560
+ });
11532
11561
  case "blockquote": return block("blockquote");
11533
11562
  case "horizontalRule":
11534
11563
  fields(node, [], path);
@@ -12027,13 +12056,15 @@ function fromNode(node, path, context, marks = []) {
12027
12056
  }];
12028
12057
  }
12029
12058
  case "heading": {
12030
- check();
12059
+ check(["align"]);
12060
+ if (attrs.align !== void 0 && !isHeadingAlignment(attrs.align)) fail(path, "unsupported heading alignment");
12031
12061
  let body = inline();
12032
12062
  if (body.some((child) => child.type === "loomaInlineImage") && body.every((child) => child.type === "loomaInlineImage" || child.type === "text" && !child.text?.trim())) body = body.filter((child) => child.type === "loomaInlineImage");
12033
12063
  return [{
12034
12064
  type: "heading",
12035
12065
  attrs: {
12036
12066
  level: node.level ?? 1,
12067
+ ...attrs.align !== void 0 ? { align: attrs.align } : {},
12037
12068
  ...node.id ? { id: node.id } : {}
12038
12069
  },
12039
12070
  ...body.length ? { content: body } : {}
@@ -12528,4 +12559,4 @@ function markdownToEditorDocument(markdown, options = {}) {
12528
12559
  return expressmarkToEditorDocument(document);
12529
12560
  }
12530
12561
  //#endregion
12531
- export { splitLoomaFrontmatter as C, normalizeLoomaChipTone as S, LOOMA_CALLOUT_TONES as _, expressmarkToEditorDocument as a, loomaHeadingSlug as b, imageSourceUrls as c, readPictureHtml as d, LoomaReference as f, setReferenceDisplay as g, referenceDisplay as h, editorToMarkdown as i, mapImageSourceUrls as l, getReferenceDisplay as m, editorDocumentToExpressmark as n, markdownToEditorDocument as o, LoomaReferencePresentation as p, editorDocumentToMarkdown as r, imageHtmlSpec as s, EditorMarkdownConversionError as t, normalizeImageSources as u, LOOMA_CHIP_TONES as v, __exportAll as w, normalizeLoomaCalloutTone as x, assignLoomaHeadingIds as y };
12562
+ export { normalizeLoomaChipTone as C, normalizeLoomaCalloutTone as S, __exportAll as T, setReferenceDisplay as _, expressmarkToEditorDocument as a, assignLoomaHeadingIds as b, imageSourceUrls as c, readPictureHtml as d, isHeadingAlignment as f, referenceDisplay as g, getReferenceDisplay as h, editorToMarkdown as i, mapImageSourceUrls as l, LoomaReferencePresentation as m, editorDocumentToExpressmark as n, markdownToEditorDocument as o, LoomaReference as p, editorDocumentToMarkdown as r, imageHtmlSpec as s, EditorMarkdownConversionError as t, normalizeImageSources as u, LOOMA_CALLOUT_TONES as v, splitLoomaFrontmatter as w, loomaHeadingSlug as x, LOOMA_CHIP_TONES as y };
@@ -1,4 +1,4 @@
1
- import { C as splitLoomaFrontmatter, S as normalizeLoomaChipTone, b as loomaHeadingSlug, d as readPictureHtml, f as LoomaReference, h as referenceDisplay, m as getReferenceDisplay, o as markdownToEditorDocument, p as LoomaReferencePresentation, s as imageHtmlSpec, u as normalizeImageSources, v as LOOMA_CHIP_TONES, x as normalizeLoomaCalloutTone, y as assignLoomaHeadingIds } from "./expressmark.js";
1
+ import { C as normalizeLoomaChipTone, S as normalizeLoomaCalloutTone, b as assignLoomaHeadingIds, 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, w as splitLoomaFrontmatter, x as loomaHeadingSlug, y as LOOMA_CHIP_TONES } from "./expressmark.js";
2
2
  import { i as TABLE_CELL_BACKGROUND_PRESETS, n as resolveTableCellAt } from "./table-overlay.js";
3
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";
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";
@@ -10371,6 +10371,19 @@ var LoomaCodeBlock = CodeBlockLowlight.extend({
10371
10371
  })];
10372
10372
  }
10373
10373
  });
10374
+ var LoomaHeading = Heading.extend({ addAttributes() {
10375
+ return {
10376
+ ...this.parent?.(),
10377
+ align: {
10378
+ default: null,
10379
+ parseHTML: (element) => {
10380
+ const align = element.getAttribute("align");
10381
+ return isHeadingAlignment(align) ? align : null;
10382
+ },
10383
+ renderHTML: (attributes) => isHeadingAlignment(attributes.align) ? { align: attributes.align } : {}
10384
+ }
10385
+ };
10386
+ } });
10374
10387
  var StoredOnlyHighlight = Highlight.extend({
10375
10388
  parseHTML: () => [],
10376
10389
  addKeyboardShortcuts: () => ({}),
@@ -10437,7 +10450,7 @@ function getDefaultEditorExtensions(options = {}) {
10437
10450
  Italic,
10438
10451
  Strike,
10439
10452
  Underline,
10440
- Heading.configure({ levels: [
10453
+ LoomaHeading.configure({ levels: [
10441
10454
  1,
10442
10455
  2,
10443
10456
  3,
@@ -1,4 +1,4 @@
1
- import { _ as LOOMA_CALLOUT_TONES, c as imageSourceUrls, f as LoomaReference, g as setReferenceDisplay, h as referenceDisplay, l as mapImageSourceUrls, m as getReferenceDisplay, p as LoomaReferencePresentation, u as normalizeImageSources } from "../chunks/expressmark.js";
1
+ import { _ as setReferenceDisplay, c as imageSourceUrls, g as referenceDisplay, h as getReferenceDisplay, l as mapImageSourceUrls, m as LoomaReferencePresentation, p as LoomaReference, u as normalizeImageSources, v as LOOMA_CALLOUT_TONES } from "../chunks/expressmark.js";
2
2
  import { i as TABLE_CELL_BACKGROUND_PRESETS } from "../chunks/table-overlay.js";
3
3
  import { $ as LoomaFootnote, A as createLoomaMentionExtension, C as getActiveTableCellBackground, D as createSiteRelativeLinks, E as LoomaSmartPaste, F as LoomaImage, G as normalizeTableOfContentsConfig, H as LoomaTableOfContents, I as LoomaInlineImage, J as LoomaTabs, M as MAX_MENTION_RESULT_LIMIT, N as filterLoomaMentionItems, O as siteRelativeHref, P as normalizeMentionResultLimit, Q as LOOMA_FOOTNOTE_LABEL, R as normalizeImageDimension, S as getActiveTableCellAlignment, T as setActiveTableCellBackground, U as getTableOfContentsEntries, X as LoomaLinkDefinition, Y as LoomaLineBlock, _ as getDefaultEditorExtensions, at as revealLoomaExpandAt, b as LoomaTableCell, c as handleTableAction, ct as normalizeLoomaChipColor, d as normalizeActiveTableColumnWidths, dt as LOOMA_ACTIVE_BLOCK_CLASS, et as LoomaFootnoteReference, f as shouldShowTextFormattingToolbar, ft as LOOMA_ACTIVE_BLOCK_TYPING_IDLE_MS, g as LoomaTableKit, i as getDefaultSlashCommands, it as LoomaExpand, j as DEFAULT_MENTION_RESULT_LIMIT, k as LoomaMentionSuggestionPluginKey, l as handleTableOverlayAction, lt as LoomaCallout, mt as LoomaActiveBlockPluginKey, n as createLoomaSlashCommandExtension, nt as LoomaFigcaption, ot as LOOMA_CHIP_COLORS, pt as LoomaActiveBlock, q as LoomaTab, r as filterLoomaSlashCommands, rt as LoomaFigure, s as getActiveTableUiState, st as LoomaChip, t as LoomaSlashCommand, tt as findLoomaFootnote, u as insertTableAtRange, ut as LOOMA_ACTIVE_BLOCK_BLUR_GRACE_MS, v as getLoomaTableExtensions, w as setActiveTableCellAlignment, x as LoomaTableHeader, y as LoomaTable, z as normalizeImagePlacement } from "../chunks/extensions.js";
4
4
  export { DEFAULT_MENTION_RESULT_LIMIT, LOOMA_ACTIVE_BLOCK_BLUR_GRACE_MS, LOOMA_ACTIVE_BLOCK_CLASS, LOOMA_ACTIVE_BLOCK_TYPING_IDLE_MS, LOOMA_CALLOUT_TONES, LOOMA_CHIP_COLORS, LOOMA_FOOTNOTE_LABEL, LoomaActiveBlock, LoomaActiveBlockPluginKey, LoomaCallout, LoomaChip, LoomaExpand, LoomaFigcaption, LoomaFigure, LoomaFootnote, LoomaFootnoteReference, LoomaImage, LoomaInlineImage, LoomaLineBlock, LoomaLinkDefinition, LoomaMentionSuggestionPluginKey, LoomaReference, LoomaReferencePresentation, LoomaSlashCommand, LoomaSmartPaste, LoomaTab, LoomaTable, LoomaTableCell, LoomaTableHeader, LoomaTableKit, LoomaTableOfContents, LoomaTabs, MAX_MENTION_RESULT_LIMIT, TABLE_CELL_BACKGROUND_PRESETS, createLoomaMentionExtension, createLoomaSlashCommandExtension, createSiteRelativeLinks, filterLoomaMentionItems, filterLoomaSlashCommands, findLoomaFootnote, getActiveTableCellAlignment, getActiveTableCellBackground, getActiveTableUiState, getDefaultEditorExtensions, getDefaultSlashCommands, getLoomaTableExtensions, getReferenceDisplay, getTableOfContentsEntries, handleTableAction, handleTableOverlayAction, imageSourceUrls, insertTableAtRange, mapImageSourceUrls, normalizeActiveTableColumnWidths, normalizeImageDimension, normalizeImagePlacement, normalizeImageSources, normalizeLoomaChipColor, normalizeMentionResultLimit, normalizeTableOfContentsConfig, referenceDisplay, revealLoomaExpandAt, setActiveTableCellAlignment, setActiveTableCellBackground, setReferenceDisplay, shouldShowTextFormattingToolbar, siteRelativeHref };
@@ -0,0 +1,2 @@
1
+ /** Native HTML heading alignment shared by the editor schema and portable conversion. */
2
+ export declare function isHeadingAlignment(value: unknown): value is "left" | "center" | "right" | "justify";
package/editor/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as LOOMA_CALLOUT_TONES, c as imageSourceUrls, f as LoomaReference, g as setReferenceDisplay, h as referenceDisplay, l as mapImageSourceUrls, m as getReferenceDisplay, p as LoomaReferencePresentation, u as normalizeImageSources, w as __exportAll } from "./chunks/expressmark.js";
1
+ import { T as __exportAll, _ as setReferenceDisplay, c as imageSourceUrls, g as referenceDisplay, h as getReferenceDisplay, l as mapImageSourceUrls, m as LoomaReferencePresentation, p as LoomaReference, u as normalizeImageSources, v as LOOMA_CALLOUT_TONES } from "./chunks/expressmark.js";
2
2
  import { i as TABLE_CELL_BACKGROUND_PRESETS, n as resolveTableCellAt, r as TABLE_CELL_BACKGROUND_OPTIONS, t as measureTableOverlayGeometry } from "./chunks/table-overlay.js";
3
3
  import "./ui.js";
4
4
  import { $ as LoomaFootnote, A as createLoomaMentionExtension, B as createImageMedia, C as getActiveTableCellBackground, D as createSiteRelativeLinks, E as LoomaSmartPaste, F as LoomaImage, G as normalizeTableOfContentsConfig, H as LoomaTableOfContents, I as LoomaInlineImage, J as LoomaTabs, K as tableOfContentsTree, L as isLoomaImageName, M as MAX_MENTION_RESULT_LIMIT, N as filterLoomaMentionItems, O as siteRelativeHref, P as normalizeMentionResultLimit, Q as LOOMA_FOOTNOTE_LABEL, R as normalizeImageDimension, S as getActiveTableCellAlignment, T as setActiveTableCellBackground, U as getTableOfContentsEntries, V as imageDeliveryAttributes, W as navigateTableOfContents, X as LoomaLinkDefinition, Y as LoomaLineBlock, Z as LOOMA_FOOTNOTE_INSERTED, _ as getDefaultEditorExtensions, a as NO_TABLE_CAPABILITIES, at as revealLoomaExpandAt, b as LoomaTableCell, c as handleTableAction, ct as normalizeLoomaChipColor, d as normalizeActiveTableColumnWidths, dt as LOOMA_ACTIVE_BLOCK_CLASS, et as LoomaFootnoteReference, f as shouldShowTextFormattingToolbar, ft as LOOMA_ACTIVE_BLOCK_TYPING_IDLE_MS, g as LoomaTableKit, h as selectedTableElement, i as getDefaultSlashCommands, it as LoomaExpand, j as DEFAULT_MENTION_RESULT_LIMIT, k as LoomaMentionSuggestionPluginKey, l as handleTableOverlayAction, lt as LoomaCallout, m as selectedTableCellElement, mt as LoomaActiveBlockPluginKey, n as createLoomaSlashCommandExtension, nt as LoomaFigcaption, o as focusTableOverlayTarget, ot as LOOMA_CHIP_COLORS, p as menuAnchorRect, pt as LoomaActiveBlock, q as LoomaTab, r as filterLoomaSlashCommands, rt as LoomaFigure, s as getActiveTableUiState, st as LoomaChip, t as LoomaSlashCommand, tt as findLoomaFootnote, u as insertTableAtRange, ut as LOOMA_ACTIVE_BLOCK_BLUR_GRACE_MS, v as getLoomaTableExtensions, w as setActiveTableCellAlignment, x as LoomaTableHeader, y as LoomaTable, z as normalizeImagePlacement } from "./chunks/extensions.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threadlabs/looma",
3
- "version": "0.53.8",
3
+ "version": "0.53.9",
4
4
  "type": "module",
5
5
  "description": "HTML Next UI components, native DOM support and design tokens.",
6
6
  "license": "MIT",
@@ -99,7 +99,7 @@
99
99
  "@nextwebwg/html-next": ">=1.0.0-alpha.92",
100
100
  "@js-temporal/polyfill": "^0.5.1",
101
101
  "dompurify": "3.4.15",
102
- "expressmark": ">=0.6.1",
102
+ "expressmark": ">=0.6.4",
103
103
  "highlight.js": "11.11.2",
104
104
  "lowlight": "^3.3.0",
105
105
  "lucide": "~0.554.0",