@zuilib/text-editor 0.11.0 → 0.12.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 (49) hide show
  1. package/CHANGELOG.md +180 -17
  2. package/DRAWING_FORMAT.md +23 -21
  3. package/README.md +486 -68
  4. package/dist/chunk-32RX4GZF.js +2 -0
  5. package/dist/chunk-3TZVOXWX.js +16 -0
  6. package/dist/chunk-5VRVC56Y.js +2 -0
  7. package/dist/chunk-7Z3CW6Q3.js +2 -0
  8. package/dist/chunk-A7MCBSAZ.js +2 -0
  9. package/dist/chunk-AGTPMKLK.js +2 -0
  10. package/dist/chunk-C7VEINKX.js +2 -0
  11. package/dist/chunk-LDVPFZCN.js +2 -0
  12. package/dist/chunk-N5JWZ2VW.js +9 -0
  13. package/dist/chunk-QKHMJQO3.js +2 -0
  14. package/dist/chunk-R5PL4Q7X.js +5 -0
  15. package/dist/chunk-SDICQI2B.js +2 -0
  16. package/dist/chunk-TGVEPLDM.js +1 -0
  17. package/dist/chunk-XP3MZRCW.js +2 -0
  18. package/dist/chunk-XRJNLGI4.js +2 -0
  19. package/dist/chunk-YFFSTMIR.js +2 -0
  20. package/dist/chunk-ZXZMYJ7F.js +2 -0
  21. package/dist/comment-markers-BrrrAdSL.d.ts +27 -0
  22. package/dist/comments.d.ts +68 -0
  23. package/dist/comments.js +2 -0
  24. package/dist/drawing-data-EWzEQ1_i.d.ts +111 -0
  25. package/dist/drawing-preset-Ag7a7F9h.d.ts +69 -0
  26. package/dist/drawing.d.ts +7 -0
  27. package/dist/drawing.js +2 -0
  28. package/dist/image-node-kR1Zf5kz.d.ts +70 -0
  29. package/dist/images.d.ts +66 -0
  30. package/dist/images.js +2 -0
  31. package/dist/index-A4S7bRwQ.d.ts +425 -0
  32. package/dist/index.d.ts +36 -1394
  33. package/dist/index.js +2 -7447
  34. package/dist/lexical.d.ts +117 -0
  35. package/dist/lexical.js +2 -0
  36. package/dist/markdown.d.ts +29 -0
  37. package/dist/markdown.js +2 -0
  38. package/dist/mention-node-eSsjUpaE.d.ts +44 -0
  39. package/dist/mentions-plugin-gio3_XKd.d.ts +74 -0
  40. package/dist/mentions.d.ts +5 -0
  41. package/dist/mentions.js +2 -0
  42. package/dist/mermaid-BwGHjwpk.d.ts +553 -0
  43. package/dist/paste.d.ts +45 -0
  44. package/dist/paste.js +2 -0
  45. package/dist/presets-BtNPH0pa.d.ts +78 -0
  46. package/dist/styles.css +406 -99
  47. package/dist/table-grid-D70tNhp2.d.ts +459 -0
  48. package/package.json +57 -12
  49. package/dist/index.css +0 -79
@@ -0,0 +1,27 @@
1
+ import { LexicalNode } from 'lexical';
2
+ import { TextMatchTransformer } from '@lexical/markdown';
3
+ import { MarkNode } from '@lexical/mark';
4
+
5
+ declare function formatCommentMarker(ids: readonly string[], inner: string): string;
6
+ declare function parseCommentIds(value: string): string[];
7
+ /**
8
+ * Markdown transformer for commented ranges (`MarkNode`). A range is
9
+ * written as HTML comment markers around its text, so every other markdown
10
+ * renderer shows the text and hides the markers. A range spanning several
11
+ * blocks is one marker pair per block, all carrying the same id; overlapping
12
+ * comments share a pair with the ids comma-separated.
13
+ */
14
+ declare const COMMENT: TextMatchTransformer;
15
+ /** Every `MarkNode` of the document, in document order */
16
+ declare function $getMarkNodes(): MarkNode[];
17
+ /** Every distinct comment id present in the document, in document order */
18
+ declare function $getCommentIds(): string[];
19
+ /** Removes `id` from every mark; marks left without ids are unwrapped */
20
+ declare function $removeComment(id: string): boolean;
21
+ /**
22
+ * Offset of `target` in the document's plain text, counted the way
23
+ * `$getRoot().getTextContent()` joins nodes (two newlines between blocks).
24
+ */
25
+ declare function $plainTextOffset(target: LexicalNode): number;
26
+
27
+ export { $getCommentIds as $, COMMENT as C, $getMarkNodes as a, $plainTextOffset as b, $removeComment as c, formatCommentMarker as f, parseCommentIds as p };
@@ -0,0 +1,68 @@
1
+ export { $createMarkNode, $getMarkIDs, $isMarkNode, $unwrapMarkNode, $wrapSelectionInMarkNode, MarkNode } from '@lexical/mark';
2
+ import { ReactNode, ReactElement } from 'react';
3
+ import { LexicalCommand } from 'lexical';
4
+ export { $ as $getCommentIds, a as $getMarkNodes, b as $plainTextOffset, c as $removeComment, C as COMMENT, f as formatCommentMarker, p as parseCommentIds } from './comment-markers-BrrrAdSL.js';
5
+ import '@lexical/markdown';
6
+
7
+ type CommentRange = Readonly<{
8
+ start: number;
9
+ end: number;
10
+ }>;
11
+ type Comment = Readonly<{
12
+ id: string;
13
+ /** Offsets of the quote in the document's plain text; informational */
14
+ range?: CommentRange;
15
+ /** The text that was selected when the comment was added */
16
+ quote: string;
17
+ resolved?: boolean;
18
+ }>;
19
+ type CommentsLabels = Readonly<{
20
+ add: string;
21
+ /** `aria-label` of the bubble listing the comments at the caret */
22
+ comments: string;
23
+ resolve: string;
24
+ reopen: string;
25
+ remove: string;
26
+ resolved: string;
27
+ /** Shown for a marker whose id is not in `comments` */
28
+ unknown: (id: string) => string;
29
+ }>;
30
+ declare const DEFAULT_COMMENTS_LABELS: CommentsLabels;
31
+ /** Lexical theme classes for the marks; optional, the plugin adds `zui-comment` itself */
32
+ declare const COMMENTS_THEME: {
33
+ readonly mark: "zui-comment";
34
+ readonly markOverlap: "zui-comment-overlap";
35
+ };
36
+ /** Wraps the current range selection in a new comment; `true` when one was added */
37
+ declare const ADD_COMMENT_COMMAND: LexicalCommand<void>;
38
+ type CommentActions = Readonly<{
39
+ resolve: () => void;
40
+ remove: () => void;
41
+ }>;
42
+ type CommentsPluginProps = Readonly<{
43
+ /** The comments the host knows; marks with other ids are listed as unknown */
44
+ comments: readonly Comment[];
45
+ /** A comment was created from the selection; its markers are already in the document */
46
+ onAdd?: (comment: Comment) => void;
47
+ /** Resolve (`true`) or reopen (`false`) was pressed */
48
+ onResolve?: (id: string, resolved: boolean) => void;
49
+ /** Delete was pressed; the markers are already removed from the document */
50
+ onDelete?: (id: string) => void;
51
+ /** Id generator for new comments (default: `crypto.randomUUID`, or a random string) */
52
+ createId?: () => string;
53
+ labels?: Partial<CommentsLabels>;
54
+ /** Body of one entry in the bubble; the buttons stay unless the renderer returns its own */
55
+ renderComment?: (comment: Comment, actions: CommentActions) => ReactNode;
56
+ }>;
57
+ /**
58
+ * Range comments on top of `@lexical/mark`. A floating "Add comment"
59
+ * button (or Mod+Shift+M) wraps the selection in a `MarkNode` with a fresh
60
+ * id and reports `{ id, quote, range }` through `onAdd`; the caret inside a
61
+ * commented range opens a bubble with resolve / reopen and delete. The
62
+ * document keeps the ranges (as `<!-- zui:comment id -->` markers in
63
+ * markdown); the host keeps everything else about a comment. Requires
64
+ * `MarkNode` in `nodes` and `COMMENT` in `transformers`.
65
+ */
66
+ declare function CommentsPlugin({ comments, onAdd, onResolve, onDelete, createId, labels: labelsProp, renderComment, }: CommentsPluginProps): ReactElement | null;
67
+
68
+ export { ADD_COMMENT_COMMAND, COMMENTS_THEME, type Comment, type CommentActions, type CommentRange, type CommentsLabels, CommentsPlugin, type CommentsPluginProps, DEFAULT_COMMENTS_LABELS };
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ "use client";import{a,b as s,c as C,d as p}from"./chunk-C7VEINKX.js";import{a as e,b as o,c as m,d as t,e as r,f as n,g as M}from"./chunk-A7MCBSAZ.js";import"./chunk-SDICQI2B.js";import{MarkNode as i,$createMarkNode as l,$isMarkNode as $,$unwrapMarkNode as f,$wrapSelectionInMarkNode as g,$getMarkIDs as k}from"@lexical/mark";export{l as $createMarkNode,r as $getCommentIds,k as $getMarkIDs,t as $getMarkNodes,$ as $isMarkNode,M as $plainTextOffset,n as $removeComment,f as $unwrapMarkNode,g as $wrapSelectionInMarkNode,C as ADD_COMMENT_COMMAND,m as COMMENT,s as COMMENTS_THEME,p as CommentsPlugin,a as DEFAULT_COMMENTS_LABELS,i as MarkNode,e as formatCommentMarker,o as parseCommentIds};
@@ -0,0 +1,111 @@
1
+ import { a as BlockWidth } from './presets-BtNPH0pa.js';
2
+
3
+ /** Card-like shapes: fillable, bindable, carrying the three text slots */
4
+ type NodeShapeType = 'rect' | 'ellipse' | 'diamond' | 'note' | 'cylinder' | 'cloud' | 'queue' | 'actor';
5
+ type ConnectorType = 'arrow' | 'line';
6
+ type DrawingShapeType = NodeShapeType | ConnectorType | 'text';
7
+ declare const NODE_SHAPE_TYPES: readonly NodeShapeType[];
8
+ declare const CONNECTOR_TYPES: readonly ConnectorType[];
9
+ declare const SHAPE_TYPES: readonly DrawingShapeType[];
10
+ declare function isNodeShapeType(type: string): type is NodeShapeType;
11
+ type Point = Readonly<{
12
+ x: number;
13
+ y: number;
14
+ }>;
15
+ type BindingSide = 'top' | 'right' | 'bottom' | 'left';
16
+ /**
17
+ * Where a connector endpoint attaches to a box.
18
+ *
19
+ * `fixedPoint` is a ratio inside the box's bounding box (`[0,0]` top-left,
20
+ * `[1,1]` bottom-right). Omitted = the box center, which makes the endpoint
21
+ * auto-aim at the other end. `mode: 'inside'` pins the endpoint exactly on
22
+ * the fixed point; the default (`'orbit'`) projects it onto the outline with
23
+ * a small gap.
24
+ */
25
+ type Binding = Readonly<{
26
+ id: string;
27
+ fixedPoint?: readonly [number, number];
28
+ mode?: 'orbit' | 'inside';
29
+ }>;
30
+ type DrawingShape = Readonly<{
31
+ id: string;
32
+ type: DrawingShapeType;
33
+ /** Top-left corner (boxes/text) or start point (connectors) */
34
+ x: number;
35
+ y: number;
36
+ /** Size (boxes/text) or delta to the end point (connectors) */
37
+ width: number;
38
+ height: number;
39
+ stroke: string;
40
+ fill: string;
41
+ strokeWidth: number;
42
+ /** Standalone text, main (center) content of a box, or connector label */
43
+ text?: string;
44
+ /** Small heading rendered at the top of a box */
45
+ label?: string;
46
+ /** Small line rendered at the bottom of a box */
47
+ footer?: string;
48
+ /** Connector: box the start point is attached to */
49
+ startBinding?: Binding;
50
+ /** Connector: box the end point is attached to */
51
+ endBinding?: Binding;
52
+ /** Arrow: arrowheads on both ends */
53
+ bidirectional?: boolean;
54
+ /** Connector routing: right-angled auto-routed path instead of a straight line */
55
+ routing?: 'elbow';
56
+ /**
57
+ * Elbow override: position of the middle segment as a fraction of the
58
+ * span, applied only when the routed path is a simple three-segment Z.
59
+ */
60
+ elbow?: number;
61
+ /**
62
+ * Connector: intermediate path points between start and end (absolute
63
+ * canvas coordinates). Takes precedence over `routing`.
64
+ */
65
+ waypoints?: readonly Point[];
66
+ }>;
67
+ type DrawingData = Readonly<{
68
+ version: 3;
69
+ /**
70
+ * Logical canvas width. When set the drawing is scaled to fit narrower
71
+ * layouts (SVG viewBox); when omitted the canvas is fluid and shapes are
72
+ * in CSS pixels.
73
+ */
74
+ canvasWidth?: number;
75
+ canvasHeight: number;
76
+ /**
77
+ * Block width: `full` (default) spans the editor; `text` aligns with the
78
+ * text column; `content` fits the shapes' horizontal extent. The editor
79
+ * omits `full` unless it was written explicitly (an insertion default or
80
+ * the source payload); unknown values are dropped.
81
+ */
82
+ width?: BlockWidth;
83
+ /** Accessible name of the drawing (SVG `aria-label`) */
84
+ title?: string;
85
+ /** Longer accessible description of the drawing */
86
+ description?: string;
87
+ shapes: readonly DrawingShape[];
88
+ }>;
89
+ declare const EMPTY_DRAWING: DrawingData;
90
+ declare const STROKE_COLORS: readonly ["#1e1e1e", "#e03131", "#2f9e44", "#1971c2", "#f08c00", "#7048e8"];
91
+ declare const FILL_COLORS: readonly ["transparent", "#ffc9c9", "#b2f2bb", "#a5d8ff", "#ffec99", "#d0bfff"];
92
+ /** Edge midpoints, used by the ```diagram skeleton's `side` option */
93
+ declare const SIDE_FIXED_POINTS: Record<BindingSide, readonly [number, number]>;
94
+ declare function serializeDrawingData(data: DrawingData): string;
95
+ /**
96
+ * Parse a ```drawing payload. Version 3 is the format the editor writes;
97
+ * version 2 (shape sizes as `w`/`h`) is migrated on read so persisted
98
+ * drawings keep loading (the ```diagram skeleton is a separate block type,
99
+ * see skeleton.ts). Shapes that fail validation are dropped and a malformed
100
+ * document yields an empty canvas. Never throws.
101
+ */
102
+ declare function deserializeDrawingData(json: string): DrawingData;
103
+ /**
104
+ * Normalize a parsed payload. Version 2 payloads are migrated to version 3
105
+ * (`w`/`h` → `width`/`height`). Payloads over `MAX_SHAPES` are truncated;
106
+ * `onWarn` hears about it (default: one `console.warn` per session, since
107
+ * the node re-parses on every read).
108
+ */
109
+ declare function normalizeDrawingData(parsed: unknown, onWarn?: (message: string) => void): DrawingData;
110
+
111
+ export { type Binding as B, CONNECTOR_TYPES as C, type DrawingData as D, EMPTY_DRAWING as E, FILL_COLORS as F, NODE_SHAPE_TYPES as N, type Point as P, SHAPE_TYPES as S, type BindingSide as a, type ConnectorType as b, type DrawingShape as c, type DrawingShapeType as d, type NodeShapeType as e, SIDE_FIXED_POINTS as f, STROKE_COLORS as g, deserializeDrawingData as h, isNodeShapeType as i, normalizeDrawingData as n, serializeDrawingData as s };
@@ -0,0 +1,69 @@
1
+ import * as lexical from 'lexical';
2
+ import { DecoratorNode, NodeKey, Spread, SerializedLexicalNode, EditorConfig, DOMExportOutput, DOMConversionMap, LexicalEditor, LexicalNode } from 'lexical';
3
+ import { MultilineElementTransformer, Transformer } from '@lexical/markdown';
4
+ import { ReactElement } from 'react';
5
+ import { a as BlockWidth, E as EditorPreset } from './presets-BtNPH0pa.js';
6
+ import { D as DrawingData } from './drawing-data-EWzEQ1_i.js';
7
+
8
+ type SerializedDrawingNode = Spread<{
9
+ data: string;
10
+ }, SerializedLexicalNode>;
11
+ /**
12
+ * A block-level decorator node embedding a vector diagram (cards, connectors,
13
+ * text) edited on a canvas.
14
+ *
15
+ * The drawing is stored as a JSON string and round-trips through markdown as
16
+ * a ```drawing fenced code block, so documents remain plain markdown.
17
+ */
18
+ declare class DrawingNode extends DecoratorNode<ReactElement> {
19
+ __data: string;
20
+ static getType(): string;
21
+ static clone(node: DrawingNode): DrawingNode;
22
+ constructor(data: string, key?: NodeKey);
23
+ static importJSON(serializedNode: SerializedDrawingNode): DrawingNode;
24
+ exportJSON(): SerializedDrawingNode;
25
+ createDOM(config: EditorConfig): HTMLElement;
26
+ updateDOM(): false;
27
+ exportDOM(): DOMExportOutput;
28
+ static importDOM(): DOMConversionMap | null;
29
+ /**
30
+ * The parsed payload. Parsing is memoized on the JSON string, so repeated
31
+ * reads of an unchanged node (every toolbar update, every decorate) cost
32
+ * one map lookup.
33
+ */
34
+ getData(): DrawingData;
35
+ setData(data: DrawingData): void;
36
+ /** Block width of the drawing (`full` when the payload leaves it implicit) */
37
+ getBlockWidth(): BlockWidth;
38
+ /** Resize the block; `full` picked by hand stays implicit in the payload */
39
+ setBlockWidth(width: BlockWidth): void;
40
+ isInline(): false;
41
+ decorate(_editor: LexicalEditor, _config: EditorConfig): ReactElement;
42
+ }
43
+ declare function $createDrawingNode(data?: string): DrawingNode;
44
+ declare function $isDrawingNode(node: LexicalNode | null | undefined): node is DrawingNode;
45
+ /**
46
+ * Markdown transformer persisting drawings as fenced ```drawing blocks with a
47
+ * JSON payload. Must be ordered before the built-in CODE transformer so it
48
+ * claims the fence first on import.
49
+ */
50
+ declare const DRAWING: MultilineElementTransformer;
51
+ /**
52
+ * Import-only transformer for ```diagram blocks: a compact skeleton
53
+ * (boxes, connectors by id, auto layout) that expands into a full drawing.
54
+ * Once in the editor the node is a regular drawing and exports as
55
+ * ```drawing, so the expansion is one-way.
56
+ */
57
+ declare const DIAGRAM: MultilineElementTransformer;
58
+
59
+ /** Every node class of the default entry */
60
+ declare const DRAWING_PRESET_NODES: (lexical.KlassConstructor<typeof lexical.LexicalNode> | typeof DrawingNode)[];
61
+ /**
62
+ * Full markdown import / export set of the default entry: CORE plus the
63
+ * drawing transformers, which sit right after FRONTMATTER so they claim
64
+ * their fences before CODE_BLOCK.
65
+ */
66
+ declare const DRAWING_PRESET_TRANSFORMERS: Transformer[];
67
+ declare const DRAWING_PRESET: EditorPreset;
68
+
69
+ export { $createDrawingNode as $, DIAGRAM as D, type SerializedDrawingNode as S, $isDrawingNode as a, DRAWING as b, DRAWING_PRESET as c, DRAWING_PRESET_NODES as d, DRAWING_PRESET_TRANSFORMERS as e, DrawingNode as f };
@@ -0,0 +1,7 @@
1
+ export { $ as $createDrawingNode, a as $isDrawingNode, D as DIAGRAM, b as DRAWING, c as DRAWING_PRESET, d as DRAWING_PRESET_NODES, e as DRAWING_PRESET_TRANSFORMERS, f as DrawingNode, S as SerializedDrawingNode } from './drawing-preset-Ag7a7F9h.js';
2
+ export { C as COLOR_PRESETS, a as ColorName, D as DRAWING_DATA_JSON_SCHEMA, b as DRAWING_FOCUS_COMMAND, c as DRAWING_SKELETON_JSON_SCHEMA, d as DrawingPlugin, e as DrawingSkeleton, I as INSERT_DRAWING_COMMAND, M as MermaidDirection, f as MermaidOptions, N as NODE_SHAPE_DEFINITIONS, g as NodeShapeDefinition, S as SkeletonBox, h as SkeletonConnector, i as SkeletonEnd, j as SkeletonText, T as TextField, k as createBinding, l as drawingToMermaid, m as expandDrawingSkeleton, n as findNodeShapeAt, o as isDrawingSkeleton, p as parseDrawingSkeleton } from './mermaid-BwGHjwpk.js';
3
+ export { B as Binding, a as BindingSide, C as CONNECTOR_TYPES, b as ConnectorType, D as DrawingData, c as DrawingShape, d as DrawingShapeType, E as EMPTY_DRAWING, F as FILL_COLORS, N as NODE_SHAPE_TYPES, e as NodeShapeType, P as Point, S as SHAPE_TYPES, f as SIDE_FIXED_POINTS, g as STROKE_COLORS, h as deserializeDrawingData, i as isNodeShapeType, n as normalizeDrawingData, s as serializeDrawingData } from './drawing-data-EWzEQ1_i.js';
4
+ export { D as DrawingStyle } from './presets-BtNPH0pa.js';
5
+ import 'lexical';
6
+ import '@lexical/markdown';
7
+ import 'react';
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ "use client";import{a as G}from"./chunk-32RX4GZF.js";import{A as M,B as y,C as k,a as o,b as i,c as n,d as a,e as t,f as S,g as D,h as p,i as d,j as N,k as E,l as g,m as _,n as w,o as m,p as R,q as T,r as A,s as O,t as f,u as x,v as l,w as I,x as s,y as P,z as C}from"./chunk-3TZVOXWX.js";import"./chunk-N5JWZ2VW.js";import{r as e,s as r}from"./chunk-LDVPFZCN.js";export{l as $createDrawingNode,I as $isDrawingNode,R as COLOR_PRESETS,i as CONNECTOR_TYPES,P as DIAGRAM,s as DRAWING,G as DRAWING_DATA_JSON_SCHEMA,e as DRAWING_FOCUS_COMMAND,k as DRAWING_PRESET,M as DRAWING_PRESET_NODES,y as DRAWING_PRESET_TRANSFORMERS,f as DRAWING_SKELETON_JSON_SCHEMA,x as DrawingNode,C as DrawingPlugin,t as EMPTY_DRAWING,D as FILL_COLORS,r as INSERT_DRAWING_COMMAND,g as NODE_SHAPE_DEFINITIONS,o as NODE_SHAPE_TYPES,n as SHAPE_TYPES,p as SIDE_FIXED_POINTS,S as STROKE_COLORS,w as createBinding,N as deserializeDrawingData,m as drawingToMermaid,O as expandDrawingSkeleton,_ as findNodeShapeAt,T as isDrawingSkeleton,a as isNodeShapeType,E as normalizeDrawingData,A as parseDrawingSkeleton,d as serializeDrawingData};
@@ -0,0 +1,70 @@
1
+ import { ReactElement } from 'react';
2
+ import { DecoratorNode, NodeKey, Spread, SerializedLexicalNode, EditorConfig, DOMExportOutput, DOMConversionMap, LexicalNode } from 'lexical';
3
+ import { TextMatchTransformer } from '@lexical/markdown';
4
+
5
+ type ImagesLabels = Readonly<{
6
+ /** `aria-label` of the alt-text input */
7
+ altText: string;
8
+ altPlaceholder: string;
9
+ /** `aria-label` of the upload placeholder */
10
+ uploading: string;
11
+ /** `aria-label` of `ImageButton` */
12
+ insertImage: string;
13
+ }>;
14
+ declare const DEFAULT_IMAGES_LABELS: ImagesLabels;
15
+ type SerializedImageNode = Spread<{
16
+ src: string;
17
+ alt: string;
18
+ title?: string;
19
+ }, SerializedLexicalNode>;
20
+ /**
21
+ * An inline image: `![alt](src)` in markdown. Click selects it (Backspace
22
+ * removes it) and shows an alt-text input. While an upload is in flight the
23
+ * node is *pending*: it renders a progress placeholder and exports as
24
+ * nothing until `ImagesPlugin` fills in the uploaded `src`.
25
+ */
26
+ declare class ImageNode extends DecoratorNode<ReactElement> {
27
+ __src: string;
28
+ __alt: string;
29
+ __title: string | undefined;
30
+ __pending: boolean;
31
+ static getType(): string;
32
+ static clone(node: ImageNode): ImageNode;
33
+ constructor(src: string, alt?: string, title?: string, pending?: boolean, key?: NodeKey);
34
+ static importJSON(json: SerializedImageNode): ImageNode;
35
+ exportJSON(): SerializedImageNode;
36
+ createDOM(config: EditorConfig): HTMLElement;
37
+ updateDOM(): false;
38
+ exportDOM(): DOMExportOutput;
39
+ static importDOM(): DOMConversionMap | null;
40
+ isInline(): true;
41
+ isKeyboardSelectable(): boolean;
42
+ getSrc(): string;
43
+ getAlt(): string;
44
+ getTitle(): string | undefined;
45
+ isPending(): boolean;
46
+ setSrc(src: string): this;
47
+ setAlt(alt: string): this;
48
+ setPending(pending: boolean): this;
49
+ /** Plain-text value: the alt text (empty while pending) */
50
+ getTextContent(): string;
51
+ decorate(): ReactElement;
52
+ }
53
+ declare function $createImageNode({ src, alt, title, pending }: {
54
+ src: string;
55
+ alt?: string;
56
+ title?: string;
57
+ pending?: boolean;
58
+ }): ImageNode;
59
+ declare function $isImageNode(node: LexicalNode | null | undefined): node is ImageNode;
60
+ /** The selected image, when the selection is exactly one image node */
61
+ declare function $getSelectedImage(): ImageNode | null;
62
+ /**
63
+ * Markdown transformer for images: `![alt](src)` and `![alt](src "title")`.
64
+ * A pending upload exports as an empty string. Sources with script-capable
65
+ * schemes are left as text. Put it before the built-ins so it claims the
66
+ * syntax ahead of `LINK`.
67
+ */
68
+ declare const IMAGE: TextMatchTransformer;
69
+
70
+ export { $createImageNode as $, DEFAULT_IMAGES_LABELS as D, type ImagesLabels as I, type SerializedImageNode as S, $getSelectedImage as a, $isImageNode as b, IMAGE as c, ImageNode as d };
@@ -0,0 +1,66 @@
1
+ import { I as ImagesLabels } from './image-node-kR1Zf5kz.js';
2
+ export { $ as $createImageNode, a as $getSelectedImage, b as $isImageNode, D as DEFAULT_IMAGES_LABELS, c as IMAGE, d as ImageNode, S as SerializedImageNode } from './image-node-kR1Zf5kz.js';
3
+ import { ReactElement } from 'react';
4
+ import { LexicalCommand } from 'lexical';
5
+ import '@lexical/markdown';
6
+
7
+ type UploadedImage = Readonly<{
8
+ src: string;
9
+ alt?: string;
10
+ }>;
11
+ type ImageError = Readonly<{
12
+ type: 'too-large';
13
+ file: File;
14
+ maxSize: number;
15
+ }> | Readonly<{
16
+ type: 'unsupported';
17
+ file: File;
18
+ }> | Readonly<{
19
+ type: 'upload';
20
+ file: File;
21
+ error: unknown;
22
+ }> | Readonly<{
23
+ type: 'unsafe-src';
24
+ src: string;
25
+ }>;
26
+ type InsertImagePayload = Readonly<{
27
+ src: string;
28
+ alt?: string;
29
+ title?: string;
30
+ }>;
31
+ /** Inserts an image at the selection; the src must pass `isSafeUrl` */
32
+ declare const INSERT_IMAGE_COMMAND: LexicalCommand<InsertImagePayload>;
33
+ /** Uploads the files (as a paste or drop would) and inserts the results */
34
+ declare const UPLOAD_IMAGES_COMMAND: LexicalCommand<readonly File[]>;
35
+ type ImagesPluginProps = Readonly<{
36
+ /**
37
+ * Stores a pasted or dropped file and returns where it lives. A pending
38
+ * placeholder stands in the document until the promise settles; a
39
+ * rejection removes it and reports `{ type: 'upload' }`.
40
+ */
41
+ upload: (file: File) => Promise<UploadedImage>;
42
+ /** Largest file accepted, in bytes; bigger ones are reported as `too-large` */
43
+ maxSize?: number;
44
+ /** MIME types accepted (default: any `image/*`) */
45
+ accept?: readonly string[];
46
+ onError?: (error: ImageError) => void;
47
+ labels?: Partial<ImagesLabels>;
48
+ }>;
49
+ /**
50
+ * Pasted, dropped and programmatic images. Files arriving through
51
+ * `DRAG_DROP_PASTE` (what `RichTextPlugin` dispatches for a paste or drop
52
+ * of files) are checked against `accept` and `maxSize`, shown as a
53
+ * pending placeholder at the caret and replaced by the uploaded image.
54
+ * Requires `ImageNode` in `nodes` and `IMAGE` in `transformers`.
55
+ */
56
+ declare function ImagesPlugin({ upload, maxSize, accept, onError, labels: labelsProp }: ImagesPluginProps): null;
57
+ /**
58
+ * Toolbar button opening a file picker; the chosen files go through
59
+ * `UPLOAD_IMAGES_COMMAND`, so `ImagesPlugin` must be mounted.
60
+ */
61
+ declare function ImageButton({ accept, labels: labelsProp }: Readonly<{
62
+ accept?: string;
63
+ labels?: Partial<ImagesLabels>;
64
+ }>): ReactElement;
65
+
66
+ export { INSERT_IMAGE_COMMAND, ImageButton, type ImageError, ImagesLabels, ImagesPlugin, type ImagesPluginProps, type InsertImagePayload, UPLOAD_IMAGES_COMMAND, type UploadedImage };
package/dist/images.js ADDED
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ "use client";import{a as r,b as t,c as d,d as s}from"./chunk-QKHMJQO3.js";import{a as e,c as a,d as g,e as o,f as m,g as I}from"./chunk-7Z3CW6Q3.js";import"./chunk-AGTPMKLK.js";import"./chunk-LDVPFZCN.js";import"./chunk-XRJNLGI4.js";import"./chunk-YFFSTMIR.js";export{g as $createImageNode,m as $getSelectedImage,o as $isImageNode,e as DEFAULT_IMAGES_LABELS,I as IMAGE,r as INSERT_IMAGE_COMMAND,s as ImageButton,a as ImageNode,d as ImagesPlugin,t as UPLOAD_IMAGES_COMMAND};