dn-react-text-editor 0.2.2 → 0.2.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.
@@ -1048,28 +1048,39 @@ function createTextEditor(options = {}) {
1048
1048
  } = {}) {
1049
1049
  const containerRef = (0, import_react3.useRef)(null);
1050
1050
  const controllerRef = (0, import_react3.useRef)(null);
1051
- (0, import_react2.useImperativeHandle)(ref || controllerRef, () => {
1052
- const container = containerRef.current;
1053
- const textEditorController = createTextEditorController(
1054
- container,
1055
- schema,
1056
- options,
1057
- {
1058
- mode,
1059
- state,
1060
- editor,
1061
- defaultValue,
1062
- updateDelay,
1063
- placeholder
1064
- }
1065
- );
1066
- controllerRef.current = textEditorController;
1067
- return textEditorController;
1068
- });
1051
+ (0, import_react2.useImperativeHandle)(
1052
+ ref || controllerRef,
1053
+ () => {
1054
+ const container = containerRef.current;
1055
+ const textEditorController = createTextEditorController(
1056
+ container,
1057
+ schema,
1058
+ options,
1059
+ {
1060
+ mode,
1061
+ state,
1062
+ editor,
1063
+ defaultValue,
1064
+ updateDelay,
1065
+ placeholder
1066
+ }
1067
+ );
1068
+ controllerRef.current = textEditorController;
1069
+ return textEditorController;
1070
+ },
1071
+ []
1072
+ );
1069
1073
  (0, import_react3.useEffect)(() => {
1074
+ const controller = controllerRef.current;
1075
+ if (!controller) {
1076
+ return;
1077
+ }
1070
1078
  if (autoFocus) {
1071
- controllerRef.current?.view.focus();
1079
+ controller.view.focus();
1072
1080
  }
1081
+ return () => {
1082
+ controller.view.destroy();
1083
+ };
1073
1084
  }, []);
1074
1085
  return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("div", { ...props, ref: containerRef, className }), /* @__PURE__ */ import_react2.default.createElement(
1075
1086
  TextEditorInput,
@@ -1020,28 +1020,39 @@ function createTextEditor(options = {}) {
1020
1020
  } = {}) {
1021
1021
  const containerRef = useRef(null);
1022
1022
  const controllerRef = useRef(null);
1023
- useImperativeHandle(ref || controllerRef, () => {
1024
- const container = containerRef.current;
1025
- const textEditorController = createTextEditorController(
1026
- container,
1027
- schema,
1028
- options,
1029
- {
1030
- mode,
1031
- state,
1032
- editor,
1033
- defaultValue,
1034
- updateDelay,
1035
- placeholder
1036
- }
1037
- );
1038
- controllerRef.current = textEditorController;
1039
- return textEditorController;
1040
- });
1023
+ useImperativeHandle(
1024
+ ref || controllerRef,
1025
+ () => {
1026
+ const container = containerRef.current;
1027
+ const textEditorController = createTextEditorController(
1028
+ container,
1029
+ schema,
1030
+ options,
1031
+ {
1032
+ mode,
1033
+ state,
1034
+ editor,
1035
+ defaultValue,
1036
+ updateDelay,
1037
+ placeholder
1038
+ }
1039
+ );
1040
+ controllerRef.current = textEditorController;
1041
+ return textEditorController;
1042
+ },
1043
+ []
1044
+ );
1041
1045
  useEffect2(() => {
1046
+ const controller = controllerRef.current;
1047
+ if (!controller) {
1048
+ return;
1049
+ }
1042
1050
  if (autoFocus) {
1043
- controllerRef.current?.view.focus();
1051
+ controller.view.focus();
1044
1052
  }
1053
+ return () => {
1054
+ controller.view.destroy();
1055
+ };
1045
1056
  }, []);
1046
1057
  return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("div", { ...props, ref: containerRef, className }), /* @__PURE__ */ React2.createElement(
1047
1058
  TextEditorInput,
package/dist/index.js CHANGED
@@ -1054,28 +1054,39 @@ function createTextEditor(options = {}) {
1054
1054
  } = {}) {
1055
1055
  const containerRef = (0, import_react3.useRef)(null);
1056
1056
  const controllerRef = (0, import_react3.useRef)(null);
1057
- (0, import_react2.useImperativeHandle)(ref || controllerRef, () => {
1058
- const container = containerRef.current;
1059
- const textEditorController = createTextEditorController(
1060
- container,
1061
- schema,
1062
- options,
1063
- {
1064
- mode,
1065
- state,
1066
- editor,
1067
- defaultValue,
1068
- updateDelay,
1069
- placeholder
1070
- }
1071
- );
1072
- controllerRef.current = textEditorController;
1073
- return textEditorController;
1074
- });
1057
+ (0, import_react2.useImperativeHandle)(
1058
+ ref || controllerRef,
1059
+ () => {
1060
+ const container = containerRef.current;
1061
+ const textEditorController = createTextEditorController(
1062
+ container,
1063
+ schema,
1064
+ options,
1065
+ {
1066
+ mode,
1067
+ state,
1068
+ editor,
1069
+ defaultValue,
1070
+ updateDelay,
1071
+ placeholder
1072
+ }
1073
+ );
1074
+ controllerRef.current = textEditorController;
1075
+ return textEditorController;
1076
+ },
1077
+ []
1078
+ );
1075
1079
  (0, import_react3.useEffect)(() => {
1080
+ const controller = controllerRef.current;
1081
+ if (!controller) {
1082
+ return;
1083
+ }
1076
1084
  if (autoFocus) {
1077
- controllerRef.current?.view.focus();
1085
+ controller.view.focus();
1078
1086
  }
1087
+ return () => {
1088
+ controller.view.destroy();
1089
+ };
1079
1090
  }, []);
1080
1091
  return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("div", { ...props, ref: containerRef, className }), /* @__PURE__ */ import_react2.default.createElement(
1081
1092
  TextEditorInput,
package/dist/index.mjs CHANGED
@@ -1020,28 +1020,39 @@ function createTextEditor(options = {}) {
1020
1020
  } = {}) {
1021
1021
  const containerRef = useRef(null);
1022
1022
  const controllerRef = useRef(null);
1023
- useImperativeHandle(ref || controllerRef, () => {
1024
- const container = containerRef.current;
1025
- const textEditorController = createTextEditorController(
1026
- container,
1027
- schema,
1028
- options,
1029
- {
1030
- mode,
1031
- state,
1032
- editor,
1033
- defaultValue,
1034
- updateDelay,
1035
- placeholder
1036
- }
1037
- );
1038
- controllerRef.current = textEditorController;
1039
- return textEditorController;
1040
- });
1023
+ useImperativeHandle(
1024
+ ref || controllerRef,
1025
+ () => {
1026
+ const container = containerRef.current;
1027
+ const textEditorController = createTextEditorController(
1028
+ container,
1029
+ schema,
1030
+ options,
1031
+ {
1032
+ mode,
1033
+ state,
1034
+ editor,
1035
+ defaultValue,
1036
+ updateDelay,
1037
+ placeholder
1038
+ }
1039
+ );
1040
+ controllerRef.current = textEditorController;
1041
+ return textEditorController;
1042
+ },
1043
+ []
1044
+ );
1041
1045
  useEffect2(() => {
1046
+ const controller = controllerRef.current;
1047
+ if (!controller) {
1048
+ return;
1049
+ }
1042
1050
  if (autoFocus) {
1043
- controllerRef.current?.view.focus();
1051
+ controller.view.focus();
1044
1052
  }
1053
+ return () => {
1054
+ controller.view.destroy();
1055
+ };
1045
1056
  }, []);
1046
1057
  return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("div", { ...props, ref: containerRef, className }), /* @__PURE__ */ React2.createElement(
1047
1058
  TextEditorInput,
package/package.json CHANGED
@@ -1,58 +1,58 @@
1
1
  {
2
- "name": "dn-react-text-editor",
3
- "version": "0.2.2",
4
- "types": "./dist/index.d.ts",
5
- "main": "./dist/index.mjs",
6
- "module": "./dist/index.js",
7
- "sideEffects": false,
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.js"
2
+ "name": "dn-react-text-editor",
3
+ "version": "0.2.4",
4
+ "types": "./dist/index.d.ts",
5
+ "main": "./dist/index.mjs",
6
+ "module": "./dist/index.js",
7
+ "sideEffects": false,
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ },
14
+ "./prosemirror": {
15
+ "types": "./dist/prosemirror/index.d.ts",
16
+ "import": "./dist/prosemirror/index.mjs",
17
+ "require": "./dist/prosemirror/index.js"
18
+ }
13
19
  },
14
- "./prosemirror": {
15
- "types": "./dist/prosemirror/index.d.ts",
16
- "import": "./dist/prosemirror/index.mjs",
17
- "require": "./dist/prosemirror/index.js"
20
+ "scripts": {
21
+ "build": "NODE_OPTIONS='--max-old-space-size=16384' tsup",
22
+ "dev": "tsup --watch"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/dndnsoft/dn-react-text-editor.git"
27
+ },
28
+ "author": "",
29
+ "license": "MIT",
30
+ "bugs": {
31
+ "url": "https://github.com/dndnsoft/dn-react-text-editor/issues"
32
+ },
33
+ "homepage": "https://github.com/dndnsoft/dn-react-text-editor#readme",
34
+ "description": "",
35
+ "devDependencies": {
36
+ "@types/node": "^24.10.1",
37
+ "@types/react": "^19",
38
+ "@types/react-dom": "^19",
39
+ "tsup": "^8.5.1",
40
+ "typescript": "^5.7.3"
41
+ },
42
+ "peerDependencies": {
43
+ "react": "^19",
44
+ "react-dom": "^19"
45
+ },
46
+ "dependencies": {
47
+ "highlight.js": "^11.11.1",
48
+ "html-entities": "^2.6.0",
49
+ "prosemirror-commands": "^1.7.1",
50
+ "prosemirror-history": "^1.5.0",
51
+ "prosemirror-keymap": "^1.2.3",
52
+ "prosemirror-model": "^1.25.4",
53
+ "prosemirror-schema-list": "^1.5.1",
54
+ "prosemirror-state": "^1.4.4",
55
+ "prosemirror-view": "^1.41.3",
56
+ "rxjs": "^7.8.2"
18
57
  }
19
- },
20
- "scripts": {
21
- "build": "NODE_OPTIONS='--max-old-space-size=16384' tsup",
22
- "dev": "tsup --watch"
23
- },
24
- "repository": {
25
- "type": "git",
26
- "url": "git+https://github.com/dndnsoft/dn-react-text-editor.git"
27
- },
28
- "author": "",
29
- "license": "MIT",
30
- "bugs": {
31
- "url": "https://github.com/dndnsoft/dn-react-text-editor/issues"
32
- },
33
- "homepage": "https://github.com/dndnsoft/dn-react-text-editor#readme",
34
- "description": "",
35
- "devDependencies": {
36
- "@types/node": "^24.10.1",
37
- "@types/react": "^19",
38
- "@types/react-dom": "^19",
39
- "tsup": "^8.5.1",
40
- "typescript": "^5.7.3"
41
- },
42
- "peerDependencies": {
43
- "react": "^19",
44
- "react-dom": "^19"
45
- },
46
- "dependencies": {
47
- "highlight.js": "^11.11.1",
48
- "html-entities": "^2.6.0",
49
- "prosemirror-commands": "^1.7.1",
50
- "prosemirror-history": "^1.5.0",
51
- "prosemirror-keymap": "^1.2.3",
52
- "prosemirror-model": "^1.25.4",
53
- "prosemirror-schema-list": "^1.5.1",
54
- "prosemirror-state": "^1.4.4",
55
- "prosemirror-view": "^1.41.3",
56
- "rxjs": "^7.8.2"
57
- }
58
- }
58
+ }