@dxos/react-ui-editor 0.4.10-main.3040945 → 0.4.10-main.334c9db
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 +10 -22
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/factories.d.ts +1 -1
- package/dist/types/src/extensions/factories.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +0 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/package.json +24 -24
- package/src/components/TextEditor/TextEditor.stories.tsx +3 -3
- package/src/components/TextEditor/TextEditor.tsx +3 -1
- package/src/components/Toolbar/Toolbar.stories.tsx +6 -8
- package/src/extensions/automerge/automerge.stories.tsx +2 -2
- package/src/extensions/factories.ts +2 -2
- package/src/hooks/index.ts +0 -1
- package/dist/types/src/hooks/useDocAccessor.d.ts +0 -9
- package/dist/types/src/hooks/useDocAccessor.d.ts.map +0 -1
- package/src/hooks/useDocAccessor.ts +0 -21
|
@@ -37,6 +37,7 @@ import { EditorView as EditorView16 } from "@codemirror/view";
|
|
|
37
37
|
import { useFocusableGroup } from "@fluentui/react-tabster";
|
|
38
38
|
import React, { forwardRef, useCallback, useEffect as useEffect2, useImperativeHandle, useRef, useState as useState2 } from "react";
|
|
39
39
|
import { log as log7 } from "@dxos/log";
|
|
40
|
+
import { useDefaultValue } from "@dxos/react-ui";
|
|
40
41
|
import { isNotFalsy as isNotFalsy4 } from "@dxos/util";
|
|
41
42
|
|
|
42
43
|
// packages/ui/react-ui-editor/src/extensions/annotations.ts
|
|
@@ -2247,9 +2248,9 @@ var createThemeExtensions = ({ theme, themeMode, slots: _slots } = {}) => {
|
|
|
2247
2248
|
].filter(isNotFalsy2);
|
|
2248
2249
|
};
|
|
2249
2250
|
var createDataExtensions = ({ id, text, space, identity }) => {
|
|
2250
|
-
const extensions = [
|
|
2251
|
+
const extensions = text ? [
|
|
2251
2252
|
automerge(text)
|
|
2252
|
-
];
|
|
2253
|
+
] : [];
|
|
2253
2254
|
if (space && identity) {
|
|
2254
2255
|
const peerId = identity?.identityKey.toHex();
|
|
2255
2256
|
const { cursorLightValue, cursorDarkValue } = hueTokens[identity?.profile?.data?.hue ?? hexToHue(peerId ?? "0")];
|
|
@@ -4404,10 +4405,11 @@ var typewriter = ({ delay = 75, items = defaultItems } = {}) => {
|
|
|
4404
4405
|
// packages/ui/react-ui-editor/src/components/TextEditor/TextEditor.tsx
|
|
4405
4406
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/components/TextEditor/TextEditor.tsx";
|
|
4406
4407
|
var instanceCount = 0;
|
|
4407
|
-
var TextEditor = /* @__PURE__ */ forwardRef(({ id, doc, selection, extensions, className, autoFocus, scrollTo
|
|
4408
|
-
yMargin: 0
|
|
4409
|
-
}), moveToEndOfLine, debug, dataTestId }, forwardedRef) => {
|
|
4408
|
+
var TextEditor = /* @__PURE__ */ forwardRef(({ id, doc, selection, extensions, className, autoFocus, scrollTo: propsScrollTo, moveToEndOfLine, debug, dataTestId }, forwardedRef) => {
|
|
4410
4409
|
const [instanceId] = useState2(() => `text-editor-${++instanceCount}`);
|
|
4410
|
+
const scrollTo = useDefaultValue(propsScrollTo, EditorView16.scrollIntoView(0, {
|
|
4411
|
+
yMargin: 0
|
|
4412
|
+
}));
|
|
4411
4413
|
const tabsterDOMAttribute = useFocusableGroup({
|
|
4412
4414
|
tabBehavior: "limited"
|
|
4413
4415
|
});
|
|
@@ -4430,7 +4432,7 @@ var TextEditor = /* @__PURE__ */ forwardRef(({ id, doc, selection, extensions, c
|
|
|
4430
4432
|
instanceId
|
|
4431
4433
|
}, {
|
|
4432
4434
|
F: __dxlog_file10,
|
|
4433
|
-
L:
|
|
4435
|
+
L: 90,
|
|
4434
4436
|
S: void 0,
|
|
4435
4437
|
C: (f, a) => f(...a)
|
|
4436
4438
|
});
|
|
@@ -4443,7 +4445,7 @@ var TextEditor = /* @__PURE__ */ forwardRef(({ id, doc, selection, extensions, c
|
|
|
4443
4445
|
EditorView16.exceptionSink.of((err) => {
|
|
4444
4446
|
log7.catch(err, void 0, {
|
|
4445
4447
|
F: __dxlog_file10,
|
|
4446
|
-
L:
|
|
4448
|
+
L: 103,
|
|
4447
4449
|
S: void 0,
|
|
4448
4450
|
C: (f, a) => f(...a)
|
|
4449
4451
|
});
|
|
@@ -4490,7 +4492,7 @@ var TextEditor = /* @__PURE__ */ forwardRef(({ id, doc, selection, extensions, c
|
|
|
4490
4492
|
instanceId
|
|
4491
4493
|
}, {
|
|
4492
4494
|
F: __dxlog_file10,
|
|
4493
|
-
L:
|
|
4495
|
+
L: 152,
|
|
4494
4496
|
S: void 0,
|
|
4495
4497
|
C: (f, a) => f(...a)
|
|
4496
4498
|
});
|
|
@@ -4939,19 +4941,6 @@ var useTextEditor = (cb = () => ({}), deps = []) => {
|
|
|
4939
4941
|
view
|
|
4940
4942
|
};
|
|
4941
4943
|
};
|
|
4942
|
-
|
|
4943
|
-
// packages/ui/react-ui-editor/src/hooks/useDocAccessor.ts
|
|
4944
|
-
import { useMemo as useMemo3 } from "react";
|
|
4945
|
-
import { createDocAccessor, getTextContent } from "@dxos/echo-schema";
|
|
4946
|
-
var useDocAccessor = (text) => {
|
|
4947
|
-
return useMemo3(() => ({
|
|
4948
|
-
id: text.id,
|
|
4949
|
-
doc: getTextContent(text),
|
|
4950
|
-
accessor: createDocAccessor(text)
|
|
4951
|
-
}), [
|
|
4952
|
-
text
|
|
4953
|
-
]);
|
|
4954
|
-
};
|
|
4955
4944
|
export {
|
|
4956
4945
|
Cursor,
|
|
4957
4946
|
EditorModes,
|
|
@@ -5034,7 +5023,6 @@ export {
|
|
|
5034
5023
|
typewriter,
|
|
5035
5024
|
useActionHandler,
|
|
5036
5025
|
useComments,
|
|
5037
|
-
useDocAccessor,
|
|
5038
5026
|
useFormattingState,
|
|
5039
5027
|
useTextEditor,
|
|
5040
5028
|
useToolbarContext
|