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.
@@ -160,7 +160,12 @@ function createAttachFile({
160
160
  if (!node) {
161
161
  return;
162
162
  }
163
- view.dispatch(tr2.replaceWith($pos, $pos, node));
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
  }
@@ -136,7 +136,12 @@ function createAttachFile({
136
136
  if (!node) {
137
137
  return;
138
138
  }
139
- view.dispatch(tr2.replaceWith($pos, $pos, node));
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, Ref, FC } from 'react';
2
- import { Transaction } from 'prosemirror-state';
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
- ref?: Ref<TextEditorController>;
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 TextEditorController, type TextEditorProps, createTextEditor };
19
+ export { type TextEditorProps, createTextEditor };
@@ -1,28 +1,19 @@
1
- import { DetailedHTMLProps, InputHTMLAttributes, Ref, FC } from 'react';
2
- import { Transaction } from 'prosemirror-state';
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
- ref?: Ref<TextEditorController>;
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 TextEditorController, type TextEditorProps, createTextEditor };
19
+ export { type TextEditorProps, createTextEditor };