dn-react-text-editor 0.3.4 → 0.3.5
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/dist/index.js +6 -2
- package/dist/index.mjs +7 -2
- package/dist/text_editor.d.mts +3 -2
- package/dist/text_editor.d.ts +3 -2
- package/dist/text_editor.js +6 -2
- package/dist/text_editor.mjs +7 -2
- package/dist/text_editor_controller.d.mts +2 -1
- package/dist/text_editor_controller.d.ts +2 -1
- package/dist/text_editor_controller.js +4 -2
- package/dist/text_editor_controller.mjs +4 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -969,6 +969,7 @@ var TextEditorController = class {
|
|
|
969
969
|
view;
|
|
970
970
|
prosemirrorParser;
|
|
971
971
|
prosemirrorSerializer;
|
|
972
|
+
element;
|
|
972
973
|
get value() {
|
|
973
974
|
if (this.props.mode === "text") {
|
|
974
975
|
return this.toTextContent();
|
|
@@ -1006,12 +1007,13 @@ var TextEditorController = class {
|
|
|
1006
1007
|
uploadFile: this.props.attachFile?.uploadFile
|
|
1007
1008
|
})(this.view, files);
|
|
1008
1009
|
}
|
|
1009
|
-
bind(
|
|
1010
|
+
bind(element) {
|
|
1011
|
+
this.element = element;
|
|
1010
1012
|
const wrapper = document.createElement("div");
|
|
1011
1013
|
wrapper.innerHTML = this.toInnerHTML(
|
|
1012
1014
|
this.props.defaultValue ? String(this.props.defaultValue) : ""
|
|
1013
1015
|
);
|
|
1014
|
-
this.view = new import_prosemirror_view4.EditorView(
|
|
1016
|
+
this.view = new import_prosemirror_view4.EditorView(element, {
|
|
1015
1017
|
...this.props.editor,
|
|
1016
1018
|
attributes: (state) => {
|
|
1017
1019
|
const propsAttributes = (() => {
|
|
@@ -1097,6 +1099,7 @@ var configTextEditorController = (options = {} = {}) => {
|
|
|
1097
1099
|
// src/text_editor.tsx
|
|
1098
1100
|
function TextEditor({
|
|
1099
1101
|
controller: externalController,
|
|
1102
|
+
ref,
|
|
1100
1103
|
name,
|
|
1101
1104
|
className,
|
|
1102
1105
|
autoFocus,
|
|
@@ -1127,6 +1130,7 @@ function TextEditor({
|
|
|
1127
1130
|
[]
|
|
1128
1131
|
);
|
|
1129
1132
|
const controller = externalController || innerController;
|
|
1133
|
+
(0, import_react2.useImperativeHandle)(ref, () => controller, [controller]);
|
|
1130
1134
|
(0, import_react3.useEffect)(() => {
|
|
1131
1135
|
const container = containerRef.current;
|
|
1132
1136
|
if (!container) {
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/text_editor.tsx
|
|
2
2
|
import React2, {
|
|
3
|
+
useImperativeHandle,
|
|
3
4
|
useMemo
|
|
4
5
|
} from "react";
|
|
5
6
|
import { useEffect as useEffect2, useRef } from "react";
|
|
@@ -933,6 +934,7 @@ var TextEditorController = class {
|
|
|
933
934
|
view;
|
|
934
935
|
prosemirrorParser;
|
|
935
936
|
prosemirrorSerializer;
|
|
937
|
+
element;
|
|
936
938
|
get value() {
|
|
937
939
|
if (this.props.mode === "text") {
|
|
938
940
|
return this.toTextContent();
|
|
@@ -970,12 +972,13 @@ var TextEditorController = class {
|
|
|
970
972
|
uploadFile: this.props.attachFile?.uploadFile
|
|
971
973
|
})(this.view, files);
|
|
972
974
|
}
|
|
973
|
-
bind(
|
|
975
|
+
bind(element) {
|
|
976
|
+
this.element = element;
|
|
974
977
|
const wrapper = document.createElement("div");
|
|
975
978
|
wrapper.innerHTML = this.toInnerHTML(
|
|
976
979
|
this.props.defaultValue ? String(this.props.defaultValue) : ""
|
|
977
980
|
);
|
|
978
|
-
this.view = new EditorView3(
|
|
981
|
+
this.view = new EditorView3(element, {
|
|
979
982
|
...this.props.editor,
|
|
980
983
|
attributes: (state) => {
|
|
981
984
|
const propsAttributes = (() => {
|
|
@@ -1061,6 +1064,7 @@ var configTextEditorController = (options = {} = {}) => {
|
|
|
1061
1064
|
// src/text_editor.tsx
|
|
1062
1065
|
function TextEditor({
|
|
1063
1066
|
controller: externalController,
|
|
1067
|
+
ref,
|
|
1064
1068
|
name,
|
|
1065
1069
|
className,
|
|
1066
1070
|
autoFocus,
|
|
@@ -1091,6 +1095,7 @@ function TextEditor({
|
|
|
1091
1095
|
[]
|
|
1092
1096
|
);
|
|
1093
1097
|
const controller = externalController || innerController;
|
|
1098
|
+
useImperativeHandle(ref, () => controller, [controller]);
|
|
1094
1099
|
useEffect2(() => {
|
|
1095
1100
|
const container = containerRef.current;
|
|
1096
1101
|
if (!container) {
|
package/dist/text_editor.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { DetailedHTMLProps, InputHTMLAttributes } from 'react';
|
|
1
|
+
import React, { DetailedHTMLProps, InputHTMLAttributes, Ref } from 'react';
|
|
2
2
|
import { TextEditorController, TextEditorControllerProps } from './text_editor_controller.mjs';
|
|
3
3
|
import 'prosemirror-model';
|
|
4
4
|
import 'prosemirror-state';
|
|
@@ -12,7 +12,8 @@ type HTMLElementProps = DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>,
|
|
|
12
12
|
type TextEditorProps = Omit<HTMLElementProps, "ref"> & {
|
|
13
13
|
controller?: TextEditorController;
|
|
14
14
|
name?: string;
|
|
15
|
+
ref?: Ref<TextEditorController>;
|
|
15
16
|
} & TextEditorControllerProps;
|
|
16
|
-
declare function TextEditor({ controller: externalController, name, className, autoFocus, onChange, mode, state, editor, defaultValue, updateDelay, placeholder, attachFile, style, ...props }?: TextEditorProps): React.JSX.Element;
|
|
17
|
+
declare function TextEditor({ controller: externalController, ref, name, className, autoFocus, onChange, mode, state, editor, defaultValue, updateDelay, placeholder, attachFile, style, ...props }?: TextEditorProps): React.JSX.Element;
|
|
17
18
|
|
|
18
19
|
export { TextEditor, type TextEditorProps };
|
package/dist/text_editor.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { DetailedHTMLProps, InputHTMLAttributes } from 'react';
|
|
1
|
+
import React, { DetailedHTMLProps, InputHTMLAttributes, Ref } from 'react';
|
|
2
2
|
import { TextEditorController, TextEditorControllerProps } from './text_editor_controller.js';
|
|
3
3
|
import 'prosemirror-model';
|
|
4
4
|
import 'prosemirror-state';
|
|
@@ -12,7 +12,8 @@ type HTMLElementProps = DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>,
|
|
|
12
12
|
type TextEditorProps = Omit<HTMLElementProps, "ref"> & {
|
|
13
13
|
controller?: TextEditorController;
|
|
14
14
|
name?: string;
|
|
15
|
+
ref?: Ref<TextEditorController>;
|
|
15
16
|
} & TextEditorControllerProps;
|
|
16
|
-
declare function TextEditor({ controller: externalController, name, className, autoFocus, onChange, mode, state, editor, defaultValue, updateDelay, placeholder, attachFile, style, ...props }?: TextEditorProps): React.JSX.Element;
|
|
17
|
+
declare function TextEditor({ controller: externalController, ref, name, className, autoFocus, onChange, mode, state, editor, defaultValue, updateDelay, placeholder, attachFile, style, ...props }?: TextEditorProps): React.JSX.Element;
|
|
17
18
|
|
|
18
19
|
export { TextEditor, type TextEditorProps };
|
package/dist/text_editor.js
CHANGED
|
@@ -961,6 +961,7 @@ var TextEditorController = class {
|
|
|
961
961
|
view;
|
|
962
962
|
prosemirrorParser;
|
|
963
963
|
prosemirrorSerializer;
|
|
964
|
+
element;
|
|
964
965
|
get value() {
|
|
965
966
|
if (this.props.mode === "text") {
|
|
966
967
|
return this.toTextContent();
|
|
@@ -998,12 +999,13 @@ var TextEditorController = class {
|
|
|
998
999
|
uploadFile: this.props.attachFile?.uploadFile
|
|
999
1000
|
})(this.view, files);
|
|
1000
1001
|
}
|
|
1001
|
-
bind(
|
|
1002
|
+
bind(element) {
|
|
1003
|
+
this.element = element;
|
|
1002
1004
|
const wrapper = document.createElement("div");
|
|
1003
1005
|
wrapper.innerHTML = this.toInnerHTML(
|
|
1004
1006
|
this.props.defaultValue ? String(this.props.defaultValue) : ""
|
|
1005
1007
|
);
|
|
1006
|
-
this.view = new import_prosemirror_view4.EditorView(
|
|
1008
|
+
this.view = new import_prosemirror_view4.EditorView(element, {
|
|
1007
1009
|
...this.props.editor,
|
|
1008
1010
|
attributes: (state) => {
|
|
1009
1011
|
const propsAttributes = (() => {
|
|
@@ -1081,6 +1083,7 @@ var TextEditorController = class {
|
|
|
1081
1083
|
// src/text_editor.tsx
|
|
1082
1084
|
function TextEditor({
|
|
1083
1085
|
controller: externalController,
|
|
1086
|
+
ref,
|
|
1084
1087
|
name,
|
|
1085
1088
|
className,
|
|
1086
1089
|
autoFocus,
|
|
@@ -1111,6 +1114,7 @@ function TextEditor({
|
|
|
1111
1114
|
[]
|
|
1112
1115
|
);
|
|
1113
1116
|
const controller = externalController || innerController;
|
|
1117
|
+
(0, import_react2.useImperativeHandle)(ref, () => controller, [controller]);
|
|
1114
1118
|
(0, import_react3.useEffect)(() => {
|
|
1115
1119
|
const container = containerRef.current;
|
|
1116
1120
|
if (!container) {
|
package/dist/text_editor.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/text_editor.tsx
|
|
2
2
|
import React2, {
|
|
3
|
+
useImperativeHandle,
|
|
3
4
|
useMemo
|
|
4
5
|
} from "react";
|
|
5
6
|
import { useEffect as useEffect2, useRef } from "react";
|
|
@@ -933,6 +934,7 @@ var TextEditorController = class {
|
|
|
933
934
|
view;
|
|
934
935
|
prosemirrorParser;
|
|
935
936
|
prosemirrorSerializer;
|
|
937
|
+
element;
|
|
936
938
|
get value() {
|
|
937
939
|
if (this.props.mode === "text") {
|
|
938
940
|
return this.toTextContent();
|
|
@@ -970,12 +972,13 @@ var TextEditorController = class {
|
|
|
970
972
|
uploadFile: this.props.attachFile?.uploadFile
|
|
971
973
|
})(this.view, files);
|
|
972
974
|
}
|
|
973
|
-
bind(
|
|
975
|
+
bind(element) {
|
|
976
|
+
this.element = element;
|
|
974
977
|
const wrapper = document.createElement("div");
|
|
975
978
|
wrapper.innerHTML = this.toInnerHTML(
|
|
976
979
|
this.props.defaultValue ? String(this.props.defaultValue) : ""
|
|
977
980
|
);
|
|
978
|
-
this.view = new EditorView3(
|
|
981
|
+
this.view = new EditorView3(element, {
|
|
979
982
|
...this.props.editor,
|
|
980
983
|
attributes: (state) => {
|
|
981
984
|
const propsAttributes = (() => {
|
|
@@ -1053,6 +1056,7 @@ var TextEditorController = class {
|
|
|
1053
1056
|
// src/text_editor.tsx
|
|
1054
1057
|
function TextEditor({
|
|
1055
1058
|
controller: externalController,
|
|
1059
|
+
ref,
|
|
1056
1060
|
name,
|
|
1057
1061
|
className,
|
|
1058
1062
|
autoFocus,
|
|
@@ -1083,6 +1087,7 @@ function TextEditor({
|
|
|
1083
1087
|
[]
|
|
1084
1088
|
);
|
|
1085
1089
|
const controller = externalController || innerController;
|
|
1090
|
+
useImperativeHandle(ref, () => controller, [controller]);
|
|
1086
1091
|
useEffect2(() => {
|
|
1087
1092
|
const container = containerRef.current;
|
|
1088
1093
|
if (!container) {
|
|
@@ -29,12 +29,13 @@ declare class TextEditorController {
|
|
|
29
29
|
view?: EditorView;
|
|
30
30
|
prosemirrorParser: DOMParser;
|
|
31
31
|
prosemirrorSerializer: DOMSerializer;
|
|
32
|
+
element?: HTMLElement;
|
|
32
33
|
get value(): string;
|
|
33
34
|
set value(value: string);
|
|
34
35
|
constructor(props?: TextEditorControllerProps);
|
|
35
36
|
toInnerHTML(value: string): string;
|
|
36
37
|
attachFile(files: File[]): Promise<void>;
|
|
37
|
-
bind(
|
|
38
|
+
bind(element: HTMLElement): void;
|
|
38
39
|
toHTML(): string;
|
|
39
40
|
toTextContent(): string;
|
|
40
41
|
get commands(): {
|
|
@@ -29,12 +29,13 @@ declare class TextEditorController {
|
|
|
29
29
|
view?: EditorView;
|
|
30
30
|
prosemirrorParser: DOMParser;
|
|
31
31
|
prosemirrorSerializer: DOMSerializer;
|
|
32
|
+
element?: HTMLElement;
|
|
32
33
|
get value(): string;
|
|
33
34
|
set value(value: string);
|
|
34
35
|
constructor(props?: TextEditorControllerProps);
|
|
35
36
|
toInnerHTML(value: string): string;
|
|
36
37
|
attachFile(files: File[]): Promise<void>;
|
|
37
|
-
bind(
|
|
38
|
+
bind(element: HTMLElement): void;
|
|
38
39
|
toHTML(): string;
|
|
39
40
|
toTextContent(): string;
|
|
40
41
|
get commands(): {
|
|
@@ -926,6 +926,7 @@ var TextEditorController = class {
|
|
|
926
926
|
view;
|
|
927
927
|
prosemirrorParser;
|
|
928
928
|
prosemirrorSerializer;
|
|
929
|
+
element;
|
|
929
930
|
get value() {
|
|
930
931
|
if (this.props.mode === "text") {
|
|
931
932
|
return this.toTextContent();
|
|
@@ -963,12 +964,13 @@ var TextEditorController = class {
|
|
|
963
964
|
uploadFile: this.props.attachFile?.uploadFile
|
|
964
965
|
})(this.view, files);
|
|
965
966
|
}
|
|
966
|
-
bind(
|
|
967
|
+
bind(element) {
|
|
968
|
+
this.element = element;
|
|
967
969
|
const wrapper = document.createElement("div");
|
|
968
970
|
wrapper.innerHTML = this.toInnerHTML(
|
|
969
971
|
this.props.defaultValue ? String(this.props.defaultValue) : ""
|
|
970
972
|
);
|
|
971
|
-
this.view = new import_prosemirror_view4.EditorView(
|
|
973
|
+
this.view = new import_prosemirror_view4.EditorView(element, {
|
|
972
974
|
...this.props.editor,
|
|
973
975
|
attributes: (state) => {
|
|
974
976
|
const propsAttributes = (() => {
|
|
@@ -893,6 +893,7 @@ var TextEditorController = class {
|
|
|
893
893
|
view;
|
|
894
894
|
prosemirrorParser;
|
|
895
895
|
prosemirrorSerializer;
|
|
896
|
+
element;
|
|
896
897
|
get value() {
|
|
897
898
|
if (this.props.mode === "text") {
|
|
898
899
|
return this.toTextContent();
|
|
@@ -930,12 +931,13 @@ var TextEditorController = class {
|
|
|
930
931
|
uploadFile: this.props.attachFile?.uploadFile
|
|
931
932
|
})(this.view, files);
|
|
932
933
|
}
|
|
933
|
-
bind(
|
|
934
|
+
bind(element) {
|
|
935
|
+
this.element = element;
|
|
934
936
|
const wrapper = document.createElement("div");
|
|
935
937
|
wrapper.innerHTML = this.toInnerHTML(
|
|
936
938
|
this.props.defaultValue ? String(this.props.defaultValue) : ""
|
|
937
939
|
);
|
|
938
|
-
this.view = new EditorView3(
|
|
940
|
+
this.view = new EditorView3(element, {
|
|
939
941
|
...this.props.editor,
|
|
940
942
|
attributes: (state) => {
|
|
941
943
|
const propsAttributes = (() => {
|