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

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";
@@ -2047,7 +2040,6 @@ var update = (state, options) => {
2047
2040
  tables.forEach((table2) => {
2048
2041
  const hide = state.readOnly || cursor < table2.from || cursor > table2.to;
2049
2042
  hide && builder.add(table2.from, table2.to, Decoration7.replace({
2050
- block: true,
2051
2043
  widget: new TableWidget(table2)
2052
2044
  }));
2053
2045
  builder.add(table2.from, table2.to, Decoration7.mark({
@@ -2088,6 +2080,9 @@ var TableWidget = class extends WidgetType6 {
2088
2080
  }
2089
2081
  return table2;
2090
2082
  }
2083
+ ignoreEvent(e) {
2084
+ return !/^mouse/.test(e.type);
2085
+ }
2091
2086
  };
2092
2087
 
2093
2088
  // packages/ui/react-ui-editor/src/extensions/tasklist.ts
@@ -2253,7 +2248,7 @@ var yjs = (content, awareness2) => [
2253
2248
  ];
2254
2249
 
2255
2250
  // packages/ui/react-ui-editor/src/themes/default.ts
2256
- import get6 from "lodash.get";
2251
+ import get3 from "lodash.get";
2257
2252
  var defaultTheme = {
2258
2253
  //
2259
2254
  // Main layout:
@@ -2284,7 +2279,7 @@ var defaultTheme = {
2284
2279
  },
2285
2280
  ".cm-scroller": {
2286
2281
  overflow: "visible",
2287
- fontFamily: get6(tokens, "fontFamily.mono", []).join(",")
2282
+ fontFamily: get3(tokens, "fontFamily.mono", []).join(",")
2288
2283
  },
2289
2284
  ".cm-content": {
2290
2285
  padding: 0,
@@ -2292,11 +2287,11 @@ var defaultTheme = {
2292
2287
  fontSize: "16px"
2293
2288
  },
2294
2289
  "&light .cm-content": {
2295
- color: get6(tokens, "extend.colors.neutral.900", "black"),
2290
+ color: get3(tokens, "extend.colors.neutral.900", "black"),
2296
2291
  caretColor: "black"
2297
2292
  },
2298
2293
  "&dark .cm-content": {
2299
- color: get6(tokens, "extend.colors.neutral.100", "white"),
2294
+ color: get3(tokens, "extend.colors.neutral.100", "white"),
2300
2295
  caretColor: "white"
2301
2296
  },
2302
2297
  //
@@ -2324,25 +2319,25 @@ var defaultTheme = {
2324
2319
  // Selection
2325
2320
  //
2326
2321
  "&light .cm-selectionBackground": {
2327
- background: get6(tokens, "extend.colors.primary.100")
2322
+ background: get3(tokens, "extend.colors.primary.100")
2328
2323
  },
2329
2324
  "&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
2330
- background: get6(tokens, "extend.colors.primary.200")
2325
+ background: get3(tokens, "extend.colors.primary.200")
2331
2326
  },
2332
2327
  "&dark .cm-selectionBackground": {
2333
- background: get6(tokens, "extend.colors.primary.700")
2328
+ background: get3(tokens, "extend.colors.primary.700")
2334
2329
  },
2335
2330
  "&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
2336
- background: get6(tokens, "extend.colors.primary.600")
2331
+ background: get3(tokens, "extend.colors.primary.600")
2337
2332
  },
2338
2333
  //
2339
2334
  // Search
2340
2335
  //
2341
2336
  "&light .cm-searchMatch": {
2342
- backgroundColor: get6(tokens, "extend.colors.yellow.100")
2337
+ backgroundColor: get3(tokens, "extend.colors.yellow.100")
2343
2338
  },
2344
2339
  "&dark .cm-searchMatch": {
2345
- backgroundColor: get6(tokens, "extend.colors.yellow.700")
2340
+ backgroundColor: get3(tokens, "extend.colors.yellow.700")
2346
2341
  },
2347
2342
  //
2348
2343
  // collaboration
@@ -2375,12 +2370,12 @@ var defaultTheme = {
2375
2370
  // link
2376
2371
  //
2377
2372
  ".cm-link": {
2378
- color: get6(tokens, "extend.colors.primary.500"),
2373
+ color: get3(tokens, "extend.colors.primary.500"),
2379
2374
  textDecorationLine: "underline",
2380
2375
  textDecorationThickness: "1px",
2381
2376
  textUnderlineOffset: "2px",
2382
2377
  borderRadius: ".125rem",
2383
- fontFamily: get6(tokens, "fontFamily.body", []).join(",")
2378
+ fontFamily: get3(tokens, "fontFamily.body", []).join(",")
2384
2379
  },
2385
2380
  //
2386
2381
  // tooltip
@@ -2402,7 +2397,7 @@ var defaultTheme = {
2402
2397
  display: "none"
2403
2398
  },
2404
2399
  ".cm-completionLabel": {
2405
- fontFamily: get6(tokens, "fontFamily.body", []).join(",")
2400
+ fontFamily: get3(tokens, "fontFamily.body", []).join(",")
2406
2401
  },
2407
2402
  ".cm-completionMatchedText": {
2408
2403
  textDecoration: "none"
@@ -2418,15 +2413,15 @@ var defaultTheme = {
2418
2413
  // table
2419
2414
  //
2420
2415
  ".cm-table *": {
2421
- fontFamily: `${get6(tokens, "fontFamily.mono", []).join(",")} !important`,
2416
+ fontFamily: `${get3(tokens, "fontFamily.mono", []).join(",")} !important`,
2422
2417
  textDecoration: "none !important"
2423
2418
  },
2424
2419
  ".cm-table-head": {
2425
2420
  padding: "2px 16px 2px 0px",
2426
- borderBottom: `1px solid ${get6(tokens, "extend.colors.neutral.500")}`,
2421
+ borderBottom: `1px solid ${get3(tokens, "extend.colors.neutral.500")}`,
2427
2422
  fontWeight: 100,
2428
2423
  textAlign: "left",
2429
- color: get6(tokens, "extend.colors.neutral.500")
2424
+ color: get3(tokens, "extend.colors.neutral.500")
2430
2425
  },
2431
2426
  ".cm-table-cell": {
2432
2427
  padding: "2px 16px 2px 0px"
@@ -2447,8 +2442,8 @@ var defaultTheme = {
2447
2442
  // font size
2448
2443
  // 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
2444
  //
2450
- ...Object.keys(get6(tokens, "extend.fontSize", {})).reduce((acc, fontSize) => {
2451
- const height = get6(tokens, [
2445
+ ...Object.keys(get3(tokens, "extend.fontSize", {})).reduce((acc, fontSize) => {
2446
+ const height = get3(tokens, [
2452
2447
  "extend",
2453
2448
  "fontSize",
2454
2449
  fontSize,
@@ -2483,23 +2478,23 @@ var defaultTheme = {
2483
2478
  * </div
2484
2479
  */
2485
2480
  ".cm-panels": {
2486
- border: `1px solid ${get6(tokens, "extend.colors.neutral.200")}`
2481
+ border: `1px solid ${get3(tokens, "extend.colors.neutral.200")}`
2487
2482
  },
2488
2483
  ".cm-panel": {
2489
- background: get6(tokens, "extend.colors.neutral.50"),
2490
- fontFamily: get6(tokens, "fontFamily.body", []).join(",")
2484
+ background: get3(tokens, "extend.colors.neutral.50"),
2485
+ fontFamily: get3(tokens, "fontFamily.body", []).join(",")
2491
2486
  },
2492
2487
  ".cm-button": {
2493
2488
  margin: "4px",
2494
- fontFamily: get6(tokens, "fontFamily.body", []).join(","),
2495
- background: get6(tokens, "extend.colors.neutral.100"),
2489
+ fontFamily: get3(tokens, "fontFamily.body", []).join(","),
2490
+ background: get3(tokens, "extend.colors.neutral.100"),
2496
2491
  backgroundImage: "none",
2497
2492
  border: "none",
2498
2493
  "&:hover": {
2499
- background: get6(tokens, "extend.colors.neutral.200")
2494
+ background: get3(tokens, "extend.colors.neutral.200")
2500
2495
  },
2501
2496
  "&:active": {
2502
- background: get6(tokens, "extend.colors.neutral.300"),
2497
+ background: get3(tokens, "extend.colors.neutral.300"),
2503
2498
  backgroundImage: "none"
2504
2499
  }
2505
2500
  },
@@ -2509,24 +2504,24 @@ var defaultTheme = {
2509
2504
  };
2510
2505
  var textTheme = {
2511
2506
  ".cm-scroller": {
2512
- fontFamily: get6(tokens, "fontFamily.body", []).join(",")
2507
+ fontFamily: get3(tokens, "fontFamily.body", []).join(",")
2513
2508
  },
2514
2509
  ".cm-placeholder": {
2515
- fontFamily: get6(tokens, "fontFamily.body", []).join(",")
2510
+ fontFamily: get3(tokens, "fontFamily.body", []).join(",")
2516
2511
  }
2517
2512
  };
2518
2513
  var markdownTheme = {
2519
2514
  // NOTE: Must leave base font family as is (i.e., monospace) due to fenced code blocks.
2520
2515
  ".cm-placeholder": {
2521
- fontFamily: get6(tokens, "fontFamily.body", []).join(",")
2516
+ fontFamily: get3(tokens, "fontFamily.body", []).join(",")
2522
2517
  }
2523
2518
  };
2524
2519
  var codeTheme = {
2525
2520
  ".cm-scroller": {
2526
- fontFamily: get6(tokens, "fontFamily.mono", []).join(",")
2521
+ fontFamily: get3(tokens, "fontFamily.mono", []).join(",")
2527
2522
  },
2528
2523
  ".cm-placeholder": {
2529
- fontFamily: get6(tokens, "fontFamily.mono", []).join(",")
2524
+ fontFamily: get3(tokens, "fontFamily.mono", []).join(",")
2530
2525
  }
2531
2526
  };
2532
2527
 
@@ -2705,7 +2700,7 @@ var defaultMarkdownSlots = {
2705
2700
  };
2706
2701
 
2707
2702
  // packages/ui/react-ui-editor/src/hooks/automerge.ts
2708
- import get7 from "lodash.get";
2703
+ import get4 from "lodash.get";
2709
2704
  import { getRawDoc } from "@dxos/echo-schema";
2710
2705
  import { isNotNullOrUndefined } from "@dxos/util";
2711
2706
 
@@ -3026,7 +3021,7 @@ var createAutomergeModel = ({ space, identity, text }) => {
3026
3021
  const model = {
3027
3022
  id: obj.id,
3028
3023
  content: doc,
3029
- text: () => get7(doc.handle.docSync(), doc.path),
3024
+ text: () => get4(doc.handle.docSync(), doc.path),
3030
3025
  // TODO(burdon): https://automerge.org/automerge/api-docs/js/functions/next.getCursor.html
3031
3026
  extension: [
3032
3027
  modelState.init(() => model),
@@ -3072,6 +3067,7 @@ export {
3072
3067
  defaultSlots,
3073
3068
  defaultTextSlots,
3074
3069
  defaultTheme,
3070
+ getToken,
3075
3071
  hr,
3076
3072
  image,
3077
3073
  link,
@@ -3082,7 +3078,6 @@ export {
3082
3078
  markdownTagsExtensions,
3083
3079
  markdownTheme,
3084
3080
  mention,
3085
- mermaid,
3086
3081
  modelState,
3087
3082
  setCommentRange,
3088
3083
  setFocus,