dn-react-text-editor 0.2.2 → 0.2.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.
@@ -1048,28 +1048,36 @@ 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)(() => {
1070
1074
  if (autoFocus) {
1071
1075
  controllerRef.current?.view.focus();
1072
1076
  }
1077
+ return () => {
1078
+ console.log(controllerRef.current);
1079
+ controllerRef.current?.view.destroy();
1080
+ };
1073
1081
  }, []);
1074
1082
  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
1083
  TextEditorInput,
@@ -1020,28 +1020,36 @@ 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(() => {
1042
1046
  if (autoFocus) {
1043
1047
  controllerRef.current?.view.focus();
1044
1048
  }
1049
+ return () => {
1050
+ console.log(controllerRef.current);
1051
+ controllerRef.current?.view.destroy();
1052
+ };
1045
1053
  }, []);
1046
1054
  return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("div", { ...props, ref: containerRef, className }), /* @__PURE__ */ React2.createElement(
1047
1055
  TextEditorInput,
package/dist/index.js CHANGED
@@ -1054,28 +1054,36 @@ 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)(() => {
1076
1080
  if (autoFocus) {
1077
1081
  controllerRef.current?.view.focus();
1078
1082
  }
1083
+ return () => {
1084
+ console.log(controllerRef.current);
1085
+ controllerRef.current?.view.destroy();
1086
+ };
1079
1087
  }, []);
1080
1088
  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
1089
  TextEditorInput,
package/dist/index.mjs CHANGED
@@ -1020,28 +1020,36 @@ 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(() => {
1042
1046
  if (autoFocus) {
1043
1047
  controllerRef.current?.view.focus();
1044
1048
  }
1049
+ return () => {
1050
+ console.log(controllerRef.current);
1051
+ controllerRef.current?.view.destroy();
1052
+ };
1045
1053
  }, []);
1046
1054
  return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("div", { ...props, ref: containerRef, className }), /* @__PURE__ */ React2.createElement(
1047
1055
  TextEditorInput,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dn-react-text-editor",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.js",