dn-react-text-editor 0.2.1 → 0.2.2

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,7 +1048,7 @@ 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, () => {
1051
+ (0, import_react2.useImperativeHandle)(ref || controllerRef, () => {
1052
1052
  const container = containerRef.current;
1053
1053
  const textEditorController = createTextEditorController(
1054
1054
  container,
@@ -1067,12 +1067,8 @@ function createTextEditor(options = {}) {
1067
1067
  return textEditorController;
1068
1068
  });
1069
1069
  (0, import_react3.useEffect)(() => {
1070
- const controller = controllerRef.current;
1071
- if (!controller) {
1072
- return;
1073
- }
1074
1070
  if (autoFocus) {
1075
- controller.view.focus();
1071
+ controllerRef.current?.view.focus();
1076
1072
  }
1077
1073
  }, []);
1078
1074
  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(
@@ -1020,7 +1020,7 @@ function createTextEditor(options = {}) {
1020
1020
  } = {}) {
1021
1021
  const containerRef = useRef(null);
1022
1022
  const controllerRef = useRef(null);
1023
- useImperativeHandle(ref, () => {
1023
+ useImperativeHandle(ref || controllerRef, () => {
1024
1024
  const container = containerRef.current;
1025
1025
  const textEditorController = createTextEditorController(
1026
1026
  container,
@@ -1039,12 +1039,8 @@ function createTextEditor(options = {}) {
1039
1039
  return textEditorController;
1040
1040
  });
1041
1041
  useEffect2(() => {
1042
- const controller = controllerRef.current;
1043
- if (!controller) {
1044
- return;
1045
- }
1046
1042
  if (autoFocus) {
1047
- controller.view.focus();
1043
+ controllerRef.current?.view.focus();
1048
1044
  }
1049
1045
  }, []);
1050
1046
  return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("div", { ...props, ref: containerRef, className }), /* @__PURE__ */ React2.createElement(
package/dist/index.js CHANGED
@@ -1054,7 +1054,7 @@ 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, () => {
1057
+ (0, import_react2.useImperativeHandle)(ref || controllerRef, () => {
1058
1058
  const container = containerRef.current;
1059
1059
  const textEditorController = createTextEditorController(
1060
1060
  container,
@@ -1073,12 +1073,8 @@ function createTextEditor(options = {}) {
1073
1073
  return textEditorController;
1074
1074
  });
1075
1075
  (0, import_react3.useEffect)(() => {
1076
- const controller = controllerRef.current;
1077
- if (!controller) {
1078
- return;
1079
- }
1080
1076
  if (autoFocus) {
1081
- controller.view.focus();
1077
+ controllerRef.current?.view.focus();
1082
1078
  }
1083
1079
  }, []);
1084
1080
  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(
package/dist/index.mjs CHANGED
@@ -1020,7 +1020,7 @@ function createTextEditor(options = {}) {
1020
1020
  } = {}) {
1021
1021
  const containerRef = useRef(null);
1022
1022
  const controllerRef = useRef(null);
1023
- useImperativeHandle(ref, () => {
1023
+ useImperativeHandle(ref || controllerRef, () => {
1024
1024
  const container = containerRef.current;
1025
1025
  const textEditorController = createTextEditorController(
1026
1026
  container,
@@ -1039,12 +1039,8 @@ function createTextEditor(options = {}) {
1039
1039
  return textEditorController;
1040
1040
  });
1041
1041
  useEffect2(() => {
1042
- const controller = controllerRef.current;
1043
- if (!controller) {
1044
- return;
1045
- }
1046
1042
  if (autoFocus) {
1047
- controller.view.focus();
1043
+ controllerRef.current?.view.focus();
1048
1044
  }
1049
1045
  }, []);
1050
1046
  return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("div", { ...props, ref: containerRef, className }), /* @__PURE__ */ React2.createElement(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dn-react-text-editor",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.js",