@mirror-physics/fractal-ui 0.2.0-next.55 → 0.2.0-next.57

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/index.cjs CHANGED
@@ -326,10 +326,11 @@ var codeTheme = import_view.EditorView.theme({
326
326
  padding: "0",
327
327
  color: "var(--fg-tertiary)",
328
328
  lineHeight: "14px",
329
- transform: "translateY(-3px)",
330
329
  transition: "color 120ms ease"
331
330
  },
331
+ '.cm-foldGutter .cm-gutterElement > span[title="Fold line"]': { transform: "translateY(-3px)" },
332
332
  ".cm-foldGutter .cm-gutterElement > span:hover": { color: "var(--fg-secondary)" },
333
+ ".fractal-code-block__escape": { color: "var(--fg-secondary)" },
333
334
  ".cm-activeLine, .cm-activeLineGutter": { backgroundColor: "var(--bg-surface-1)" },
334
335
  ".cm-selectionBackground, &.cm-focused .cm-selectionBackground, ::selection": {
335
336
  backgroundColor: "var(--accent-surface-stroke) !important"
@@ -372,9 +373,8 @@ function countVisualColumns(value) {
372
373
  return columns;
373
374
  }
374
375
  function getWrappedLineIndent(line) {
375
- const propertyPrefix = line.match(JSON_PROPERTY_PREFIX)?.[1];
376
- if (propertyPrefix) return Math.min(countVisualColumns(propertyPrefix), 24);
377
376
  const leadingWhitespace = line.match(/^\s*/)?.[0] ?? "";
377
+ if (JSON_PROPERTY_PREFIX.test(line)) return Math.min(countVisualColumns(leadingWhitespace), 24);
378
378
  return Math.min(countVisualColumns(leadingWhitespace) + 2, 12);
379
379
  }
380
380
  function buildWrappedLineIndentation(view) {
@@ -407,6 +407,20 @@ var wrappedLineIndentation = import_view.ViewPlugin.fromClass(class {
407
407
  }, {
408
408
  decorations: (plugin) => plugin.decorations
409
409
  });
410
+ var jsonEscapeMatcher = new import_view.MatchDecorator({
411
+ regexp: /\\(?:["\\/bfnrt]|u[0-9a-fA-F]{4})/g,
412
+ decoration: import_view.Decoration.mark({ class: "fractal-code-block__escape" })
413
+ });
414
+ var jsonEscapeHighlighting = import_view.ViewPlugin.fromClass(class {
415
+ constructor(view) {
416
+ this.decorations = jsonEscapeMatcher.createDeco(view);
417
+ }
418
+ update(update) {
419
+ this.decorations = jsonEscapeMatcher.updateDeco(update, this.decorations);
420
+ }
421
+ }, {
422
+ decorations: (plugin) => plugin.decorations
423
+ });
410
424
  function formatJsonLinesForDisplay(value) {
411
425
  return value.split(/\r?\n/).map((line) => {
412
426
  const firstContentIndex = line.search(/\S/);
@@ -520,6 +534,7 @@ function CodeBlock({
520
534
  codeTheme,
521
535
  (0, import_language.syntaxHighlighting)(fractalHighlightStyle),
522
536
  ...resolvedLanguage.support ? [resolvedLanguage.support] : [],
537
+ ...resolvedLanguage.support ? [jsonEscapeHighlighting] : [],
523
538
  ...resolvedLanguage.isJsonLines ? [jsonLinesFoldSupport] : [],
524
539
  ...lineNumbers ? [(0, import_language.foldGutter)(), (0, import_view.lineNumbers)()] : [],
525
540
  ...wrap ? [import_view.EditorView.lineWrapping, wrappedLineIndentation] : []