@haklex/rich-kit-shiro 0.0.3
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/LICENSE +28 -0
- package/README.md +111 -0
- package/dist/ShiroEditor.d.ts +10 -0
- package/dist/ShiroEditor.d.ts.map +1 -0
- package/dist/ShiroRenderer.d.ts +7 -0
- package/dist/ShiroRenderer.d.ts.map +1 -0
- package/dist/editor.mjs +55 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +10 -0
- package/dist/renderer.mjs +27 -0
- package/package.json +64 -0
- package/src/style.css +6 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Innei
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
Additional Terms and Conditions
|
|
25
|
+
|
|
26
|
+
----------------
|
|
27
|
+
|
|
28
|
+
Use of this software is governed by the terms of MIT and, in addition, by the terms and conditions described in the additional file (ADDITIONAL_TERMS.md). By using this software, you agree to abide by these additional terms and conditions.
|
package/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# @haklex/rich-kit-shiro
|
|
2
|
+
|
|
3
|
+
生产就绪的编辑器包,包含所有渲染器、插件和扩展。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @haklex/rich-kit-shiro lexical @lexical/react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 使用
|
|
12
|
+
|
|
13
|
+
### 编辑器
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { ShiroEditor } from '@haklex/rich-kit-shiro/editor'
|
|
17
|
+
import '@haklex/rich-kit-shiro/style.css'
|
|
18
|
+
|
|
19
|
+
function Editor() {
|
|
20
|
+
const [state, setState] = useState()
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<ShiroEditor
|
|
24
|
+
initialValue={state}
|
|
25
|
+
onChange={setState}
|
|
26
|
+
variant="article"
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 渲染器
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { ShiroRenderer } from '@haklex/rich-kit-shiro/renderer'
|
|
36
|
+
import '@haklex/rich-kit-shiro/style.css'
|
|
37
|
+
|
|
38
|
+
function Article({ content }) {
|
|
39
|
+
return <ShiroRenderer value={content} variant="article" />
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## 内置功能
|
|
44
|
+
|
|
45
|
+
ShiroEditor 自动包含:
|
|
46
|
+
|
|
47
|
+
- 所有编辑渲染器
|
|
48
|
+
- SlashMenuPlugin
|
|
49
|
+
- FloatingToolbarPlugin
|
|
50
|
+
- FloatingLinkEditorPlugin
|
|
51
|
+
- TldrawPlugin
|
|
52
|
+
- EmbedPlugin
|
|
53
|
+
- 表格单元格调整
|
|
54
|
+
|
|
55
|
+
## API
|
|
56
|
+
|
|
57
|
+
### ShiroEditorProps
|
|
58
|
+
|
|
59
|
+
继承 `RichEditorProps`,但省略 `rendererConfig`、`extraNodes`:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
interface ShiroEditorProps extends Omit<RichEditorProps, 'rendererConfig' | 'extraNodes' | 'actions'> {
|
|
63
|
+
extraNodes?: Array<Klass<LexicalNode>>
|
|
64
|
+
actions?: ReactNode
|
|
65
|
+
selfHostnames?: string[] // EmbedPlugin 用
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### ShiroRendererProps
|
|
70
|
+
|
|
71
|
+
继承 `RichRendererProps`,但省略 `rendererConfig`、`extraNodes`:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
interface ShiroRendererProps extends Omit<RichRendererProps, 'rendererConfig' | 'extraNodes'> {
|
|
75
|
+
extraNodes?: Array<Klass<LexicalNode>>
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 导出
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
// 组件
|
|
83
|
+
export { ShiroEditor } from './ShiroEditor'
|
|
84
|
+
export { ShiroRenderer } from './ShiroRenderer'
|
|
85
|
+
|
|
86
|
+
// 类型
|
|
87
|
+
export type { ShiroEditorProps } from './ShiroEditor'
|
|
88
|
+
export type { ShiroRendererProps } from './ShiroRenderer'
|
|
89
|
+
|
|
90
|
+
// 重新导出常用类型
|
|
91
|
+
export type { ColorScheme, RendererConfig, RichEditorVariant } from '@haklex/rich-editor'
|
|
92
|
+
|
|
93
|
+
// 重新导出配置(高级用法)
|
|
94
|
+
export { enhancedRendererConfig } from '@haklex/rich-renderers'
|
|
95
|
+
export { enhancedEditRendererConfig } from '@haklex/rich-renderers-edit'
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## 依赖
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"lexical": "^0.39.0",
|
|
103
|
+
"@lexical/react": "^0.39.0",
|
|
104
|
+
"react": ">=19",
|
|
105
|
+
"react-dom": ">=19"
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## License
|
|
110
|
+
|
|
111
|
+
MIT
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RichEditorProps } from '@haklex/rich-editor';
|
|
2
|
+
import { Klass, LexicalNode } from 'lexical';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
export interface ShiroEditorProps extends Omit<RichEditorProps, 'rendererConfig' | 'extraNodes' | 'actions'> {
|
|
5
|
+
extraNodes?: Array<Klass<LexicalNode>>;
|
|
6
|
+
actions?: ReactNode;
|
|
7
|
+
selfHostnames?: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare function ShiroEditor({ extraNodes, actions, children, selfHostnames, ...props }: ShiroEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=ShiroEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShiroEditor.d.ts","sourceRoot":"","sources":["../src/ShiroEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAoB1D,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAYtC,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAC5C,eAAe,EACf,gBAAgB,GAAG,YAAY,GAAG,SAAS,CAC5C;IACC,UAAU,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAA;IACtC,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;CACzB;AAED,wBAAgB,WAAW,CAAC,EAC1B,UAAU,EACV,OAAO,EACP,QAAQ,EACR,aAAa,EACb,GAAG,KAAK,EACT,EAAE,gBAAgB,2CA6BlB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RichRendererProps } from '@haklex/rich-editor';
|
|
2
|
+
import { Klass, LexicalNode } from 'lexical';
|
|
3
|
+
export interface ShiroRendererProps extends Omit<RichRendererProps, 'rendererConfig' | 'extraNodes'> {
|
|
4
|
+
extraNodes?: Array<Klass<LexicalNode>>;
|
|
5
|
+
}
|
|
6
|
+
export declare function ShiroRenderer({ extraNodes, ...props }: ShiroRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=ShiroRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShiroRenderer.d.ts","sourceRoot":"","sources":["../src/ShiroRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAS5D,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAUjD,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAC9C,iBAAiB,EACjB,gBAAgB,GAAG,YAAY,CAChC;IACC,UAAU,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAA;CACvC;AAED,wBAAgB,aAAa,CAAC,EAAE,UAAU,EAAE,GAAG,KAAK,EAAE,EAAE,kBAAkB,2CAczE"}
|
package/dist/editor.mjs
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { RichEditor } from "@haklex/rich-editor";
|
|
3
|
+
import { BlockHandlePlugin } from "@haklex/rich-plugin-block-handle";
|
|
4
|
+
import { FloatingToolbarPlugin } from "@haklex/rich-plugin-floating-toolbar";
|
|
5
|
+
import { FloatingLinkEditorPlugin } from "@haklex/rich-plugin-link-edit";
|
|
6
|
+
import { SlashMenuPlugin } from "@haklex/rich-plugin-slash-menu";
|
|
7
|
+
import { TableRowColumnHandlesPlugin, TableCellResizerPlugin } from "@haklex/rich-plugin-table";
|
|
8
|
+
import { TldrawNode, galleryNodes } from "@haklex/rich-renderers";
|
|
9
|
+
import { embedEditNodes, linkCardEditNodes, katexEditNodes, codeSnippetEditNodes, enhancedEditRendererConfig, TldrawPlugin, EmbedPlugin } from "@haklex/rich-renderers-edit";
|
|
10
|
+
import { useMemo } from "react";
|
|
11
|
+
const defaultExtraNodes = [
|
|
12
|
+
TldrawNode,
|
|
13
|
+
...embedEditNodes,
|
|
14
|
+
...linkCardEditNodes,
|
|
15
|
+
...katexEditNodes,
|
|
16
|
+
...galleryNodes,
|
|
17
|
+
...codeSnippetEditNodes
|
|
18
|
+
];
|
|
19
|
+
function ShiroEditor({
|
|
20
|
+
extraNodes,
|
|
21
|
+
actions,
|
|
22
|
+
children,
|
|
23
|
+
selfHostnames,
|
|
24
|
+
...props
|
|
25
|
+
}) {
|
|
26
|
+
const mergedNodes = useMemo(
|
|
27
|
+
() => extraNodes ? [...defaultExtraNodes, ...extraNodes] : defaultExtraNodes,
|
|
28
|
+
[extraNodes]
|
|
29
|
+
);
|
|
30
|
+
return /* @__PURE__ */ jsxs(
|
|
31
|
+
RichEditor,
|
|
32
|
+
{
|
|
33
|
+
...props,
|
|
34
|
+
extraNodes: mergedNodes,
|
|
35
|
+
rendererConfig: enhancedEditRendererConfig,
|
|
36
|
+
actions: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
37
|
+
/* @__PURE__ */ jsx(SlashMenuPlugin, {}),
|
|
38
|
+
actions
|
|
39
|
+
] }),
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ jsx(BlockHandlePlugin, {}),
|
|
42
|
+
/* @__PURE__ */ jsx(FloatingToolbarPlugin, {}),
|
|
43
|
+
/* @__PURE__ */ jsx(FloatingLinkEditorPlugin, {}),
|
|
44
|
+
/* @__PURE__ */ jsx(TldrawPlugin, {}),
|
|
45
|
+
/* @__PURE__ */ jsx(EmbedPlugin, { selfHostnames }),
|
|
46
|
+
/* @__PURE__ */ jsx(TableRowColumnHandlesPlugin, {}),
|
|
47
|
+
/* @__PURE__ */ jsx(TableCellResizerPlugin, {}),
|
|
48
|
+
children
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
ShiroEditor
|
|
55
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { ShiroEditorProps } from './ShiroEditor';
|
|
2
|
+
export { ShiroEditor } from './ShiroEditor';
|
|
3
|
+
export type { ShiroRendererProps } from './ShiroRenderer';
|
|
4
|
+
export { ShiroRenderer } from './ShiroRenderer';
|
|
5
|
+
export type { ColorScheme, RendererConfig, RichEditorVariant, } from '@haklex/rich-editor';
|
|
6
|
+
export { enhancedRendererConfig } from '@haklex/rich-renderers';
|
|
7
|
+
export { enhancedEditRendererConfig } from '@haklex/rich-renderers-edit';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAG/C,YAAY,EACV,WAAW,EACX,cAAc,EACd,iBAAiB,GAClB,MAAM,qBAAqB,CAAA;AAG5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAA"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ShiroEditor } from "./editor.mjs";
|
|
2
|
+
import { ShiroRenderer } from "./renderer.mjs";
|
|
3
|
+
import { enhancedRendererConfig } from "@haklex/rich-renderers";
|
|
4
|
+
import { enhancedEditRendererConfig } from "@haklex/rich-renderers-edit";
|
|
5
|
+
export {
|
|
6
|
+
ShiroEditor,
|
|
7
|
+
ShiroRenderer,
|
|
8
|
+
enhancedEditRendererConfig,
|
|
9
|
+
enhancedRendererConfig
|
|
10
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { RichRenderer } from "@haklex/rich-editor";
|
|
3
|
+
import { TldrawNode, embedNodes, galleryNodes, codeSnippetNodes, enhancedRendererConfig } from "@haklex/rich-renderers";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
const defaultExtraNodes = [
|
|
6
|
+
TldrawNode,
|
|
7
|
+
...embedNodes,
|
|
8
|
+
...galleryNodes,
|
|
9
|
+
...codeSnippetNodes
|
|
10
|
+
];
|
|
11
|
+
function ShiroRenderer({ extraNodes, ...props }) {
|
|
12
|
+
const mergedNodes = useMemo(
|
|
13
|
+
() => extraNodes ? [...defaultExtraNodes, ...extraNodes] : defaultExtraNodes,
|
|
14
|
+
[extraNodes]
|
|
15
|
+
);
|
|
16
|
+
return /* @__PURE__ */ jsx(
|
|
17
|
+
RichRenderer,
|
|
18
|
+
{
|
|
19
|
+
...props,
|
|
20
|
+
extraNodes: mergedNodes,
|
|
21
|
+
rendererConfig: enhancedRendererConfig
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
ShiroRenderer
|
|
27
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@haklex/rich-kit-shiro",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "Production bundle for Shiroi blog",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/index.mjs",
|
|
10
|
+
"types": "./dist/index.d.ts"
|
|
11
|
+
},
|
|
12
|
+
"./editor": {
|
|
13
|
+
"import": "./dist/editor.mjs",
|
|
14
|
+
"types": "./dist/editor.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./renderer": {
|
|
17
|
+
"import": "./dist/renderer.mjs",
|
|
18
|
+
"types": "./dist/renderer.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./style.css": "./src/style.css"
|
|
21
|
+
},
|
|
22
|
+
"main": "./dist/index.mjs",
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"src/style.css"
|
|
26
|
+
],
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@haklex/rich-editor": "0.0.3",
|
|
29
|
+
"@haklex/rich-editor-ui": "0.0.3",
|
|
30
|
+
"@haklex/rich-plugin-block-handle": "0.0.3",
|
|
31
|
+
"@haklex/rich-ext-tldraw": "0.0.3",
|
|
32
|
+
"@haklex/rich-plugin-floating-toolbar": "0.0.3",
|
|
33
|
+
"@haklex/rich-plugin-link-edit": "0.0.3",
|
|
34
|
+
"@haklex/rich-plugin-slash-menu": "0.0.3",
|
|
35
|
+
"@haklex/rich-plugin-table": "0.0.3",
|
|
36
|
+
"@haklex/rich-renderers": "0.0.3",
|
|
37
|
+
"@haklex/rich-renderers-edit": "0.0.3"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@lexical/react": "^0.39.0",
|
|
41
|
+
"@types/react": "^19.0.0",
|
|
42
|
+
"@types/react-dom": "^19.0.0",
|
|
43
|
+
"lexical": "^0.39.0",
|
|
44
|
+
"react": "19.2.4",
|
|
45
|
+
"react-dom": "19.2.4",
|
|
46
|
+
"typescript": "^5.9.0",
|
|
47
|
+
"vite": "^7.3.1",
|
|
48
|
+
"vite-plugin-dts": "^4.5.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@lexical/react": "^0.39.0",
|
|
52
|
+
"lexical": "^0.39.0",
|
|
53
|
+
"react": ">=19",
|
|
54
|
+
"react-dom": ">=19"
|
|
55
|
+
},
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"access": "public"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "vite build",
|
|
61
|
+
"dev:build": "vite build --watch"
|
|
62
|
+
},
|
|
63
|
+
"types": "./dist/index.d.ts"
|
|
64
|
+
}
|
package/src/style.css
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
@import '@haklex/rich-editor/style.css';
|
|
2
|
+
@import '@haklex/rich-editor-ui/style.css';
|
|
3
|
+
@import '@haklex/rich-plugin-block-handle/style.css';
|
|
4
|
+
@import '@haklex/rich-plugin-floating-toolbar/style.css';
|
|
5
|
+
@import '@haklex/rich-plugin-table/style.css';
|
|
6
|
+
@import '@haklex/rich-renderers/style.css';
|