@dxos/react-ui-editor 0.3.11-main.dafb7f2 → 0.3.11-main.dd122a6

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.
@@ -930,7 +930,6 @@ var random = (min, max) => {
930
930
 
931
931
  // packages/ui/react-ui-editor/src/extensions/code.ts
932
932
  import { ViewPlugin as ViewPlugin3, EditorView as EditorView4, Decoration as Decoration2 } from "@codemirror/view";
933
- import get2 from "lodash.get";
934
933
  import { mx as mx2 } from "@dxos/react-ui-theme";
935
934
 
936
935
  // packages/ui/react-ui-editor/src/styles/cursors.ts
@@ -1014,20 +1013,22 @@ var inlineUrl = mx(code, "px-1");
1014
1013
  var blockquote = mx("pl-1 mr-1 border-is-4 border-primary-500/70 dark:border-primary-500/30", light);
1015
1014
 
1016
1015
  // packages/ui/react-ui-editor/src/styles/tokens.ts
1016
+ import get2 from "lodash.get";
1017
1017
  import { tailwindConfig } from "@dxos/react-ui-theme";
1018
1018
  var tokens = tailwindConfig({}).theme;
1019
+ var getToken = (path, defaultValue = void 0) => get2(tokens, path, defaultValue);
1019
1020
 
1020
1021
  // packages/ui/react-ui-editor/src/extensions/code.ts
1021
1022
  var CODE_REGEX = /```[\s\S]*?```/gs;
1022
1023
  var styles2 = EditorView4.baseTheme({
1023
1024
  "& .cm-codeblock": {
1024
- fontFamily: get2(tokens, "fontFamily.mono", []).join(",")
1025
+ fontFamily: getToken("fontFamily.mono", []).join(",")
1025
1026
  },
1026
1027
  '&light [aria-readonly="true"] .cm-codeblock': {
1027
- background: get2(tokens, "extend.colors.neutral.50")
1028
+ background: getToken("extend.colors.neutral.50")
1028
1029
  },
1029
1030
  '&dark [aria-readonly="true"] .cm-codeblock': {
1030
- background: get2(tokens, "extend.colors.neutral.850")
1031
+ background: getToken("extend.colors.neutral.850")
1031
1032
  },
1032
1033
  '& [aria-readonly="true"] .cm-codeblock': {
1033
1034
  display: "block",
@@ -1091,7 +1092,6 @@ var code2 = () => {
1091
1092
  // packages/ui/react-ui-editor/src/extensions/comments.ts
1092
1093
  import { StateEffect as StateEffect2, StateField as StateField2 } from "@codemirror/state";
1093
1094
  import { hoverTooltip, keymap as keymap3, Decoration as Decoration3, EditorView as EditorView5, MatchDecorator, ViewPlugin as ViewPlugin4, WidgetType as WidgetType2 } from "@codemirror/view";
1094
- import get3 from "lodash.get";
1095
1095
  import sortBy from "lodash.sortby";
1096
1096
  import { debounce } from "@dxos/async";
1097
1097
  import { invariant as invariant2 } from "@dxos/invariant";
@@ -1109,10 +1109,10 @@ var styles3 = EditorView5.baseTheme({
1109
1109
  backgroundColor: "orange"
1110
1110
  },
1111
1111
  "& .cm-comment": {
1112
- backgroundColor: get3(tokens, "extend.colors.yellow.50")
1112
+ backgroundColor: getToken("extend.colors.yellow.50")
1113
1113
  },
1114
1114
  "& .cm-comment-active": {
1115
- backgroundColor: get3(tokens, "extend.colors.yellow.100")
1115
+ backgroundColor: getToken("extend.colors.yellow.100")
1116
1116
  }
1117
1117
  });
1118
1118
  var marks = {
@@ -1203,7 +1203,7 @@ var BookmarkWidget = class extends WidgetType2 {
1203
1203
  this._handleClick = _handleClick;
1204
1204
  invariant2(this._id, void 0, {
1205
1205
  F: __dxlog_file3,
1206
- L: 169,
1206
+ L: 168,
1207
1207
  S: this,
1208
1208
  A: [
1209
1209
  "this._id",
@@ -1230,7 +1230,7 @@ var comments = (options = {}) => {
1230
1230
  const cursorConverter3 = view.state.facet(CursorConverter);
1231
1231
  invariant2(options.onCreate, void 0, {
1232
1232
  F: __dxlog_file3,
1233
- L: 225,
1233
+ L: 224,
1234
1234
  S: void 0,
1235
1235
  A: [
1236
1236
  "options.onCreate",
@@ -1361,7 +1361,7 @@ var comments = (options = {}) => {
1361
1361
  thread: range.id
1362
1362
  }, {
1363
1363
  F: __dxlog_file3,
1364
- L: 359,
1364
+ L: 358,
1365
1365
  S: void 0,
1366
1366
  C: (f, a) => f(...a)
1367
1367
  });
@@ -1429,7 +1429,7 @@ var getRangeFromCursor = (cursorConverter3, cursor) => {
1429
1429
  const parts = cursor.split(":");
1430
1430
  const from = cursorConverter3.fromCursor(parts[0]);
1431
1431
  const to = cursorConverter3.fromCursor(parts[1]);
1432
- return from && to ? {
1432
+ return from !== void 0 && to !== void 0 ? {
1433
1433
  from,
1434
1434
  to
1435
1435
  } : void 0;
@@ -1437,12 +1437,11 @@ var getRangeFromCursor = (cursorConverter3, cursor) => {
1437
1437
 
1438
1438
  // packages/ui/react-ui-editor/src/extensions/hr.ts
1439
1439
  import { Decoration as Decoration4, EditorView as EditorView6, MatchDecorator as MatchDecorator2, ViewPlugin as ViewPlugin5, WidgetType as WidgetType3 } from "@codemirror/view";
1440
- import get4 from "lodash.get";
1441
1440
  var styles4 = EditorView6.baseTheme({
1442
1441
  "& .cm-hr": {
1443
1442
  // TODO(burdon): ???
1444
1443
  // Note that block-level decorations should not have vertical margins,
1445
- borderBottom: `1px solid ${get4(tokens, "extend.colors.neutral.200")}`
1444
+ borderBottom: `1px solid ${getToken("extend.colors.neutral.200")}`
1446
1445
  }
1447
1446
  });
1448
1447
  var HorizontalRuleWidget = class extends WidgetType3 {
@@ -1672,7 +1671,7 @@ var buildDecorations2 = (view, options) => {
1672
1671
  if (!url) {
1673
1672
  return false;
1674
1673
  }
1675
- if (state.readOnly || cursor < node.from || cursor > node.to) {
1674
+ if (!view.hasFocus || state.readOnly || cursor < node.from || cursor > node.to) {
1676
1675
  builder.add(node.from, node.to, Decoration6.replace({
1677
1676
  widget: new LinkText(text, options.link ? url : void 0)
1678
1677
  }));
@@ -1722,7 +1721,6 @@ import { markdownLanguage } from "@codemirror/lang-markdown";
1722
1721
  import { HighlightStyle } from "@codemirror/language";
1723
1722
  import { tags, styleTags, Tag } from "@lezer/highlight";
1724
1723
  import { Table } from "@lezer/markdown";
1725
- import get5 from "lodash.get";
1726
1724
  var markdownTags = {
1727
1725
  Blockquote: Tag.define(),
1728
1726
  CodeMark: Tag.define(),
@@ -1908,7 +1906,7 @@ var markdownHighlightStyle = (readonly) => {
1908
1906
  ], {
1909
1907
  scope: markdownLanguage,
1910
1908
  all: {
1911
- fontFamily: get5(tokens, "fontFamily.body", []).join(",")
1909
+ fontFamily: getToken("fontFamily.body", []).join(",")
1912
1910
  }
1913
1911
  });
1914
1912
  };
@@ -1989,11 +1987,6 @@ var mention = ({ onSearch }) => {
1989
1987
  });
1990
1988
  };
1991
1989
 
1992
- // packages/ui/react-ui-editor/src/extensions/mermaid.ts
1993
- var mermaid = () => {
1994
- return [];
1995
- };
1996
-
1997
1990
  // packages/ui/react-ui-editor/src/extensions/table.ts
1998
1991
  import { syntaxTree as syntaxTree3 } from "@codemirror/language";
1999
1992
  import { RangeSetBuilder as RangeSetBuilder2, StateField as StateField4 } from "@codemirror/state";
@@ -2253,7 +2246,7 @@ var yjs = (content, awareness2) => [
2253
2246
  ];
2254
2247
 
2255
2248
  // packages/ui/react-ui-editor/src/themes/default.ts
2256
- import get6 from "lodash.get";
2249
+ import get3 from "lodash.get";
2257
2250
  var defaultTheme = {
2258
2251
  //
2259
2252
  // Main layout:
@@ -2284,7 +2277,7 @@ var defaultTheme = {
2284
2277
  },
2285
2278
  ".cm-scroller": {
2286
2279
  overflow: "visible",
2287
- fontFamily: get6(tokens, "fontFamily.mono", []).join(",")
2280
+ fontFamily: get3(tokens, "fontFamily.mono", []).join(",")
2288
2281
  },
2289
2282
  ".cm-content": {
2290
2283
  padding: 0,
@@ -2292,11 +2285,11 @@ var defaultTheme = {
2292
2285
  fontSize: "16px"
2293
2286
  },
2294
2287
  "&light .cm-content": {
2295
- color: get6(tokens, "extend.colors.neutral.900", "black"),
2288
+ color: get3(tokens, "extend.colors.neutral.900", "black"),
2296
2289
  caretColor: "black"
2297
2290
  },
2298
2291
  "&dark .cm-content": {
2299
- color: get6(tokens, "extend.colors.neutral.100", "white"),
2292
+ color: get3(tokens, "extend.colors.neutral.100", "white"),
2300
2293
  caretColor: "white"
2301
2294
  },
2302
2295
  //
@@ -2324,25 +2317,25 @@ var defaultTheme = {
2324
2317
  // Selection
2325
2318
  //
2326
2319
  "&light .cm-selectionBackground": {
2327
- background: get6(tokens, "extend.colors.primary.100")
2320
+ background: get3(tokens, "extend.colors.primary.100")
2328
2321
  },
2329
2322
  "&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
2330
- background: get6(tokens, "extend.colors.primary.200")
2323
+ background: get3(tokens, "extend.colors.primary.200")
2331
2324
  },
2332
2325
  "&dark .cm-selectionBackground": {
2333
- background: get6(tokens, "extend.colors.primary.700")
2326
+ background: get3(tokens, "extend.colors.primary.700")
2334
2327
  },
2335
2328
  "&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
2336
- background: get6(tokens, "extend.colors.primary.600")
2329
+ background: get3(tokens, "extend.colors.primary.600")
2337
2330
  },
2338
2331
  //
2339
2332
  // Search
2340
2333
  //
2341
2334
  "&light .cm-searchMatch": {
2342
- backgroundColor: get6(tokens, "extend.colors.yellow.100")
2335
+ backgroundColor: get3(tokens, "extend.colors.yellow.100")
2343
2336
  },
2344
2337
  "&dark .cm-searchMatch": {
2345
- backgroundColor: get6(tokens, "extend.colors.yellow.700")
2338
+ backgroundColor: get3(tokens, "extend.colors.yellow.700")
2346
2339
  },
2347
2340
  //
2348
2341
  // collaboration
@@ -2375,12 +2368,12 @@ var defaultTheme = {
2375
2368
  // link
2376
2369
  //
2377
2370
  ".cm-link": {
2378
- color: get6(tokens, "extend.colors.primary.500"),
2371
+ color: get3(tokens, "extend.colors.primary.500"),
2379
2372
  textDecorationLine: "underline",
2380
2373
  textDecorationThickness: "1px",
2381
2374
  textUnderlineOffset: "2px",
2382
2375
  borderRadius: ".125rem",
2383
- fontFamily: get6(tokens, "fontFamily.body", []).join(",")
2376
+ fontFamily: get3(tokens, "fontFamily.body", []).join(",")
2384
2377
  },
2385
2378
  //
2386
2379
  // tooltip
@@ -2402,7 +2395,7 @@ var defaultTheme = {
2402
2395
  display: "none"
2403
2396
  },
2404
2397
  ".cm-completionLabel": {
2405
- fontFamily: get6(tokens, "fontFamily.body", []).join(",")
2398
+ fontFamily: get3(tokens, "fontFamily.body", []).join(",")
2406
2399
  },
2407
2400
  ".cm-completionMatchedText": {
2408
2401
  textDecoration: "none"
@@ -2418,15 +2411,15 @@ var defaultTheme = {
2418
2411
  // table
2419
2412
  //
2420
2413
  ".cm-table *": {
2421
- fontFamily: `${get6(tokens, "fontFamily.mono", []).join(",")} !important`,
2414
+ fontFamily: `${get3(tokens, "fontFamily.mono", []).join(",")} !important`,
2422
2415
  textDecoration: "none !important"
2423
2416
  },
2424
2417
  ".cm-table-head": {
2425
2418
  padding: "2px 16px 2px 0px",
2426
- borderBottom: `1px solid ${get6(tokens, "extend.colors.neutral.500")}`,
2419
+ borderBottom: `1px solid ${get3(tokens, "extend.colors.neutral.500")}`,
2427
2420
  fontWeight: 100,
2428
2421
  textAlign: "left",
2429
- color: get6(tokens, "extend.colors.neutral.500")
2422
+ color: get3(tokens, "extend.colors.neutral.500")
2430
2423
  },
2431
2424
  ".cm-table-cell": {
2432
2425
  padding: "2px 16px 2px 0px"
@@ -2447,8 +2440,8 @@ var defaultTheme = {
2447
2440
  // font size
2448
2441
  // TODO(thure): This appears to be the best or only way to set selection caret heights, but it's far more verbose than it needs to be.
2449
2442
  //
2450
- ...Object.keys(get6(tokens, "extend.fontSize", {})).reduce((acc, fontSize) => {
2451
- const height = get6(tokens, [
2443
+ ...Object.keys(get3(tokens, "extend.fontSize", {})).reduce((acc, fontSize) => {
2444
+ const height = get3(tokens, [
2452
2445
  "extend",
2453
2446
  "fontSize",
2454
2447
  fontSize,
@@ -2483,23 +2476,23 @@ var defaultTheme = {
2483
2476
  * </div
2484
2477
  */
2485
2478
  ".cm-panels": {
2486
- border: `1px solid ${get6(tokens, "extend.colors.neutral.200")}`
2479
+ border: `1px solid ${get3(tokens, "extend.colors.neutral.200")}`
2487
2480
  },
2488
2481
  ".cm-panel": {
2489
- background: get6(tokens, "extend.colors.neutral.50"),
2490
- fontFamily: get6(tokens, "fontFamily.body", []).join(",")
2482
+ background: get3(tokens, "extend.colors.neutral.50"),
2483
+ fontFamily: get3(tokens, "fontFamily.body", []).join(",")
2491
2484
  },
2492
2485
  ".cm-button": {
2493
2486
  margin: "4px",
2494
- fontFamily: get6(tokens, "fontFamily.body", []).join(","),
2495
- background: get6(tokens, "extend.colors.neutral.100"),
2487
+ fontFamily: get3(tokens, "fontFamily.body", []).join(","),
2488
+ background: get3(tokens, "extend.colors.neutral.100"),
2496
2489
  backgroundImage: "none",
2497
2490
  border: "none",
2498
2491
  "&:hover": {
2499
- background: get6(tokens, "extend.colors.neutral.200")
2492
+ background: get3(tokens, "extend.colors.neutral.200")
2500
2493
  },
2501
2494
  "&:active": {
2502
- background: get6(tokens, "extend.colors.neutral.300"),
2495
+ background: get3(tokens, "extend.colors.neutral.300"),
2503
2496
  backgroundImage: "none"
2504
2497
  }
2505
2498
  },
@@ -2509,24 +2502,24 @@ var defaultTheme = {
2509
2502
  };
2510
2503
  var textTheme = {
2511
2504
  ".cm-scroller": {
2512
- fontFamily: get6(tokens, "fontFamily.body", []).join(",")
2505
+ fontFamily: get3(tokens, "fontFamily.body", []).join(",")
2513
2506
  },
2514
2507
  ".cm-placeholder": {
2515
- fontFamily: get6(tokens, "fontFamily.body", []).join(",")
2508
+ fontFamily: get3(tokens, "fontFamily.body", []).join(",")
2516
2509
  }
2517
2510
  };
2518
2511
  var markdownTheme = {
2519
2512
  // NOTE: Must leave base font family as is (i.e., monospace) due to fenced code blocks.
2520
2513
  ".cm-placeholder": {
2521
- fontFamily: get6(tokens, "fontFamily.body", []).join(",")
2514
+ fontFamily: get3(tokens, "fontFamily.body", []).join(",")
2522
2515
  }
2523
2516
  };
2524
2517
  var codeTheme = {
2525
2518
  ".cm-scroller": {
2526
- fontFamily: get6(tokens, "fontFamily.mono", []).join(",")
2519
+ fontFamily: get3(tokens, "fontFamily.mono", []).join(",")
2527
2520
  },
2528
2521
  ".cm-placeholder": {
2529
- fontFamily: get6(tokens, "fontFamily.mono", []).join(",")
2522
+ fontFamily: get3(tokens, "fontFamily.mono", []).join(",")
2530
2523
  }
2531
2524
  };
2532
2525
 
@@ -2705,7 +2698,7 @@ var defaultMarkdownSlots = {
2705
2698
  };
2706
2699
 
2707
2700
  // packages/ui/react-ui-editor/src/hooks/automerge.ts
2708
- import get7 from "lodash.get";
2701
+ import get4 from "lodash.get";
2709
2702
  import { getRawDoc } from "@dxos/echo-schema";
2710
2703
  import { isNotNullOrUndefined } from "@dxos/util";
2711
2704
 
@@ -3026,7 +3019,7 @@ var createAutomergeModel = ({ space, identity, text }) => {
3026
3019
  const model = {
3027
3020
  id: obj.id,
3028
3021
  content: doc,
3029
- text: () => get7(doc.handle.docSync(), doc.path),
3022
+ text: () => get4(doc.handle.docSync(), doc.path),
3030
3023
  // TODO(burdon): https://automerge.org/automerge/api-docs/js/functions/next.getCursor.html
3031
3024
  extension: [
3032
3025
  modelState.init(() => model),
@@ -3072,6 +3065,7 @@ export {
3072
3065
  defaultSlots,
3073
3066
  defaultTextSlots,
3074
3067
  defaultTheme,
3068
+ getToken,
3075
3069
  hr,
3076
3070
  image,
3077
3071
  link,
@@ -3082,7 +3076,6 @@ export {
3082
3076
  markdownTagsExtensions,
3083
3077
  markdownTheme,
3084
3078
  mention,
3085
- mermaid,
3086
3079
  modelState,
3087
3080
  setCommentRange,
3088
3081
  setFocus,