@mirror-physics/fractal-ui 0.2.0-next.55 → 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 +17 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -173,6 +173,7 @@ import { json } from "@codemirror/lang-json";
|
|
|
173
173
|
import {
|
|
174
174
|
Decoration,
|
|
175
175
|
EditorView,
|
|
176
|
+
MatchDecorator,
|
|
176
177
|
ViewPlugin,
|
|
177
178
|
lineNumbers as lineNumberGutter
|
|
178
179
|
} from "@codemirror/view";
|
|
@@ -226,6 +227,7 @@ var codeTheme = EditorView.theme({
|
|
|
226
227
|
transition: "color 120ms ease"
|
|
227
228
|
},
|
|
228
229
|
".cm-foldGutter .cm-gutterElement > span:hover": { color: "var(--fg-secondary)" },
|
|
230
|
+
".fractal-code-block__escape": { color: "var(--fg-secondary)" },
|
|
229
231
|
".cm-activeLine, .cm-activeLineGutter": { backgroundColor: "var(--bg-surface-1)" },
|
|
230
232
|
".cm-selectionBackground, &.cm-focused .cm-selectionBackground, ::selection": {
|
|
231
233
|
backgroundColor: "var(--accent-surface-stroke) !important"
|
|
@@ -268,9 +270,8 @@ function countVisualColumns(value) {
|
|
|
268
270
|
return columns;
|
|
269
271
|
}
|
|
270
272
|
function getWrappedLineIndent(line) {
|
|
271
|
-
const propertyPrefix = line.match(JSON_PROPERTY_PREFIX)?.[1];
|
|
272
|
-
if (propertyPrefix) return Math.min(countVisualColumns(propertyPrefix), 24);
|
|
273
273
|
const leadingWhitespace = line.match(/^\s*/)?.[0] ?? "";
|
|
274
|
+
if (JSON_PROPERTY_PREFIX.test(line)) return Math.min(countVisualColumns(leadingWhitespace), 24);
|
|
274
275
|
return Math.min(countVisualColumns(leadingWhitespace) + 2, 12);
|
|
275
276
|
}
|
|
276
277
|
function buildWrappedLineIndentation(view) {
|
|
@@ -303,6 +304,20 @@ var wrappedLineIndentation = ViewPlugin.fromClass(class {
|
|
|
303
304
|
}, {
|
|
304
305
|
decorations: (plugin) => plugin.decorations
|
|
305
306
|
});
|
|
307
|
+
var jsonEscapeMatcher = new MatchDecorator({
|
|
308
|
+
regexp: /\\(?:["\\/bfnrt]|u[0-9a-fA-F]{4})/g,
|
|
309
|
+
decoration: Decoration.mark({ class: "fractal-code-block__escape" })
|
|
310
|
+
});
|
|
311
|
+
var jsonEscapeHighlighting = ViewPlugin.fromClass(class {
|
|
312
|
+
constructor(view) {
|
|
313
|
+
this.decorations = jsonEscapeMatcher.createDeco(view);
|
|
314
|
+
}
|
|
315
|
+
update(update) {
|
|
316
|
+
this.decorations = jsonEscapeMatcher.updateDeco(update, this.decorations);
|
|
317
|
+
}
|
|
318
|
+
}, {
|
|
319
|
+
decorations: (plugin) => plugin.decorations
|
|
320
|
+
});
|
|
306
321
|
function formatJsonLinesForDisplay(value) {
|
|
307
322
|
return value.split(/\r?\n/).map((line) => {
|
|
308
323
|
const firstContentIndex = line.search(/\S/);
|
|
@@ -416,6 +431,7 @@ function CodeBlock({
|
|
|
416
431
|
codeTheme,
|
|
417
432
|
syntaxHighlighting(fractalHighlightStyle),
|
|
418
433
|
...resolvedLanguage.support ? [resolvedLanguage.support] : [],
|
|
434
|
+
...resolvedLanguage.support ? [jsonEscapeHighlighting] : [],
|
|
419
435
|
...resolvedLanguage.isJsonLines ? [jsonLinesFoldSupport] : [],
|
|
420
436
|
...lineNumbers ? [foldGutter(), lineNumberGutter()] : [],
|
|
421
437
|
...wrap ? [EditorView.lineWrapping, wrappedLineIndentation] : []
|