@lobehub/editor 4.3.2 → 4.5.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/es/locale/index.d.ts +2 -0
- package/es/locale/index.js +2 -0
- package/es/plugins/common/react/ReactPlainText.js +7 -2
- package/es/plugins/common/react/type.d.ts +11 -1
- package/es/plugins/markdown/command/index.d.ts +2 -2
- package/es/plugins/markdown/command/index.js +13 -20
- package/es/plugins/markdown/plugin/index.d.ts +11 -1
- package/es/plugins/markdown/plugin/index.js +175 -98
- package/es/plugins/markdown/react/index.js +8 -42
- package/es/react/Editor/Editor.js +7 -2
- package/es/react/Editor/type.d.ts +11 -1
- package/es/renderer/LexicalDiff.d.ts +22 -0
- package/es/renderer/LexicalDiff.js +116 -0
- package/es/renderer/diff/compute.d.ts +3 -0
- package/es/renderer/diff/compute.js +510 -0
- package/es/renderer/diff/style.d.ts +13 -0
- package/es/renderer/diff/style.js +20 -0
- package/es/renderer/diff/types.d.ts +28 -0
- package/es/renderer/diff/types.js +1 -0
- package/es/renderer/index.d.ts +3 -0
- package/es/renderer/index.js +1 -0
- package/es/renderer/renderers/codeblock.js +5 -0
- package/es/renderer/renderers/mermaid.d.ts +2 -0
- package/es/renderer/renderers/mermaid.js +18 -0
- package/es/types/kernel.d.ts +6 -4
- package/package.json +2 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
|
|
2
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
3
|
+
import { createStaticStyles } from 'antd-style';
|
|
4
|
+
export var styles = createStaticStyles(function (_ref) {
|
|
5
|
+
var css = _ref.css,
|
|
6
|
+
cssVar = _ref.cssVar;
|
|
7
|
+
return {
|
|
8
|
+
body: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n background: ", ";\n "])), cssVar.colorBgContainer),
|
|
9
|
+
cell: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n overflow: auto;\n min-width: 0;\n min-height: 24px;\n\n > div {\n width: 100%;\n min-width: 0;\n }\n "]))),
|
|
10
|
+
cellOld: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral([""]))),
|
|
11
|
+
deleteCell: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n background: color-mix(in srgb, ", " 10%, transparent);\n "])), cssVar.colorError),
|
|
12
|
+
emptyCell: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n background: ", ";\n "])), cssVar.colorFillQuaternary),
|
|
13
|
+
header: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n display: grid;\n grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);\n border-block-end: 1px solid ", ";\n background: ", ";\n "])), cssVar.colorBorderSecondary, cssVar.colorFillQuaternary),
|
|
14
|
+
headerCell: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n padding-block: 8px;\n padding-inline: 16px;\n\n font-size: 12px;\n font-weight: 600;\n color: ", ";\n text-transform: uppercase;\n letter-spacing: 0.05em;\n "])), cssVar.colorTextSecondary),
|
|
15
|
+
headerOld: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n border-inline-end: 1px solid ", ";\n "])), cssVar.colorBorderSecondary),
|
|
16
|
+
insertCell: css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n background: color-mix(in srgb, ", " 10%, transparent);\n "])), cssVar.colorSuccess),
|
|
17
|
+
root: css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n overflow: hidden;\n\n border: 1px solid ", ";\n border-radius: ", ";\n\n font-size: 14px;\n\n background: ", ";\n "])), cssVar.colorBorderSecondary, cssVar.borderRadiusSM, cssVar.colorBgContainer),
|
|
18
|
+
row: css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n display: grid;\n grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);\n "])))
|
|
19
|
+
};
|
|
20
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { SerializedLexicalNode } from 'lexical';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
export type LexicalDiffRowKind = 'delete' | 'equal' | 'insert' | 'modify';
|
|
4
|
+
export interface LexicalDiffCell {
|
|
5
|
+
baseBlockType: string | null;
|
|
6
|
+
block: SerializedLexicalNode | null;
|
|
7
|
+
blockType: string | null;
|
|
8
|
+
}
|
|
9
|
+
export interface LexicalDiffRow {
|
|
10
|
+
kind: LexicalDiffRowKind;
|
|
11
|
+
newCell: LexicalDiffCell | null;
|
|
12
|
+
oldCell: LexicalDiffCell | null;
|
|
13
|
+
}
|
|
14
|
+
export interface LexicalDiffBlockRenderContext {
|
|
15
|
+
baseBlockType: string | null;
|
|
16
|
+
blockType: string | null;
|
|
17
|
+
newBaseBlockType: string | null;
|
|
18
|
+
newBlockType: string | null;
|
|
19
|
+
oldBaseBlockType: string | null;
|
|
20
|
+
oldBlockType: string | null;
|
|
21
|
+
renderDefaultNew: () => ReactNode;
|
|
22
|
+
renderDefaultOld: () => ReactNode;
|
|
23
|
+
row: LexicalDiffRow;
|
|
24
|
+
}
|
|
25
|
+
export type LexicalDiffBlockRenderer = (context: LexicalDiffBlockRenderContext) => {
|
|
26
|
+
new?: ReactNode;
|
|
27
|
+
old?: ReactNode;
|
|
28
|
+
} | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/es/renderer/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
export type { LexicalDiffBlockRenderContext, LexicalDiffBlockRenderer, LexicalDiffCell, LexicalDiffRow, LexicalDiffRowKind, } from './diff/types';
|
|
1
2
|
export { loadLanguage } from './engine/shiki';
|
|
3
|
+
export type { LexicalDiffProps } from './LexicalDiff';
|
|
4
|
+
export { LexicalDiff } from './LexicalDiff';
|
|
2
5
|
export { LexicalRenderer } from './LexicalRenderer';
|
|
3
6
|
export { rendererNodes } from './nodes';
|
|
4
7
|
export { createDefaultRenderers } from './renderers';
|
package/es/renderer/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import { createStaticStyles } from 'antd-style';
|
|
|
13
13
|
import { Check, ChevronDown, ChevronRight, CopyIcon } from 'lucide-react';
|
|
14
14
|
import { useCallback, useState } from 'react';
|
|
15
15
|
import { highlightCode } from "../engine/shiki";
|
|
16
|
+
import { renderMermaidBlock } from "./mermaid";
|
|
16
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
18
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
19
|
var useStyles = createStaticStyles(function (_ref) {
|
|
@@ -150,6 +151,10 @@ function CodeBlockRenderer(_ref3) {
|
|
|
150
151
|
});
|
|
151
152
|
}
|
|
152
153
|
export function renderCodeBlock(node, key, children) {
|
|
154
|
+
var language = (node.language || '').toLowerCase();
|
|
155
|
+
if (language === 'mermaid') {
|
|
156
|
+
return renderMermaidBlock(node, key);
|
|
157
|
+
}
|
|
153
158
|
return /*#__PURE__*/_jsx(CodeBlockRenderer, {
|
|
154
159
|
codeChildren: children,
|
|
155
160
|
node: node
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Mermaid } from '@lobehub/ui';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
export function renderMermaidBlock(node, key) {
|
|
6
|
+
var code = node.code || '';
|
|
7
|
+
return /*#__PURE__*/_jsx(Mermaid, {
|
|
8
|
+
animated: false,
|
|
9
|
+
defaultExpand: true,
|
|
10
|
+
fullFeatured: true,
|
|
11
|
+
style: {
|
|
12
|
+
width: '100%'
|
|
13
|
+
},
|
|
14
|
+
theme: "lobe-theme",
|
|
15
|
+
variant: "filled",
|
|
16
|
+
children: code
|
|
17
|
+
}, key);
|
|
18
|
+
}
|
package/es/types/kernel.d.ts
CHANGED
|
@@ -57,6 +57,8 @@ export interface IKernelEventMap {
|
|
|
57
57
|
cacheState: EditorState;
|
|
58
58
|
historyState: HistoryStateEntry | null;
|
|
59
59
|
markdown: string;
|
|
60
|
+
matchedPatterns: string[];
|
|
61
|
+
score: number;
|
|
60
62
|
}) => void;
|
|
61
63
|
/**
|
|
62
64
|
* handle paste event
|
|
@@ -93,6 +95,10 @@ export interface IEditor {
|
|
|
93
95
|
* Get editor content of specified type
|
|
94
96
|
*/
|
|
95
97
|
getDocument(type: string): DataSource | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Lexical history state (undo stack metadata)
|
|
100
|
+
*/
|
|
101
|
+
getHistoryState(): HistoryState;
|
|
96
102
|
/**
|
|
97
103
|
* Get Lexical editor instance
|
|
98
104
|
*/
|
|
@@ -249,10 +255,6 @@ export interface IEditorKernel extends IEditor {
|
|
|
249
255
|
* @param name
|
|
250
256
|
*/
|
|
251
257
|
getDecorator(name: string): IDecorator | undefined;
|
|
252
|
-
/**
|
|
253
|
-
* Get editor history state
|
|
254
|
-
*/
|
|
255
|
-
getHistoryState(): HistoryState;
|
|
256
258
|
/**
|
|
257
259
|
* Get all registered decorator names
|
|
258
260
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/editor",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "A powerful and extensible rich text editor built on Meta's Lexical framework, providing a modern editing experience with React integration.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lobehub",
|
|
@@ -86,6 +86,7 @@
|
|
|
86
86
|
"katex": "^0.16.27",
|
|
87
87
|
"lexical": "^0.39.0",
|
|
88
88
|
"lucide-react": "^0.562.0",
|
|
89
|
+
"mermaid": "^11.13.0",
|
|
89
90
|
"polished": "^4.3.1",
|
|
90
91
|
"re-resizable": "^6.11.2",
|
|
91
92
|
"react-error-boundary": "^6.0.2",
|