@kerebron/editor 0.4.2 → 0.4.4
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/assets/vars.css +46 -4
- package/package.json +2 -6
- package/esm/_dnt.shims.d.ts +0 -6
- package/esm/_dnt.shims.d.ts.map +0 -1
- package/esm/_dnt.shims.js +0 -61
- package/esm/react/EditorContent.d.ts +0 -26
- package/esm/react/EditorContent.d.ts.map +0 -1
- package/esm/react/EditorContent.js +0 -32
- package/esm/react/mod.d.ts +0 -24
- package/esm/react/mod.d.ts.map +0 -1
- package/esm/react/mod.js +0 -24
- package/esm/react/useEditor.d.ts +0 -38
- package/esm/react/useEditor.d.ts.map +0 -1
- package/esm/react/useEditor.js +0 -69
package/assets/vars.css
CHANGED
|
@@ -48,10 +48,15 @@
|
|
|
48
48
|
--kb-color-border: #e5e7eb;
|
|
49
49
|
--kb-color-border-strong: #d1d5db;
|
|
50
50
|
|
|
51
|
-
/* Menu specific colors
|
|
52
|
-
|
|
53
|
-
--kb-menu-dropdown-
|
|
54
|
-
--kb-menu-dropdown-
|
|
51
|
+
/* Menu specific colors */
|
|
52
|
+
/* Light theme defaults (used for dropdown menus) */
|
|
53
|
+
--kb-menu-dropdown-bg: #ffffff;
|
|
54
|
+
--kb-menu-dropdown-border: #d1d5db;
|
|
55
|
+
--kb-menu-dropdown-text: #1f2937;
|
|
56
|
+
/* Legacy naming - kept for backwards compatibility */
|
|
57
|
+
--kb-menu-dropdown-dark-bg: #ffffff;
|
|
58
|
+
--kb-menu-dropdown-dark-border: #d1d5db;
|
|
59
|
+
--kb-menu-dropdown-dark-text: #1f2937;
|
|
55
60
|
--kb-menu-info-bg: #e8f0fe;
|
|
56
61
|
--kb-menu-info-text: #1967d2;
|
|
57
62
|
}
|
|
@@ -67,6 +72,14 @@
|
|
|
67
72
|
--kb-color-border-strong: #4b5563;
|
|
68
73
|
--kb-color-hover: rgba(59, 130, 246, 0.1);
|
|
69
74
|
--kb-color-active: rgba(59, 130, 246, 0.2);
|
|
75
|
+
/* Menu dropdown colors for dark mode */
|
|
76
|
+
--kb-menu-dropdown-bg: #344154;
|
|
77
|
+
--kb-menu-dropdown-border: #5f6368;
|
|
78
|
+
--kb-menu-dropdown-text: #e8eaed;
|
|
79
|
+
/* Legacy naming */
|
|
80
|
+
--kb-menu-dropdown-dark-bg: #344154;
|
|
81
|
+
--kb-menu-dropdown-dark-border: #5f6368;
|
|
82
|
+
--kb-menu-dropdown-dark-text: #e8eaed;
|
|
70
83
|
}
|
|
71
84
|
}
|
|
72
85
|
|
|
@@ -92,4 +105,33 @@
|
|
|
92
105
|
--kb-color-border-strong: #4b5563;
|
|
93
106
|
--kb-color-hover: rgba(59, 130, 246, 0.1);
|
|
94
107
|
--kb-color-active: rgba(59, 130, 246, 0.2);
|
|
108
|
+
/* Menu dropdown colors for dark mode */
|
|
109
|
+
--kb-menu-dropdown-bg: #344154;
|
|
110
|
+
--kb-menu-dropdown-border: #5f6368;
|
|
111
|
+
--kb-menu-dropdown-text: #e8eaed;
|
|
112
|
+
/* Legacy naming */
|
|
113
|
+
--kb-menu-dropdown-dark-bg: #344154;
|
|
114
|
+
--kb-menu-dropdown-dark-border: #5f6368;
|
|
115
|
+
--kb-menu-dropdown-dark-text: #e8eaed;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* Explicit light theme class (overrides system dark mode preference) */
|
|
119
|
+
.kb-component--light {
|
|
120
|
+
--kb-color-text: #1f2937;
|
|
121
|
+
--kb-color-text-muted: #6b7280;
|
|
122
|
+
--kb-color-surface: #ffffff;
|
|
123
|
+
--kb-color-surface-elevated: #f9fafb;
|
|
124
|
+
--kb-color-surface-hover: rgba(60, 64, 67, 0.08);
|
|
125
|
+
--kb-color-border: #e5e7eb;
|
|
126
|
+
--kb-color-border-strong: #d1d5db;
|
|
127
|
+
--kb-color-hover: rgba(59, 130, 246, 0.05);
|
|
128
|
+
--kb-color-active: rgba(59, 130, 246, 0.1);
|
|
129
|
+
/* Menu dropdown colors for light mode */
|
|
130
|
+
--kb-menu-dropdown-bg: #ffffff;
|
|
131
|
+
--kb-menu-dropdown-border: #d1d5db;
|
|
132
|
+
--kb-menu-dropdown-text: #1f2937;
|
|
133
|
+
/* Legacy naming */
|
|
134
|
+
--kb-menu-dropdown-dark-bg: #ffffff;
|
|
135
|
+
--kb-menu-dropdown-dark-border: #d1d5db;
|
|
136
|
+
--kb-menu-dropdown-dark-text: #1f2937;
|
|
95
137
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kerebron/editor",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"module": "./esm/mod.js",
|
|
6
6
|
"exports": {
|
|
@@ -21,9 +21,6 @@
|
|
|
21
21
|
},
|
|
22
22
|
"./utilities": {
|
|
23
23
|
"import": "./esm/utilities/mod.js"
|
|
24
|
-
},
|
|
25
|
-
"./react": {
|
|
26
|
-
"import": "./esm/react/mod.js"
|
|
27
24
|
}
|
|
28
25
|
},
|
|
29
26
|
"scripts": {},
|
|
@@ -31,8 +28,7 @@
|
|
|
31
28
|
"prosemirror-model": "1.25.3",
|
|
32
29
|
"prosemirror-state": "1.4.3",
|
|
33
30
|
"prosemirror-transform": "1.10.4",
|
|
34
|
-
"prosemirror-view": "1.40.0"
|
|
35
|
-
"@deno/shim-deno": "~0.18.0"
|
|
31
|
+
"prosemirror-view": "1.40.0"
|
|
36
32
|
},
|
|
37
33
|
"devDependencies": {
|
|
38
34
|
"@types/node": "^20.9.0"
|
package/esm/_dnt.shims.d.ts
DELETED
package/esm/_dnt.shims.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAKvC,eAAO,MAAM,aAAa;;CAA2C,CAAC"}
|
package/esm/_dnt.shims.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Deno } from "@deno/shim-deno";
|
|
2
|
-
export { Deno } from "@deno/shim-deno";
|
|
3
|
-
const dntGlobals = {
|
|
4
|
-
Deno,
|
|
5
|
-
};
|
|
6
|
-
export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
|
|
7
|
-
function createMergeProxy(baseObj, extObj) {
|
|
8
|
-
return new Proxy(baseObj, {
|
|
9
|
-
get(_target, prop, _receiver) {
|
|
10
|
-
if (prop in extObj) {
|
|
11
|
-
return extObj[prop];
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
return baseObj[prop];
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
set(_target, prop, value) {
|
|
18
|
-
if (prop in extObj) {
|
|
19
|
-
delete extObj[prop];
|
|
20
|
-
}
|
|
21
|
-
baseObj[prop] = value;
|
|
22
|
-
return true;
|
|
23
|
-
},
|
|
24
|
-
deleteProperty(_target, prop) {
|
|
25
|
-
let success = false;
|
|
26
|
-
if (prop in extObj) {
|
|
27
|
-
delete extObj[prop];
|
|
28
|
-
success = true;
|
|
29
|
-
}
|
|
30
|
-
if (prop in baseObj) {
|
|
31
|
-
delete baseObj[prop];
|
|
32
|
-
success = true;
|
|
33
|
-
}
|
|
34
|
-
return success;
|
|
35
|
-
},
|
|
36
|
-
ownKeys(_target) {
|
|
37
|
-
const baseKeys = Reflect.ownKeys(baseObj);
|
|
38
|
-
const extKeys = Reflect.ownKeys(extObj);
|
|
39
|
-
const extKeysSet = new Set(extKeys);
|
|
40
|
-
return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
|
|
41
|
-
},
|
|
42
|
-
defineProperty(_target, prop, desc) {
|
|
43
|
-
if (prop in extObj) {
|
|
44
|
-
delete extObj[prop];
|
|
45
|
-
}
|
|
46
|
-
Reflect.defineProperty(baseObj, prop, desc);
|
|
47
|
-
return true;
|
|
48
|
-
},
|
|
49
|
-
getOwnPropertyDescriptor(_target, prop) {
|
|
50
|
-
if (prop in extObj) {
|
|
51
|
-
return Reflect.getOwnPropertyDescriptor(extObj, prop);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
return Reflect.getOwnPropertyDescriptor(baseObj, prop);
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
has(_target, prop) {
|
|
58
|
-
return prop in extObj || prop in baseObj;
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { CoreEditor } from '../CoreEditor.js';
|
|
3
|
-
export interface EditorContentProps {
|
|
4
|
-
/** The editor instance from useEditor */
|
|
5
|
-
editor: CoreEditor | null;
|
|
6
|
-
/** Additional class name */
|
|
7
|
-
className?: string;
|
|
8
|
-
/** Additional inline styles */
|
|
9
|
-
style?: React.CSSProperties;
|
|
10
|
-
}
|
|
11
|
-
export interface EditorContentRef {
|
|
12
|
-
/** Get the container element */
|
|
13
|
-
getElement: () => HTMLDivElement | null;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* EditorContent renders the Kerebron editor.
|
|
17
|
-
* Use with the useEditor hook.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```tsx
|
|
21
|
-
* const editor = useEditor({ extensions: [StarterKit] })
|
|
22
|
-
* return <EditorContent editor={editor} />
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export declare const EditorContent: any;
|
|
26
|
-
//# sourceMappingURL=EditorContent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EditorContent.d.ts","sourceRoot":"","sources":["../../src/react/EditorContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAKN,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,WAAW,kBAAkB;IACjC,yCAAyC;IACzC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IAC1B,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+BAA+B;IAC/B,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,gCAAgC;IAChC,UAAU,EAAE,MAAM,cAAc,GAAG,IAAI,CAAC;CACzC;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,KA+BzB,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, useEffect, useImperativeHandle, useRef, } from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* EditorContent renders the Kerebron editor.
|
|
4
|
-
* Use with the useEditor hook.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```tsx
|
|
8
|
-
* const editor = useEditor({ extensions: [StarterKit] })
|
|
9
|
-
* return <EditorContent editor={editor} />
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
export const EditorContent = forwardRef(({ editor, className = '', style }, ref) => {
|
|
13
|
-
const containerRef = useRef(null);
|
|
14
|
-
useImperativeHandle(ref, () => ({
|
|
15
|
-
getElement: () => containerRef.current,
|
|
16
|
-
}));
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
const container = containerRef.current;
|
|
19
|
-
if (!container || !editor)
|
|
20
|
-
return;
|
|
21
|
-
// Get the editor's DOM element and append it to our container
|
|
22
|
-
const editorDom = editor.view?.dom;
|
|
23
|
-
if (editorDom && editorDom.parentElement !== container) {
|
|
24
|
-
container.appendChild(editorDom);
|
|
25
|
-
}
|
|
26
|
-
return () => {
|
|
27
|
-
// Don't remove on cleanup - editor.destroy() handles this
|
|
28
|
-
};
|
|
29
|
-
}, [editor]);
|
|
30
|
-
return (React.createElement("div", { ref: containerRef, className: `kb-component ${className}`.trim(), style: style }));
|
|
31
|
-
});
|
|
32
|
-
EditorContent.displayName = 'EditorContent';
|
package/esm/react/mod.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* React bindings for Kerebron Editor
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* ```tsx
|
|
6
|
-
* import { useEditor, EditorContent } from '@kerebron/editor/react'
|
|
7
|
-
* import { StarterKit } from '@kerebron/editor-kits/StarterKit'
|
|
8
|
-
*
|
|
9
|
-
* const MyEditor = () => {
|
|
10
|
-
* const editor = useEditor({
|
|
11
|
-
* extensions: [StarterKit],
|
|
12
|
-
* content: '<p>Hello World!</p>',
|
|
13
|
-
* })
|
|
14
|
-
*
|
|
15
|
-
* return <EditorContent editor={editor} />
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @module
|
|
20
|
-
*/
|
|
21
|
-
export { useEditor, type UseEditorOptions } from './useEditor.js';
|
|
22
|
-
export { EditorContent, type EditorContentProps, type EditorContentRef, } from './EditorContent.js';
|
|
23
|
-
export { CoreEditor } from '../CoreEditor.js';
|
|
24
|
-
//# sourceMappingURL=mod.d.ts.map
|
package/esm/react/mod.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/react/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EACL,aAAa,EACb,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,GACtB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
package/esm/react/mod.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* React bindings for Kerebron Editor
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* ```tsx
|
|
6
|
-
* import { useEditor, EditorContent } from '@kerebron/editor/react'
|
|
7
|
-
* import { StarterKit } from '@kerebron/editor-kits/StarterKit'
|
|
8
|
-
*
|
|
9
|
-
* const MyEditor = () => {
|
|
10
|
-
* const editor = useEditor({
|
|
11
|
-
* extensions: [StarterKit],
|
|
12
|
-
* content: '<p>Hello World!</p>',
|
|
13
|
-
* })
|
|
14
|
-
*
|
|
15
|
-
* return <EditorContent editor={editor} />
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @module
|
|
20
|
-
*/
|
|
21
|
-
export { useEditor } from './useEditor.js';
|
|
22
|
-
export { EditorContent, } from './EditorContent.js';
|
|
23
|
-
// Re-export CoreEditor for convenience
|
|
24
|
-
export { CoreEditor } from '../CoreEditor.js';
|
package/esm/react/useEditor.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { type DependencyList } from 'react';
|
|
2
|
-
import { CoreEditor } from '../CoreEditor.js';
|
|
3
|
-
import type { AnyExtensionOrReq, Content } from '../types.js';
|
|
4
|
-
export interface UseEditorOptions {
|
|
5
|
-
/** Array of extensions to use */
|
|
6
|
-
extensions?: AnyExtensionOrReq[];
|
|
7
|
-
/** Initial HTML content */
|
|
8
|
-
content?: string;
|
|
9
|
-
/** Initial JSON content */
|
|
10
|
-
initialContent?: Content;
|
|
11
|
-
/** CDN URL for WASM files */
|
|
12
|
-
cdnUrl?: string;
|
|
13
|
-
/** Document URI */
|
|
14
|
-
uri?: string;
|
|
15
|
-
/** Called when editor is ready */
|
|
16
|
-
onReady?: (editor: CoreEditor) => void;
|
|
17
|
-
/** Called on every transaction */
|
|
18
|
-
onTransaction?: (editor: CoreEditor) => void;
|
|
19
|
-
/** Called when content changes */
|
|
20
|
-
onChange?: (editor: CoreEditor) => void;
|
|
21
|
-
/** Prevent immediate render (useful for SSR) */
|
|
22
|
-
immediatelyRender?: boolean;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* React hook for creating and managing a Kerebron editor instance.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```tsx
|
|
29
|
-
* const editor = useEditor({
|
|
30
|
-
* extensions: [StarterKit],
|
|
31
|
-
* content: '<p>Hello World!</p>',
|
|
32
|
-
* })
|
|
33
|
-
*
|
|
34
|
-
* return <EditorContent editor={editor} />
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare function useEditor(options?: UseEditorOptions, deps?: DependencyList): CoreEditor | null;
|
|
38
|
-
//# sourceMappingURL=useEditor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useEditor.d.ts","sourceRoot":"","sources":["../../src/react/useEditor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAA+B,MAAM,OAAO,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE9D,MAAM,WAAW,gBAAgB;IAC/B,iCAAiC;IACjC,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACjC,2BAA2B;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,6BAA6B;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mBAAmB;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACvC,kCAAkC;IAClC,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IAC7C,kCAAkC;IAClC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACxC,gDAAgD;IAChD,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CACvB,OAAO,GAAE,gBAAqB,EAC9B,IAAI,GAAE,cAAmB,GACxB,UAAU,GAAG,IAAI,CAyEnB"}
|
package/esm/react/useEditor.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import * as dntShim from "../_dnt.shims.js";
|
|
2
|
-
import { useEffect, useRef, useState } from 'react';
|
|
3
|
-
import { CoreEditor } from '../CoreEditor.js';
|
|
4
|
-
/**
|
|
5
|
-
* React hook for creating and managing a Kerebron editor instance.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```tsx
|
|
9
|
-
* const editor = useEditor({
|
|
10
|
-
* extensions: [StarterKit],
|
|
11
|
-
* content: '<p>Hello World!</p>',
|
|
12
|
-
* })
|
|
13
|
-
*
|
|
14
|
-
* return <EditorContent editor={editor} />
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export function useEditor(options = {}, deps = []) {
|
|
18
|
-
const [editor, setEditor] = useState(null);
|
|
19
|
-
const editorContainerRef = useRef(null);
|
|
20
|
-
const optionsRef = useRef(options);
|
|
21
|
-
// Keep options ref updated
|
|
22
|
-
optionsRef.current = options;
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
// Skip if SSR and immediatelyRender is false
|
|
25
|
-
if (options.immediatelyRender === false && typeof dntShim.dntGlobalThis === 'undefined') {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const { extensions = [], content, initialContent, cdnUrl, uri, onReady, onTransaction, onChange, } = optionsRef.current;
|
|
29
|
-
// Create a container element for the editor
|
|
30
|
-
const container = document.createElement('div');
|
|
31
|
-
editorContainerRef.current = container;
|
|
32
|
-
const editorInstance = new CoreEditor({
|
|
33
|
-
element: container,
|
|
34
|
-
extensions,
|
|
35
|
-
content: initialContent,
|
|
36
|
-
cdnUrl,
|
|
37
|
-
uri,
|
|
38
|
-
});
|
|
39
|
-
// Set up event listeners
|
|
40
|
-
if (onTransaction) {
|
|
41
|
-
editorInstance.addEventListener('transaction', () => {
|
|
42
|
-
onTransaction(editorInstance);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
if (onChange) {
|
|
46
|
-
editorInstance.addEventListener('changed', () => {
|
|
47
|
-
onChange(editorInstance);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
// Load HTML content if provided
|
|
51
|
-
if (content) {
|
|
52
|
-
const buffer = new TextEncoder().encode(content);
|
|
53
|
-
editorInstance.loadDocument('text/html', buffer).catch(() => {
|
|
54
|
-
// If HTML loading fails, try setting as plain text
|
|
55
|
-
console.warn('Failed to load HTML content');
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
setEditor(editorInstance);
|
|
59
|
-
if (onReady) {
|
|
60
|
-
onReady(editorInstance);
|
|
61
|
-
}
|
|
62
|
-
// Cleanup
|
|
63
|
-
return () => {
|
|
64
|
-
editorInstance.destroy();
|
|
65
|
-
setEditor(null);
|
|
66
|
-
};
|
|
67
|
-
}, deps); // eslint-disable-line react-hooks/exhaustive-deps
|
|
68
|
-
return editor;
|
|
69
|
-
}
|