dn-react-text-editor 0.2.4 → 0.3.1
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/attach_file.js +6 -1
- package/dist/attach_file.mjs +6 -1
- package/dist/create_text_editor.d.mts +10 -19
- package/dist/create_text_editor.d.ts +10 -19
- package/dist/create_text_editor.js +478 -451
- package/dist/create_text_editor.mjs +479 -452
- package/dist/html.js +6 -5
- package/dist/html.mjs +6 -5
- package/dist/index.d.mts +5 -6
- package/dist/index.d.ts +5 -6
- package/dist/index.js +486 -456
- package/dist/index.mjs +486 -457
- package/dist/input.d.mts +6 -9
- package/dist/input.d.ts +6 -9
- package/dist/input.js +12 -13
- package/dist/input.mjs +12 -13
- package/dist/plugins/keymap.js +45 -17
- package/dist/plugins/keymap.mjs +45 -17
- package/dist/text_editor_controller.d.mts +20 -10
- package/dist/text_editor_controller.d.ts +20 -10
- package/dist/text_editor_controller.js +658 -125
- package/dist/text_editor_controller.mjs +656 -123
- package/package.json +56 -55
package/dist/attach_file.js
CHANGED
|
@@ -160,7 +160,12 @@ function createAttachFile({
|
|
|
160
160
|
if (!node) {
|
|
161
161
|
return;
|
|
162
162
|
}
|
|
163
|
-
view.
|
|
163
|
+
const current = view.state.doc.resolve($pos);
|
|
164
|
+
if (current.parentOffset === 0) {
|
|
165
|
+
view.dispatch(tr2.replaceWith($pos - 1, $pos, node));
|
|
166
|
+
} else {
|
|
167
|
+
view.dispatch(tr2.replaceWith($pos, $pos, node));
|
|
168
|
+
}
|
|
164
169
|
} catch (e) {
|
|
165
170
|
view.dispatch(tr.setMeta(uploadPlaceholderPlugin, { remove: { id } }));
|
|
166
171
|
}
|
package/dist/attach_file.mjs
CHANGED
|
@@ -136,7 +136,12 @@ function createAttachFile({
|
|
|
136
136
|
if (!node) {
|
|
137
137
|
return;
|
|
138
138
|
}
|
|
139
|
-
view.
|
|
139
|
+
const current = view.state.doc.resolve($pos);
|
|
140
|
+
if (current.parentOffset === 0) {
|
|
141
|
+
view.dispatch(tr2.replaceWith($pos - 1, $pos, node));
|
|
142
|
+
} else {
|
|
143
|
+
view.dispatch(tr2.replaceWith($pos, $pos, node));
|
|
144
|
+
}
|
|
140
145
|
} catch (e) {
|
|
141
146
|
view.dispatch(tr.setMeta(uploadPlaceholderPlugin, { remove: { id } }));
|
|
142
147
|
}
|
|
@@ -1,28 +1,19 @@
|
|
|
1
|
-
import { DetailedHTMLProps, InputHTMLAttributes,
|
|
2
|
-
import {
|
|
3
|
-
import { EditorView } from 'prosemirror-view';
|
|
4
|
-
import { createSchema } from './schema.mjs';
|
|
5
|
-
import { Subject } from 'rxjs';
|
|
6
|
-
import { createCommands } from './commands.mjs';
|
|
7
|
-
import { TextEditorControllerProps, CreateTextEditorOptions } from './text_editor_controller.mjs';
|
|
8
|
-
import 'orderedmap';
|
|
1
|
+
import { DetailedHTMLProps, InputHTMLAttributes, FC } from 'react';
|
|
2
|
+
import { TextEditorController, TextEditorControllerProps } from './text_editor_controller.mjs';
|
|
9
3
|
import 'prosemirror-model';
|
|
4
|
+
import 'prosemirror-state';
|
|
5
|
+
import 'prosemirror-view';
|
|
10
6
|
import './attach_file.mjs';
|
|
7
|
+
import './schema.mjs';
|
|
8
|
+
import 'orderedmap';
|
|
9
|
+
import 'rxjs';
|
|
11
10
|
|
|
12
|
-
type TextEditorController = {
|
|
13
|
-
schema: ReturnType<typeof createSchema>;
|
|
14
|
-
view: EditorView;
|
|
15
|
-
subject: Subject<Transaction>;
|
|
16
|
-
set value(value: string);
|
|
17
|
-
get value(): string;
|
|
18
|
-
} & {
|
|
19
|
-
commands: ReturnType<typeof createCommands>;
|
|
20
|
-
};
|
|
21
11
|
type HTMLElementProps = DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
22
12
|
type TextEditorProps = Omit<HTMLElementProps, "ref"> & {
|
|
23
|
-
|
|
13
|
+
controller?: TextEditorController;
|
|
24
14
|
name?: string;
|
|
25
15
|
} & TextEditorControllerProps;
|
|
16
|
+
type CreateTextEditorOptions = Pick<TextEditorControllerProps, "className" | "style" | "attachFile">;
|
|
26
17
|
declare function createTextEditor(options?: CreateTextEditorOptions): FC<TextEditorProps>;
|
|
27
18
|
|
|
28
|
-
export { type
|
|
19
|
+
export { type TextEditorProps, createTextEditor };
|
|
@@ -1,28 +1,19 @@
|
|
|
1
|
-
import { DetailedHTMLProps, InputHTMLAttributes,
|
|
2
|
-
import {
|
|
3
|
-
import { EditorView } from 'prosemirror-view';
|
|
4
|
-
import { createSchema } from './schema.js';
|
|
5
|
-
import { Subject } from 'rxjs';
|
|
6
|
-
import { createCommands } from './commands.js';
|
|
7
|
-
import { TextEditorControllerProps, CreateTextEditorOptions } from './text_editor_controller.js';
|
|
8
|
-
import 'orderedmap';
|
|
1
|
+
import { DetailedHTMLProps, InputHTMLAttributes, FC } from 'react';
|
|
2
|
+
import { TextEditorController, TextEditorControllerProps } from './text_editor_controller.js';
|
|
9
3
|
import 'prosemirror-model';
|
|
4
|
+
import 'prosemirror-state';
|
|
5
|
+
import 'prosemirror-view';
|
|
10
6
|
import './attach_file.js';
|
|
7
|
+
import './schema.js';
|
|
8
|
+
import 'orderedmap';
|
|
9
|
+
import 'rxjs';
|
|
11
10
|
|
|
12
|
-
type TextEditorController = {
|
|
13
|
-
schema: ReturnType<typeof createSchema>;
|
|
14
|
-
view: EditorView;
|
|
15
|
-
subject: Subject<Transaction>;
|
|
16
|
-
set value(value: string);
|
|
17
|
-
get value(): string;
|
|
18
|
-
} & {
|
|
19
|
-
commands: ReturnType<typeof createCommands>;
|
|
20
|
-
};
|
|
21
11
|
type HTMLElementProps = DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
22
12
|
type TextEditorProps = Omit<HTMLElementProps, "ref"> & {
|
|
23
|
-
|
|
13
|
+
controller?: TextEditorController;
|
|
24
14
|
name?: string;
|
|
25
15
|
} & TextEditorControllerProps;
|
|
16
|
+
type CreateTextEditorOptions = Pick<TextEditorControllerProps, "className" | "style" | "attachFile">;
|
|
26
17
|
declare function createTextEditor(options?: CreateTextEditorOptions): FC<TextEditorProps>;
|
|
27
18
|
|
|
28
|
-
export { type
|
|
19
|
+
export { type TextEditorProps, createTextEditor };
|