@mirror-physics/fractal-ui 0.2.0-next.54 → 0.2.0-next.56
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 +18 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -326,9 +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)",
|
|
329
330
|
transition: "color 120ms ease"
|
|
330
331
|
},
|
|
331
332
|
".cm-foldGutter .cm-gutterElement > span:hover": { color: "var(--fg-secondary)" },
|
|
333
|
+
".fractal-code-block__escape": { color: "var(--fg-secondary)" },
|
|
332
334
|
".cm-activeLine, .cm-activeLineGutter": { backgroundColor: "var(--bg-surface-1)" },
|
|
333
335
|
".cm-selectionBackground, &.cm-focused .cm-selectionBackground, ::selection": {
|
|
334
336
|
backgroundColor: "var(--accent-surface-stroke) !important"
|
|
@@ -371,9 +373,8 @@ function countVisualColumns(value) {
|
|
|
371
373
|
return columns;
|
|
372
374
|
}
|
|
373
375
|
function getWrappedLineIndent(line) {
|
|
374
|
-
const propertyPrefix = line.match(JSON_PROPERTY_PREFIX)?.[1];
|
|
375
|
-
if (propertyPrefix) return Math.min(countVisualColumns(propertyPrefix), 24);
|
|
376
376
|
const leadingWhitespace = line.match(/^\s*/)?.[0] ?? "";
|
|
377
|
+
if (JSON_PROPERTY_PREFIX.test(line)) return Math.min(countVisualColumns(leadingWhitespace), 24);
|
|
377
378
|
return Math.min(countVisualColumns(leadingWhitespace) + 2, 12);
|
|
378
379
|
}
|
|
379
380
|
function buildWrappedLineIndentation(view) {
|
|
@@ -406,6 +407,20 @@ var wrappedLineIndentation = import_view.ViewPlugin.fromClass(class {
|
|
|
406
407
|
}, {
|
|
407
408
|
decorations: (plugin) => plugin.decorations
|
|
408
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
|
+
});
|
|
409
424
|
function formatJsonLinesForDisplay(value) {
|
|
410
425
|
return value.split(/\r?\n/).map((line) => {
|
|
411
426
|
const firstContentIndex = line.search(/\S/);
|
|
@@ -519,6 +534,7 @@ function CodeBlock({
|
|
|
519
534
|
codeTheme,
|
|
520
535
|
(0, import_language.syntaxHighlighting)(fractalHighlightStyle),
|
|
521
536
|
...resolvedLanguage.support ? [resolvedLanguage.support] : [],
|
|
537
|
+
...resolvedLanguage.support ? [jsonEscapeHighlighting] : [],
|
|
522
538
|
...resolvedLanguage.isJsonLines ? [jsonLinesFoldSupport] : [],
|
|
523
539
|
...lineNumbers ? [(0, import_language.foldGutter)(), (0, import_view.lineNumbers)()] : [],
|
|
524
540
|
...wrap ? [import_view.EditorView.lineWrapping, wrappedLineIndentation] : []
|