@haklex/rich-editor 0.35.0 → 0.37.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.
Files changed (64) hide show
  1. package/dist/{AlertQuoteEditNode-CRMUWeGh.js → AlertQuoteEditNode-DUvNEyjw.js} +3 -3
  2. package/dist/{KaTeXRenderer-DLtnsRSv.js → KaTeXRenderer-DvxFML1l.js} +2 -1
  3. package/dist/LinkCardRenderer-BT8P5aJC.js +100 -0
  4. package/dist/{MermaidPlugin-V7sqQ-I0.js → MermaidPlugin-DgIAgFH8.js} +2 -2
  5. package/dist/{SubmitShortcutPlugin-CtG1tXDj.js → SubmitShortcutPlugin-DuKGB15Q.js} +286 -7
  6. package/dist/commands-entry.d.ts +1 -0
  7. package/dist/commands-entry.d.ts.map +1 -1
  8. package/dist/commands-entry.mjs +3 -3
  9. package/dist/components/CorePlugins.d.ts.map +1 -1
  10. package/dist/components/RichEditor.d.ts +1 -1
  11. package/dist/components/RichEditor.d.ts.map +1 -1
  12. package/dist/components/renderers/FileRenderer.d.ts +14 -0
  13. package/dist/components/renderers/FileRenderer.d.ts.map +1 -0
  14. package/dist/components/renderers/ImageRenderer.d.ts +3 -1
  15. package/dist/components/renderers/ImageRenderer.d.ts.map +1 -1
  16. package/dist/{config-DMoe8QNB.js → config-D8JJ7F11.js} +154 -8
  17. package/dist/config-edit.d.ts.map +1 -1
  18. package/dist/config.d.ts.map +1 -1
  19. package/dist/context/FileUploadContext.d.ts +8 -0
  20. package/dist/context/FileUploadContext.d.ts.map +1 -0
  21. package/dist/index.mjs +30 -26
  22. package/dist/{node-registry-SayN3e8q.js → node-registry-BFDycNE-.js} +5 -4
  23. package/dist/nodes/FileNode.d.ts +49 -0
  24. package/dist/nodes/FileNode.d.ts.map +1 -0
  25. package/dist/nodes/ImageNode.d.ts +14 -1
  26. package/dist/nodes/ImageNode.d.ts.map +1 -1
  27. package/dist/nodes/KaTeXInlineNode.d.ts.map +1 -1
  28. package/dist/nodes/MentionNode.d.ts.map +1 -1
  29. package/dist/nodes-entry.d.ts +4 -0
  30. package/dist/nodes-entry.d.ts.map +1 -1
  31. package/dist/nodes-entry.mjs +5 -5
  32. package/dist/plugins/FileUploadPlugin.d.ts +12 -0
  33. package/dist/plugins/FileUploadPlugin.d.ts.map +1 -0
  34. package/dist/plugins/InlineDndPlugin.d.ts +2 -0
  35. package/dist/plugins/InlineDndPlugin.d.ts.map +1 -0
  36. package/dist/plugins/file-upload-command.d.ts +3 -0
  37. package/dist/plugins/file-upload-command.d.ts.map +1 -0
  38. package/dist/plugins/file-upload-store.d.ts +11 -0
  39. package/dist/plugins/file-upload-store.d.ts.map +1 -0
  40. package/dist/plugins/image-upload.css.d.ts +1 -1
  41. package/dist/plugins/inline-dnd-shared.d.ts +4 -0
  42. package/dist/plugins/inline-dnd-shared.d.ts.map +1 -0
  43. package/dist/plugins/inline-dnd.css.d.ts +3 -0
  44. package/dist/plugins/inline-dnd.css.d.ts.map +1 -0
  45. package/dist/plugins-entry.d.ts +5 -0
  46. package/dist/plugins-entry.d.ts.map +1 -1
  47. package/dist/plugins-entry.mjs +5 -4
  48. package/dist/renderers-entry.d.ts +3 -1
  49. package/dist/renderers-entry.d.ts.map +1 -1
  50. package/dist/renderers-entry.mjs +3 -3
  51. package/dist/rich-editor.css +1 -1
  52. package/dist/static-entry.mjs +3 -3
  53. package/dist/styles/shared.css.d.ts.map +1 -1
  54. package/dist/{theme-C7HnCTta.js → theme-Vu_9D3oG.js} +238 -24
  55. package/dist/types/renderer-config.d.ts +3 -0
  56. package/dist/types/renderer-config.d.ts.map +1 -1
  57. package/dist/types/renderer-keys.d.ts +1 -0
  58. package/dist/types/renderer-keys.d.ts.map +1 -1
  59. package/dist/types.d.ts +5 -0
  60. package/dist/types.d.ts.map +1 -1
  61. package/dist/utils/image-display-size.d.ts +38 -0
  62. package/dist/utils/image-display-size.d.ts.map +1 -0
  63. package/package.json +9 -9
  64. package/dist/LinkCardRenderer-DPV1JP0X.js +0 -45
@@ -1,11 +1,19 @@
1
- import { C as MENTION_NODE_KEY, b as IMAGE_NODE_KEY, h as ALERT_NODE_KEY, i as FootnoteStaticRenderer, l as RendererWrapper, r as decodeThumbHash, t as KaTeXRenderer, u as createRendererDecoration, v as FOOTNOTE_NODE_KEY, w as MERMAID_NODE_KEY, x as KATEX_NODE_KEY } from "./KaTeXRenderer-DLtnsRSv.js";
2
1
  import { l as semanticClassNames, u as sharedStyles } from "./katex.css-0TJGE4On.js";
2
+ import { S as KATEX_NODE_KEY, T as MERMAID_NODE_KEY, h as ALERT_NODE_KEY, i as FootnoteStaticRenderer, l as RendererWrapper, r as decodeThumbHash, t as KaTeXRenderer, u as createRendererDecoration, w as MENTION_NODE_KEY, x as IMAGE_NODE_KEY, y as FOOTNOTE_NODE_KEY } from "./KaTeXRenderer-DvxFML1l.js";
3
3
  import { createContext, createElement, use, useCallback, useEffect, useMemo, useState } from "react";
4
4
  import { QuoteNode } from "@lexical/rich-text";
5
5
  import { $getEditor, $getNodeByKey, $getSelection, $insertNodes, $isNodeSelection, $isRangeSelection, DecoratorNode, ElementNode, TextNode, createCommand, getRegisteredNode } from "lexical";
6
- import { $getTableCellNodeFromLexicalNode } from "@lexical/table";
7
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ import { $getTableCellNodeFromLexicalNode } from "@lexical/table";
8
8
  import { ImageIcon, Info, Lightbulb, MessageSquareWarning, OctagonAlert, Sigma, Tag, TriangleAlert, Workflow } from "lucide-react";
9
+ //#region src/plugins/inline-dnd-shared.ts
10
+ var INLINE_DRAG_ATTR = "data-inline-drag";
11
+ var INLINE_DRAG_MIME = "application/x-haklex-inline-node";
12
+ function markInlineDraggable(el, nodeKey) {
13
+ el.draggable = true;
14
+ el.setAttribute(INLINE_DRAG_ATTR, nodeKey);
15
+ }
16
+ //#endregion
9
17
  //#region src/context/NestedContentRendererContext.tsx
10
18
  var NestedContentRendererContext = createContext(null);
11
19
  var NestedContentRendererProvider = NestedContentRendererContext.Provider;
@@ -69,7 +77,7 @@ function extractTextContent(state) {
69
77
  return walk(state);
70
78
  }
71
79
  //#endregion
72
- //#region \0@oxc-project+runtime@0.142.0/helpers/esm/typeof.js
80
+ //#region \0@oxc-project+runtime@0.146.0/helpers/esm/typeof.js
73
81
  function _typeof(o) {
74
82
  "@babel/helpers - typeof";
75
83
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -79,7 +87,7 @@ function _typeof(o) {
79
87
  }, _typeof(o);
80
88
  }
81
89
  //#endregion
82
- //#region \0@oxc-project+runtime@0.142.0/helpers/esm/toPrimitive.js
90
+ //#region \0@oxc-project+runtime@0.146.0/helpers/esm/toPrimitive.js
83
91
  function toPrimitive(t, r) {
84
92
  if ("object" != _typeof(t) || !t) return t;
85
93
  var e = t[Symbol.toPrimitive];
@@ -91,13 +99,13 @@ function toPrimitive(t, r) {
91
99
  return ("string" === r ? String : Number)(t);
92
100
  }
93
101
  //#endregion
94
- //#region \0@oxc-project+runtime@0.142.0/helpers/esm/toPropertyKey.js
102
+ //#region \0@oxc-project+runtime@0.146.0/helpers/esm/toPropertyKey.js
95
103
  function toPropertyKey(t) {
96
104
  var i = toPrimitive(t, "string");
97
105
  return "symbol" == _typeof(i) ? i : i + "";
98
106
  }
99
107
  //#endregion
100
- //#region \0@oxc-project+runtime@0.142.0/helpers/esm/defineProperty.js
108
+ //#region \0@oxc-project+runtime@0.146.0/helpers/esm/defineProperty.js
101
109
  function _defineProperty(e, r, t) {
102
110
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
103
111
  value: t,
@@ -205,6 +213,9 @@ function $isAlertQuoteNode(node) {
205
213
  return node instanceof AlertQuoteNode;
206
214
  }
207
215
  //#endregion
216
+ //#region src/plugins/file-upload-command.ts
217
+ var OPEN_FILE_PICKER_COMMAND = createCommand("OPEN_FILE_PICKER_COMMAND");
218
+ //#endregion
208
219
  //#region src/nodes/FootnoteNode.ts
209
220
  var FootnoteNode = class FootnoteNode extends DecoratorNode {
210
221
  static getType() {
@@ -255,8 +266,131 @@ function $createFootnoteNode(identifier) {
255
266
  return new FootnoteNode(identifier);
256
267
  }
257
268
  //#endregion
269
+ //#region src/utils/image-display-size.ts
270
+ function sanitizeImageDisplayWidth(value) {
271
+ if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
272
+ return Math.round(Math.min(100, Math.max(10, value)));
273
+ }
274
+ function sanitizeImageFixedPx(value) {
275
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) return void 0;
276
+ return Math.round(value);
277
+ }
278
+ function resolveImageDisplaySize(fields) {
279
+ const displayWidth = sanitizeImageDisplayWidth(fields.displayWidth);
280
+ if (displayWidth !== void 0) return {
281
+ mode: "percent",
282
+ value: displayWidth
283
+ };
284
+ const fixedWidth = sanitizeImageFixedPx(fields.fixedWidth);
285
+ if (fixedWidth !== void 0) return {
286
+ mode: "fixed-width",
287
+ px: fixedWidth
288
+ };
289
+ const fixedHeight = sanitizeImageFixedPx(fields.fixedHeight);
290
+ if (fixedHeight !== void 0) return {
291
+ mode: "fixed-height",
292
+ px: fixedHeight
293
+ };
294
+ return { mode: "auto" };
295
+ }
296
+ function imageDisplayFieldsFromSize(size) {
297
+ switch (size.mode) {
298
+ case "percent": return { displayWidth: size.value };
299
+ case "fixed-width": return { fixedWidth: size.px };
300
+ case "fixed-height": return { fixedHeight: size.px };
301
+ default: return {};
302
+ }
303
+ }
304
+ function aspectRatio(ctx) {
305
+ const width = ctx.intrinsicWidth;
306
+ const height = ctx.intrinsicHeight;
307
+ if (!width || !height || width <= 0 || height <= 0) return void 0;
308
+ return width / height;
309
+ }
310
+ function computedWidthPx(size, ctx) {
311
+ switch (size.mode) {
312
+ case "percent": return ctx.containerWidth > 0 ? ctx.containerWidth * size.value / 100 : void 0;
313
+ case "fixed-width": return size.px;
314
+ case "fixed-height": {
315
+ const ratio = aspectRatio(ctx);
316
+ return ratio ? size.px * ratio : void 0;
317
+ }
318
+ case "auto": return ctx.intrinsicWidth;
319
+ }
320
+ }
321
+ function computedHeightPx(size, ctx) {
322
+ if (size.mode === "fixed-height") return size.px;
323
+ const widthPx = computedWidthPx(size, ctx);
324
+ const ratio = aspectRatio(ctx);
325
+ if (!widthPx || !ratio) return void 0;
326
+ return widthPx / ratio;
327
+ }
328
+ function computeImageDisplayPixels(size, ctx) {
329
+ const useRendered = size.mode === "auto";
330
+ return {
331
+ widthPx: sanitizeImageFixedPx(useRendered ? ctx.renderedWidth ?? computedWidthPx(size, ctx) : computedWidthPx(size, ctx)),
332
+ heightPx: sanitizeImageFixedPx(useRendered ? ctx.renderedHeight ?? computedHeightPx(size, ctx) : computedHeightPx(size, ctx))
333
+ };
334
+ }
335
+ function convertImageDisplaySize(from, to, ctx) {
336
+ if (to === "auto") return { mode: "auto" };
337
+ if (from.mode === to) return from;
338
+ const pixels = computeImageDisplayPixels(from, ctx);
339
+ if (to === "percent") {
340
+ if (!pixels.widthPx || ctx.containerWidth <= 0) return from;
341
+ const value = sanitizeImageDisplayWidth(pixels.widthPx / ctx.containerWidth * 100);
342
+ return value === void 0 ? from : {
343
+ mode: "percent",
344
+ value
345
+ };
346
+ }
347
+ if (to === "fixed-width") {
348
+ const px = sanitizeImageFixedPx(pixels.widthPx);
349
+ return px === void 0 ? from : {
350
+ mode: "fixed-width",
351
+ px
352
+ };
353
+ }
354
+ const px = sanitizeImageFixedPx(pixels.heightPx);
355
+ return px === void 0 ? from : {
356
+ mode: "fixed-height",
357
+ px
358
+ };
359
+ }
360
+ function imageDisplayCssVars(size) {
361
+ switch (size.mode) {
362
+ case "percent": return { "--rich-image-display-width": `${size.value}%` };
363
+ case "fixed-width": return { "--rich-image-display-width": `${size.px}px` };
364
+ case "fixed-height": return { "--rich-image-display-height": `${size.px}px` };
365
+ default: return;
366
+ }
367
+ }
368
+ function imageDisplayDataAttr(size) {
369
+ return size.mode === "auto" ? void 0 : size.mode;
370
+ }
371
+ function imageDisplaySizeAfterResize(mode, nextWidth, nextHeight, containerWidth) {
372
+ if (mode === "fixed-width") {
373
+ const px = sanitizeImageFixedPx(nextWidth);
374
+ return px === void 0 ? { mode: "auto" } : {
375
+ mode: "fixed-width",
376
+ px
377
+ };
378
+ }
379
+ if (mode === "fixed-height") {
380
+ const px = sanitizeImageFixedPx(nextHeight);
381
+ return px === void 0 ? { mode: "auto" } : {
382
+ mode: "fixed-height",
383
+ px
384
+ };
385
+ }
386
+ return {
387
+ mode: "percent",
388
+ value: sanitizeImageDisplayWidth(nextWidth / containerWidth * 100) ?? 100
389
+ };
390
+ }
391
+ //#endregion
258
392
  //#region src/components/renderers/ImageRenderer.tsx
259
- function ImageRenderer({ src, altText, width, height, caption, thumbhash, accent, displayWidth, layout }) {
393
+ function ImageRenderer({ src, altText, width, height, caption, thumbhash, accent, displayWidth, fixedWidth, fixedHeight, layout }) {
260
394
  const [loaded, setLoaded] = useState(false);
261
395
  const [zoomed, setZoomed] = useState(false);
262
396
  const handleLoad = useCallback(() => setLoaded(true), []);
@@ -288,14 +422,22 @@ function ImageRenderer({ src, altText, width, height, caption, thumbhash, accent
288
422
  }
289
423
  }, [loaded]);
290
424
  const placeholderUrl = useMemo(() => thumbhash ? decodeThumbHash(thumbhash) : void 0, [thumbhash]);
425
+ const displaySize = resolveImageDisplaySize({
426
+ displayWidth,
427
+ fixedWidth,
428
+ fixedHeight
429
+ });
430
+ const fillsFigure = displaySize.mode === "percent" || displaySize.mode === "fixed-width";
291
431
  const aspectStyle = {
292
432
  ...width && height ? { aspectRatio: `${width} / ${height}` } : {},
293
433
  maxWidth: "100%",
294
- width: displayWidth !== void 0 ? "100%" : width && height ? width : void 0
434
+ maxHeight: displaySize.mode === "fixed-height" ? `${displaySize.px}px` : void 0,
435
+ width: fillsFigure ? "100%" : width && height ? width : void 0
295
436
  };
296
- const figureStyle = displayWidth ? { "--rich-image-display-width": `${displayWidth}%` } : void 0;
437
+ const figureStyle = imageDisplayCssVars(displaySize);
297
438
  return /* @__PURE__ */ jsxs("figure", {
298
439
  className: "rich-image",
440
+ "data-display": imageDisplayDataAttr(displaySize),
299
441
  "data-layout": layout,
300
442
  style: figureStyle,
301
443
  children: [
@@ -319,11 +461,16 @@ function ImageRenderer({ src, altText, width, height, caption, thumbhash, accent
319
461
  height,
320
462
  loading: "lazy",
321
463
  src,
322
- style: {
464
+ width,
465
+ style: displaySize.mode === "fixed-height" ? {
466
+ width: "auto",
467
+ height: "auto",
468
+ maxWidth: "100%",
469
+ maxHeight: "100%"
470
+ } : {
323
471
  maxWidth: "100%",
324
472
  height: "auto"
325
473
  },
326
- width,
327
474
  onLoad: handleLoad
328
475
  })
329
476
  }),
@@ -383,10 +530,6 @@ function sanitizeColor(value) {
383
530
  if (/^(?:rgb|hsl)a?\([^)]+\)$/i.test(trimmed)) return trimmed;
384
531
  if (/^[a-z]{3,20}$/i.test(trimmed)) return trimmed;
385
532
  }
386
- function sanitizeImageDisplayWidth(value) {
387
- if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
388
- return Math.round(Math.min(100, Math.max(10, value)));
389
- }
390
533
  var IMAGE_LAYOUTS = [
391
534
  "align-left",
392
535
  "align-right",
@@ -396,11 +539,29 @@ var IMAGE_LAYOUTS = [
396
539
  function sanitizeImageLayout(value) {
397
540
  return IMAGE_LAYOUTS.includes(value) ? value : void 0;
398
541
  }
399
- function applyLayoutToDOM(dom, layout, displayWidth) {
542
+ function applyLayoutToDOM(dom, layout, size) {
400
543
  if (layout) dom.dataset.layout = layout;
401
544
  else delete dom.dataset.layout;
545
+ if (size.mode === "auto") delete dom.dataset.display;
546
+ else dom.dataset.display = size.mode;
402
547
  const isFloat = layout === "float-left" || layout === "float-right";
403
- dom.style.width = isFloat && displayWidth !== void 0 ? `${displayWidth}%` : "";
548
+ if (isFloat && size.mode === "percent") {
549
+ dom.style.width = `${size.value}%`;
550
+ dom.style.maxWidth = "";
551
+ return;
552
+ }
553
+ if (isFloat && size.mode === "fixed-width") {
554
+ dom.style.width = `${size.px}px`;
555
+ dom.style.maxWidth = "100%";
556
+ return;
557
+ }
558
+ if (isFloat && size.mode === "fixed-height") {
559
+ dom.style.width = "auto";
560
+ dom.style.maxWidth = "100%";
561
+ return;
562
+ }
563
+ dom.style.width = "";
564
+ dom.style.maxWidth = "";
404
565
  }
405
566
  var ImageNode = class ImageNode extends DecoratorNode {
406
567
  static getType() {
@@ -416,6 +577,8 @@ var ImageNode = class ImageNode extends DecoratorNode {
416
577
  thumbhash: node.__thumbhash,
417
578
  accent: node.__accent,
418
579
  displayWidth: node.__displayWidth,
580
+ fixedWidth: node.__fixedWidth,
581
+ fixedHeight: node.__fixedHeight,
419
582
  layout: node.__layout
420
583
  }, node.__key);
421
584
  }
@@ -429,6 +592,8 @@ var ImageNode = class ImageNode extends DecoratorNode {
429
592
  _defineProperty(this, "__thumbhash", void 0);
430
593
  _defineProperty(this, "__accent", void 0);
431
594
  _defineProperty(this, "__displayWidth", void 0);
595
+ _defineProperty(this, "__fixedHeight", void 0);
596
+ _defineProperty(this, "__fixedWidth", void 0);
432
597
  _defineProperty(this, "__layout", void 0);
433
598
  this.__src = sanitizeImageSrc(payload.src);
434
599
  this.__altText = payload.altText;
@@ -437,17 +602,20 @@ var ImageNode = class ImageNode extends DecoratorNode {
437
602
  this.__caption = payload.caption;
438
603
  this.__thumbhash = payload.thumbhash;
439
604
  this.__accent = sanitizeColor(payload.accent);
440
- this.__displayWidth = sanitizeImageDisplayWidth(payload.displayWidth);
605
+ const display = imageDisplayFieldsFromSize(resolveImageDisplaySize(payload));
606
+ this.__displayWidth = display.displayWidth;
607
+ this.__fixedWidth = display.fixedWidth;
608
+ this.__fixedHeight = display.fixedHeight;
441
609
  this.__layout = sanitizeImageLayout(payload.layout);
442
610
  }
443
611
  createDOM(_config) {
444
612
  const div = document.createElement("div");
445
613
  div.className = "rich-image-wrapper";
446
- applyLayoutToDOM(div, this.__layout, this.__displayWidth);
614
+ applyLayoutToDOM(div, this.__layout, this.getDisplaySize());
447
615
  return div;
448
616
  }
449
617
  updateDOM(prevNode, dom) {
450
- if (prevNode.__layout !== this.__layout || prevNode.__displayWidth !== this.__displayWidth) applyLayoutToDOM(dom, this.__layout, this.__displayWidth);
618
+ if (prevNode.__layout !== this.__layout || prevNode.__displayWidth !== this.__displayWidth || prevNode.__fixedWidth !== this.__fixedWidth || prevNode.__fixedHeight !== this.__fixedHeight) applyLayoutToDOM(dom, this.__layout, this.getDisplaySize());
451
619
  return false;
452
620
  }
453
621
  isInline() {
@@ -464,6 +632,8 @@ var ImageNode = class ImageNode extends DecoratorNode {
464
632
  thumbhash: serializedNode.thumbhash,
465
633
  accent: serializedNode.accent,
466
634
  displayWidth: serializedNode.displayWidth,
635
+ fixedWidth: serializedNode.fixedWidth,
636
+ fixedHeight: serializedNode.fixedHeight,
467
637
  layout: serializedNode.layout
468
638
  });
469
639
  }
@@ -479,6 +649,8 @@ var ImageNode = class ImageNode extends DecoratorNode {
479
649
  thumbhash: this.__thumbhash,
480
650
  accent: this.__accent,
481
651
  displayWidth: this.__displayWidth,
652
+ fixedWidth: this.__fixedWidth,
653
+ fixedHeight: this.__fixedHeight,
482
654
  layout: this.__layout,
483
655
  version: 1
484
656
  };
@@ -508,9 +680,33 @@ var ImageNode = class ImageNode extends DecoratorNode {
508
680
  const writable = this.getWritable();
509
681
  writable.__accent = sanitizeColor(accent);
510
682
  }
511
- setDisplayWidth(width) {
683
+ applyDisplaySize(size) {
512
684
  const writable = this.getWritable();
513
- writable.__displayWidth = sanitizeImageDisplayWidth(width);
685
+ const fields = imageDisplayFieldsFromSize(size);
686
+ writable.__displayWidth = fields.displayWidth;
687
+ writable.__fixedWidth = fields.fixedWidth;
688
+ writable.__fixedHeight = fields.fixedHeight;
689
+ }
690
+ setDisplayWidth(width) {
691
+ const value = sanitizeImageDisplayWidth(width);
692
+ this.applyDisplaySize(value === void 0 ? { mode: "auto" } : {
693
+ mode: "percent",
694
+ value
695
+ });
696
+ }
697
+ setFixedWidth(width) {
698
+ const px = sanitizeImageFixedPx(width);
699
+ this.applyDisplaySize(px === void 0 ? { mode: "auto" } : {
700
+ mode: "fixed-width",
701
+ px
702
+ });
703
+ }
704
+ setFixedHeight(height) {
705
+ const px = sanitizeImageFixedPx(height);
706
+ this.applyDisplaySize(px === void 0 ? { mode: "auto" } : {
707
+ mode: "fixed-height",
708
+ px
709
+ });
514
710
  }
515
711
  setLayout(layout) {
516
712
  const writable = this.getWritable();
@@ -540,6 +736,19 @@ var ImageNode = class ImageNode extends DecoratorNode {
540
736
  getDisplayWidth() {
541
737
  return this.__displayWidth;
542
738
  }
739
+ getFixedWidth() {
740
+ return this.__fixedWidth;
741
+ }
742
+ getFixedHeight() {
743
+ return this.__fixedHeight;
744
+ }
745
+ getDisplaySize() {
746
+ return resolveImageDisplaySize({
747
+ displayWidth: this.__displayWidth,
748
+ fixedWidth: this.__fixedWidth,
749
+ fixedHeight: this.__fixedHeight
750
+ });
751
+ }
543
752
  getLayout() {
544
753
  return this.__layout;
545
754
  }
@@ -553,6 +762,8 @@ var ImageNode = class ImageNode extends DecoratorNode {
553
762
  thumbhash: this.__thumbhash,
554
763
  accent: this.__accent,
555
764
  displayWidth: this.__displayWidth,
765
+ fixedWidth: this.__fixedWidth,
766
+ fixedHeight: this.__fixedHeight,
556
767
  layout: this.__layout
557
768
  });
558
769
  }
@@ -709,7 +920,9 @@ var KaTeXInlineNode = class KaTeXInlineNode extends DecoratorNode {
709
920
  this.__color = color;
710
921
  }
711
922
  createDOM(_config) {
712
- return document.createElement("span");
923
+ const el = document.createElement("span");
924
+ markInlineDraggable(el, this.getKey());
925
+ return el;
713
926
  }
714
927
  updateDOM() {
715
928
  return false;
@@ -805,6 +1018,7 @@ var MentionNode = class MentionNode extends DecoratorNode {
805
1018
  el.style.display = "inline-flex";
806
1019
  el.style.alignItems = "center";
807
1020
  el.style.height = "1lh";
1021
+ markInlineDraggable(el, this.getKey());
808
1022
  return el;
809
1023
  }
810
1024
  updateDOM() {
@@ -1219,4 +1433,4 @@ var editorTheme = {
1219
1433
  hr: shared("hr")
1220
1434
  };
1221
1435
  //#endregion
1222
- export { OPEN_IMAGE_UPLOAD_DIALOG_COMMAND as A, NestedContentRendererProvider as B, KaTeXBlockNode as C, sanitizeImageDisplayWidth as D, ImageNode as E, ALERT_TYPES as F, useOptionalNestedContentRenderer as H, AlertQuoteNode as I, _defineProperty as L, FootnoteNode as M, $isAlertQuoteNode as N, sanitizeImageLayout as O, ALERT_LABELS as P, extractTextContent as R, $isKaTeXBlockNode as S, $isImageNode as T, useNestedContentRenderer as V, MentionNode as _, getTagBgColor as a, KaTeXInlineNode as b, SpoilerNode as c, RichQuoteNode as d, $createMermaidNode as f, $isMentionNode as g, $createMentionNode as h, TagNode as i, $createFootnoteNode as j, $withAdaptiveImageDisplayWidth as k, $createRichQuoteNode as l, MermaidNode as m, $createTagNode as n, $createSpoilerNode as o, $isMermaidNode as p, $isTagNode as r, $isSpoilerNode as s, editorTheme as t, $isRichQuoteNode as u, $createKaTeXInlineNode as v, $createImageNode as w, $createKaTeXBlockNode as x, $isKaTeXInlineNode as y, AlertRenderer as z };
1436
+ export { INLINE_DRAG_MIME as $, computeImageDisplayPixels as A, FootnoteNode as B, KaTeXBlockNode as C, sanitizeImageLayout as D, ImageNode as E, imageDisplaySizeAfterResize as F, AlertQuoteNode as G, $isAlertQuoteNode as H, resolveImageDisplaySize as I, AlertRenderer as J, _defineProperty as K, sanitizeImageDisplayWidth as L, imageDisplayCssVars as M, imageDisplayDataAttr as N, $withAdaptiveImageDisplayWidth as O, imageDisplayFieldsFromSize as P, INLINE_DRAG_ATTR as Q, sanitizeImageFixedPx as R, $isKaTeXBlockNode as S, $isImageNode as T, ALERT_LABELS as U, OPEN_FILE_PICKER_COMMAND as V, ALERT_TYPES as W, useNestedContentRenderer as X, NestedContentRendererProvider as Y, useOptionalNestedContentRenderer as Z, MentionNode as _, getTagBgColor as a, KaTeXInlineNode as b, SpoilerNode as c, RichQuoteNode as d, markInlineDraggable as et, $createMermaidNode as f, $isMentionNode as g, $createMentionNode as h, TagNode as i, convertImageDisplaySize as j, OPEN_IMAGE_UPLOAD_DIALOG_COMMAND as k, $createRichQuoteNode as l, MermaidNode as m, $createTagNode as n, $createSpoilerNode as o, $isMermaidNode as p, extractTextContent as q, $isTagNode as r, $isSpoilerNode as s, editorTheme as t, $isRichQuoteNode as u, $createKaTeXInlineNode as v, $createImageNode as w, $createKaTeXBlockNode as x, $isKaTeXInlineNode as y, $createFootnoteNode as z };
@@ -2,6 +2,7 @@ import { ComponentType } from 'react';
2
2
  import { AlertRendererProps } from '../components/renderers/AlertRenderer';
3
3
  import { BannerRendererProps } from '../components/renderers/BannerRenderer';
4
4
  import { CodeBlockRendererProps } from '../components/renderers/CodeBlockRenderer';
5
+ import { FileRendererProps } from '../components/renderers/FileRenderer';
5
6
  import { FootnoteRendererProps } from '../components/renderers/FootnoteRenderer';
6
7
  import { FootnoteSectionRendererProps } from '../components/renderers/FootnoteSectionRenderer';
7
8
  import { ImageRendererProps } from '../components/renderers/ImageRenderer';
@@ -50,6 +51,8 @@ export interface RendererConfig {
50
51
  Banner?: ComponentType<BannerRendererProps>;
51
52
  /** Custom renderer for code blocks with syntax highlighting */
52
53
  CodeBlock?: ComponentType<CodeBlockRendererProps>;
54
+ /** Custom renderer for file attachments */
55
+ File?: ComponentType<FileRendererProps>;
53
56
  /** Custom renderer for footnote references */
54
57
  Footnote?: ComponentType<FootnoteRendererProps>;
55
58
  /** Custom renderer for footnote definition section */
@@ -1 +1 @@
1
- {"version":3,"file":"renderer-config.d.ts","sourceRoot":"","sources":["../../src/types/renderer-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AACxF,OAAO,K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ALERT_NODE_KEY: "Alert";
14
14
  export declare const BANNER_NODE_KEY: "Banner";
15
15
  export declare const CODE_BLOCK_NODE_KEY: "CodeBlock";
16
+ export declare const FILE_NODE_KEY: "File";
16
17
  export declare const FOOTNOTE_NODE_KEY: "Footnote";
17
18
  export declare const FOOTNOTE_SECTION_NODE_KEY: "FootnoteSection";
18
19
  export declare const IMAGE_NODE_KEY: "Image";
@@ -1 +1 @@
1
- {"version":3,"file":"renderer-keys.d.ts","sourceRoot":"","sources":["../../src/types/renderer-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,EAAG,OAAgB,CAAC;AAC/C,eAAO,MAAM,eAAe,EAAG,QAAiB,CAAC;AACjD,eAAO,MAAM,mBAAmB,EAAG,WAAoB,CAAC;AACxD,eAAO,MAAM,iBAAiB,EAAG,UAAmB,CAAC;AACrD,eAAO,MAAM,yBAAyB,EAAG,iBAA0B,CAAC;AACpE,eAAO,MAAM,cAAc,EAAG,OAAgB,CAAC;AAC/C,eAAO,MAAM,cAAc,EAAG,OAAgB,CAAC;AAC/C,eAAO,MAAM,kBAAkB,EAAG,UAAmB,CAAC;AACtD,eAAO,MAAM,gBAAgB,EAAG,SAAkB,CAAC;AACnD,eAAO,MAAM,gBAAgB,EAAG,SAAkB,CAAC;AACnD,eAAO,MAAM,aAAa,EAAG,MAAe,CAAC;AAC7C,eAAO,MAAM,YAAY,EAAG,KAAc,CAAC;AAC3C,eAAO,MAAM,cAAc,EAAG,OAAgB,CAAC"}
1
+ {"version":3,"file":"renderer-keys.d.ts","sourceRoot":"","sources":["../../src/types/renderer-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,EAAG,OAAgB,CAAC;AAC/C,eAAO,MAAM,eAAe,EAAG,QAAiB,CAAC;AACjD,eAAO,MAAM,mBAAmB,EAAG,WAAoB,CAAC;AACxD,eAAO,MAAM,aAAa,EAAG,MAAe,CAAC;AAC7C,eAAO,MAAM,iBAAiB,EAAG,UAAmB,CAAC;AACrD,eAAO,MAAM,yBAAyB,EAAG,iBAA0B,CAAC;AACpE,eAAO,MAAM,cAAc,EAAG,OAAgB,CAAC;AAC/C,eAAO,MAAM,cAAc,EAAG,OAAgB,CAAC;AAC/C,eAAO,MAAM,kBAAkB,EAAG,UAAmB,CAAC;AACtD,eAAO,MAAM,gBAAgB,EAAG,SAAkB,CAAC;AACnD,eAAO,MAAM,gBAAgB,EAAG,SAAkB,CAAC;AACnD,eAAO,MAAM,aAAa,EAAG,MAAe,CAAC;AAC7C,eAAO,MAAM,YAAY,EAAG,KAAc,CAAC;AAC3C,eAAO,MAAM,cAAc,EAAG,OAAgB,CAAC"}
package/dist/types.d.ts CHANGED
@@ -11,6 +11,11 @@ export interface RichEditorProps {
11
11
  contentClassName?: string;
12
12
  debounceMs?: number;
13
13
  extraNodes?: Array<Klass<LexicalNode>>;
14
+ fileUpload?: (file: File, opts?: {
15
+ onProgress?: (percent: number) => void;
16
+ }) => Promise<{
17
+ src: string;
18
+ }>;
14
19
  header?: ReactNode;
15
20
  imageUpload?: (file: File) => Promise<{
16
21
  src: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAE/D,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;I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AqB,KAAK,IAAI,CAAC;IAClD,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,KAAK,IAAI,CAAC;IACvD,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,WAAW,CAAC,EAAE,CACZ,IAAI,EAAE,IAAI,EACV,IAAI,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;KAAE,KAC9C,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC/B"}
@@ -0,0 +1,38 @@
1
+ export type ImageDisplayMode = 'auto' | 'percent' | 'fixed-width' | 'fixed-height';
2
+ export type ImageDisplayFields = {
3
+ displayWidth?: number;
4
+ fixedWidth?: number;
5
+ fixedHeight?: number;
6
+ };
7
+ export type ImageDisplaySize = {
8
+ mode: 'auto';
9
+ } | {
10
+ mode: 'percent';
11
+ value: number;
12
+ } | {
13
+ mode: 'fixed-width';
14
+ px: number;
15
+ } | {
16
+ mode: 'fixed-height';
17
+ px: number;
18
+ };
19
+ export type ImageDisplayConvertContext = {
20
+ containerWidth: number;
21
+ intrinsicHeight?: number;
22
+ intrinsicWidth?: number;
23
+ renderedHeight?: number;
24
+ renderedWidth?: number;
25
+ };
26
+ export declare function sanitizeImageDisplayWidth(value: number | undefined): number | undefined;
27
+ export declare function sanitizeImageFixedPx(value: number | undefined): number | undefined;
28
+ export declare function resolveImageDisplaySize(fields: ImageDisplayFields): ImageDisplaySize;
29
+ export declare function imageDisplayFieldsFromSize(size: ImageDisplaySize): ImageDisplayFields;
30
+ export declare function computeImageDisplayPixels(size: ImageDisplaySize, ctx: ImageDisplayConvertContext): {
31
+ heightPx?: number;
32
+ widthPx?: number;
33
+ };
34
+ export declare function convertImageDisplaySize(from: ImageDisplaySize, to: ImageDisplayMode, ctx: ImageDisplayConvertContext): ImageDisplaySize;
35
+ export declare function imageDisplayCssVars(size: ImageDisplaySize): Record<string, string> | undefined;
36
+ export declare function imageDisplayDataAttr(size: ImageDisplaySize): string | undefined;
37
+ export declare function imageDisplaySizeAfterResize(mode: ImageDisplayMode, nextWidth: number, nextHeight: number, containerWidth: number): ImageDisplaySize;
38
+ //# sourceMappingURL=image-display-size.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-display-size.d.ts","sourceRoot":"","sources":["../../src/utils/image-display-size.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,SAAS,GAAG,aAAa,GAAG,cAAc,CAAC;AAEnF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzC,MAAM,MAAM,0BAA0B,GAAG;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAGvF;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAGlF;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,kBAAkB,GAAG,gBAAgB,CAQpF;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,gBAAgB,GAAG,kBAAkB,CAerF;AAyCD,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,gBAAgB,EACtB,GAAG,EAAE,0BAA0B,GAC9B;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAYzC;AAED,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,gBAAgB,EACtB,EAAE,EAAE,gBAAgB,EACpB,GAAG,EAAE,0BAA0B,GAC9B,gBAAgB,CAmBlB;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAe9F;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,GAAG,SAAS,CAE/E;AAED,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,gBAAgB,EACtB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,GACrB,gBAAgB,CAWlB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haklex/rich-editor",
3
- "version": "0.35.0",
3
+ "version": "0.37.0",
4
4
  "description": "Core rich text editor based on Lexical",
5
5
  "repository": {
6
6
  "type": "git",
@@ -46,11 +46,11 @@
46
46
  ],
47
47
  "dependencies": {
48
48
  "@lexical/code-core": "^0.49.0",
49
- "nanoid": "^6.0.0",
49
+ "nanoid": "^6.0.1",
50
50
  "thumbhash": "^0.1.1",
51
- "@haklex/rich-editor-ui": "0.35.0",
52
- "@haklex/rich-style-token": "0.35.0",
53
- "@haklex/rich-headless": "0.35.0"
51
+ "@haklex/rich-editor-ui": "0.37.0",
52
+ "@haklex/rich-style-token": "0.37.0",
53
+ "@haklex/rich-headless": "0.37.0"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@lexical/extension": "^0.49.0",
@@ -64,15 +64,15 @@
64
64
  "@types/react-dom": "^19.2.4",
65
65
  "@vanilla-extract/css": "^1.21.2",
66
66
  "@vanilla-extract/vite-plugin": "^5.2.6",
67
- "katex": "^0.18.1",
67
+ "katex": "^0.18.4",
68
68
  "lexical": "^0.49.0",
69
- "lucide-react": "^1.28.0",
69
+ "lucide-react": "^1.33.0",
70
70
  "react": "^19.2.8",
71
71
  "react-dom": "^19.2.8",
72
- "shiki": "^4.4.1",
72
+ "shiki": "^4.4.3",
73
73
  "typescript": "^7.0.2",
74
74
  "unplugin-dts": "^1.0.3",
75
- "vite": "^8.2.0"
75
+ "vite": "^8.2.2"
76
76
  },
77
77
  "peerDependencies": {
78
78
  "@base-ui/react": ">=1.5.0",
@@ -1,45 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- //#region src/components/renderers/LinkCardRenderer.tsx
3
- function LinkCardRenderer({ url, title, description, favicon, image }) {
4
- return /* @__PURE__ */ jsxs("a", {
5
- className: "rich-link-card",
6
- href: url,
7
- rel: "noopener noreferrer",
8
- target: "_blank",
9
- children: [image && /* @__PURE__ */ jsx("span", {
10
- className: "rich-link-card-image",
11
- children: /* @__PURE__ */ jsx("img", {
12
- alt: "",
13
- loading: "lazy",
14
- src: image
15
- })
16
- }), /* @__PURE__ */ jsxs("span", {
17
- className: "rich-link-card-content",
18
- children: [
19
- /* @__PURE__ */ jsxs("span", {
20
- className: "rich-link-card-title",
21
- children: [favicon && /* @__PURE__ */ jsx("img", {
22
- alt: "",
23
- className: "rich-link-card-favicon",
24
- height: 16,
25
- src: favicon,
26
- width: 16,
27
- onError: (e) => {
28
- e.target.style.display = "none";
29
- }
30
- }), title || url]
31
- }),
32
- description && /* @__PURE__ */ jsx("span", {
33
- className: "rich-link-card-description",
34
- children: description
35
- }),
36
- /* @__PURE__ */ jsx("span", {
37
- className: "rich-link-card-url",
38
- children: url
39
- })
40
- ]
41
- })]
42
- });
43
- }
44
- //#endregion
45
- export { LinkCardRenderer as t };