@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.
@@ -12,7 +12,7 @@ import { EditorView as EditorView15 } from "@codemirror/view";
12
12
  import { useFocusableGroup } from "@fluentui/react-tabster";
13
13
  import defaultsDeep2 from "lodash.defaultsdeep";
14
14
  import React, { forwardRef, useCallback, useEffect as useEffect2, useImperativeHandle, useRef, useState as useState2 } from "react";
15
- import { log as log3 } from "@dxos/log";
15
+ import { log as log2 } from "@dxos/log";
16
16
  import { useThemeContext } from "@dxos/react-ui";
17
17
  import { focusRing } from "@dxos/react-ui-theme";
18
18
  import { isNotFalsy as isNotFalsy4 } from "@dxos/util";
@@ -163,8 +163,6 @@ import { next as A4 } from "@dxos/automerge/automerge";
163
163
  // packages/ui/react-ui-editor/src/extensions/automerge/cursor.ts
164
164
  import get from "lodash.get";
165
165
  import { next as A } from "@dxos/automerge/automerge";
166
- import { log } from "@dxos/log";
167
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/automerge/cursor.ts";
168
166
  var cursorConverter = (handle, path) => ({
169
167
  // TODO(burdon): Handle assoc to associate with a previous character.
170
168
  toCursor: (pos) => {
@@ -179,12 +177,6 @@ var cursorConverter = (handle, path) => ({
179
177
  try {
180
178
  return A.getCursor(doc, path.slice(), pos);
181
179
  } catch (err) {
182
- log.catch(err, void 0, {
183
- F: __dxlog_file,
184
- L: 31,
185
- S: void 0,
186
- C: (f, a) => f(...a)
187
- });
188
180
  return "";
189
181
  }
190
182
  },
@@ -207,12 +199,6 @@ var cursorConverter = (handle, path) => ({
207
199
  try {
208
200
  return A.getCursorPosition(doc, path.slice(), cursor);
209
201
  } catch (err) {
210
- log.catch(err, void 0, {
211
- F: __dxlog_file,
212
- L: 59,
213
- S: void 0,
214
- C: (f, a) => f(...a)
215
- });
216
202
  return 0;
217
203
  }
218
204
  }
@@ -732,7 +718,7 @@ var createBasicBundle = ({ themeMode, placeholder: _placeholder, lineWrapping =
732
718
  import { EditorView as EditorView5, keymap as keymap2 } from "@codemirror/view";
733
719
  import defaultsDeep from "lodash.defaultsdeep";
734
720
  import { invariant } from "@dxos/invariant";
735
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/blast.ts";
721
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/blast.ts";
736
722
  var defaultOptions = {
737
723
  effect: 2,
738
724
  maxParticles: 200,
@@ -859,7 +845,7 @@ var Blaster = class {
859
845
  }
860
846
  initialize() {
861
847
  invariant(!this._canvas && !this._ctx, void 0, {
862
- F: __dxlog_file2,
848
+ F: __dxlog_file,
863
849
  L: 141,
864
850
  S: this,
865
851
  A: [
@@ -896,7 +882,7 @@ var Blaster = class {
896
882
  }
897
883
  start() {
898
884
  invariant(this._canvas && this._ctx, void 0, {
899
- F: __dxlog_file2,
885
+ F: __dxlog_file,
900
886
  L: 180,
901
887
  S: this,
902
888
  A: [
@@ -1121,14 +1107,14 @@ var editorFillLayoutEditor = "min-bs-full";
1121
1107
  var editorHalfViewportOverscrollContent = "after:block after:min-bs-[50dvh] after:pointer-events-none";
1122
1108
 
1123
1109
  // packages/ui/react-ui-editor/src/util.ts
1124
- import { log as log2 } from "@dxos/log";
1125
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/util.ts";
1110
+ import { log } from "@dxos/log";
1111
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/util.ts";
1126
1112
  var callbackWrapper = (fn) => (...args) => {
1127
1113
  try {
1128
1114
  return fn(...args);
1129
1115
  } catch (err) {
1130
- log2.catch(err, void 0, {
1131
- F: __dxlog_file3,
1116
+ log.catch(err, void 0, {
1117
+ F: __dxlog_file2,
1132
1118
  L: 18,
1133
1119
  S: void 0,
1134
1120
  C: (f, a) => f(...a)
@@ -3906,7 +3892,7 @@ var codeTheme = {
3906
3892
  };
3907
3893
 
3908
3894
  // packages/ui/react-ui-editor/src/components/TextEditor/TextEditor.tsx
3909
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/components/TextEditor/TextEditor.tsx";
3895
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/components/TextEditor/TextEditor.tsx";
3910
3896
  var BaseTextEditor = /* @__PURE__ */ forwardRef(({ model, readonly, autoFocus, scrollTo, selection, theme, slots = defaultSlots, extensions = [], debug }, forwardedRef) => {
3911
3897
  const tabsterDOMAttribute = useFocusableGroup({
3912
3898
  tabBehavior: "limited"
@@ -3943,8 +3929,8 @@ var BaseTextEditor = /* @__PURE__ */ forwardRef(({ model, readonly, autoFocus, s
3943
3929
  extensions: [
3944
3930
  // TODO(burdon): Doesn't catch errors in keymap functions.
3945
3931
  EditorView15.exceptionSink.of((err) => {
3946
- log3.catch(err, void 0, {
3947
- F: __dxlog_file4,
3932
+ log2.catch(err, void 0, {
3933
+ F: __dxlog_file3,
3948
3934
  L: 112,
3949
3935
  S: void 0,
3950
3936
  C: (f, a) => f(...a)
@@ -4346,8 +4332,8 @@ var Toolbar = {
4346
4332
  import { DeferredTask, Event as Event2, sleep } from "@dxos/async";
4347
4333
  import { Context as Context2 } from "@dxos/context";
4348
4334
  import { invariant as invariant2 } from "@dxos/invariant";
4349
- import { log as log4 } from "@dxos/log";
4350
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/hooks/awareness-provider.ts";
4335
+ import { log as log3 } from "@dxos/log";
4336
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/hooks/awareness-provider.ts";
4351
4337
  var DEBOUNCE_INTERVAL = 100;
4352
4338
  var SpaceAwarenessProvider = class {
4353
4339
  constructor(params) {
@@ -4384,10 +4370,10 @@ var SpaceAwarenessProvider = class {
4384
4370
  void this._space.postMessage(this._channel, {
4385
4371
  kind: "query"
4386
4372
  }).catch((err) => {
4387
- log4.debug("failed to query awareness", {
4373
+ log3.debug("failed to query awareness", {
4388
4374
  err
4389
4375
  }, {
4390
- F: __dxlog_file5,
4376
+ F: __dxlog_file4,
4391
4377
  L: 89,
4392
4378
  S: this,
4393
4379
  C: (f, a) => f(...a)
@@ -4404,7 +4390,7 @@ var SpaceAwarenessProvider = class {
4404
4390
  }
4405
4391
  update(position) {
4406
4392
  invariant2(this._postTask, void 0, {
4407
- F: __dxlog_file5,
4393
+ F: __dxlog_file4,
4408
4394
  L: 104,
4409
4395
  S: this,
4410
4396
  A: [
@@ -4421,7 +4407,7 @@ var SpaceAwarenessProvider = class {
4421
4407
  }
4422
4408
  _handleQueryMessage() {
4423
4409
  invariant2(this._postTask, void 0, {
4424
- F: __dxlog_file5,
4410
+ F: __dxlog_file4,
4425
4411
  L: 115,
4426
4412
  S: this,
4427
4413
  A: [
@@ -4433,7 +4419,7 @@ var SpaceAwarenessProvider = class {
4433
4419
  }
4434
4420
  _handlePostMessage(message) {
4435
4421
  invariant2(message.kind === "post", void 0, {
4436
- F: __dxlog_file5,
4422
+ F: __dxlog_file4,
4437
4423
  L: 120,
4438
4424
  S: this,
4439
4425
  A: [
@@ -4502,36 +4488,28 @@ var useActionHandler = (view) => {
4502
4488
  };
4503
4489
 
4504
4490
  // packages/ui/react-ui-editor/src/hooks/useEditorView.ts
4505
- import { useRef as useRef2, useState as useState3 } from "react";
4506
- var useEditorView = (id) => {
4507
- const editorRef = useRef2(null);
4508
- const [prev, setPrev] = useState3([
4509
- null,
4510
- ""
4511
- ]);
4512
- if (prev[0] !== editorRef.current) {
4513
- setPrev([
4514
- editorRef.current,
4515
- id
4516
- ]);
4517
- }
4491
+ import { useState as useState3 } from "react";
4492
+ var useEditorView = () => {
4493
+ const [view, setView] = useState3(null);
4518
4494
  return [
4519
- editorRef,
4520
- prev[1] !== id
4495
+ (ref) => {
4496
+ setView(ref);
4497
+ },
4498
+ view
4521
4499
  ];
4522
4500
  };
4523
4501
 
4524
4502
  // packages/ui/react-ui-editor/src/hooks/useTextEditor.ts
4525
4503
  import { EditorSelection as EditorSelection2, EditorState as EditorState3 } from "@codemirror/state";
4526
4504
  import { EditorView as EditorView16 } from "@codemirror/view";
4527
- import { useEffect as useEffect3, useRef as useRef3, useState as useState4 } from "react";
4528
- import { log as log5 } from "@dxos/log";
4505
+ import { useEffect as useEffect3, useRef as useRef2, useState as useState4 } from "react";
4506
+ import { log as log4 } from "@dxos/log";
4529
4507
  import { isNotFalsy as isNotFalsy5 } from "@dxos/util";
4530
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/hooks/useTextEditor.ts";
4508
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/hooks/useTextEditor.ts";
4531
4509
  var useTextEditor = ({ autoFocus, scrollTo, debug, doc, selection, extensions } = {}) => {
4532
- const onUpdate = useRef3();
4510
+ const onUpdate = useRef2();
4533
4511
  const [view, setView] = useState4();
4534
- const parentRef = useRef3(null);
4512
+ const parentRef = useRef2(null);
4535
4513
  useEffect3(() => {
4536
4514
  if (parentRef.current) {
4537
4515
  const state = EditorState3.create({
@@ -4540,8 +4518,8 @@ var useTextEditor = ({ autoFocus, scrollTo, debug, doc, selection, extensions }
4540
4518
  extensions: [
4541
4519
  // TODO(burdon): Doesn't catch errors in keymap functions.
4542
4520
  EditorView16.exceptionSink.of((err) => {
4543
- log5.catch(err, void 0, {
4544
- F: __dxlog_file6,
4521
+ log4.catch(err, void 0, {
4522
+ F: __dxlog_file5,
4545
4523
  L: 57,
4546
4524
  S: void 0,
4547
4525
  C: (f, a) => f(...a)
@@ -4630,13 +4608,24 @@ var createThemeExtensions = ({ theme, themeMode, slots } = {}) => {
4630
4608
 
4631
4609
  // packages/ui/react-ui-editor/src/hooks/useTextModel.ts
4632
4610
  import get4 from "lodash.get";
4633
- import { useState as useState5, useMemo as useMemo2 } from "react";
4611
+ import { useEffect as useEffect4, useState as useState5 } from "react";
4634
4612
  import { generateName } from "@dxos/display-name";
4635
4613
  import { getRawDoc } from "@dxos/echo-schema";
4636
4614
  import { invariant as invariant3 } from "@dxos/invariant";
4637
4615
  import { isAutomergeObject } from "@dxos/react-client/echo";
4638
- var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/hooks/useTextModel.ts";
4639
- var useTextModel = (props) => useMemo2(() => createModel(props), Object.values(props));
4616
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/hooks/useTextModel.ts";
4617
+ var useTextModel = (props) => {
4618
+ const [model, setModel] = useState5();
4619
+ const { identity, space, text } = props;
4620
+ useEffect4(() => {
4621
+ setModel(createModel(props));
4622
+ }, [
4623
+ identity,
4624
+ space,
4625
+ text
4626
+ ]);
4627
+ return model;
4628
+ };
4640
4629
  var useInMemoryTextModel = ({ id, defaultContent }) => {
4641
4630
  const [content, setContent] = useState5(defaultContent ?? "");
4642
4631
  return {
@@ -4651,8 +4640,8 @@ var createModel = ({ space, identity, text }) => {
4651
4640
  return void 0;
4652
4641
  }
4653
4642
  invariant3(isAutomergeObject(text), void 0, {
4654
- F: __dxlog_file7,
4655
- L: 54,
4643
+ F: __dxlog_file6,
4644
+ L: 60,
4656
4645
  S: void 0,
4657
4646
  A: [
4658
4647
  "isAutomergeObject(text)",