@threadlabs/looma 0.53.12 → 0.53.13

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.12",
783
+ "version": "0.53.13",
784
784
  "groups": [
785
785
  {
786
786
  "id": "layout",
@@ -156,192 +156,6 @@ function splitLoomaFrontmatter(document) {
156
156
  };
157
157
  }
158
158
  //#endregion
159
- //#region src/editor/reference-display.ts
160
- var referenceDisplayKey = new PluginKey("loomaReferenceDisplay");
161
- var referenceDisplayMeta = "loomaReferenceDisplay";
162
- /**
163
- * Replaces presentation without editing the document or adding an undo/history entry.
164
- * @lifecycle Values last until the next replacement or editor destruction; hosts own persistence.
165
- */
166
- function setReferenceDisplay(editor, references) {
167
- if (editor.isDestroyed) return;
168
- editor.storage.loomaReferencePresentation?.enableMentions?.();
169
- editor.view.dispatch(editor.state.tr.setMeta(referenceDisplayMeta, references).setMeta("addToHistory", false));
170
- }
171
- /**
172
- * The current replaceable presentation; absent entries use the saved fallback.
173
- * @ownership The returned map belongs to the host; replace it rather than mutating it.
174
- */
175
- function getReferenceDisplay(editor) {
176
- return editor.storage.loomaReferencePresentation?.references ?? {};
177
- }
178
- /**
179
- * Reads current host presentation, with a durable insertion-time fallback for offline copies.
180
- * @failure Unsafe cached destinations fall back to the saved safe URL or no destination.
181
- */
182
- function referenceDisplay(node, references = {}) {
183
- const kind = node.type.name === "mention" ? "mention" : node.attrs.kind;
184
- const display = references[`${kind}:${node.attrs.id}`];
185
- const label = typeof display?.label === "string" ? display.label : typeof node.attrs.label === "string" ? node.attrs.label : String(node.attrs.id ?? "Reference");
186
- const href = typeof display?.href === "string" ? validLinkHref(display.href) : null;
187
- return {
188
- label,
189
- ...kind === "link" ? { href: href ?? (typeof node.attrs.href === "string" ? validLinkHref(node.attrs.href) : null) ?? void 0 } : {}
190
- };
191
- }
192
- /**
193
- * An automatically labelled link; custom wording remains an ordinary text link.
194
- * @contract Identity and insertion-time fallback stay in JSON; cached presentation stays outside it.
195
- */
196
- var LoomaReference = Node.create({
197
- name: "loomaReference",
198
- inline: true,
199
- group: "inline",
200
- atom: true,
201
- addAttributes: () => ({
202
- id: {
203
- default: null,
204
- renderHTML: () => ({})
205
- },
206
- kind: {
207
- default: "link",
208
- renderHTML: () => ({})
209
- },
210
- href: {
211
- default: null,
212
- renderHTML: () => ({})
213
- },
214
- label: {
215
- default: null,
216
- renderHTML: () => ({})
217
- },
218
- target: {
219
- default: "_self",
220
- renderHTML: () => ({})
221
- }
222
- }),
223
- parseHTML: () => [{
224
- tag: "a[data-looma-reference]",
225
- priority: 1001,
226
- getAttrs: (element) => ({
227
- id: element.getAttribute("data-looma-reference"),
228
- kind: "link",
229
- href: element.getAttribute("href"),
230
- label: element.textContent,
231
- target: element.getAttribute("target") ?? "_self"
232
- })
233
- }],
234
- renderHTML({ node, HTMLAttributes }) {
235
- const display = referenceDisplay(node, this.editor ? getReferenceDisplay(this.editor) : {});
236
- return [
237
- "a",
238
- mergeAttributes(HTMLAttributes, {
239
- "data-looma-reference": node.attrs.id,
240
- href: display.href,
241
- target: node.attrs.target === "_blank" ? "_blank" : "_self",
242
- rel: "noopener noreferrer"
243
- }),
244
- display.label
245
- ];
246
- },
247
- renderText({ node }) {
248
- return referenceDisplay(node, this.editor ? getReferenceDisplay(this.editor) : {}).label;
249
- }
250
- });
251
- /**
252
- * Installs metadata-backed node views for references and existing stable-id mentions.
253
- * @lifecycle Node views register until destroyed, including across editor reattachment.
254
- */
255
- var LoomaReferencePresentation = Extension.create({
256
- name: "loomaReferencePresentation",
257
- addOptions: () => ({
258
- references: {},
259
- mentions: false
260
- }),
261
- addStorage() {
262
- return { references: this.options.references };
263
- },
264
- addProseMirrorPlugins() {
265
- const initial = this.options.references;
266
- const refresh = /* @__PURE__ */ new Set();
267
- const nodeView = (node, view, getPosition) => {
268
- let current = node;
269
- const mention = node.type.name === "mention";
270
- const dom = document.createElement(mention ? "span" : "a");
271
- if (mention) {
272
- dom.className = "looma-mention";
273
- dom.setAttribute("data-type", "mention");
274
- } else dom.addEventListener("click", (event) => {
275
- if (!(event instanceof MouseEvent) || !view.editable || event.metaKey || event.ctrlKey) return;
276
- const position = getPosition();
277
- if (position === void 0) return;
278
- event.preventDefault();
279
- view.dispatch(view.state.tr.setSelection(NodeSelection.create(view.state.doc, position)));
280
- view.focus();
281
- });
282
- const render = () => {
283
- const display = referenceDisplay(current, referenceDisplayKey.getState(view.state));
284
- dom.textContent = `${mention ? "@" : ""}${display.label}`;
285
- if (mention) {
286
- dom.setAttribute("data-id", current.attrs.id ?? "");
287
- dom.setAttribute("data-label", display.label);
288
- }
289
- if (!mention) {
290
- dom.setAttribute("data-looma-reference", current.attrs.id ?? "");
291
- if (display.href) dom.setAttribute("href", display.href);
292
- else dom.removeAttribute("href");
293
- dom.setAttribute("target", current.attrs.target === "_blank" ? "_blank" : "_self");
294
- dom.setAttribute("rel", "noopener noreferrer");
295
- }
296
- };
297
- refresh.add(render);
298
- render();
299
- return {
300
- dom,
301
- update(next) {
302
- if (next.type !== current.type) return false;
303
- current = next;
304
- render();
305
- return true;
306
- },
307
- destroy: () => {
308
- refresh.delete(render);
309
- }
310
- };
311
- };
312
- const nodeViews = {
313
- loomaReference: nodeView,
314
- ...this.options.mentions && this.editor.schema.nodes.mention ? { mention: nodeView } : {}
315
- };
316
- this.storage.enableMentions = () => {
317
- if (nodeViews.mention || !this.editor.schema.nodes.mention) return;
318
- nodeViews.mention = nodeView;
319
- this.editor.view.setProps({ nodeViews: { ...this.editor.view.props.nodeViews } });
320
- };
321
- return [new Plugin({
322
- key: referenceDisplayKey,
323
- state: {
324
- init: () => initial,
325
- apply: (transaction, previous) => {
326
- const next = transaction.getMeta(referenceDisplayMeta) ?? previous;
327
- this.storage.references = next;
328
- return next;
329
- }
330
- },
331
- props: { nodeViews },
332
- view: () => ({ update: (view, previous) => {
333
- if (referenceDisplayKey.getState(view.state) !== referenceDisplayKey.getState(previous)) refresh.forEach((render) => render());
334
- } })
335
- })];
336
- }
337
- });
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
345
159
  //#region ../../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/decode-codepoint.js
346
160
  /**
347
161
  * True for NUL, UTF-16 surrogates, and values past U+10FFFF.
@@ -4106,6 +3920,330 @@ var init_dist = __esmMin((() => {
4106
3920
  parseFeedDefaultOptions = { xmlMode: true };
4107
3921
  }));
4108
3922
  //#endregion
3923
+ //#region src/editor/extensions/file-attachment.ts
3924
+ init_dist();
3925
+ /** Reject malformed metadata and active URL schemes before rendering a file action. */
3926
+ function fileAttachmentAttrs(value) {
3927
+ const { href, name, size, contentType } = value;
3928
+ if (typeof href !== "string" || !href || href !== href.trim() || /[\u0000-\u001f\u007f]/.test(href) || typeof name !== "string" || !name.trim() || !Number.isSafeInteger(size) || Number(size) < 0 || typeof contentType !== "string") throw new Error("Invalid file attachment");
3929
+ const url = new URL(href, "https://files.example.invalid/");
3930
+ if (!["https:", "http:"].includes(url.protocol) || url.username || url.password) throw new Error("Invalid file attachment URL");
3931
+ return {
3932
+ href,
3933
+ name,
3934
+ size: Number(size),
3935
+ contentType
3936
+ };
3937
+ }
3938
+ /** The same decimal byte units used by upload receipts. */
3939
+ function fileAttachmentSize(size) {
3940
+ if (size < 1e3) return `${size} B`;
3941
+ if (size < 1e6) return `${Number((size / 1e3).toFixed(1))} KB`;
3942
+ return `${Number((size / 1e6).toFixed(1))} MB`;
3943
+ }
3944
+ var escape$1 = (value) => String(value).replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
3945
+ /** Portable HTML keeps the original link, filename and byte count without editor chrome. */
3946
+ function fileAttachmentHtml(value) {
3947
+ const a = fileAttachmentAttrs(value);
3948
+ return `<div data-looma-file-attachment="" data-href="${escape$1(a.href)}" data-name="${escape$1(a.name)}" data-size="${a.size}" data-content-type="${escape$1(a.contentType)}"><a href="${escape$1(a.href)}" target="_blank" rel="noopener noreferrer">${escape$1(a.name)}</a> <span>${fileAttachmentSize(a.size)}</span></div>`;
3949
+ }
3950
+ /** Read only the complete authored attachment shape; refuse extra executable or lost content. */
3951
+ function readFileAttachmentHtml(html) {
3952
+ const roots = parseDocument(html).children.filter((n) => n.type !== "text" || n.data.trim());
3953
+ const root = roots[0];
3954
+ if (roots.length !== 1 || root?.type !== "tag" || root.name !== "div" || !Object.hasOwn(root.attribs, "data-looma-file-attachment")) return null;
3955
+ if (Object.keys(root.attribs).some((key) => ![
3956
+ "data-looma-file-attachment",
3957
+ "data-href",
3958
+ "data-name",
3959
+ "data-size",
3960
+ "data-content-type"
3961
+ ].includes(key))) throw new Error("Unsupported attachment attributes");
3962
+ const a = fileAttachmentAttrs({
3963
+ href: root.attribs["data-href"],
3964
+ name: root.attribs["data-name"],
3965
+ size: Number(root.attribs["data-size"]),
3966
+ contentType: root.attribs["data-content-type"]
3967
+ });
3968
+ let children = root.children.filter((n) => n.type !== "text" || n.data.trim());
3969
+ if (children.length === 1 && children[0]?.type === "tag" && children[0].name === "p" && !Object.keys(children[0].attribs).length) children = children[0].children.filter((n) => n.type !== "text" || n.data.trim());
3970
+ const [link, size] = children;
3971
+ const plain = (nodes) => nodes.map((n) => {
3972
+ if (n.type === "text") return n.data;
3973
+ if (n.type === "tag" && n.name === "p" && !Object.keys(n.attribs).length && n.children.every((c) => c.type === "text")) return n.children.map((c) => c.type === "text" ? c.data : "").join("");
3974
+ throw new Error("Unsupported attachment content");
3975
+ }).join("").replace(/^\n+|\n+$/g, "");
3976
+ if (children.length !== 2 || link?.type !== "tag" || link.name !== "a" || size?.type !== "tag" || size.name !== "span" || link.attribs.href !== a.href || Object.keys(link.attribs).some((key) => ![
3977
+ "href",
3978
+ "target",
3979
+ "rel"
3980
+ ].includes(key)) || Object.keys(size.attribs).length || plain(link.children) !== a.name || plain(size.children) !== fileAttachmentSize(a.size)) throw new Error("Unsupported attachment content");
3981
+ return a;
3982
+ }
3983
+ /** A movable, atomic file block. Its rich view composes the standard card action. */
3984
+ var LoomaFileAttachment = Node.create({
3985
+ name: "loomaFileAttachment",
3986
+ group: "block",
3987
+ atom: true,
3988
+ draggable: true,
3989
+ addAttributes() {
3990
+ return {
3991
+ href: { default: "" },
3992
+ name: { default: "" },
3993
+ size: { default: 0 },
3994
+ contentType: { default: "application/octet-stream" }
3995
+ };
3996
+ },
3997
+ parseHTML() {
3998
+ return [{
3999
+ tag: "div[data-looma-file-attachment]",
4000
+ getAttrs: (element) => {
4001
+ try {
4002
+ return fileAttachmentAttrs({
4003
+ href: element.getAttribute("data-href"),
4004
+ name: element.getAttribute("data-name"),
4005
+ size: Number(element.getAttribute("data-size")),
4006
+ contentType: element.getAttribute("data-content-type")
4007
+ });
4008
+ } catch {
4009
+ return false;
4010
+ }
4011
+ }
4012
+ }];
4013
+ },
4014
+ renderHTML({ node }) {
4015
+ let a;
4016
+ try {
4017
+ a = fileAttachmentAttrs(node.attrs);
4018
+ } catch {
4019
+ return [
4020
+ "div",
4021
+ {},
4022
+ "Unavailable attachment"
4023
+ ];
4024
+ }
4025
+ return [
4026
+ "div",
4027
+ {
4028
+ "data-looma-file-attachment": "",
4029
+ "data-href": a.href,
4030
+ "data-name": a.name,
4031
+ "data-size": a.size,
4032
+ "data-content-type": a.contentType
4033
+ },
4034
+ [
4035
+ "a",
4036
+ {
4037
+ href: a.href,
4038
+ target: "_blank",
4039
+ rel: "noopener noreferrer"
4040
+ },
4041
+ a.name
4042
+ ],
4043
+ " ",
4044
+ [
4045
+ "span",
4046
+ {},
4047
+ fileAttachmentSize(a.size)
4048
+ ]
4049
+ ];
4050
+ },
4051
+ renderText({ node }) {
4052
+ try {
4053
+ const a = fileAttachmentAttrs(node.attrs);
4054
+ return `${a.name} (${fileAttachmentSize(a.size)})`;
4055
+ } catch {
4056
+ return "Unavailable attachment";
4057
+ }
4058
+ }
4059
+ });
4060
+ //#endregion
4061
+ //#region src/editor/reference-display.ts
4062
+ var referenceDisplayKey = new PluginKey("loomaReferenceDisplay");
4063
+ var referenceDisplayMeta = "loomaReferenceDisplay";
4064
+ /**
4065
+ * Replaces presentation without editing the document or adding an undo/history entry.
4066
+ * @lifecycle Values last until the next replacement or editor destruction; hosts own persistence.
4067
+ */
4068
+ function setReferenceDisplay(editor, references) {
4069
+ if (editor.isDestroyed) return;
4070
+ editor.storage.loomaReferencePresentation?.enableMentions?.();
4071
+ editor.view.dispatch(editor.state.tr.setMeta(referenceDisplayMeta, references).setMeta("addToHistory", false));
4072
+ }
4073
+ /**
4074
+ * The current replaceable presentation; absent entries use the saved fallback.
4075
+ * @ownership The returned map belongs to the host; replace it rather than mutating it.
4076
+ */
4077
+ function getReferenceDisplay(editor) {
4078
+ return editor.storage.loomaReferencePresentation?.references ?? {};
4079
+ }
4080
+ /**
4081
+ * Reads current host presentation, with a durable insertion-time fallback for offline copies.
4082
+ * @failure Unsafe cached destinations fall back to the saved safe URL or no destination.
4083
+ */
4084
+ function referenceDisplay(node, references = {}) {
4085
+ const kind = node.type.name === "mention" ? "mention" : node.attrs.kind;
4086
+ const display = references[`${kind}:${node.attrs.id}`];
4087
+ const label = typeof display?.label === "string" ? display.label : typeof node.attrs.label === "string" ? node.attrs.label : String(node.attrs.id ?? "Reference");
4088
+ const href = typeof display?.href === "string" ? validLinkHref(display.href) : null;
4089
+ return {
4090
+ label,
4091
+ ...kind === "link" ? { href: href ?? (typeof node.attrs.href === "string" ? validLinkHref(node.attrs.href) : null) ?? void 0 } : {}
4092
+ };
4093
+ }
4094
+ /**
4095
+ * An automatically labelled link; custom wording remains an ordinary text link.
4096
+ * @contract Identity and insertion-time fallback stay in JSON; cached presentation stays outside it.
4097
+ */
4098
+ var LoomaReference = Node.create({
4099
+ name: "loomaReference",
4100
+ inline: true,
4101
+ group: "inline",
4102
+ atom: true,
4103
+ addAttributes: () => ({
4104
+ id: {
4105
+ default: null,
4106
+ renderHTML: () => ({})
4107
+ },
4108
+ kind: {
4109
+ default: "link",
4110
+ renderHTML: () => ({})
4111
+ },
4112
+ href: {
4113
+ default: null,
4114
+ renderHTML: () => ({})
4115
+ },
4116
+ label: {
4117
+ default: null,
4118
+ renderHTML: () => ({})
4119
+ },
4120
+ target: {
4121
+ default: "_self",
4122
+ renderHTML: () => ({})
4123
+ }
4124
+ }),
4125
+ parseHTML: () => [{
4126
+ tag: "a[data-looma-reference]",
4127
+ priority: 1001,
4128
+ getAttrs: (element) => ({
4129
+ id: element.getAttribute("data-looma-reference"),
4130
+ kind: "link",
4131
+ href: element.getAttribute("href"),
4132
+ label: element.textContent,
4133
+ target: element.getAttribute("target") ?? "_self"
4134
+ })
4135
+ }],
4136
+ renderHTML({ node, HTMLAttributes }) {
4137
+ const display = referenceDisplay(node, this.editor ? getReferenceDisplay(this.editor) : {});
4138
+ return [
4139
+ "a",
4140
+ mergeAttributes(HTMLAttributes, {
4141
+ "data-looma-reference": node.attrs.id,
4142
+ href: display.href,
4143
+ target: node.attrs.target === "_blank" ? "_blank" : "_self",
4144
+ rel: "noopener noreferrer"
4145
+ }),
4146
+ display.label
4147
+ ];
4148
+ },
4149
+ renderText({ node }) {
4150
+ return referenceDisplay(node, this.editor ? getReferenceDisplay(this.editor) : {}).label;
4151
+ }
4152
+ });
4153
+ /**
4154
+ * Installs metadata-backed node views for references and existing stable-id mentions.
4155
+ * @lifecycle Node views register until destroyed, including across editor reattachment.
4156
+ */
4157
+ var LoomaReferencePresentation = Extension.create({
4158
+ name: "loomaReferencePresentation",
4159
+ addOptions: () => ({
4160
+ references: {},
4161
+ mentions: false
4162
+ }),
4163
+ addStorage() {
4164
+ return { references: this.options.references };
4165
+ },
4166
+ addProseMirrorPlugins() {
4167
+ const initial = this.options.references;
4168
+ const refresh = /* @__PURE__ */ new Set();
4169
+ const nodeView = (node, view, getPosition) => {
4170
+ let current = node;
4171
+ const mention = node.type.name === "mention";
4172
+ const dom = document.createElement(mention ? "span" : "a");
4173
+ if (mention) {
4174
+ dom.className = "looma-mention";
4175
+ dom.setAttribute("data-type", "mention");
4176
+ } else dom.addEventListener("click", (event) => {
4177
+ if (!(event instanceof MouseEvent) || !view.editable || event.metaKey || event.ctrlKey) return;
4178
+ const position = getPosition();
4179
+ if (position === void 0) return;
4180
+ event.preventDefault();
4181
+ view.dispatch(view.state.tr.setSelection(NodeSelection.create(view.state.doc, position)));
4182
+ view.focus();
4183
+ });
4184
+ const render = () => {
4185
+ const display = referenceDisplay(current, referenceDisplayKey.getState(view.state));
4186
+ dom.textContent = `${mention ? "@" : ""}${display.label}`;
4187
+ if (mention) {
4188
+ dom.setAttribute("data-id", current.attrs.id ?? "");
4189
+ dom.setAttribute("data-label", display.label);
4190
+ }
4191
+ if (!mention) {
4192
+ dom.setAttribute("data-looma-reference", current.attrs.id ?? "");
4193
+ if (display.href) dom.setAttribute("href", display.href);
4194
+ else dom.removeAttribute("href");
4195
+ dom.setAttribute("target", current.attrs.target === "_blank" ? "_blank" : "_self");
4196
+ dom.setAttribute("rel", "noopener noreferrer");
4197
+ }
4198
+ };
4199
+ refresh.add(render);
4200
+ render();
4201
+ return {
4202
+ dom,
4203
+ update(next) {
4204
+ if (next.type !== current.type) return false;
4205
+ current = next;
4206
+ render();
4207
+ return true;
4208
+ },
4209
+ destroy: () => {
4210
+ refresh.delete(render);
4211
+ }
4212
+ };
4213
+ };
4214
+ const nodeViews = {
4215
+ loomaReference: nodeView,
4216
+ ...this.options.mentions && this.editor.schema.nodes.mention ? { mention: nodeView } : {}
4217
+ };
4218
+ this.storage.enableMentions = () => {
4219
+ if (nodeViews.mention || !this.editor.schema.nodes.mention) return;
4220
+ nodeViews.mention = nodeView;
4221
+ this.editor.view.setProps({ nodeViews: { ...this.editor.view.props.nodeViews } });
4222
+ };
4223
+ return [new Plugin({
4224
+ key: referenceDisplayKey,
4225
+ state: {
4226
+ init: () => initial,
4227
+ apply: (transaction, previous) => {
4228
+ const next = transaction.getMeta(referenceDisplayMeta) ?? previous;
4229
+ this.storage.references = next;
4230
+ return next;
4231
+ }
4232
+ },
4233
+ props: { nodeViews },
4234
+ view: () => ({ update: (view, previous) => {
4235
+ if (referenceDisplayKey.getState(view.state) !== referenceDisplayKey.getState(previous)) refresh.forEach((render) => render());
4236
+ } })
4237
+ })];
4238
+ }
4239
+ });
4240
+ //#endregion
4241
+ //#region src/editor/heading-alignment.ts
4242
+ /** Native HTML heading alignment shared by the editor schema and portable conversion. */
4243
+ function isHeadingAlignment(value) {
4244
+ return typeof value === "string" && /^(left|center|right|justify)$/.test(value);
4245
+ }
4246
+ //#endregion
4109
4247
  //#region ../../node_modules/.pnpm/parse-srcset@1.0.2/node_modules/parse-srcset/src/parse-srcset.js
4110
4248
  var require_parse_srcset = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4111
4249
  /**
@@ -4241,8 +4379,6 @@ var require_parse_srcset = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4241
4379
  }));
4242
4380
  //#endregion
4243
4381
  //#region ../../node_modules/.pnpm/parseman@0.56.0/node_modules/parseman/dist/index.js
4244
- init_dist();
4245
- var import_parse_srcset = /* @__PURE__ */ __toESM(require_parse_srcset(), 1);
4246
4382
  function union(a, b) {
4247
4383
  if (a.kind === "any" || b.kind === "any") return { kind: "any" };
4248
4384
  if (a.kind === "empty") return b;
@@ -9152,8 +9288,8 @@ var require_launder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9152
9288
  module.exports.naughtyHref = naughtyHref;
9153
9289
  }));
9154
9290
  //#endregion
9155
- //#region ../../node_modules/.pnpm/expressmark@0.6.4/node_modules/expressmark/dist/html.js
9156
- var import_sanitize_html = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
9291
+ //#region ../../node_modules/.pnpm/sanitize-html@2.18.1/node_modules/sanitize-html/index.js
9292
+ var require_sanitize_html = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9157
9293
  var htmlparser = (init_dist(), __toCommonJS(dist_exports));
9158
9294
  var escapeStringRegexp = require_escape_string_regexp();
9159
9295
  var { isPlainObject } = require_is_plain_object();
@@ -10175,7 +10311,11 @@ var import_sanitize_html = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
10175
10311
  };
10176
10312
  };
10177
10313
  };
10178
- })))(), 1);
10314
+ }));
10315
+ //#endregion
10316
+ //#region ../../node_modules/.pnpm/expressmark@0.6.4/node_modules/expressmark/dist/html.js
10317
+ init_dist();
10318
+ var import_sanitize_html = /* @__PURE__ */ __toESM(require_sanitize_html(), 1);
10179
10319
  var color = /^(?:#[\da-f]{3,8}|[a-z]+|rgba?\([\d.,% ]+\)|hsla?\([\d.,% ]+\))$/i;
10180
10320
  var size = /^(?:auto|0|\d+(?:\.\d+)?(?:px|em|rem|%|ch|vh|vw))$/;
10181
10321
  var policy = {
@@ -10994,6 +11134,7 @@ function renderHtml(document, options = {}) {
10994
11134
  //#endregion
10995
11135
  //#region src/editor/image-sources.ts
10996
11136
  init_dist();
11137
+ var import_parse_srcset = /* @__PURE__ */ __toESM(require_parse_srcset(), 1);
10997
11138
  var escape = (value) => String(value).replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
10998
11139
  var attributes = (value) => Object.entries(value).filter(([, value]) => value !== null && value !== void 0 && value !== false).map(([name, value]) => ` ${name}="${escape(value)}"`).join("");
10999
11140
  var safeUrl = (url) => {
@@ -11200,6 +11341,13 @@ var AST_FIELDS = {
11200
11341
  paragraph: [],
11201
11342
  lineBlock: [],
11202
11343
  html: ["display"],
11344
+ htmlElement: [
11345
+ "display",
11346
+ "tag",
11347
+ "open",
11348
+ "close"
11349
+ ],
11350
+ group: ["display", "tag"],
11203
11351
  heading: ["level"],
11204
11352
  break: [],
11205
11353
  softBreak: [],
@@ -11516,6 +11664,19 @@ function toBareNode(node, path, context) {
11516
11664
  };
11517
11665
  };
11518
11666
  switch (node.type) {
11667
+ case "loomaFileAttachment":
11668
+ fields(node, [
11669
+ "href",
11670
+ "name",
11671
+ "size",
11672
+ "contentType"
11673
+ ], path);
11674
+ safeNavigation(attrs.href, false, path);
11675
+ return {
11676
+ type: "html",
11677
+ display: "block",
11678
+ value: fileAttachmentHtml(attrs)
11679
+ };
11519
11680
  case "loomaReference": {
11520
11681
  fields(node, [
11521
11682
  "id",
@@ -12073,9 +12234,35 @@ function fromNode(node, path, context, marks = []) {
12073
12234
  case "lineBlock":
12074
12235
  check();
12075
12236
  return wrap("loomaLineBlock");
12237
+ case "group":
12238
+ case "htmlElement": {
12239
+ check(node.type === "group" ? [
12240
+ "dataLoomaFileAttachment",
12241
+ "dataHref",
12242
+ "dataName",
12243
+ "dataSize",
12244
+ "dataContentType"
12245
+ ] : []);
12246
+ if (node.display !== "block" || node.tag !== "div") return fail(path, "non-block attachment");
12247
+ const file = readFileAttachmentHtml(renderHtml({
12248
+ type: "document",
12249
+ version: 1,
12250
+ body: [node]
12251
+ }));
12252
+ if (file) return [{
12253
+ type: "loomaFileAttachment",
12254
+ attrs: { ...file }
12255
+ }];
12256
+ return fail(path, "HTML other than a supported attachment");
12257
+ }
12076
12258
  case "html":
12077
12259
  check();
12078
12260
  try {
12261
+ const file = readFileAttachmentHtml(node.value ?? "");
12262
+ if (file) return [{
12263
+ type: "loomaFileAttachment",
12264
+ attrs: { ...file }
12265
+ }];
12079
12266
  const image = readPictureHtml(node.value ?? "");
12080
12267
  if (image) return [{
12081
12268
  type: "image",
@@ -12559,4 +12746,4 @@ function markdownToEditorDocument(markdown, options = {}) {
12559
12746
  return expressmarkToEditorDocument(document);
12560
12747
  }
12561
12748
  //#endregion
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 };
12749
+ export { assignLoomaHeadingIds as C, splitLoomaFrontmatter as D, normalizeLoomaChipTone as E, __exportAll as O, LOOMA_CHIP_TONES as S, normalizeLoomaCalloutTone as T, setReferenceDisplay as _, expressmarkToEditorDocument as a, fileAttachmentSize 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, LoomaFileAttachment as v, loomaHeadingSlug as w, LOOMA_CALLOUT_TONES as x, fileAttachmentAttrs as y };
@@ -1,4 +1,4 @@
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";
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
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";
@@ -10432,7 +10432,7 @@ function getLoomaTableExtensions() {
10432
10432
  * the code and explicit language stay in the document schema.
10433
10433
  */
10434
10434
  function getDefaultEditorExtensions(options = {}) {
10435
- const { placeholder = "Type “/” for commands, or start writing…", linkOpenOnClick = false, linkBaseUrl, imageInline = false, imageNodeView, inlineImageNodeView, dividerNodeView, headingNodeView, mention = createLoomaMentionExtension(), disableHighlight = false, codeLanguages, codeLowlight, codeBlockNodeView, tableOfContentsNodeView, expandNodeView, calloutNodeView } = options;
10435
+ const { placeholder = "Type “/” for commands, or start writing…", linkOpenOnClick = false, linkBaseUrl, imageInline = false, imageNodeView, inlineImageNodeView, dividerNodeView, fileAttachmentNodeView, headingNodeView, mention = createLoomaMentionExtension(), disableHighlight = false, codeLanguages, codeLowlight, codeBlockNodeView, tableOfContentsNodeView, expandNodeView, calloutNodeView } = options;
10436
10436
  const image = LoomaImage.configure({ inline: imageInline });
10437
10437
  const codeBlock = LoomaCodeBlock.configure({ lowlight: codeLowlight ?? createLowlight(codeLanguages) });
10438
10438
  return [
@@ -10474,6 +10474,7 @@ function getDefaultEditorExtensions(options = {}) {
10474
10474
  LoomaFootnoteReference,
10475
10475
  LoomaFootnote,
10476
10476
  LoomaLinkDefinition,
10477
+ fileAttachmentNodeView ? LoomaFileAttachment.extend({ addNodeView: () => fileAttachmentNodeView }) : LoomaFileAttachment,
10477
10478
  dividerNodeView ? HorizontalRule.extend({ addNodeView: () => dividerNodeView }) : HorizontalRule,
10478
10479
  HardBreak,
10479
10480
  History,
@@ -111,7 +111,7 @@
111
111
  }
112
112
 
113
113
  /* An anchor keeps the boxed button look even when an app styles ordinary links. */
114
- :scope:where(:is([component~="ui-button"]:not(template), [data-component~="ui-button"]:not([component]))):is(a) {
114
+ :scope:where(:is([component~="ui-button"]:not(template), [data-component~="ui-button"]:not([component]))):is(a)[data-appearance][data-tone]:not([data-appearance="link"]) {
115
115
  text-decoration: none;
116
116
  }
117
117