@zuilib/text-editor 0.11.1 → 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.
- package/CHANGELOG.md +174 -18
- package/DRAWING_FORMAT.md +23 -21
- package/README.md +485 -67
- package/dist/chunk-32RX4GZF.js +2 -0
- package/dist/chunk-3TZVOXWX.js +16 -0
- package/dist/chunk-5VRVC56Y.js +2 -0
- package/dist/chunk-7Z3CW6Q3.js +2 -0
- package/dist/chunk-A7MCBSAZ.js +2 -0
- package/dist/chunk-AGTPMKLK.js +2 -0
- package/dist/chunk-C7VEINKX.js +2 -0
- package/dist/chunk-LDVPFZCN.js +2 -0
- package/dist/chunk-N5JWZ2VW.js +9 -0
- package/dist/chunk-QKHMJQO3.js +2 -0
- package/dist/chunk-R5PL4Q7X.js +5 -0
- package/dist/chunk-SDICQI2B.js +2 -0
- package/dist/chunk-TGVEPLDM.js +1 -0
- package/dist/chunk-XP3MZRCW.js +2 -0
- package/dist/chunk-XRJNLGI4.js +2 -0
- package/dist/chunk-YFFSTMIR.js +2 -0
- package/dist/chunk-ZXZMYJ7F.js +2 -0
- package/dist/comment-markers-BrrrAdSL.d.ts +27 -0
- package/dist/comments.d.ts +68 -0
- package/dist/comments.js +2 -0
- package/dist/drawing-data-EWzEQ1_i.d.ts +111 -0
- package/dist/drawing-preset-Ag7a7F9h.d.ts +69 -0
- package/dist/drawing.d.ts +7 -0
- package/dist/drawing.js +2 -0
- package/dist/image-node-kR1Zf5kz.d.ts +70 -0
- package/dist/images.d.ts +66 -0
- package/dist/images.js +2 -0
- package/dist/index-A4S7bRwQ.d.ts +425 -0
- package/dist/index.d.ts +36 -1394
- package/dist/index.js +1 -7449
- package/dist/lexical.d.ts +117 -0
- package/dist/lexical.js +2 -0
- package/dist/markdown.d.ts +29 -0
- package/dist/markdown.js +2 -0
- package/dist/mention-node-eSsjUpaE.d.ts +44 -0
- package/dist/mentions-plugin-gio3_XKd.d.ts +74 -0
- package/dist/mentions.d.ts +5 -0
- package/dist/mentions.js +2 -0
- package/dist/mermaid-BwGHjwpk.d.ts +553 -0
- package/dist/paste.d.ts +45 -0
- package/dist/paste.js +2 -0
- package/dist/presets-BtNPH0pa.d.ts +78 -0
- package/dist/styles.css +402 -95
- package/dist/table-grid-D70tNhp2.d.ts +459 -0
- package/package.json +52 -7
- package/dist/index.css +0 -79
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export { $ as $deleteTableColumnAt, z as $deleteTableColumnNear, A as $deleteTableRowAt, G as $deleteTableRowNear, J as $getSelectedTable, K as $getSelectedTableCell, L as $getTableCellPosition, N as $getTableDensity, P as $getTableSettings, Q as $getTableWidth, R as $insertTableColumnAt, S as $insertTableColumnNear, U as $insertTableRowAt, V as $insertTableRowNear, W as $isTableWidthExplicit, X as $setTableDensity, Y as $setTableSettings, Z as $setTableWidth, _ as createMarkdownEditor } from './table-grid-D70tNhp2.js';
|
|
2
|
+
export { E as EditorPreset, M as MARKDOWN_NODES, b as MARKDOWN_PRESET, c as MARKDOWN_TRANSFORMERS, T as TransformersInput, r as resolveTransformers, s as shortcutTransformers } from './presets-BtNPH0pa.js';
|
|
3
|
+
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';
|
|
4
|
+
import { Transformer, MultilineElementTransformer, ElementTransformer } from '@lexical/markdown';
|
|
5
|
+
import { LexicalEditor, EditorThemeClasses, ElementNode, NodeKey, EditorConfig, SerializedElementNode, LexicalNode } from 'lexical';
|
|
6
|
+
import { registerCodeHighlighting } from '@lexical/code';
|
|
7
|
+
export { $ as $createMentionNode, a as $isMentionNode, M as MENTION, b as MentionNode, S as SerializedMentionNode } from './mention-node-eSsjUpaE.js';
|
|
8
|
+
export { $ as $createImageNode, a as $getSelectedImage, b as $isImageNode, c as IMAGE, d as ImageNode, S as SerializedImageNode } from './image-node-kR1Zf5kz.js';
|
|
9
|
+
export { $ as $getCommentIds, a as $getMarkNodes, b as $plainTextOffset, c as $removeComment, C as COMMENT } from './comment-markers-BrrrAdSL.js';
|
|
10
|
+
import 'react';
|
|
11
|
+
import '@lexical/table';
|
|
12
|
+
import './drawing-data-EWzEQ1_i.js';
|
|
13
|
+
import '@lexical/mark';
|
|
14
|
+
|
|
15
|
+
type LexicalTokenizer = NonNullable<Parameters<typeof registerCodeHighlighting>[1]>;
|
|
16
|
+
/**
|
|
17
|
+
* The tokenizer handed to `@lexical/code`. It never touches Prism: the
|
|
18
|
+
* registry's grammars produce the tokens, and `$tokenize` turns them into the
|
|
19
|
+
* flat CodeHighlightNode / LineBreakNode / TabNode structure CodeNode expects.
|
|
20
|
+
*/
|
|
21
|
+
declare const codeTokenizer: LexicalTokenizer;
|
|
22
|
+
/**
|
|
23
|
+
* Registers syntax highlighting for every CodeNode in the editor, driven by
|
|
24
|
+
* the language registry. Unknown languages render as plain text with the
|
|
25
|
+
* same line structure, so editing behaves identically.
|
|
26
|
+
*/
|
|
27
|
+
declare function registerCodeBlockHighlighting(editor: LexicalEditor): () => void;
|
|
28
|
+
|
|
29
|
+
/** Tag on every import update: the sync listener must not echo it back as a change */
|
|
30
|
+
declare const EXTERNAL_UPDATE_TAG = "initial-load";
|
|
31
|
+
/**
|
|
32
|
+
* Replaces the whole document with `markdown` inside one update (one undo
|
|
33
|
+
* step). The caret is put back at the same path/offset when the new
|
|
34
|
+
* document still has that position.
|
|
35
|
+
*/
|
|
36
|
+
declare function $replaceMarkdown(markdown: string, transformers: Transformer[]): void;
|
|
37
|
+
declare function replaceMarkdown(editor: LexicalEditor, markdown: string, transformers: Transformer[]): void;
|
|
38
|
+
|
|
39
|
+
declare const editorNodeClassNames: EditorThemeClasses;
|
|
40
|
+
/**
|
|
41
|
+
* `overrides` on top of `base`, one level deep: a nested group (`heading`,
|
|
42
|
+
* `list`, `text`, ...) is merged key by key, a string replaces the string.
|
|
43
|
+
*/
|
|
44
|
+
declare function mergeNodeClassNames(base: EditorThemeClasses, overrides: EditorThemeClasses): EditorThemeClasses;
|
|
45
|
+
|
|
46
|
+
type SerializedFrontmatterNode = SerializedElementNode;
|
|
47
|
+
/**
|
|
48
|
+
* A block node holding a document's YAML frontmatter — the metadata section
|
|
49
|
+
* delimited by `---` lines at the very top of a markdown file (as used by
|
|
50
|
+
* Claude skills, static-site generators, etc.).
|
|
51
|
+
*
|
|
52
|
+
* Content is stored as plain TextNode children separated by LineBreakNodes, so
|
|
53
|
+
* `getTextContent()` yields the raw YAML with `\n` line separators — exactly
|
|
54
|
+
* what the FRONTMATTER transformer re-serializes on export.
|
|
55
|
+
*/
|
|
56
|
+
declare class FrontmatterNode extends ElementNode {
|
|
57
|
+
static getType(): string;
|
|
58
|
+
static clone(node: FrontmatterNode): FrontmatterNode;
|
|
59
|
+
constructor(key?: NodeKey);
|
|
60
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
61
|
+
updateDOM(): boolean;
|
|
62
|
+
static importJSON(_serializedNode: SerializedFrontmatterNode): FrontmatterNode;
|
|
63
|
+
exportJSON(): SerializedFrontmatterNode;
|
|
64
|
+
isInline(): false;
|
|
65
|
+
canBeEmpty(): boolean;
|
|
66
|
+
canIndent(): false;
|
|
67
|
+
}
|
|
68
|
+
declare function $createFrontmatterNode(): FrontmatterNode;
|
|
69
|
+
declare function $isFrontmatterNode(node: LexicalNode | null | undefined): node is FrontmatterNode;
|
|
70
|
+
/**
|
|
71
|
+
* Markdown transformer for a leading YAML frontmatter block:
|
|
72
|
+
*
|
|
73
|
+
* ```
|
|
74
|
+
* ---
|
|
75
|
+
* name: my-skill
|
|
76
|
+
* description: ...
|
|
77
|
+
* ---
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* Import only claims the block when it's the very first thing in the document
|
|
81
|
+
* (frontmatter is defined as leading metadata); a `---` fence appearing later
|
|
82
|
+
* falls through to normal handling. Must be ordered before other multiline
|
|
83
|
+
* transformers so its `export` runs first for a FrontmatterNode.
|
|
84
|
+
*/
|
|
85
|
+
declare const FRONTMATTER: MultilineElementTransformer;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Markdown transformer for GFM tables. Adapted from the Lexical playground.
|
|
89
|
+
* Rows are matched line-by-line on import and stitched into a single
|
|
90
|
+
* TableNode; the divider row promotes the row above it to a header row.
|
|
91
|
+
* A `<!-- width: text; density: compact -->` settings line directly
|
|
92
|
+
* above the table (see tableSettings.ts) is consumed on import and
|
|
93
|
+
* re-emitted on export.
|
|
94
|
+
*/
|
|
95
|
+
declare const TABLE: ElementTransformer;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* List import/export companion to `@lexical/markdown`'s list transformers.
|
|
99
|
+
* On import it is a pre-pass: when a list line is reached it normalises the
|
|
100
|
+
* whole run of list lines that follows (never a fenced code block, which
|
|
101
|
+
* is consumed before its lines are seen) and then declines the match so
|
|
102
|
+
* the regular list transformers create the nodes. On export it claims
|
|
103
|
+
* every list first (multiline transformers export before element ones)
|
|
104
|
+
* and writes 2-space nesting.
|
|
105
|
+
*/
|
|
106
|
+
declare const LISTS: MultilineElementTransformer;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* `@lexical/markdown`'s CODE transformer, except that a block whose language
|
|
110
|
+
* is the highlighter's default (`plain`, assigned to every untagged block)
|
|
111
|
+
* exports as a bare ``` fence — markdown in, markdown out — and a fence
|
|
112
|
+
* info string beyond the language (```js title=a.js) is preserved instead
|
|
113
|
+
* of leaking into the code body.
|
|
114
|
+
*/
|
|
115
|
+
declare const CODE_BLOCK: MultilineElementTransformer;
|
|
116
|
+
|
|
117
|
+
export { $createFrontmatterNode, $isFrontmatterNode, $replaceMarkdown, CODE_BLOCK, EXTERNAL_UPDATE_TAG, FRONTMATTER, FrontmatterNode, LISTS, type SerializedFrontmatterNode, TABLE, codeTokenizer, editorNodeClassNames, mergeNodeClassNames, registerCodeBlockHighlighting, replaceMarkdown };
|
package/dist/lexical.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use client";import{b as e,c as o,e as t,f as r,g as a,h as b,i as D,k as h}from"./chunk-R5PL4Q7X.js";import{A as v,B as H,C as U,u as k,v as z,w as K,x as L,y as B}from"./chunk-3TZVOXWX.js";import{h as c,i as I,j as C,k as O,l as w,m as _,n as W,o as u,p as y,q as F,r as G,s as P}from"./chunk-N5JWZ2VW.js";import{a as X,b as j,c as q,d as J}from"./chunk-5VRVC56Y.js";import{c as Q,d as V,e as Y,f as Z,g as ee}from"./chunk-A7MCBSAZ.js";import{c as oe,d as te,e as re,f as ae,g as ne}from"./chunk-7Z3CW6Q3.js";import{a as p,b as $,e as f,f as g,g as R,h as E,k as x,l as A,m as S,n as M}from"./chunk-AGTPMKLK.js";import{g as n,h as d,i,j as m,k as l,l as s,m as N,n as T}from"./chunk-LDVPFZCN.js";import"./chunk-XRJNLGI4.js";import"./chunk-YFFSTMIR.js";export{z as $createDrawingNode,I as $createFrontmatterNode,te as $createImageNode,j as $createMentionNode,A as $deleteTableColumnAt,M as $deleteTableColumnNear,g as $deleteTableRowAt,E as $deleteTableRowNear,Y as $getCommentIds,V as $getMarkNodes,ae as $getSelectedImage,T as $getSelectedTable,p as $getSelectedTableCell,$ as $getTableCellPosition,s as $getTableDensity,n as $getTableSettings,m as $getTableWidth,x as $insertTableColumnAt,S as $insertTableColumnNear,f as $insertTableRowAt,R as $insertTableRowNear,K as $isDrawingNode,C as $isFrontmatterNode,re as $isImageNode,q as $isMentionNode,i as $isTableWidthExplicit,ee as $plainTextOffset,Z as $removeComment,r as $replaceMarkdown,N as $setTableDensity,d as $setTableSettings,l as $setTableWidth,W as CODE_BLOCK,Q as COMMENT,B as DIAGRAM,L as DRAWING,U as DRAWING_PRESET,v as DRAWING_PRESET_NODES,H as DRAWING_PRESET_TRANSFORMERS,k as DrawingNode,t as EXTERNAL_UPDATE_TAG,O as FRONTMATTER,c as FrontmatterNode,ne as IMAGE,oe as ImageNode,_ as LISTS,u as MARKDOWN_NODES,F as MARKDOWN_PRESET,y as MARKDOWN_TRANSFORMERS,J as MENTION,X as MentionNode,w as TABLE,e as codeTokenizer,h as createMarkdownEditor,b as editorNodeClassNames,D as mergeNodeClassNames,o as registerCodeBlockHighlighting,a as replaceMarkdown,G as resolveTransformers,P as shortcutTransformers};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { M as MarkdownEditorProps, E as EditorRootProps, a as EditorContent, T as ToolbarButton, b as ToolbarDivider, F as FormatButtons, B as BlockButtons, I as InsertButtons, H as HistoryButtons, O as OutlinePlugin, C as CharacterCount } from './table-grid-D70tNhp2.js';
|
|
2
|
+
export { D as DEFAULT_LABELS, c as DEFAULT_TABLE_SETTINGS, d as DeepPartial, e as EditorContentProps, f as EditorFieldProps, g as EditorLabels, h as EditorLabelsInput, i as EditorMode, j as TABLE_WIDTH_MARKER, k as TableCellPosition, l as TableDensity, m as TableSettings, n as TableSettingsOptions, o as Toolbar, p as ToolbarItems, q as canDeleteColumn, r as canDeleteRow, s as formatTableSettingsMarker, t as insertableColumnIndices, u as insertableRowIndices, v as parseTableSettingsMarker, w as resolveLabels, x as useEditorContext, y as useLabels } from './table-grid-D70tNhp2.js';
|
|
3
|
+
export { B as BUILTIN_CODE_LANGUAGES, a as BlockType, C as CODE_TOKEN_TYPES, b as CodeGrammar, c as CodeRule, d as CodeToken, e as CodeTokenType, f as CollapsibleHeadingsLabels, E as EDIT_LINK_COMMAND, M as MarkdownEditorApi, P as PLAIN_LANGUAGE, S as SAFE_LINK_PROTOCOLS, T as TOOLBAR_ITEM_ATTRIBUTE, g as TableColumnShortcutsLabels, h as TableRowShortcutsLabels, i as getCodeLanguages, j as hasCodeLanguage, k as isSafeUrl, r as registerCodeLanguage, l as resolveCodeLanguage, t as tokenizeCode, u as useMarkdownEditor, m as useToolbarKeyboard } from './index-A4S7bRwQ.js';
|
|
4
|
+
export { B as BLOCK_WIDTHS, a as BlockWidth, N as NewBlockWidths, i as isBlockWidth } from './presets-BtNPH0pa.js';
|
|
5
|
+
import * as react from 'react';
|
|
6
|
+
import 'lexical';
|
|
7
|
+
import '@lexical/table';
|
|
8
|
+
import '@lexical/rich-text';
|
|
9
|
+
import '@lexical/markdown';
|
|
10
|
+
|
|
11
|
+
declare const MarkdownEditor: {
|
|
12
|
+
({ placeholder, toolbar, outline, collapsible, showCharacterCount, children, ...rootProps }: MarkdownEditorProps): react.ReactElement;
|
|
13
|
+
Root: (props: Omit<EditorRootProps, "preset">) => react.ReactElement;
|
|
14
|
+
Content: typeof EditorContent;
|
|
15
|
+
Toolbar: ({ children, className, }: Readonly<{
|
|
16
|
+
children?: react.ReactNode;
|
|
17
|
+
className?: string;
|
|
18
|
+
}>) => react.ReactElement | null;
|
|
19
|
+
ToolbarButton: typeof ToolbarButton;
|
|
20
|
+
ToolbarDivider: typeof ToolbarDivider;
|
|
21
|
+
FormatButtons: typeof FormatButtons;
|
|
22
|
+
BlockButtons: typeof BlockButtons;
|
|
23
|
+
InsertButtons: typeof InsertButtons;
|
|
24
|
+
HistoryButtons: typeof HistoryButtons;
|
|
25
|
+
Outline: typeof OutlinePlugin;
|
|
26
|
+
CharacterCount: typeof CharacterCount;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { BlockButtons, CharacterCount, EditorRootProps, FormatButtons, HistoryButtons, InsertButtons, MarkdownEditor, MarkdownEditorProps, ToolbarButton, ToolbarDivider };
|
package/dist/markdown.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use client";import"./chunk-TGVEPLDM.js";import{a as t,d as E,j as q,k as r}from"./chunk-R5PL4Q7X.js";import{a as e,b as i,d as m,e as p,f as d,g as n,q as o,v,w as y}from"./chunk-N5JWZ2VW.js";import{c as A,d as D,i as K,j as N,o as O,p as T,q as W,r as _,s as b,t as g,u as h,v as j}from"./chunk-AGTPMKLK.js";import{b as M,c as k,d as s,e as w,f as x,o as R,p as l,q as u,t as P,u as S}from"./chunk-LDVPFZCN.js";import{a,b as c,c as f}from"./chunk-YFFSTMIR.js";var F=r(o);export{v as BLOCK_WIDTHS,e as BUILTIN_CODE_LANGUAGES,g as BlockButtons,E as CODE_TOKEN_TYPES,q as CharacterCount,k as DEFAULT_LABELS,x as DEFAULT_TABLE_SETTINGS,c as EDIT_LINK_COMMAND,b as FormatButtons,j as HistoryButtons,h as InsertButtons,F as MarkdownEditor,i as PLAIN_LANGUAGE,a as SAFE_LINK_PROTOCOLS,R as TABLE_WIDTH_MARKER,P as TOOLBAR_ITEM_ATTRIBUTE,T as Toolbar,_ as ToolbarButton,W as ToolbarDivider,N as canDeleteColumn,D as canDeleteRow,u as formatTableSettingsMarker,n as getCodeLanguages,p as hasCodeLanguage,K as insertableColumnIndices,A as insertableRowIndices,y as isBlockWidth,f as isSafeUrl,l as parseTableSettingsMarker,m as registerCodeLanguage,d as resolveCodeLanguage,s as resolveLabels,t as tokenizeCode,M as useEditorContext,w as useLabels,O as useMarkdownEditor,S as useToolbarKeyboard};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { TextNode, NodeKey, Spread, SerializedTextNode, EditorConfig, DOMExportOutput, DOMConversionMap, LexicalNode } from 'lexical';
|
|
2
|
+
import { TextMatchTransformer } from '@lexical/markdown';
|
|
3
|
+
|
|
4
|
+
type SerializedMentionNode = Spread<{
|
|
5
|
+
mentionId: string;
|
|
6
|
+
mentionName: string;
|
|
7
|
+
trigger: string;
|
|
8
|
+
}, SerializedTextNode>;
|
|
9
|
+
/**
|
|
10
|
+
* An inline reference to a person, page or tag: `@name` in the document,
|
|
11
|
+
* `[@name](mention:id)` in markdown. A token text node: the caret cannot
|
|
12
|
+
* enter it, Backspace removes it whole and its text is the trigger plus the
|
|
13
|
+
* name (so plain-text export reads naturally).
|
|
14
|
+
*/
|
|
15
|
+
declare class MentionNode extends TextNode {
|
|
16
|
+
__id: string;
|
|
17
|
+
__name: string;
|
|
18
|
+
__trigger: string;
|
|
19
|
+
static getType(): string;
|
|
20
|
+
static clone(node: MentionNode): MentionNode;
|
|
21
|
+
constructor(id: string, name: string, trigger?: string, key?: NodeKey);
|
|
22
|
+
static importJSON(json: SerializedMentionNode): MentionNode;
|
|
23
|
+
exportJSON(): SerializedMentionNode;
|
|
24
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
25
|
+
exportDOM(): DOMExportOutput;
|
|
26
|
+
static importDOM(): DOMConversionMap | null;
|
|
27
|
+
getMentionId(): string;
|
|
28
|
+
getMentionName(): string;
|
|
29
|
+
getTrigger(): string;
|
|
30
|
+
canInsertTextBefore(): boolean;
|
|
31
|
+
canInsertTextAfter(): boolean;
|
|
32
|
+
isTextEntity(): true;
|
|
33
|
+
}
|
|
34
|
+
declare function $createMentionNode(id: string, name: string, trigger?: string): MentionNode;
|
|
35
|
+
declare function $isMentionNode(node: LexicalNode | null | undefined): node is MentionNode;
|
|
36
|
+
/**
|
|
37
|
+
* Markdown transformer for mentions. Export writes `[<trigger><name>](mention:<id>)`,
|
|
38
|
+
* a link other renderers show as plain text with a `mention:` href; import
|
|
39
|
+
* (and typing the closing `)`) turns it back into a `MentionNode`. Put it
|
|
40
|
+
* before the built-ins so it claims the syntax ahead of `LINK`.
|
|
41
|
+
*/
|
|
42
|
+
declare const MENTION: TextMatchTransformer;
|
|
43
|
+
|
|
44
|
+
export { $createMentionNode as $, MENTION as M, type SerializedMentionNode as S, $isMentionNode as a, MentionNode as b };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ReactNode, ReactElement } from 'react';
|
|
2
|
+
import { LexicalCommand } from 'lexical';
|
|
3
|
+
|
|
4
|
+
type MentionItem = Readonly<{
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
/** Secondary text shown after the name (a handle, a team, a path) */
|
|
8
|
+
hint?: string;
|
|
9
|
+
}>;
|
|
10
|
+
type MentionRenderState = Readonly<{
|
|
11
|
+
active: boolean;
|
|
12
|
+
query: string;
|
|
13
|
+
trigger: string;
|
|
14
|
+
}>;
|
|
15
|
+
type MentionTrigger = Readonly<{
|
|
16
|
+
/** One character that opens the menu, typed at the start of a word (`'@'`, `'#'`) */
|
|
17
|
+
trigger: string;
|
|
18
|
+
/** Items for the text typed after the trigger; called again on every keystroke */
|
|
19
|
+
search: (query: string) => Promise<readonly MentionItem[]>;
|
|
20
|
+
/** Custom option body; the option element, its role and selection state are the plugin's */
|
|
21
|
+
render?: (item: MentionItem, state: MentionRenderState) => ReactNode;
|
|
22
|
+
}>;
|
|
23
|
+
type MentionsLabels = Readonly<{
|
|
24
|
+
/** `aria-label` of the listbox */
|
|
25
|
+
suggestions: (trigger: string) => string;
|
|
26
|
+
noResults: string;
|
|
27
|
+
loading: string;
|
|
28
|
+
}>;
|
|
29
|
+
declare const DEFAULT_MENTIONS_LABELS: MentionsLabels;
|
|
30
|
+
type InsertMentionPayload = Readonly<{
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
trigger?: string;
|
|
34
|
+
}>;
|
|
35
|
+
/** Inserts a mention at the selection (replacing any selected text) */
|
|
36
|
+
declare const INSERT_MENTION_COMMAND: LexicalCommand<InsertMentionPayload>;
|
|
37
|
+
type MentionsPluginProps = Readonly<{
|
|
38
|
+
/** The single trigger's character (default `'@'`); ignored when `triggers` is given */
|
|
39
|
+
trigger?: string;
|
|
40
|
+
/** The single trigger's search */
|
|
41
|
+
search?: MentionTrigger['search'];
|
|
42
|
+
/** The single trigger's option renderer */
|
|
43
|
+
render?: MentionTrigger['render'];
|
|
44
|
+
/** Several triggers, each with its own search (`@` people, `#` tags) */
|
|
45
|
+
triggers?: readonly MentionTrigger[];
|
|
46
|
+
/** At most this many options are listed (default 8) */
|
|
47
|
+
maxItems?: number;
|
|
48
|
+
labels?: Partial<MentionsLabels>;
|
|
49
|
+
/** Called after a mention was inserted */
|
|
50
|
+
onSelect?: (item: MentionItem, trigger: string) => void;
|
|
51
|
+
}>;
|
|
52
|
+
type MentionMatch = Readonly<{
|
|
53
|
+
trigger: string;
|
|
54
|
+
query: string;
|
|
55
|
+
/** Offset of the trigger character in the text node */
|
|
56
|
+
from: number;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* The trigger + query ending at `offset` in `text`, or `null`. The trigger
|
|
60
|
+
* must start a word (start of text, or after whitespace or an opening
|
|
61
|
+
* bracket) and the query has no whitespace.
|
|
62
|
+
*/
|
|
63
|
+
declare function findMentionMatch(text: string, offset: number, triggers: readonly string[]): MentionMatch | null;
|
|
64
|
+
/**
|
|
65
|
+
* Typeahead mentions. Typing a trigger character opens a listbox of the
|
|
66
|
+
* `search` results under the caret; arrows move, Enter or Tab inserts the
|
|
67
|
+
* highlighted item as a `MentionNode` followed by a space, Escape closes.
|
|
68
|
+
* The surface gets `aria-activedescendant` and `aria-controls` while the
|
|
69
|
+
* list is open. Requires `MentionNode` in `nodes` and `MENTION` in
|
|
70
|
+
* `transformers`.
|
|
71
|
+
*/
|
|
72
|
+
declare function MentionsPlugin({ trigger, search, render, triggers, maxItems, labels: labelsProp, onSelect, }: MentionsPluginProps): ReactElement | null;
|
|
73
|
+
|
|
74
|
+
export { DEFAULT_MENTIONS_LABELS as D, INSERT_MENTION_COMMAND as I, type MentionItem as M, type InsertMentionPayload as a, type MentionMatch as b, type MentionRenderState as c, type MentionTrigger as d, type MentionsLabels as e, MentionsPlugin as f, type MentionsPluginProps as g, findMentionMatch as h };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { $ as $createMentionNode, a as $isMentionNode, M as MENTION, b as MentionNode, S as SerializedMentionNode } from './mention-node-eSsjUpaE.js';
|
|
2
|
+
export { D as DEFAULT_MENTIONS_LABELS, I as INSERT_MENTION_COMMAND, a as InsertMentionPayload, M as MentionItem, b as MentionMatch, c as MentionRenderState, d as MentionTrigger, e as MentionsLabels, f as MentionsPlugin, g as MentionsPluginProps, h as findMentionMatch } from './mentions-plugin-gio3_XKd.js';
|
|
3
|
+
import 'lexical';
|
|
4
|
+
import '@lexical/markdown';
|
|
5
|
+
import 'react';
|
package/dist/mentions.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use client";import{a as i,b as M,c as r,d as s}from"./chunk-XP3MZRCW.js";import{a as e,b as n,c as o,d as t}from"./chunk-5VRVC56Y.js";import"./chunk-SDICQI2B.js";import"./chunk-XRJNLGI4.js";export{n as $createMentionNode,o as $isMentionNode,i as DEFAULT_MENTIONS_LABELS,M as INSERT_MENTION_COMMAND,t as MENTION,e as MentionNode,s as MentionsPlugin,r as findMentionMatch};
|