@dxos/react-ui-editor 0.3.11-main.42059c4 → 0.3.11-main.4d95695

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.
@@ -595,7 +595,7 @@ var styles = EditorView.baseTheme({
595
595
  zIndex: 101,
596
596
  transition: "opacity .3s ease-in-out",
597
597
  backgroundColor: "inherit",
598
- // these should be separate
598
+ // These should be separate.
599
599
  opacity: 0,
600
600
  transitionDelay: "0s",
601
601
  whiteSpace: "nowrap"
@@ -1059,20 +1059,18 @@ var getLineRange = (lines, from, to) => {
1059
1059
  ];
1060
1060
  };
1061
1061
  var code2 = () => {
1062
- const getDecorations = (view) => {
1062
+ const buildDecorations4 = (view) => {
1063
1063
  const decorations = [];
1064
- if (!view.hasFocus || view.state.readOnly) {
1065
- const text = view.state.doc.sliceString(0);
1066
- const matches = text.matchAll(CODE_REGEX);
1067
- const blocks = view.viewportLineBlocks;
1068
- for (const match of matches) {
1069
- const range = getLineRange(blocks, match.index, match.index + match[0].length);
1070
- for (let i = range[0]; i <= range[1]; i++) {
1071
- const block = blocks[i];
1072
- decorations.push(Decoration2.line({
1073
- class: mx2("cm-codeblock", i === range[0] && "cm-codeblock-first", i === range[1] && "cm-codeblock-last")
1074
- }).range(block.from));
1075
- }
1064
+ const text = view.state.doc.sliceString(0);
1065
+ const matches = text.matchAll(CODE_REGEX);
1066
+ const blocks = view.viewportLineBlocks;
1067
+ for (const match of matches) {
1068
+ const range = getLineRange(blocks, match.index, match.index + match[0].length);
1069
+ for (let i = range[0]; i <= range[1]; i++) {
1070
+ const block = blocks[i];
1071
+ decorations.push(Decoration2.line({
1072
+ class: mx2("cm-codeblock", i === range[0] && "cm-codeblock-first", i === range[1] && "cm-codeblock-last")
1073
+ }).range(block.from));
1076
1074
  }
1077
1075
  }
1078
1076
  return Decoration2.set(decorations);
@@ -1081,7 +1079,7 @@ var code2 = () => {
1081
1079
  ViewPlugin3.fromClass(class {
1082
1080
  constructor(view) {
1083
1081
  this.hasFocus = false;
1084
- this.decorations = getDecorations(view);
1082
+ this.decorations = buildDecorations4(view);
1085
1083
  }
1086
1084
  update(update2) {
1087
1085
  if (
@@ -1089,7 +1087,7 @@ var code2 = () => {
1089
1087
  this.hasFocus !== update2.view.hasFocus || update2.startState.readOnly !== update2.view.state.readOnly || update2.docChanged || update2.viewportChanged
1090
1088
  ) {
1091
1089
  this.hasFocus = update2.view.hasFocus;
1092
- this.decorations = getDecorations(update2.view);
1090
+ this.decorations = buildDecorations4(update2.view);
1093
1091
  }
1094
1092
  }
1095
1093
  }, {
@@ -1172,7 +1170,7 @@ var commentsStateField = StateField2.define({
1172
1170
  ...effect.value
1173
1171
  };
1174
1172
  }
1175
- if (effect.is(setCommentRange) && effect.value.comments.length > 0) {
1173
+ if (effect.is(setCommentRange)) {
1176
1174
  const { comments: comments2 } = effect.value;
1177
1175
  const ranges = comments2.map((comment) => {
1178
1176
  const range = Cursor.getRangeFromCursor(cursorConverter3, comment.cursor);
@@ -1279,7 +1277,7 @@ var comments = (options = {}) => {
1279
1277
  const cursorConverter3 = view.state.facet(Cursor.converter);
1280
1278
  invariant2(options.onCreate, void 0, {
1281
1279
  F: __dxlog_file3,
1282
- L: 262,
1280
+ L: 264,
1283
1281
  S: void 0,
1284
1282
  A: [
1285
1283
  "options.onCreate",
@@ -1336,7 +1334,7 @@ var comments = (options = {}) => {
1336
1334
  above: true,
1337
1335
  create: () => {
1338
1336
  const el = document.createElement("div");
1339
- options.onHover?.(el, shortcut);
1337
+ options.onHover(el, shortcut);
1340
1338
  return {
1341
1339
  dom: el,
1342
1340
  offset: {
@@ -1349,7 +1347,8 @@ var comments = (options = {}) => {
1349
1347
  }
1350
1348
  return null;
1351
1349
  }, {
1352
- hideOnChange: true,
1350
+ // TODO(burdon): Hide on change triggered immediately?
1351
+ // hideOnChange: true,
1353
1352
  hoverTime: 1e3
1354
1353
  }) : [],
1355
1354
  //
@@ -1445,7 +1444,8 @@ var HorizontalRuleWidget = class extends WidgetType2 {
1445
1444
  }
1446
1445
  };
1447
1446
  var placeholderMatcher = new MatchDecorator({
1448
- regexp: /^---$/g,
1447
+ // regexp: /(?<=\n\n)---/gs,
1448
+ regexp: /^---$/gs,
1449
1449
  decoration: (match, view, pos) => Decoration4.replace({
1450
1450
  widget: new HorizontalRuleWidget(pos)
1451
1451
  })
@@ -1460,11 +1460,7 @@ var hr = () => [
1460
1460
  this.rules = placeholderMatcher.updateDeco(update2, this.rules);
1461
1461
  }
1462
1462
  }, {
1463
- decorations: (instance) => instance.rules,
1464
- // TODO(burdon): Is this really atomic (cursor can move into ---).
1465
- provide: (plugin) => EditorView6.atomicRanges.of((view) => {
1466
- return view.plugin(plugin)?.rules || Decoration4.none;
1467
- })
1463
+ decorations: (instance) => instance.rules
1468
1464
  })
1469
1465
  ];
1470
1466
 
@@ -1543,7 +1539,7 @@ var ImageWidget = class extends WidgetType3 {
1543
1539
  // packages/ui/react-ui-editor/src/extensions/link.ts
1544
1540
  import { syntaxTree as syntaxTree2 } from "@codemirror/language";
1545
1541
  import { RangeSetBuilder } from "@codemirror/state";
1546
- import { Decoration as Decoration6, WidgetType as WidgetType4, hoverTooltip as hoverTooltip2, ViewPlugin as ViewPlugin5 } from "@codemirror/view";
1542
+ import { hoverTooltip as hoverTooltip2, Decoration as Decoration6, ViewPlugin as ViewPlugin5, WidgetType as WidgetType4 } from "@codemirror/view";
1547
1543
  import { tooltipContent } from "@dxos/react-ui-theme";
1548
1544
  var link = (options = {}) => {
1549
1545
  const extensions = [
@@ -2122,6 +2118,7 @@ var tasklist = (options = {}) => {
2122
2118
  }
2123
2119
  }, {
2124
2120
  decorations: (v) => v.decorations,
2121
+ // TODO(burdon): Is this still required?
2125
2122
  provide: (plugin) => EditorView11.atomicRanges.of((view) => {
2126
2123
  return view.plugin(plugin)?.decorations || Decoration8.none;
2127
2124
  })