@dxos/react-ui-editor 0.4.4-main.385c016 → 0.4.4-main.3a00f69
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/lib/browser/index.mjs +48 -59
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.d.ts +3 -3
- package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +1 -1
- package/dist/types/src/components/TextEditor/hooks.stories.d.ts +1 -1
- package/dist/types/src/extensions/automerge/cursor.d.ts.map +1 -1
- package/dist/types/src/hooks/useEditorView.d.ts +4 -6
- package/dist/types/src/hooks/useEditorView.d.ts.map +1 -1
- package/dist/types/src/hooks/useTextModel.d.ts.map +1 -1
- package/package.json +24 -24
- package/src/components/TextEditor/TextEditor.tsx +3 -3
- package/src/components/Toolbar/Toolbar.stories.tsx +3 -3
- package/src/extensions/automerge/cursor.ts +2 -3
- package/src/hooks/useEditorView.ts +11 -13
- package/src/hooks/useTextModel.ts +9 -3
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import get from 'lodash.get';
|
|
6
|
-
import { type Dispatch, type SetStateAction,
|
|
6
|
+
import { type Dispatch, type SetStateAction, useEffect, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { generateName } from '@dxos/display-name';
|
|
9
9
|
import { type AutomergeTextCompat, getRawDoc } from '@dxos/echo-schema';
|
|
@@ -27,8 +27,14 @@ export type UseTextModelProps = {
|
|
|
27
27
|
* @deprecated
|
|
28
28
|
*/
|
|
29
29
|
// TODO(burdon): Remove once automerge lands.
|
|
30
|
-
export const useTextModel = (props: UseTextModelProps): EditorModel | undefined =>
|
|
31
|
-
|
|
30
|
+
export const useTextModel = (props: UseTextModelProps): EditorModel | undefined => {
|
|
31
|
+
const [model, setModel] = useState<EditorModel>();
|
|
32
|
+
const { identity, space, text } = props;
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
setModel(createModel(props));
|
|
35
|
+
}, [identity, space, text]);
|
|
36
|
+
return model;
|
|
37
|
+
};
|
|
32
38
|
|
|
33
39
|
/**
|
|
34
40
|
* For use primarily in stories & tests so the dependence on TextObject can be avoided.
|