@haklex/rich-editor 0.0.38 → 0.0.40
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/dist/{RichEditor-B9KIgSwn.js → RichEditor-DnJwe663.js} +582 -18
- package/dist/components/RichEditor.d.ts.map +1 -1
- package/dist/components/decorators/AlertEditDecorator.d.ts.map +1 -1
- package/dist/components/decorators/CodeBlockEditDecorator.d.ts.map +1 -1
- package/dist/components/renderers/CodeBlockRenderer.d.ts +5 -0
- package/dist/components/renderers/CodeBlockRenderer.d.ts.map +1 -1
- package/dist/editor.mjs +2 -2
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +198 -35
- package/dist/nodes/CodeBlockEditNode.d.ts +9 -0
- package/dist/nodes/CodeBlockEditNode.d.ts.map +1 -1
- package/dist/nodes/CodeBlockNode.d.ts +1 -0
- package/dist/nodes/CodeBlockNode.d.ts.map +1 -1
- package/dist/nodes/MentionNode.d.ts +2 -0
- package/dist/nodes/MentionNode.d.ts.map +1 -1
- package/dist/plugins/BlockExitPlugin.d.ts +2 -0
- package/dist/plugins/BlockExitPlugin.d.ts.map +1 -0
- package/dist/plugins/BlockIdPlugin.d.ts +3 -0
- package/dist/plugins/BlockIdPlugin.d.ts.map +1 -0
- package/dist/rich-editor.css +1 -1
- package/dist/static-entry.mjs +1 -1
- package/dist/{theme-D1COY7pa.js → theme-gVNBI_ET.js} +79 -50
- package/dist/transformers/code-block.d.ts +3 -0
- package/dist/transformers/code-block.d.ts.map +1 -0
- package/dist/transformers/index.d.ts +1 -0
- package/dist/transformers/index.d.ts.map +1 -1
- package/dist/transformers/quote.d.ts +3 -0
- package/dist/transformers/quote.d.ts.map +1 -0
- package/dist/utils/codeBlockSelectionIntent.d.ts +4 -0
- package/dist/utils/codeBlockSelectionIntent.d.ts.map +1 -0
- package/dist/utils/comment-anchor.d.ts +32 -0
- package/dist/utils/comment-anchor.d.ts.map +1 -0
- package/package.json +5 -5
package/dist/static-entry.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C, F, N, R, d, a, b, e, c, f, g, u, h, i, j, k, l, m, n } from "./theme-
|
|
1
|
+
import { C, F, N, R, d, a, b, e, c, f, g, u, h, i, j, k, l, m, n } from "./theme-gVNBI_ET.js";
|
|
2
2
|
import { a as a2, c as c2, g as g2, n as n2 } from "./utils-fpeaZV1R.js";
|
|
3
3
|
import { r } from "./shared.css-BqX4HjVE.js";
|
|
4
4
|
import { articleTheme, commentTheme, noteTheme, vars } from "@haklex/rich-style-token";
|
|
@@ -7,7 +7,7 @@ import { LinkNode, AutoLinkNode } from "@lexical/link";
|
|
|
7
7
|
import { ListNode, ListItemNode } from "@lexical/list";
|
|
8
8
|
import { HeadingNode, QuoteNode } from "@lexical/rich-text";
|
|
9
9
|
import { TableNode, TableCellNode, TableRowNode } from "@lexical/table";
|
|
10
|
-
import { DecoratorNode, $insertNodes, ElementNode, createCommand, $getNodeByKey } from "lexical";
|
|
10
|
+
import { DecoratorNode, $insertNodes, ElementNode, createCommand, $getSelection, $isRangeSelection, $getNodeByKey } from "lexical";
|
|
11
11
|
import { createContext, use, useMemo, createElement, useState, useRef, useEffect, useCallback } from "react";
|
|
12
12
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
13
13
|
import { OctagonAlert, TriangleAlert, MessageSquareWarning, Lightbulb, Info, Code, ChevronRight, ImageIcon, Sigma, Link, Workflow, Video } from "lucide-react";
|
|
@@ -484,6 +484,9 @@ const _CodeBlockNode = class _CodeBlockNode extends DecoratorNode {
|
|
|
484
484
|
isInline() {
|
|
485
485
|
return false;
|
|
486
486
|
}
|
|
487
|
+
isKeyboardSelectable() {
|
|
488
|
+
return true;
|
|
489
|
+
}
|
|
487
490
|
static importJSON(serializedNode) {
|
|
488
491
|
return $createCodeBlockNode(serializedNode.code, serializedNode.language);
|
|
489
492
|
}
|
|
@@ -1802,7 +1805,7 @@ function MentionRenderer({ handle, displayName }) {
|
|
|
1802
1805
|
label
|
|
1803
1806
|
] }) });
|
|
1804
1807
|
}
|
|
1805
|
-
class
|
|
1808
|
+
const _MentionNode = class _MentionNode extends DecoratorNode {
|
|
1806
1809
|
constructor(platform, handle, displayName, key) {
|
|
1807
1810
|
super(key);
|
|
1808
1811
|
__publicField(this, "__platform");
|
|
@@ -1816,7 +1819,7 @@ class MentionNode extends DecoratorNode {
|
|
|
1816
1819
|
return "mention";
|
|
1817
1820
|
}
|
|
1818
1821
|
static clone(node) {
|
|
1819
|
-
return new
|
|
1822
|
+
return new _MentionNode(
|
|
1820
1823
|
node.__platform,
|
|
1821
1824
|
node.__handle,
|
|
1822
1825
|
node.__displayName,
|
|
@@ -1869,10 +1872,35 @@ class MentionNode extends DecoratorNode {
|
|
|
1869
1872
|
displayName: this.__displayName
|
|
1870
1873
|
});
|
|
1871
1874
|
}
|
|
1872
|
-
}
|
|
1875
|
+
};
|
|
1876
|
+
__publicField(_MentionNode, "slashMenuItems", [
|
|
1877
|
+
{
|
|
1878
|
+
title: "Mention",
|
|
1879
|
+
icon: createElement(
|
|
1880
|
+
"span",
|
|
1881
|
+
{ style: { fontSize: 16, fontWeight: 700 } },
|
|
1882
|
+
"@"
|
|
1883
|
+
),
|
|
1884
|
+
description: "Mention a social account",
|
|
1885
|
+
keywords: ["mention", "at", "@", "github", "twitter"],
|
|
1886
|
+
section: "INLINE",
|
|
1887
|
+
onSelect: (editor) => {
|
|
1888
|
+
editor.update(() => {
|
|
1889
|
+
const selection = $getSelection();
|
|
1890
|
+
if ($isRangeSelection(selection)) {
|
|
1891
|
+
selection.insertText("@");
|
|
1892
|
+
}
|
|
1893
|
+
});
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
]);
|
|
1897
|
+
let MentionNode = _MentionNode;
|
|
1873
1898
|
function $createMentionNode(platform, handle, displayName) {
|
|
1874
1899
|
return new MentionNode(platform, handle, displayName);
|
|
1875
1900
|
}
|
|
1901
|
+
function $isMentionNode(node) {
|
|
1902
|
+
return node instanceof MentionNode;
|
|
1903
|
+
}
|
|
1876
1904
|
function MermaidRenderer({ content }) {
|
|
1877
1905
|
return /* @__PURE__ */ jsx("div", { className: "rich-mermaid-block", children: /* @__PURE__ */ jsx("pre", { children: /* @__PURE__ */ jsx("code", { children: content }) }) });
|
|
1878
1906
|
}
|
|
@@ -2200,49 +2228,50 @@ const editorTheme = {
|
|
|
2200
2228
|
};
|
|
2201
2229
|
export {
|
|
2202
2230
|
$createFootnoteSectionNode as $,
|
|
2203
|
-
|
|
2204
|
-
|
|
2231
|
+
$isMentionNode as A,
|
|
2232
|
+
$isMermaidNode as B,
|
|
2205
2233
|
ColorSchemeProvider as C,
|
|
2206
|
-
|
|
2207
|
-
|
|
2234
|
+
ALERT_LABELS as D,
|
|
2235
|
+
ALERT_TYPES as E,
|
|
2208
2236
|
FootnoteDefinitionsProvider as F,
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2237
|
+
BANNER_LABELS as G,
|
|
2238
|
+
BANNER_TYPES as H,
|
|
2239
|
+
FootnoteSectionNode as I,
|
|
2240
|
+
FootnoteStaticRenderer as J,
|
|
2241
|
+
GridContainerNode as K,
|
|
2242
|
+
ImageNode as L,
|
|
2243
|
+
KaTeXBlockNode as M,
|
|
2216
2244
|
NestedContentRendererProvider as N,
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2245
|
+
KaTeXInlineNode as O,
|
|
2246
|
+
KaTeXRenderer as P,
|
|
2247
|
+
LinkCardNode as Q,
|
|
2220
2248
|
RendererConfigProvider as R,
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2249
|
+
LinkCardRenderer as S,
|
|
2250
|
+
MentionNode as T,
|
|
2251
|
+
MermaidNode as U,
|
|
2252
|
+
OPEN_IMAGE_UPLOAD_DIALOG_COMMAND as V,
|
|
2253
|
+
computeImageMeta as W,
|
|
2254
|
+
decodeThumbHash as X,
|
|
2255
|
+
$isAlertQuoteNode as Y,
|
|
2256
|
+
AlertRenderer as Z,
|
|
2257
|
+
SpoilerNode as _,
|
|
2230
2258
|
allNodes as a,
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
$
|
|
2243
|
-
$
|
|
2244
|
-
$
|
|
2245
|
-
$
|
|
2259
|
+
FootnoteNode as a0,
|
|
2260
|
+
AlertQuoteNode as a1,
|
|
2261
|
+
$isBannerNode as a2,
|
|
2262
|
+
BannerRenderer as a3,
|
|
2263
|
+
BannerNode as a4,
|
|
2264
|
+
normalizeBannerType as a5,
|
|
2265
|
+
$isCodeBlockNode as a6,
|
|
2266
|
+
CodeBlockRenderer as a7,
|
|
2267
|
+
CodeBlockNode as a8,
|
|
2268
|
+
VideoNode as a9,
|
|
2269
|
+
DetailsNode as aa,
|
|
2270
|
+
$createKaTeXInlineNode as ab,
|
|
2271
|
+
$createKaTeXBlockNode as ac,
|
|
2272
|
+
$createDetailsNode as ad,
|
|
2273
|
+
$createFootnoteNode as ae,
|
|
2274
|
+
$createSpoilerNode as af,
|
|
2246
2275
|
builtinNodes as b,
|
|
2247
2276
|
customNodes as c,
|
|
2248
2277
|
RendererWrapper as d,
|
|
@@ -2259,13 +2288,13 @@ export {
|
|
|
2259
2288
|
$createGridContainerNode as o,
|
|
2260
2289
|
$createImageNode as p,
|
|
2261
2290
|
$createLinkCardNode as q,
|
|
2262
|
-
$
|
|
2263
|
-
$
|
|
2264
|
-
$
|
|
2291
|
+
$createMentionNode as r,
|
|
2292
|
+
$createMermaidNode as s,
|
|
2293
|
+
$isFootnoteSectionNode as t,
|
|
2265
2294
|
useColorScheme as u,
|
|
2266
|
-
$
|
|
2267
|
-
$
|
|
2268
|
-
$
|
|
2269
|
-
$
|
|
2270
|
-
$
|
|
2295
|
+
$isGridContainerNode as v,
|
|
2296
|
+
$isImageNode as w,
|
|
2297
|
+
$isKaTeXBlockNode as x,
|
|
2298
|
+
$isKaTeXInlineNode as y,
|
|
2299
|
+
$isLinkCardNode as z
|
|
2271
2300
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-block.d.ts","sourceRoot":"","sources":["../../src/transformers/code-block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAA;AAapE,eAAO,MAAM,gCAAgC,EAAE,2BA2B9C,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const ALL_TRANSFORMERS: import('@lexical/markdown').Transformer[];
|
|
2
2
|
export { GIT_ALERT_TRANSFORMER } from './alert';
|
|
3
|
+
export { CODE_BLOCK_MULTILINE_TRANSFORMER } from './code-block';
|
|
3
4
|
export { CONTAINER_TRANSFORMER } from './container';
|
|
4
5
|
export { FOOTNOTE_SECTION_TRANSFORMER, FOOTNOTE_TRANSFORMER } from './footnote';
|
|
5
6
|
export { INSERT_TRANSFORMER } from './insert';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transformers/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transformers/index.ts"],"names":[],"mappings":"AA0BA,eAAO,MAAM,gBAAgB,2CA0B5B,CAAA;AAED,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAC/C,OAAO,EAAE,gCAAgC,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACnD,OAAO,EAAE,4BAA4B,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EACL,2BAA2B,EAC3B,gCAAgC,EAChC,iCAAiC,EACjC,uBAAuB,EACvB,2BAA2B,EAC3B,yBAAyB,EACzB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EACL,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,yBAAyB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../../src/transformers/quote.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAI3D,eAAO,MAAM,iBAAiB,EAAE,kBAkC/B,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type CodeBlockCursorPlacement = 'start' | 'end';
|
|
2
|
+
export declare function setCodeBlockCursorIntent(nodeKey: string, placement: CodeBlockCursorPlacement): void;
|
|
3
|
+
export declare function consumeCodeBlockCursorIntent(nodeKey: string): CodeBlockCursorPlacement | null;
|
|
4
|
+
//# sourceMappingURL=codeBlockSelectionIntent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codeBlockSelectionIntent.d.ts","sourceRoot":"","sources":["../../src/utils/codeBlockSelectionIntent.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,wBAAwB,GAAG,OAAO,GAAG,KAAK,CAAA;AAItD,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,wBAAwB,QAGpC;AAED,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,MAAM,GACd,wBAAwB,GAAG,IAAI,CAKjC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { LexicalEditor } from 'lexical';
|
|
2
|
+
export interface BlockAnchor {
|
|
3
|
+
mode: 'block';
|
|
4
|
+
blockId: string;
|
|
5
|
+
blockType: string;
|
|
6
|
+
blockFingerprint: string;
|
|
7
|
+
snapshotText: string;
|
|
8
|
+
}
|
|
9
|
+
export interface RangeAnchor {
|
|
10
|
+
mode: 'range';
|
|
11
|
+
blockId: string;
|
|
12
|
+
blockType: string;
|
|
13
|
+
blockFingerprint: string;
|
|
14
|
+
snapshotText: string;
|
|
15
|
+
quote: string;
|
|
16
|
+
prefix: string;
|
|
17
|
+
suffix: string;
|
|
18
|
+
startOffset: number;
|
|
19
|
+
endOffset: number;
|
|
20
|
+
}
|
|
21
|
+
export type CommentAnchor = BlockAnchor | RangeAnchor;
|
|
22
|
+
export type AnchorError = 'no-selection' | 'cross-block' | 'collapsed' | 'no-block-id' | 'not-root-block';
|
|
23
|
+
export type AnchorResult<T> = {
|
|
24
|
+
ok: true;
|
|
25
|
+
anchor: T;
|
|
26
|
+
} | {
|
|
27
|
+
ok: false;
|
|
28
|
+
error: AnchorError;
|
|
29
|
+
};
|
|
30
|
+
export declare function buildBlockAnchor(editor: LexicalEditor, blockKey?: string): AnchorResult<BlockAnchor>;
|
|
31
|
+
export declare function buildRangeAnchor(editor: LexicalEditor): AnchorResult<RangeAnchor>;
|
|
32
|
+
//# sourceMappingURL=comment-anchor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comment-anchor.d.ts","sourceRoot":"","sources":["../../src/utils/comment-anchor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EAGd,MAAM,SAAS,CAAA;AAahB,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,EAAE,MAAM,CAAA;IACxB,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,EAAE,MAAM,CAAA;IACxB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,WAAW,CAAA;AAErD,MAAM,MAAM,WAAW,GACnB,cAAc,GACd,aAAa,GACb,WAAW,GACX,aAAa,GACb,gBAAgB,CAAA;AAEpB,MAAM,MAAM,YAAY,CAAC,CAAC,IACtB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,CAAC,CAAA;CAAE,GACvB;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,CAAA;AAgGrC,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,aAAa,EACrB,QAAQ,CAAC,EAAE,MAAM,GAChB,YAAY,CAAC,WAAW,CAAC,CAyB3B;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,aAAa,GACpB,YAAY,CAAC,WAAW,CAAC,CAmE3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haklex/rich-editor",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.40",
|
|
4
4
|
"description": "Core rich text editor based on Lexical",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"thumbhash": "^0.1.1",
|
|
32
|
-
"@haklex/rich-editor-ui": "0.0.
|
|
33
|
-
"@haklex/rich-
|
|
34
|
-
"@haklex/rich-
|
|
32
|
+
"@haklex/rich-editor-ui": "0.0.40",
|
|
33
|
+
"@haklex/rich-style-token": "0.0.40",
|
|
34
|
+
"@haklex/rich-headless": "0.0.40"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@base-ui/react": "^1.2.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"lucide-react": "^0.574.0",
|
|
53
53
|
"react": "^19.2.4",
|
|
54
54
|
"react-dom": "^19.2.4",
|
|
55
|
-
"shiki": "^3.
|
|
55
|
+
"shiki": "^3.23.0",
|
|
56
56
|
"typescript": "^5.9.3",
|
|
57
57
|
"vite": "^7.3.1",
|
|
58
58
|
"vite-plugin-dts": "^4.5.4"
|