@haklex/rich-ext-tldraw 0.0.1
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 +59 -0
- package/dist/TldrawConfigContext.d.ts +10 -0
- package/dist/TldrawConfigContext.d.ts.map +1 -0
- package/dist/TldrawEditRenderer.d.ts +7 -0
- package/dist/TldrawEditRenderer.d.ts.map +1 -0
- package/dist/TldrawNode.d.ts +24 -0
- package/dist/TldrawNode.d.ts.map +1 -0
- package/dist/TldrawPlugin.d.ts +3 -0
- package/dist/TldrawPlugin.d.ts.map +1 -0
- package/dist/TldrawRenderer.d.ts +3 -0
- package/dist/TldrawRenderer.d.ts.map +1 -0
- package/dist/TldrawStaticRenderer.d.ts +6 -0
- package/dist/TldrawStaticRenderer.d.ts.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +1004 -0
- package/dist/rich-ext-tldraw.css +306 -0
- package/dist/styles.css.d.ts +25 -0
- package/dist/styles.css.d.ts.map +1 -0
- package/dist/useTldrawData.d.ts +8 -0
- package/dist/useTldrawData.d.ts.map +1 -0
- package/package.json +56 -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,59 @@
|
|
|
1
|
+
# @haklex/rich-ext-tldraw
|
|
2
|
+
|
|
3
|
+
Tldraw 白板扩展。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @haklex/rich-ext-tldraw @haklex/rich-editor tldraw
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 导出
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
// 节点
|
|
15
|
+
export { TldrawNode } from './TldrawNode'
|
|
16
|
+
export { $createTldrawNode, $isTldrawNode } from './TldrawNode'
|
|
17
|
+
export type { SerializedTldrawNode } from './TldrawNode'
|
|
18
|
+
|
|
19
|
+
// 插件
|
|
20
|
+
export { TldrawPlugin, INSERT_TLDRAW_COMMAND } from './TldrawPlugin'
|
|
21
|
+
|
|
22
|
+
// 渲染器
|
|
23
|
+
export { TldrawStaticRenderer } from './TldrawStaticRenderer'
|
|
24
|
+
export type { TldrawStaticRendererProps } from './TldrawStaticRenderer'
|
|
25
|
+
export { TldrawEditRenderer } from './TldrawEditRenderer'
|
|
26
|
+
export type { TldrawEditRendererProps } from './TldrawEditRenderer'
|
|
27
|
+
|
|
28
|
+
// 上下文
|
|
29
|
+
export { TldrawConfigProvider, useTldrawConfig } from './TldrawConfigContext'
|
|
30
|
+
export type { TldrawConfig } from './TldrawConfigContext'
|
|
31
|
+
|
|
32
|
+
// 向后兼容
|
|
33
|
+
export { TldrawStaticRenderer as TldrawRenderer } from './TldrawStaticRenderer'
|
|
34
|
+
export type { TldrawStaticRendererProps as TldrawRendererProps } from './TldrawStaticRenderer'
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## 使用
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { TldrawPlugin, TldrawNode } from '@haklex/rich-ext-tldraw'
|
|
41
|
+
import { RichEditor } from '@haklex/rich-editor'
|
|
42
|
+
|
|
43
|
+
<RichEditor extraNodes={[TldrawNode]}>
|
|
44
|
+
<TldrawPlugin />
|
|
45
|
+
</RichEditor>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## 依赖
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"@haklex/rich-editor": "workspace:*",
|
|
53
|
+
"tldraw": "^3.0.0"
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## License
|
|
58
|
+
|
|
59
|
+
MIT
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface TldrawConfig {
|
|
3
|
+
apiUrl?: string;
|
|
4
|
+
saveSnapshot?: (snapshot: object) => Promise<string>;
|
|
5
|
+
}
|
|
6
|
+
export declare function TldrawConfigProvider({ apiUrl, saveSnapshot, children, }: TldrawConfig & {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function useTldrawConfig(): TldrawConfig;
|
|
10
|
+
//# sourceMappingURL=TldrawConfigContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TldrawConfigContext.d.ts","sourceRoot":"","sources":["../src/TldrawConfigContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;CACrD;AAID,wBAAgB,oBAAoB,CAAC,EACnC,MAAM,EACN,YAAY,EACZ,QAAQ,GACT,EAAE,YAAY,GAAG;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,2CAUxC;AAED,wBAAgB,eAAe,IAAI,YAAY,CAE9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TldrawEditRenderer.d.ts","sourceRoot":"","sources":["../src/TldrawEditRenderer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAO/B,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,MAAM,CAAA;IAChB,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;CAC7C;AA0TD,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,uBAAuB,CAuH1D,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SlashMenuItemConfig } from '@haklex/rich-editor';
|
|
2
|
+
import { EditorConfig, LexicalEditor, LexicalNode, NodeKey, SerializedLexicalNode, Spread, DecoratorNode } from 'lexical';
|
|
3
|
+
import { ReactElement } from 'react';
|
|
4
|
+
export type SerializedTldrawNode = Spread<{
|
|
5
|
+
snapshot: string;
|
|
6
|
+
}, SerializedLexicalNode>;
|
|
7
|
+
export declare class TldrawNode extends DecoratorNode<ReactElement> {
|
|
8
|
+
__snapshot: string;
|
|
9
|
+
static slashMenuItems: SlashMenuItemConfig[];
|
|
10
|
+
static getType(): string;
|
|
11
|
+
static clone(node: TldrawNode): TldrawNode;
|
|
12
|
+
constructor(snapshot: string, key?: NodeKey);
|
|
13
|
+
createDOM(_config: EditorConfig): HTMLElement;
|
|
14
|
+
updateDOM(): boolean;
|
|
15
|
+
isInline(): boolean;
|
|
16
|
+
static importJSON(serializedNode: SerializedTldrawNode): TldrawNode;
|
|
17
|
+
exportJSON(): SerializedTldrawNode;
|
|
18
|
+
getSnapshot(): string;
|
|
19
|
+
setSnapshot(snapshot: string): void;
|
|
20
|
+
decorate(editor: LexicalEditor, _config: EditorConfig): ReactElement;
|
|
21
|
+
}
|
|
22
|
+
export declare function $createTldrawNode(snapshot: string): TldrawNode;
|
|
23
|
+
export declare function $isTldrawNode(node: LexicalNode | null | undefined): node is TldrawNode;
|
|
24
|
+
//# sourceMappingURL=TldrawNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TldrawNode.d.ts","sourceRoot":"","sources":["../src/TldrawNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,OAAO,EACP,qBAAqB,EACrB,MAAM,EACP,MAAM,SAAS,CAAA;AAChB,OAAO,EAA+B,aAAa,EAAE,MAAM,SAAS,CAAA;AAEpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAczC,MAAM,MAAM,oBAAoB,GAAG,MAAM,CACvC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,EACpB,qBAAqB,CACtB,CAAA;AAED,qBAAa,UAAW,SAAQ,aAAa,CAAC,YAAY,CAAC;IACzD,UAAU,EAAE,MAAM,CAAA;IAElB,MAAM,CAAC,cAAc,EAAE,mBAAmB,EAAE,CAa3C;IAED,MAAM,CAAC,OAAO,IAAI,MAAM;IAIxB,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU;gBAI9B,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO;IAK3C,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,WAAW;IAM7C,SAAS,IAAI,OAAO;IAIpB,QAAQ,IAAI,OAAO;IAInB,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,oBAAoB,GAAG,UAAU;IAInE,UAAU,IAAI,oBAAoB;IASlC,WAAW,IAAI,MAAM;IAIrB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAKnC,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,GAAG,YAAY;CAsCrE;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAE9D;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GACnC,IAAI,IAAI,UAAU,CAEpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TldrawPlugin.d.ts","sourceRoot":"","sources":["../src/TldrawPlugin.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,qBAAqB,0CAAyC,CAAA;AAE3E,wBAAgB,YAAY,SAgB3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TldrawRenderer.d.ts","sourceRoot":"","sources":["../src/TldrawRenderer.tsx"],"names":[],"mappings":"AAAA,YAAY,EAAE,yBAAyB,IAAI,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC9F,OAAO,EAAE,oBAAoB,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TldrawStaticRenderer.d.ts","sourceRoot":"","sources":["../src/TldrawStaticRenderer.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,EAAE,EAAkB,MAAM,OAAO,CAAA;AAM1D,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,eAAO,MAAM,oBAAoB,EAAE,EAAE,CAAC,yBAAyB,CAsC9D,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type { TldrawConfig } from './TldrawConfigContext';
|
|
2
|
+
export { TldrawConfigProvider, useTldrawConfig } from './TldrawConfigContext';
|
|
3
|
+
export type { TldrawEditRendererProps } from './TldrawEditRenderer';
|
|
4
|
+
export { TldrawEditRenderer } from './TldrawEditRenderer';
|
|
5
|
+
export type { SerializedTldrawNode } from './TldrawNode';
|
|
6
|
+
export { $createTldrawNode, $isTldrawNode, TldrawNode } from './TldrawNode';
|
|
7
|
+
export { INSERT_TLDRAW_COMMAND, TldrawPlugin } from './TldrawPlugin';
|
|
8
|
+
export type { TldrawStaticRendererProps } from './TldrawStaticRenderer';
|
|
9
|
+
export { TldrawStaticRenderer } from './TldrawStaticRenderer';
|
|
10
|
+
export type { TldrawStaticRendererProps as TldrawRendererProps } from './TldrawStaticRenderer';
|
|
11
|
+
export { TldrawStaticRenderer as TldrawRenderer } from './TldrawStaticRenderer';
|
|
12
|
+
//# 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,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC7E,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,YAAY,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC3E,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACpE,YAAY,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAG7D,YAAY,EAAE,yBAAyB,IAAI,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC9F,OAAO,EAAE,oBAAoB,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAA"}
|