@jbpark/live-editor 1.11.0 → 1.13.0
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/{ast-C0FNDLFQ.mjs → ast-Dq1EfxA5.js} +128 -147
- package/dist/ast-Dq1EfxA5.js.map +1 -0
- package/dist/{document-CBw2uF_P.mjs → document-CSIscFpL.js} +2976 -3446
- package/dist/document-CSIscFpL.js.map +1 -0
- package/dist/{document-DqLm4Vqi.d.mts → document-DXOwpvWM.d.ts} +22 -12
- package/dist/{utils/ast/index.d.mts → index-BVjSMVya.d.ts} +5 -9
- package/dist/{index.d.mts → index.d.ts} +39 -150
- package/dist/{index.mjs → index.js} +799 -516
- package/dist/index.js.map +1 -0
- package/dist/style.css +782 -0
- package/dist/{utils/tailwind/index.mjs → tailwind-CzPhj3D9.js} +3 -4
- package/dist/tailwind-CzPhj3D9.js.map +1 -0
- package/dist/utils/ast/index.d.ts +3 -0
- package/dist/utils/ast/{index.mjs → index.js} +3 -4
- package/dist/utils/{index.d.mts → index.d.ts} +2 -4
- package/dist/utils/{index.mjs → index.js} +3 -4
- package/dist/utils/tailwind/{index.d.mts → index.d.ts} +1 -1
- package/dist/utils/tailwind/index.js +2 -0
- package/dist/{utils-BjYg1Sh8.mjs → utils-B11t9ZYd.js} +1505 -18
- package/dist/utils-B11t9ZYd.js.map +1 -0
- package/package.json +50 -51
- package/dist/ast-C0FNDLFQ.mjs.map +0 -1
- package/dist/document-CBw2uF_P.mjs.map +0 -1
- package/dist/index-DdSjzvA3.d.mts +0 -15
- package/dist/index.css +0 -77
- package/dist/index.css.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/utils/tailwind/index.mjs.map +0 -1
- package/dist/utils-BjYg1Sh8.mjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { _ as DEFAULT_TEMPLATE, f as require_lib$1, m as BINDING_PROP, n as createSectionPreviewCache, p as require_lib, v as DRAGGABLE_ITEMS, x as __toESM } from "./document-
|
|
2
|
-
import { a as detectTypeScript, d as replaceSections, i as compile, l as getCachedScriptBlob, n as clearCompilationCache, o as extractSections, r as cn, s as generateSection, t as baseModules, u as preloadScripts } from "./utils-
|
|
3
|
-
import { _ as parseArrayExpression, c as extract, d as getCurrentValue, f as parseBinding, g as extractObjectProperties, h as extractNodeValue, i as replaceIds, l as nanoid, m as createNodeFromValue, n as clone, o as update, p as arrayExpressionToCode, r as fillIds, t as validateBindingValue, u as findEditableChildren, v as parseValue, y as generateCode } from "./ast-
|
|
4
|
-
import { generateTailwindCSS } from "./
|
|
1
|
+
import { _ as DEFAULT_TEMPLATE, f as require_lib$1, m as BINDING_PROP, n as createSectionPreviewCache, p as require_lib, v as DRAGGABLE_ITEMS, x as __toESM } from "./document-CSIscFpL.js";
|
|
2
|
+
import { a as detectTypeScript, d as replaceSections, i as compile, l as getCachedScriptBlob, n as clearCompilationCache, o as extractSections, r as cn, s as generateSection, t as baseModules, u as preloadScripts } from "./utils-B11t9ZYd.js";
|
|
3
|
+
import { _ as parseArrayExpression, c as extract, d as getCurrentValue, f as parseBinding, g as extractObjectProperties, h as extractNodeValue, i as replaceIds, l as nanoid, m as createNodeFromValue, n as clone, o as update, p as arrayExpressionToCode, r as fillIds, t as validateBindingValue, u as findEditableChildren, v as parseValue, y as generateCode } from "./ast-Dq1EfxA5.js";
|
|
4
|
+
import { t as generateTailwindCSS } from "./tailwind-CzPhj3D9.js";
|
|
5
5
|
import "@jbpark/ui-kit/style.css";
|
|
6
6
|
import React, { createContext, memo, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
7
7
|
import { Button, Card, Checkbox, ColorPicker, DatePicker, Drawer, Input, Select, Space, Toast, Typography, Upload } from "@jbpark/ui-kit";
|
|
@@ -10,7 +10,7 @@ import { DndContext, DragOverlay, PointerSensor, closestCenter, useDndContext, u
|
|
|
10
10
|
import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
|
|
11
11
|
import { SortableContext, arrayMove, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
12
12
|
import { useDebounce, useDebouncedValue, useEventListener, useMultiSelect, useMutationObserver, useResizeObserver, useResponsiveSize } from "@jbpark/use-hooks";
|
|
13
|
-
import { AlertCircle, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, Bell, Bookmark, Calendar, Camera, Check, ChevronDown, ChevronRight, Clock, Copy, Download, Edit, Eye, Filter, Heart, Home, Image, Info, LayoutGrid, Link, Mail, Map as Map$1, Menu, MessageCircle, Phone, Plus, Search, Settings, Share, ShoppingCart, Star, Trash, Upload as Upload$1, User, X } from "lucide-react";
|
|
13
|
+
import { AlertCircle, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, Bell, Bookmark, Calendar, Camera, Check, ChevronDown, ChevronRight, ChevronUp, Clock, Copy, Download, Edit, Eye, Filter, Heart, Home, Image, Info, LayoutGrid, Link, Mail, Map as Map$1, Menu, MessageCircle, Phone, Plus, Search, Settings, Share, ShoppingCart, Star, Trash, Upload as Upload$1, User, X } from "lucide-react";
|
|
14
14
|
import { v4 } from "uuid";
|
|
15
15
|
import { createPortal } from "react-dom";
|
|
16
16
|
import { CSS } from "@dnd-kit/utilities";
|
|
@@ -24,7 +24,6 @@ import prettierPluginTypeScript from "prettier/plugins/typescript";
|
|
|
24
24
|
import Placeholder from "@tiptap/extension-placeholder";
|
|
25
25
|
import { EditorContent, useEditor } from "@tiptap/react";
|
|
26
26
|
import StarterKit from "@tiptap/starter-kit";
|
|
27
|
-
|
|
28
27
|
//#region src/components/context/states.ts
|
|
29
28
|
const PreviewContext = createContext(void 0);
|
|
30
29
|
const ErrorContext = createContext(void 0);
|
|
@@ -38,7 +37,6 @@ const useError = () => {
|
|
|
38
37
|
if (context === void 0) throw new Error("useError must be used within <Live> (ContextProvider)");
|
|
39
38
|
return context;
|
|
40
39
|
};
|
|
41
|
-
|
|
42
40
|
//#endregion
|
|
43
41
|
//#region src/components/context/context.tsx
|
|
44
42
|
const ContextProvider = ({ children }) => {
|
|
@@ -69,10 +67,8 @@ const ContextProvider = ({ children }) => {
|
|
|
69
67
|
})
|
|
70
68
|
});
|
|
71
69
|
};
|
|
72
|
-
|
|
73
70
|
//#endregion
|
|
74
71
|
//#region src/components/frame/measure.ts
|
|
75
|
-
const FALLBACK_PROBE_HEIGHT = 812;
|
|
76
72
|
const computeProbeHeight = (scrollContainerClientHeight, wrapperInsets) => {
|
|
77
73
|
const usable = scrollContainerClientHeight - wrapperInsets;
|
|
78
74
|
return usable > 0 ? usable : null;
|
|
@@ -91,7 +87,6 @@ const estimatePositionedElementHeight = (offsetHeight, transform, probeHeight) =
|
|
|
91
87
|
const offsetY = parseTranslateY(transform);
|
|
92
88
|
return Math.min(offsetY + offsetHeight, probeHeight);
|
|
93
89
|
};
|
|
94
|
-
|
|
95
90
|
//#endregion
|
|
96
91
|
//#region src/components/frame/viewport-units.ts
|
|
97
92
|
const UNIT_MAP = {
|
|
@@ -105,7 +100,6 @@ const UNIT_MAP = {
|
|
|
105
100
|
const UNITS_PATTERN = Object.keys(UNIT_MAP).sort((a, b) => b.length - a.length).join("|");
|
|
106
101
|
const VIEWPORT_UNIT_RE = new RegExp(`(?<![\\w.-])(-?(?:\\d+\\.?\\d*|\\.\\d+))(${UNITS_PATTERN})(?![a-zA-Z0-9_-])`, "gi");
|
|
107
102
|
const convertViewportUnits = (css) => css.replace(VIEWPORT_UNIT_RE, (_match, number, unit) => number + UNIT_MAP[unit.toLowerCase()]);
|
|
108
|
-
|
|
109
103
|
//#endregion
|
|
110
104
|
//#region src/components/frame/iframe.tsx
|
|
111
105
|
const EMPTY_STRING_ARRAY = [];
|
|
@@ -243,6 +237,7 @@ const IFrame = ({ title = "Live Preview", sandbox, style = {}, scripts = EMPTY_S
|
|
|
243
237
|
prevStylesheetCountRef.current = stylesheets.length;
|
|
244
238
|
}, [styles, stylesheets]);
|
|
245
239
|
const CONTAINER_STYLE_ID = "autoheight-container";
|
|
240
|
+
const HIDE_SCROLLBAR_STYLE_ID = "autoheight-hide-scrollbar";
|
|
246
241
|
const ensureContainerStyle = (doc, probeHeight) => {
|
|
247
242
|
let styleEl = doc.getElementById(CONTAINER_STYLE_ID);
|
|
248
243
|
if (!styleEl) {
|
|
@@ -278,7 +273,7 @@ const IFrame = ({ title = "Live Preview", sandbox, style = {}, scripts = EMPTY_S
|
|
|
278
273
|
if (!doc || !win) return;
|
|
279
274
|
const scrollParent = iframe.closest("[data-frame-container]");
|
|
280
275
|
let probeHeight;
|
|
281
|
-
if (!scrollParent) probeHeight =
|
|
276
|
+
if (!scrollParent) probeHeight = 812;
|
|
282
277
|
else {
|
|
283
278
|
let wrapperInsets = 0;
|
|
284
279
|
let node = iframe.parentElement;
|
|
@@ -310,6 +305,20 @@ const IFrame = ({ title = "Live Preview", sandbox, style = {}, scripts = EMPTY_S
|
|
|
310
305
|
if (shouldAutoHeight) return;
|
|
311
306
|
iframeRef.current?.contentDocument?.getElementById(CONTAINER_STYLE_ID)?.remove();
|
|
312
307
|
}, [shouldAutoHeight]);
|
|
308
|
+
useEffect(() => {
|
|
309
|
+
const doc = iframeRef.current?.contentDocument;
|
|
310
|
+
if (!doc?.head) return;
|
|
311
|
+
const existing = doc.getElementById(HIDE_SCROLLBAR_STYLE_ID);
|
|
312
|
+
if (!shouldAutoHeight) {
|
|
313
|
+
existing?.remove();
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
if (existing) return;
|
|
317
|
+
const styleEl = doc.createElement("style");
|
|
318
|
+
styleEl.id = HIDE_SCROLLBAR_STYLE_ID;
|
|
319
|
+
styleEl.textContent = ["html, body { scrollbar-width: none !important; }", "html::-webkit-scrollbar, body::-webkit-scrollbar { display: none !important; }"].join("\n");
|
|
320
|
+
doc.head.appendChild(styleEl);
|
|
321
|
+
}, [shouldAutoHeight, mountNode]);
|
|
313
322
|
useEffect(() => {
|
|
314
323
|
updateHeight();
|
|
315
324
|
}, [updateHeight]);
|
|
@@ -348,7 +357,6 @@ const IFrame = ({ title = "Live Preview", sandbox, style = {}, scripts = EMPTY_S
|
|
|
348
357
|
children: content
|
|
349
358
|
});
|
|
350
359
|
};
|
|
351
|
-
|
|
352
360
|
//#endregion
|
|
353
361
|
//#region src/components/frame/shadow.tsx
|
|
354
362
|
const Shadow = ({ children }) => {
|
|
@@ -359,7 +367,8 @@ const Shadow = ({ children }) => {
|
|
|
359
367
|
const [hostContainer, setHostContainer] = useState(null);
|
|
360
368
|
useLayoutEffect(() => {
|
|
361
369
|
if (!hostRef.current) return;
|
|
362
|
-
|
|
370
|
+
const container = hostRef.current.closest("[data-frame-container]");
|
|
371
|
+
setHostContainer(container);
|
|
363
372
|
let shadowRoot = shadowRootRef.current;
|
|
364
373
|
if (!shadowRoot) {
|
|
365
374
|
shadowRoot = hostRef.current.shadowRoot || hostRef.current.attachShadow({ mode: "open" });
|
|
@@ -382,7 +391,6 @@ const Shadow = ({ children }) => {
|
|
|
382
391
|
children: renderTarget && createPortal(children(hostContainer), renderTarget)
|
|
383
392
|
});
|
|
384
393
|
};
|
|
385
|
-
|
|
386
394
|
//#endregion
|
|
387
395
|
//#region src/components/frame/frame.tsx
|
|
388
396
|
const Frame = ({ mode, children, ...restProps }) => {
|
|
@@ -393,7 +401,6 @@ const Frame = ({ mode, children, ...restProps }) => {
|
|
|
393
401
|
children
|
|
394
402
|
});
|
|
395
403
|
};
|
|
396
|
-
|
|
397
404
|
//#endregion
|
|
398
405
|
//#region src/components/dnd/draggable.tsx
|
|
399
406
|
const DraggableItem = ({ item, children }) => {
|
|
@@ -413,18 +420,18 @@ const DraggableItem = ({ item, children }) => {
|
|
|
413
420
|
isDragging
|
|
414
421
|
});
|
|
415
422
|
};
|
|
416
|
-
const DefaultDraggableItem = ({ item, onAdd }) => /* @__PURE__ */ jsx(DraggableItem, {
|
|
423
|
+
const DefaultDraggableItem = ({ item, onAdd, tapToAdd = false }) => /* @__PURE__ */ jsx(DraggableItem, {
|
|
417
424
|
item,
|
|
418
425
|
children: ({ ref, dragProps, isDragging }) => /* @__PURE__ */ jsx(Card, {
|
|
419
426
|
ref,
|
|
420
427
|
style: { opacity: isDragging ? .5 : 1 },
|
|
421
428
|
...dragProps,
|
|
422
429
|
className: cn("cursor-grab", "outline-none", "hover:border-blue-300 hover:shadow-md", isDragging && "opacity-50"),
|
|
430
|
+
onClick: tapToAdd && onAdd ? () => onAdd(item) : void 0,
|
|
423
431
|
onDoubleClick: onAdd ? () => onAdd(item) : void 0,
|
|
424
432
|
children: item.name
|
|
425
433
|
})
|
|
426
434
|
});
|
|
427
|
-
|
|
428
435
|
//#endregion
|
|
429
436
|
//#region src/components/dnd/droppable.tsx
|
|
430
437
|
const Droppable = ({ children, className }) => {
|
|
@@ -446,7 +453,6 @@ const Droppable = ({ children, className }) => {
|
|
|
446
453
|
})]
|
|
447
454
|
});
|
|
448
455
|
};
|
|
449
|
-
|
|
450
456
|
//#endregion
|
|
451
457
|
//#region src/components/dnd/renderer.tsx
|
|
452
458
|
const Renderer = ({ preview, headers, modules, frame, provider }) => {
|
|
@@ -483,7 +489,6 @@ const Renderer = ({ preview, headers, modules, frame, provider }) => {
|
|
|
483
489
|
});
|
|
484
490
|
};
|
|
485
491
|
var renderer_default = memo(Renderer);
|
|
486
|
-
|
|
487
492
|
//#endregion
|
|
488
493
|
//#region src/components/dnd/sortable.tsx
|
|
489
494
|
const Sortable = ({ id, children, selected, onClick, onDelete: _onDelete, onCopy: _onCopy }) => {
|
|
@@ -527,7 +532,6 @@ const Sortable = ({ id, children, selected, onClick, onDelete: _onDelete, onCopy
|
|
|
527
532
|
]
|
|
528
533
|
});
|
|
529
534
|
};
|
|
530
|
-
|
|
531
535
|
//#endregion
|
|
532
536
|
//#region src/components/dnd/overlay.tsx
|
|
533
537
|
const Overlay = ({ sections, renderProps }) => {
|
|
@@ -552,10 +556,10 @@ const Overlay = ({ sections, renderProps }) => {
|
|
|
552
556
|
}
|
|
553
557
|
return null;
|
|
554
558
|
};
|
|
555
|
-
|
|
556
559
|
//#endregion
|
|
557
560
|
//#region node_modules/.pnpm/@marijn+find-cluster-break@1.0.3/node_modules/@marijn/find-cluster-break/src/index.js
|
|
558
|
-
let rangeFrom = []
|
|
561
|
+
let rangeFrom = [];
|
|
562
|
+
let rangeTo = [];
|
|
559
563
|
(() => {
|
|
560
564
|
let numbers = "lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((s) => s ? parseInt(s, 36) : 1);
|
|
561
565
|
for (let i = 0, n = 0; i < numbers.length; i++) (i % 2 ? rangeTo : rangeFrom).push(n = n + numbers[i]);
|
|
@@ -623,7 +627,6 @@ function surrogateHigh(ch) {
|
|
|
623
627
|
function codePointSize(code) {
|
|
624
628
|
return code < 65536 ? 1 : 2;
|
|
625
629
|
}
|
|
626
|
-
|
|
627
630
|
//#endregion
|
|
628
631
|
//#region node_modules/.pnpm/@codemirror+state@6.7.1/node_modules/@codemirror/state/dist/index.js
|
|
629
632
|
/**
|
|
@@ -938,7 +941,7 @@ var TextNode = class TextNode extends Text {
|
|
|
938
941
|
return chunked.length == 1 ? chunked[0] : new TextNode(chunked, length);
|
|
939
942
|
}
|
|
940
943
|
};
|
|
941
|
-
Text.empty =
|
|
944
|
+
Text.empty = /*@__PURE__*/ new TextLeaf([""], 0);
|
|
942
945
|
function textLength(text) {
|
|
943
946
|
let length = -1;
|
|
944
947
|
for (let line of text) length += line.length + 1;
|
|
@@ -1072,12 +1075,13 @@ var LineCursor = class {
|
|
|
1072
1075
|
} else if (done) {
|
|
1073
1076
|
this.done = true;
|
|
1074
1077
|
this.value = "";
|
|
1075
|
-
} else if (lineBreak)
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1078
|
+
} else if (lineBreak) {
|
|
1079
|
+
if (this.afterBreak) this.value = "";
|
|
1080
|
+
else {
|
|
1081
|
+
this.afterBreak = true;
|
|
1082
|
+
this.next();
|
|
1083
|
+
}
|
|
1084
|
+
} else {
|
|
1081
1085
|
this.value = value;
|
|
1082
1086
|
this.afterBreak = false;
|
|
1083
1087
|
}
|
|
@@ -1135,7 +1139,7 @@ const DefaultSplit = /\r\n?|\n/;
|
|
|
1135
1139
|
/**
|
|
1136
1140
|
Distinguishes different ways in which positions can be mapped.
|
|
1137
1141
|
*/
|
|
1138
|
-
var MapMode =
|
|
1142
|
+
var MapMode = /*@__PURE__*/ (function(MapMode) {
|
|
1139
1143
|
/**
|
|
1140
1144
|
Map a position to a valid new position, even when its context
|
|
1141
1145
|
was deleted.
|
|
@@ -2108,7 +2112,7 @@ function dynamicFacetSlot(addresses, facet, providers) {
|
|
|
2108
2112
|
}
|
|
2109
2113
|
};
|
|
2110
2114
|
}
|
|
2111
|
-
const initField =
|
|
2115
|
+
const initField = /*@__PURE__*/ Facet.define({ static: true });
|
|
2112
2116
|
/**
|
|
2113
2117
|
Fields can store additional information in an editor state, and
|
|
2114
2118
|
keep it in sync with the rest of the state.
|
|
@@ -2210,11 +2214,30 @@ final ordering of extensions is determined by first sorting by
|
|
|
2210
2214
|
precedence and then by order within each precedence.
|
|
2211
2215
|
*/
|
|
2212
2216
|
const Prec = {
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2217
|
+
/**
|
|
2218
|
+
The highest precedence level, for extensions that should end up
|
|
2219
|
+
near the start of the precedence ordering.
|
|
2220
|
+
*/
|
|
2221
|
+
highest: /*@__PURE__*/ prec(Prec_.highest),
|
|
2222
|
+
/**
|
|
2223
|
+
A higher-than-default precedence, for extensions that should
|
|
2224
|
+
come before those with default precedence.
|
|
2225
|
+
*/
|
|
2226
|
+
high: /*@__PURE__*/ prec(Prec_.high),
|
|
2227
|
+
/**
|
|
2228
|
+
The default precedence, which is also used for extensions
|
|
2229
|
+
without an explicit precedence.
|
|
2230
|
+
*/
|
|
2231
|
+
default: /*@__PURE__*/ prec(Prec_.default),
|
|
2232
|
+
/**
|
|
2233
|
+
A lower-than-default precedence.
|
|
2234
|
+
*/
|
|
2235
|
+
low: /*@__PURE__*/ prec(Prec_.low),
|
|
2236
|
+
/**
|
|
2237
|
+
The lowest precedence level. Meant for things that should end up
|
|
2238
|
+
near the end of the extension order.
|
|
2239
|
+
*/
|
|
2240
|
+
lowest: /*@__PURE__*/ prec(Prec_.lowest)
|
|
2218
2241
|
};
|
|
2219
2242
|
var PrecExtension = class {
|
|
2220
2243
|
constructor(inner, prec) {
|
|
@@ -2318,7 +2341,8 @@ var Configuration = class Configuration {
|
|
|
2318
2341
|
dynamicSlots.push((a) => dynamicFacetSlot(a, facet, providers));
|
|
2319
2342
|
}
|
|
2320
2343
|
}
|
|
2321
|
-
|
|
2344
|
+
let dynamic = dynamicSlots.map((f) => f(address));
|
|
2345
|
+
return new Configuration(base, newCompartments, dynamic, address, staticValues, facets);
|
|
2322
2346
|
}
|
|
2323
2347
|
};
|
|
2324
2348
|
function flatten(extension, compartments, newCompartments) {
|
|
@@ -2375,19 +2399,19 @@ function ensureAddr(state, addr) {
|
|
|
2375
2399
|
function getAddr(state, addr) {
|
|
2376
2400
|
return addr & 1 ? state.config.staticValues[addr >> 1] : state.values[addr >> 1];
|
|
2377
2401
|
}
|
|
2378
|
-
const languageData =
|
|
2379
|
-
const allowMultipleSelections =
|
|
2402
|
+
const languageData = /*@__PURE__*/ Facet.define();
|
|
2403
|
+
const allowMultipleSelections = /*@__PURE__*/ Facet.define({
|
|
2380
2404
|
combine: (values) => values.some((v) => v),
|
|
2381
2405
|
static: true
|
|
2382
2406
|
});
|
|
2383
|
-
const lineSeparator =
|
|
2407
|
+
const lineSeparator = /*@__PURE__*/ Facet.define({
|
|
2384
2408
|
combine: (values) => values.length ? values[0] : void 0,
|
|
2385
2409
|
static: true
|
|
2386
2410
|
});
|
|
2387
|
-
const changeFilter =
|
|
2388
|
-
const transactionFilter =
|
|
2389
|
-
const transactionExtender =
|
|
2390
|
-
const readOnly =
|
|
2411
|
+
const changeFilter = /*@__PURE__*/ Facet.define();
|
|
2412
|
+
const transactionFilter = /*@__PURE__*/ Facet.define();
|
|
2413
|
+
const transactionExtender = /*@__PURE__*/ Facet.define();
|
|
2414
|
+
const readOnly = /*@__PURE__*/ Facet.define({ combine: (values) => values.length ? values[0] : false });
|
|
2391
2415
|
/**
|
|
2392
2416
|
Annotations are tagged values that are used to add metadata to
|
|
2393
2417
|
transactions in an extensible way. They should be used to model
|
|
@@ -2502,11 +2526,11 @@ the editor. Doing this will discard any extensions
|
|
|
2502
2526
|
the content of [reconfigured](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure)
|
|
2503
2527
|
compartments.
|
|
2504
2528
|
*/
|
|
2505
|
-
StateEffect.reconfigure =
|
|
2529
|
+
StateEffect.reconfigure = /*@__PURE__*/ StateEffect.define();
|
|
2506
2530
|
/**
|
|
2507
2531
|
Append extensions to the top-level configuration of the editor.
|
|
2508
2532
|
*/
|
|
2509
|
-
StateEffect.appendConfig =
|
|
2533
|
+
StateEffect.appendConfig = /*@__PURE__*/ StateEffect.define();
|
|
2510
2534
|
/**
|
|
2511
2535
|
Changes to the editor state are grouped into transactions.
|
|
2512
2536
|
Typically, a user action creates a single transaction, which may
|
|
@@ -2608,7 +2632,7 @@ var Transaction = class Transaction {
|
|
|
2608
2632
|
Annotation used to store transaction timestamps. Automatically
|
|
2609
2633
|
added to every transaction, holding `Date.now()`.
|
|
2610
2634
|
*/
|
|
2611
|
-
Transaction.time =
|
|
2635
|
+
Transaction.time = /*@__PURE__*/ Annotation.define();
|
|
2612
2636
|
/**
|
|
2613
2637
|
Annotation used to associate a transaction with a user interface
|
|
2614
2638
|
event. Holds a string identifying the event, using a
|
|
@@ -2635,19 +2659,19 @@ information. The events used by the core libraries are:
|
|
|
2635
2659
|
Use [`isUserEvent`](https://codemirror.net/6/docs/ref/#state.Transaction.isUserEvent) to check
|
|
2636
2660
|
whether the annotation matches a given event.
|
|
2637
2661
|
*/
|
|
2638
|
-
Transaction.userEvent =
|
|
2662
|
+
Transaction.userEvent = /*@__PURE__*/ Annotation.define();
|
|
2639
2663
|
/**
|
|
2640
2664
|
Annotation indicating whether a transaction should be added to
|
|
2641
2665
|
the undo history or not.
|
|
2642
2666
|
*/
|
|
2643
|
-
Transaction.addToHistory =
|
|
2667
|
+
Transaction.addToHistory = /*@__PURE__*/ Annotation.define();
|
|
2644
2668
|
/**
|
|
2645
2669
|
Annotation indicating (when present and true) that a transaction
|
|
2646
2670
|
represents a change made by some other actor, not the user. This
|
|
2647
2671
|
is used, for example, to tag other people's changes in
|
|
2648
2672
|
collaborative editing.
|
|
2649
2673
|
*/
|
|
2650
|
-
Transaction.remote =
|
|
2674
|
+
Transaction.remote = /*@__PURE__*/ Annotation.define();
|
|
2651
2675
|
function joinRanges(a, b) {
|
|
2652
2676
|
let result = [];
|
|
2653
2677
|
for (let iA = 0, iB = 0;;) {
|
|
@@ -2754,7 +2778,7 @@ The categories produced by a [character
|
|
|
2754
2778
|
categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer). These are used
|
|
2755
2779
|
do things like selecting by word.
|
|
2756
2780
|
*/
|
|
2757
|
-
var CharCategory =
|
|
2781
|
+
var CharCategory = /*@__PURE__*/ (function(CharCategory) {
|
|
2758
2782
|
/**
|
|
2759
2783
|
Word characters.
|
|
2760
2784
|
*/
|
|
@@ -2772,7 +2796,7 @@ var CharCategory = /* @__PURE__ */ (function(CharCategory) {
|
|
|
2772
2796
|
const nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
|
|
2773
2797
|
let wordChar;
|
|
2774
2798
|
try {
|
|
2775
|
-
wordChar =
|
|
2799
|
+
wordChar = /*@__PURE__*/ new RegExp("[\\p{Alphabetic}\\p{Number}_]", "u");
|
|
2776
2800
|
} catch (_) {}
|
|
2777
2801
|
function hasWordChar(str) {
|
|
2778
2802
|
if (wordChar) return wordChar.test(str);
|
|
@@ -3110,7 +3134,7 @@ Configures the tab size to use in this state. The first
|
|
|
3110
3134
|
(highest-precedence) value of the facet is used. If no value is
|
|
3111
3135
|
given, this defaults to 4.
|
|
3112
3136
|
*/
|
|
3113
|
-
EditorState.tabSize =
|
|
3137
|
+
EditorState.tabSize = /*@__PURE__*/ Facet.define({ combine: (values) => values.length ? values[0] : 4 });
|
|
3114
3138
|
/**
|
|
3115
3139
|
The line separator to use. By default, any of `"\n"`, `"\r\n"`
|
|
3116
3140
|
and `"\r"` is treated as a separator when splitting lines, and
|
|
@@ -3141,7 +3165,7 @@ Registers translation phrases. The
|
|
|
3141
3165
|
all objects registered with this facet to find translations for
|
|
3142
3166
|
its argument.
|
|
3143
3167
|
*/
|
|
3144
|
-
EditorState.phrases =
|
|
3168
|
+
EditorState.phrases = /*@__PURE__*/ Facet.define({ compare(a, b) {
|
|
3145
3169
|
let kA = Object.keys(a), kB = Object.keys(b);
|
|
3146
3170
|
return kA.length == kB.length && kA.every((k) => a[k] == b[k]);
|
|
3147
3171
|
} });
|
|
@@ -3199,7 +3223,7 @@ but do want to process every transaction.
|
|
|
3199
3223
|
Extenders run _after_ filters, when both are present.
|
|
3200
3224
|
*/
|
|
3201
3225
|
EditorState.transactionExtender = transactionExtender;
|
|
3202
|
-
Compartment.reconfigure =
|
|
3226
|
+
Compartment.reconfigure = /*@__PURE__*/ StateEffect.define();
|
|
3203
3227
|
/**
|
|
3204
3228
|
Each range is associated with a value, which must inherit from
|
|
3205
3229
|
this class.
|
|
@@ -3453,7 +3477,7 @@ var RangeSet = class RangeSet {
|
|
|
3453
3477
|
if they are equivalent in the given range.
|
|
3454
3478
|
*/
|
|
3455
3479
|
static eq(oldSets, newSets, from = 0, to) {
|
|
3456
|
-
if (to == null) to =
|
|
3480
|
+
if (to == null) to = 1e9 - 1;
|
|
3457
3481
|
let a = oldSets.filter((set) => !set.isEmpty && newSets.indexOf(set) < 0);
|
|
3458
3482
|
let b = newSets.filter((set) => !set.isEmpty && oldSets.indexOf(set) < 0);
|
|
3459
3483
|
if (a.length != b.length) return false;
|
|
@@ -3518,7 +3542,7 @@ var RangeSet = class RangeSet {
|
|
|
3518
3542
|
/**
|
|
3519
3543
|
The empty set of ranges.
|
|
3520
3544
|
*/
|
|
3521
|
-
RangeSet.empty =
|
|
3545
|
+
RangeSet.empty = /*@__PURE__*/ new RangeSet([], [], null, -1);
|
|
3522
3546
|
function lazySort(ranges) {
|
|
3523
3547
|
if (ranges.length > 1) for (let prev = ranges[0], i = 1; i < ranges.length; i++) {
|
|
3524
3548
|
let cur = ranges[i];
|
|
@@ -3672,7 +3696,8 @@ var LayerCursor = class {
|
|
|
3672
3696
|
break;
|
|
3673
3697
|
} else {
|
|
3674
3698
|
let chunkPos = this.layer.chunkPos[this.chunkIndex], chunk = this.layer.chunk[this.chunkIndex];
|
|
3675
|
-
|
|
3699
|
+
let from = chunkPos + chunk.from[this.rangeIndex];
|
|
3700
|
+
this.from = from;
|
|
3676
3701
|
this.to = chunkPos + chunk.to[this.rangeIndex];
|
|
3677
3702
|
this.value = chunk.value[this.rangeIndex];
|
|
3678
3703
|
this.setRangeIndex(this.rangeIndex + 1);
|
|
@@ -3912,11 +3937,10 @@ function findColumn(string, col, tabSize, strict) {
|
|
|
3912
3937
|
}
|
|
3913
3938
|
return strict === true ? -1 : string.length;
|
|
3914
3939
|
}
|
|
3915
|
-
|
|
3916
3940
|
//#endregion
|
|
3917
3941
|
//#region node_modules/.pnpm/style-mod@4.1.3/node_modules/style-mod/src/style-mod.js
|
|
3918
3942
|
const C = "ͼ";
|
|
3919
|
-
const COUNT = typeof Symbol == "undefined" ? "__"
|
|
3943
|
+
const COUNT = typeof Symbol == "undefined" ? "__ͼ" : Symbol.for(C);
|
|
3920
3944
|
const SET = typeof Symbol == "undefined" ? "__styleSet" + Math.floor(Math.random() * 1e8) : Symbol("styleSet");
|
|
3921
3945
|
const top = typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : {};
|
|
3922
3946
|
var StyleModule = class {
|
|
@@ -4005,7 +4029,6 @@ var StyleSet = class {
|
|
|
4005
4029
|
if (this.styleTag && this.styleTag.getAttribute("nonce") != nonce) this.styleTag.setAttribute("nonce", nonce);
|
|
4006
4030
|
}
|
|
4007
4031
|
};
|
|
4008
|
-
|
|
4009
4032
|
//#endregion
|
|
4010
4033
|
//#region node_modules/.pnpm/w3c-keyname@2.2.8/node_modules/w3c-keyname/index.js
|
|
4011
4034
|
var base = {
|
|
@@ -4088,8 +4111,8 @@ var shift = {
|
|
|
4088
4111
|
221: "}",
|
|
4089
4112
|
222: "\""
|
|
4090
4113
|
};
|
|
4091
|
-
|
|
4092
|
-
|
|
4114
|
+
typeof navigator != "undefined" && /Mac/.test(navigator.platform);
|
|
4115
|
+
typeof navigator != "undefined" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
|
|
4093
4116
|
for (var i = 0; i < 10; i++) base[48 + i] = base[96 + i] = String(i);
|
|
4094
4117
|
for (var i = 1; i <= 24; i++) base[i + 111] = "F" + i;
|
|
4095
4118
|
for (var i = 65; i <= 90; i++) {
|
|
@@ -4097,40 +4120,39 @@ for (var i = 65; i <= 90; i++) {
|
|
|
4097
4120
|
shift[i] = String.fromCharCode(i);
|
|
4098
4121
|
}
|
|
4099
4122
|
for (var code in base) if (!shift.hasOwnProperty(code)) shift[code] = base[code];
|
|
4100
|
-
|
|
4101
4123
|
//#endregion
|
|
4102
|
-
//#region node_modules/.pnpm/@codemirror+view@6.
|
|
4124
|
+
//#region node_modules/.pnpm/@codemirror+view@6.43.8/node_modules/@codemirror/view/dist/index.js
|
|
4103
4125
|
let nav = typeof navigator != "undefined" ? navigator : {
|
|
4104
4126
|
userAgent: "",
|
|
4105
4127
|
vendor: "",
|
|
4106
4128
|
platform: ""
|
|
4107
4129
|
};
|
|
4108
4130
|
let doc = typeof document != "undefined" ? document : { documentElement: { style: {} } };
|
|
4109
|
-
const ie_edge =
|
|
4110
|
-
const ie_upto10 =
|
|
4111
|
-
const ie_11up =
|
|
4131
|
+
const ie_edge = /*@__PURE__*/ /Edge\/(\d+)/.exec(nav.userAgent);
|
|
4132
|
+
const ie_upto10 = /*@__PURE__*/ /MSIE \d/.test(nav.userAgent);
|
|
4133
|
+
const ie_11up = /*@__PURE__*/ /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nav.userAgent);
|
|
4112
4134
|
const ie = !!(ie_upto10 || ie_11up || ie_edge);
|
|
4113
|
-
const gecko = !ie &&
|
|
4114
|
-
const chrome = !ie &&
|
|
4135
|
+
const gecko = !ie && /*@__PURE__*/ /gecko\/(\d+)/i.test(nav.userAgent);
|
|
4136
|
+
const chrome = !ie && /*@__PURE__*/ /Chrome\/(\d+)/.exec(nav.userAgent);
|
|
4115
4137
|
const webkit = "webkitFontSmoothing" in doc.documentElement.style;
|
|
4116
|
-
const safari = !ie &&
|
|
4117
|
-
const ios = safari && (
|
|
4138
|
+
const safari = !ie && /*@__PURE__*/ /Apple Computer/.test(nav.vendor);
|
|
4139
|
+
const ios = safari && (/*@__PURE__*/ /Mobile\/\w+/.test(nav.userAgent) || nav.maxTouchPoints > 2);
|
|
4118
4140
|
var browser = {
|
|
4119
|
-
mac: ios ||
|
|
4120
|
-
windows:
|
|
4121
|
-
linux:
|
|
4141
|
+
mac: ios || /*@__PURE__*/ /Mac/.test(nav.platform),
|
|
4142
|
+
windows: /*@__PURE__*/ /Win/.test(nav.platform),
|
|
4143
|
+
linux: /*@__PURE__*/ /Linux|X11/.test(nav.platform),
|
|
4122
4144
|
ie,
|
|
4123
4145
|
ie_version: ie_upto10 ? doc.documentMode || 6 : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : 0,
|
|
4124
4146
|
gecko,
|
|
4125
|
-
gecko_version: gecko ? +(
|
|
4147
|
+
gecko_version: gecko ? +(/*@__PURE__*/ /Firefox\/(\d+)/.exec(nav.userAgent) || [0, 0])[1] : 0,
|
|
4126
4148
|
chrome: !!chrome,
|
|
4127
4149
|
chrome_version: chrome ? +chrome[1] : 0,
|
|
4128
4150
|
ios,
|
|
4129
|
-
android:
|
|
4151
|
+
android: /*@__PURE__*/ /Android\b/.test(nav.userAgent),
|
|
4130
4152
|
webkit,
|
|
4131
|
-
webkit_version: webkit ? +(
|
|
4153
|
+
webkit_version: webkit ? +(/*@__PURE__*/ /\bAppleWebKit\/(\d+)/.exec(nav.userAgent) || [0, 0])[1] : 0,
|
|
4132
4154
|
safari,
|
|
4133
|
-
safari_version: safari ? +(
|
|
4155
|
+
safari_version: safari ? +(/*@__PURE__*/ /\bVersion\/(\d+(\.\d+)?)/.exec(nav.userAgent) || [0, 0])[1] : 0,
|
|
4134
4156
|
tabSize: doc.documentElement.style.tabSize != null ? "tab-size" : "-moz-tab-size"
|
|
4135
4157
|
};
|
|
4136
4158
|
function combineAttrs(source, target) {
|
|
@@ -4139,7 +4161,7 @@ function combineAttrs(source, target) {
|
|
|
4139
4161
|
else target[name] = source[name];
|
|
4140
4162
|
return target;
|
|
4141
4163
|
}
|
|
4142
|
-
const noAttrs =
|
|
4164
|
+
const noAttrs = /*@__PURE__*/ Object.create(null);
|
|
4143
4165
|
function attrsEq(a, b, ignore) {
|
|
4144
4166
|
if (a == b) return true;
|
|
4145
4167
|
if (!a) a = noAttrs;
|
|
@@ -4213,7 +4235,7 @@ var WidgetType = class {
|
|
|
4213
4235
|
couldn't (in which case the widget will be redrawn). The default
|
|
4214
4236
|
implementation just returns false.
|
|
4215
4237
|
*/
|
|
4216
|
-
updateDOM(dom, view) {
|
|
4238
|
+
updateDOM(dom, view, from) {
|
|
4217
4239
|
return false;
|
|
4218
4240
|
}
|
|
4219
4241
|
/**
|
|
@@ -4279,7 +4301,7 @@ var WidgetType = class {
|
|
|
4279
4301
|
/**
|
|
4280
4302
|
The different types of blocks that can occur in an editor view.
|
|
4281
4303
|
*/
|
|
4282
|
-
var BlockType =
|
|
4304
|
+
var BlockType = /*@__PURE__*/ (function(BlockType) {
|
|
4283
4305
|
/**
|
|
4284
4306
|
A line of text.
|
|
4285
4307
|
*/
|
|
@@ -4458,10 +4480,11 @@ widget that starts inside its range, including blocks starting
|
|
|
4458
4480
|
directly at `from` but not including `to`.
|
|
4459
4481
|
*/
|
|
4460
4482
|
var BlockWrapper = class BlockWrapper extends RangeValue {
|
|
4461
|
-
constructor(tagName, attributes) {
|
|
4483
|
+
constructor(tagName, attributes, rank) {
|
|
4462
4484
|
super();
|
|
4463
4485
|
this.tagName = tagName;
|
|
4464
4486
|
this.attributes = attributes;
|
|
4487
|
+
this.rank = rank;
|
|
4465
4488
|
}
|
|
4466
4489
|
eq(other) {
|
|
4467
4490
|
return other == this || other instanceof BlockWrapper && this.tagName == other.tagName && attrsEq(this.attributes, other.attributes);
|
|
@@ -4471,7 +4494,7 @@ var BlockWrapper = class BlockWrapper extends RangeValue {
|
|
|
4471
4494
|
attributes.
|
|
4472
4495
|
*/
|
|
4473
4496
|
static create(spec) {
|
|
4474
|
-
return new BlockWrapper(spec.tagName, spec.attributes || noAttrs);
|
|
4497
|
+
return new BlockWrapper(spec.tagName, spec.attributes || noAttrs, spec.rank == null ? 50 : Math.max(0, Math.min(spec.rank, 100)));
|
|
4475
4498
|
}
|
|
4476
4499
|
/**
|
|
4477
4500
|
Create a range set from the given block wrapper ranges.
|
|
@@ -4534,8 +4557,10 @@ function scanFor(node, off, targetNode, targetOff, dir) {
|
|
|
4534
4557
|
function maxOffset(node) {
|
|
4535
4558
|
return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
|
|
4536
4559
|
}
|
|
4537
|
-
function flattenRect(rect,
|
|
4538
|
-
let
|
|
4560
|
+
function flattenRect(rect, toLeft) {
|
|
4561
|
+
let { left, right } = rect;
|
|
4562
|
+
if (left == right) return rect;
|
|
4563
|
+
let x = toLeft ? left : right;
|
|
4539
4564
|
return {
|
|
4540
4565
|
left: x,
|
|
4541
4566
|
right: x,
|
|
@@ -4591,10 +4616,10 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
|
|
|
4591
4616
|
}
|
|
4592
4617
|
let moveX = 0, moveY = 0;
|
|
4593
4618
|
if (y == "nearest") {
|
|
4594
|
-
if (rect.top < bounding.top) {
|
|
4619
|
+
if (rect.top < bounding.top + yMargin) {
|
|
4595
4620
|
moveY = rect.top - (bounding.top + yMargin);
|
|
4596
4621
|
if (side > 0 && rect.bottom > bounding.bottom + moveY) moveY = rect.bottom - bounding.bottom + yMargin;
|
|
4597
|
-
} else if (rect.bottom > bounding.bottom) {
|
|
4622
|
+
} else if (rect.bottom > bounding.bottom - yMargin) {
|
|
4598
4623
|
moveY = rect.bottom - bounding.bottom + yMargin;
|
|
4599
4624
|
if (side < 0 && rect.top - moveY < bounding.top) moveY = rect.top - (bounding.top + yMargin);
|
|
4600
4625
|
}
|
|
@@ -4603,35 +4628,37 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
|
|
|
4603
4628
|
moveY = (y == "center" && rectHeight <= boundingHeight ? rect.top + rectHeight / 2 - boundingHeight / 2 : y == "start" || y == "center" && side < 0 ? rect.top - yMargin : rect.bottom - boundingHeight + yMargin) - bounding.top;
|
|
4604
4629
|
}
|
|
4605
4630
|
if (x == "nearest") {
|
|
4606
|
-
if (rect.left < bounding.left) {
|
|
4631
|
+
if (rect.left < bounding.left + xMargin) {
|
|
4607
4632
|
moveX = rect.left - (bounding.left + xMargin);
|
|
4608
4633
|
if (side > 0 && rect.right > bounding.right + moveX) moveX = rect.right - bounding.right + xMargin;
|
|
4609
|
-
} else if (rect.right > bounding.right) {
|
|
4634
|
+
} else if (rect.right > bounding.right - xMargin) {
|
|
4610
4635
|
moveX = rect.right - bounding.right + xMargin;
|
|
4611
4636
|
if (side < 0 && rect.left < bounding.left + moveX) moveX = rect.left - (bounding.left + xMargin);
|
|
4612
4637
|
}
|
|
4613
4638
|
} else moveX = (x == "center" ? rect.left + (rect.right - rect.left) / 2 - (bounding.right - bounding.left) / 2 : x == "start" == ltr ? rect.left - xMargin : rect.right - (bounding.right - bounding.left) + xMargin) - bounding.left;
|
|
4614
|
-
if (moveX || moveY)
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4639
|
+
if (moveX || moveY) {
|
|
4640
|
+
if (top) win.scrollBy(moveX, moveY);
|
|
4641
|
+
else {
|
|
4642
|
+
let movedX = 0, movedY = 0;
|
|
4643
|
+
if (moveY) {
|
|
4644
|
+
let start = cur.scrollTop;
|
|
4645
|
+
cur.scrollTop += moveY / scaleY;
|
|
4646
|
+
movedY = (cur.scrollTop - start) * scaleY;
|
|
4647
|
+
}
|
|
4648
|
+
if (moveX) {
|
|
4649
|
+
let start = cur.scrollLeft;
|
|
4650
|
+
cur.scrollLeft += moveX / scaleX;
|
|
4651
|
+
movedX = (cur.scrollLeft - start) * scaleX;
|
|
4652
|
+
}
|
|
4653
|
+
rect = {
|
|
4654
|
+
left: rect.left - movedX,
|
|
4655
|
+
top: rect.top - movedY,
|
|
4656
|
+
right: rect.right - movedX,
|
|
4657
|
+
bottom: rect.bottom - movedY
|
|
4658
|
+
};
|
|
4659
|
+
if (movedX && Math.abs(movedX - moveX) < 1) x = "nearest";
|
|
4660
|
+
if (movedY && Math.abs(movedY - moveY) < 1) y = "nearest";
|
|
4661
|
+
}
|
|
4635
4662
|
}
|
|
4636
4663
|
if (top) break;
|
|
4637
4664
|
if (rect.top < bounding.top || rect.bottom > bounding.bottom || rect.left < bounding.left || rect.right > bounding.right) rect = {
|
|
@@ -4644,12 +4671,12 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
|
|
|
4644
4671
|
} else if (cur.nodeType == 11) cur = cur.host;
|
|
4645
4672
|
else break;
|
|
4646
4673
|
}
|
|
4647
|
-
function scrollableParents(dom) {
|
|
4648
|
-
let doc = dom.ownerDocument, x, y;
|
|
4649
|
-
for (let cur = dom.parentNode; cur;) if (cur == doc.body || x && y) break;
|
|
4674
|
+
function scrollableParents(dom, getX = true) {
|
|
4675
|
+
let doc = dom.ownerDocument, x = null, y = null;
|
|
4676
|
+
for (let cur = dom.parentNode; cur;) if (cur == doc.body || (!getX || x) && y) break;
|
|
4650
4677
|
else if (cur.nodeType == 1) {
|
|
4651
4678
|
if (!y && cur.scrollHeight > cur.clientHeight) y = cur;
|
|
4652
|
-
if (!x && cur.scrollWidth > cur.clientWidth) x = cur;
|
|
4679
|
+
if (getX && !x && cur.scrollWidth > cur.clientWidth) x = cur;
|
|
4653
4680
|
cur = cur.assignedSlot || cur.parentNode;
|
|
4654
4681
|
} else if (cur.nodeType == 11) cur = cur.host;
|
|
4655
4682
|
else break;
|
|
@@ -4679,27 +4706,34 @@ var DOMSelectionState = class {
|
|
|
4679
4706
|
this.focusOffset = focusOffset;
|
|
4680
4707
|
}
|
|
4681
4708
|
};
|
|
4709
|
+
function getScrollStack(target) {
|
|
4710
|
+
let stack = [];
|
|
4711
|
+
for (let cur = target; cur; cur = cur.nodeType == 11 ? cur.host : cur.parentNode) if (cur.nodeType == 1) stack.push({
|
|
4712
|
+
node: cur,
|
|
4713
|
+
left: cur.scrollLeft,
|
|
4714
|
+
top: cur.scrollTop
|
|
4715
|
+
});
|
|
4716
|
+
return stack;
|
|
4717
|
+
}
|
|
4718
|
+
function restoreScrollStack(stack, vert = true) {
|
|
4719
|
+
for (let { node, left, top } of stack) {
|
|
4720
|
+
if (vert && node.scrollTop != top) node.scrollTop = top;
|
|
4721
|
+
if (node.scrollLeft != left) node.scrollLeft = left;
|
|
4722
|
+
}
|
|
4723
|
+
}
|
|
4682
4724
|
let preventScrollSupported = null;
|
|
4683
4725
|
if (browser.safari && browser.safari_version >= 26) preventScrollSupported = false;
|
|
4684
4726
|
function focusPreventScroll(dom) {
|
|
4685
4727
|
if (dom.setActive) return dom.setActive();
|
|
4686
4728
|
if (preventScrollSupported) return dom.focus(preventScrollSupported);
|
|
4687
|
-
let stack =
|
|
4688
|
-
for (let cur = dom; cur; cur = cur.parentNode) {
|
|
4689
|
-
stack.push(cur, cur.scrollTop, cur.scrollLeft);
|
|
4690
|
-
if (cur == cur.ownerDocument) break;
|
|
4691
|
-
}
|
|
4729
|
+
let stack = getScrollStack(dom);
|
|
4692
4730
|
dom.focus(preventScrollSupported == null ? { get preventScroll() {
|
|
4693
4731
|
preventScrollSupported = { preventScroll: true };
|
|
4694
4732
|
return true;
|
|
4695
4733
|
} } : void 0);
|
|
4696
4734
|
if (!preventScrollSupported) {
|
|
4697
4735
|
preventScrollSupported = false;
|
|
4698
|
-
|
|
4699
|
-
let elt = stack[i++], top = stack[i++], left = stack[i++];
|
|
4700
|
-
if (elt.scrollTop != top) elt.scrollTop = top;
|
|
4701
|
-
if (elt.scrollLeft != left) elt.scrollLeft = left;
|
|
4702
|
-
}
|
|
4736
|
+
restoreScrollStack(stack);
|
|
4703
4737
|
}
|
|
4704
4738
|
}
|
|
4705
4739
|
let scratchRange;
|
|
@@ -4752,6 +4786,7 @@ function atElementStart(doc, selection) {
|
|
|
4752
4786
|
}
|
|
4753
4787
|
}
|
|
4754
4788
|
function isScrolledToBottom(elt) {
|
|
4789
|
+
if (elt instanceof Window) return elt.pageYOffset > Math.max(0, elt.document.documentElement.scrollHeight - elt.innerHeight - 4);
|
|
4755
4790
|
return elt.scrollTop > Math.max(1, elt.scrollHeight - elt.clientHeight - 4);
|
|
4756
4791
|
}
|
|
4757
4792
|
function textNodeBefore(startNode, startOffset) {
|
|
@@ -4798,7 +4833,7 @@ var DOMPos = class DOMPos {
|
|
|
4798
4833
|
/**
|
|
4799
4834
|
Used to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
|
|
4800
4835
|
*/
|
|
4801
|
-
var Direction =
|
|
4836
|
+
var Direction = /*@__PURE__*/ (function(Direction) {
|
|
4802
4837
|
/**
|
|
4803
4838
|
Left-to-right.
|
|
4804
4839
|
*/
|
|
@@ -4809,21 +4844,23 @@ var Direction = /* @__PURE__ */ (function(Direction) {
|
|
|
4809
4844
|
Direction[Direction["RTL"] = 1] = "RTL";
|
|
4810
4845
|
return Direction;
|
|
4811
4846
|
})(Direction || (Direction = {}));
|
|
4812
|
-
const LTR = Direction.LTR
|
|
4847
|
+
const LTR = Direction.LTR;
|
|
4848
|
+
const RTL = Direction.RTL;
|
|
4813
4849
|
function dec(str) {
|
|
4814
4850
|
let result = [];
|
|
4815
4851
|
for (let i = 0; i < str.length; i++) result.push(1 << +str[i]);
|
|
4816
4852
|
return result;
|
|
4817
4853
|
}
|
|
4818
|
-
const LowTypes =
|
|
4819
|
-
const ArabicTypes =
|
|
4820
|
-
const Brackets =
|
|
4854
|
+
const LowTypes = /*@__PURE__*/ dec("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008");
|
|
4855
|
+
const ArabicTypes = /*@__PURE__*/ dec("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333");
|
|
4856
|
+
const Brackets = /*@__PURE__*/ Object.create(null);
|
|
4857
|
+
const BracketStack = [];
|
|
4821
4858
|
for (let p of [
|
|
4822
4859
|
"()",
|
|
4823
4860
|
"[]",
|
|
4824
4861
|
"{}"
|
|
4825
4862
|
]) {
|
|
4826
|
-
let l =
|
|
4863
|
+
let l = /*@__PURE__*/ p.charCodeAt(0), r = /*@__PURE__*/ p.charCodeAt(1);
|
|
4827
4864
|
Brackets[l] = r;
|
|
4828
4865
|
Brackets[r] = -l;
|
|
4829
4866
|
}
|
|
@@ -4901,9 +4938,10 @@ function computeCharTypes(line, rFrom, rTo, isolates, outerType) {
|
|
|
4901
4938
|
}
|
|
4902
4939
|
for (let i = from, prev = prevType, prevStrong = prevType; i < to; i++) {
|
|
4903
4940
|
let type = types[i];
|
|
4904
|
-
if (type == 128)
|
|
4905
|
-
|
|
4906
|
-
|
|
4941
|
+
if (type == 128) {
|
|
4942
|
+
if (i < to - 1 && prev == types[i + 1] && prev & 24) type = types[i] = prev;
|
|
4943
|
+
else types[i] = 256;
|
|
4944
|
+
} else if (type == 64) {
|
|
4907
4945
|
let end = i + 1;
|
|
4908
4946
|
while (end < to && types[end] == 64) end++;
|
|
4909
4947
|
let replace = i && prev == 8 || end < rTo && types[end] == 8 ? prevStrong == 1 ? 1 : 8 : 256;
|
|
@@ -4919,21 +4957,22 @@ function processBracketPairs(line, rFrom, rTo, isolates, outerType) {
|
|
|
4919
4957
|
let oppositeType = outerType == 1 ? 2 : 1;
|
|
4920
4958
|
for (let iI = 0, sI = 0, context = 0; iI <= isolates.length; iI++) {
|
|
4921
4959
|
let from = iI ? isolates[iI - 1].to : rFrom, to = iI < isolates.length ? isolates[iI].from : rTo;
|
|
4922
|
-
for (let i = from, ch, br, type; i < to; i++) if (br = Brackets[ch = line.charCodeAt(i)])
|
|
4923
|
-
|
|
4924
|
-
let
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4960
|
+
for (let i = from, ch, br, type; i < to; i++) if (br = Brackets[ch = line.charCodeAt(i)]) {
|
|
4961
|
+
if (br < 0) {
|
|
4962
|
+
for (let sJ = sI - 3; sJ >= 0; sJ -= 3) if (BracketStack[sJ + 1] == -br) {
|
|
4963
|
+
let flags = BracketStack[sJ + 2];
|
|
4964
|
+
let type = flags & 2 ? outerType : !(flags & 4) ? 0 : flags & 1 ? oppositeType : outerType;
|
|
4965
|
+
if (type) types[i] = types[BracketStack[sJ]] = type;
|
|
4966
|
+
sI = sJ;
|
|
4967
|
+
break;
|
|
4968
|
+
}
|
|
4969
|
+
} else if (BracketStack.length == 189) break;
|
|
4970
|
+
else {
|
|
4971
|
+
BracketStack[sI++] = i;
|
|
4972
|
+
BracketStack[sI++] = ch;
|
|
4973
|
+
BracketStack[sI++] = context;
|
|
4929
4974
|
}
|
|
4930
|
-
} else if (
|
|
4931
|
-
else {
|
|
4932
|
-
BracketStack[sI++] = i;
|
|
4933
|
-
BracketStack[sI++] = ch;
|
|
4934
|
-
BracketStack[sI++] = context;
|
|
4935
|
-
}
|
|
4936
|
-
else if ((type = types[i]) == 2 || type == 1) {
|
|
4975
|
+
} else if ((type = types[i]) == 2 || type == 1) {
|
|
4937
4976
|
let embed = type == outerType;
|
|
4938
4977
|
context = embed ? 0 : 1;
|
|
4939
4978
|
for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
|
|
@@ -5096,20 +5135,20 @@ function autoDirection(text, from, to) {
|
|
|
5096
5135
|
}
|
|
5097
5136
|
return LTR;
|
|
5098
5137
|
}
|
|
5099
|
-
const clickAddsSelectionRange =
|
|
5100
|
-
const dragMovesSelection$1 =
|
|
5101
|
-
const mouseSelectionStyle =
|
|
5102
|
-
const exceptionSink =
|
|
5103
|
-
const updateListener =
|
|
5104
|
-
const inputHandler =
|
|
5105
|
-
const focusChangeEffect =
|
|
5106
|
-
const clipboardInputFilter =
|
|
5107
|
-
const clipboardOutputFilter =
|
|
5108
|
-
const perLineTextDirection =
|
|
5109
|
-
const nativeSelectionHidden =
|
|
5110
|
-
const scrollHandler =
|
|
5138
|
+
const clickAddsSelectionRange = /*@__PURE__*/ Facet.define();
|
|
5139
|
+
const dragMovesSelection$1 = /*@__PURE__*/ Facet.define();
|
|
5140
|
+
const mouseSelectionStyle = /*@__PURE__*/ Facet.define();
|
|
5141
|
+
const exceptionSink = /*@__PURE__*/ Facet.define();
|
|
5142
|
+
const updateListener = /*@__PURE__*/ Facet.define();
|
|
5143
|
+
const inputHandler = /*@__PURE__*/ Facet.define();
|
|
5144
|
+
const focusChangeEffect = /*@__PURE__*/ Facet.define();
|
|
5145
|
+
const clipboardInputFilter = /*@__PURE__*/ Facet.define();
|
|
5146
|
+
const clipboardOutputFilter = /*@__PURE__*/ Facet.define();
|
|
5147
|
+
const perLineTextDirection = /*@__PURE__*/ Facet.define({ combine: (values) => values.some((x) => x) });
|
|
5148
|
+
const nativeSelectionHidden = /*@__PURE__*/ Facet.define({ combine: (values) => values.some((x) => x) });
|
|
5149
|
+
const scrollHandler = /*@__PURE__*/ Facet.define();
|
|
5111
5150
|
var ScrollTarget = class ScrollTarget {
|
|
5112
|
-
constructor(range, y
|
|
5151
|
+
constructor(range, y, x, yMargin, xMargin, isSnapshot = false) {
|
|
5113
5152
|
this.range = range;
|
|
5114
5153
|
this.y = y;
|
|
5115
5154
|
this.x = x;
|
|
@@ -5124,8 +5163,8 @@ var ScrollTarget = class ScrollTarget {
|
|
|
5124
5163
|
return this.range.to <= state.doc.length ? this : new ScrollTarget(EditorSelection.cursor(state.doc.length), this.y, this.x, this.yMargin, this.xMargin, this.isSnapshot);
|
|
5125
5164
|
}
|
|
5126
5165
|
};
|
|
5127
|
-
const scrollIntoView =
|
|
5128
|
-
const setEditContextFormatting =
|
|
5166
|
+
const scrollIntoView = /*@__PURE__*/ StateEffect.define({ map: (t, ch) => t.map(ch) });
|
|
5167
|
+
const setEditContextFormatting = /*@__PURE__*/ StateEffect.define();
|
|
5129
5168
|
/**
|
|
5130
5169
|
Log or report an unhandled exception in client code. Should
|
|
5131
5170
|
probably only be used by extension code that allows client code to
|
|
@@ -5145,9 +5184,9 @@ function logException(state, exception, context) {
|
|
|
5145
5184
|
else if (context) console.error(context + ":", exception);
|
|
5146
5185
|
else console.error(exception);
|
|
5147
5186
|
}
|
|
5148
|
-
const editable =
|
|
5187
|
+
const editable = /*@__PURE__*/ Facet.define({ combine: (values) => values.length ? values[0] : true });
|
|
5149
5188
|
let nextPluginID = 0;
|
|
5150
|
-
const viewPlugin =
|
|
5189
|
+
const viewPlugin = /*@__PURE__*/ Facet.define({ combine(plugins) {
|
|
5151
5190
|
return plugins.filter((p, i) => {
|
|
5152
5191
|
for (let j = 0; j < i; j++) if (plugins[j].plugin == p.plugin) return false;
|
|
5153
5192
|
return true;
|
|
@@ -5250,13 +5289,13 @@ var PluginInstance = class {
|
|
|
5250
5289
|
this.spec = this.value = null;
|
|
5251
5290
|
}
|
|
5252
5291
|
};
|
|
5253
|
-
const editorAttributes =
|
|
5254
|
-
const contentAttributes =
|
|
5255
|
-
const decorations =
|
|
5256
|
-
const blockWrappers =
|
|
5257
|
-
const outerDecorations =
|
|
5258
|
-
const atomicRanges =
|
|
5259
|
-
const bidiIsolatedRanges =
|
|
5292
|
+
const editorAttributes = /*@__PURE__*/ Facet.define();
|
|
5293
|
+
const contentAttributes = /*@__PURE__*/ Facet.define();
|
|
5294
|
+
const decorations = /*@__PURE__*/ Facet.define();
|
|
5295
|
+
const blockWrappers = /*@__PURE__*/ Facet.define();
|
|
5296
|
+
const outerDecorations = /*@__PURE__*/ Facet.define();
|
|
5297
|
+
const atomicRanges = /*@__PURE__*/ Facet.define();
|
|
5298
|
+
const bidiIsolatedRanges = /*@__PURE__*/ Facet.define();
|
|
5260
5299
|
function getIsolatedRanges(view, line) {
|
|
5261
5300
|
let isolates = view.state.facet(bidiIsolatedRanges);
|
|
5262
5301
|
if (!isolates.length) return isolates;
|
|
@@ -5288,7 +5327,7 @@ function getIsolatedRanges(view, line) {
|
|
|
5288
5327
|
});
|
|
5289
5328
|
return result;
|
|
5290
5329
|
}
|
|
5291
|
-
const scrollMargins =
|
|
5330
|
+
const scrollMargins = /*@__PURE__*/ Facet.define();
|
|
5292
5331
|
function getScrollMargins(view) {
|
|
5293
5332
|
let left = 0, right = 0, top = 0, bottom = 0;
|
|
5294
5333
|
for (let source of view.state.facet(scrollMargins)) {
|
|
@@ -5307,7 +5346,7 @@ function getScrollMargins(view) {
|
|
|
5307
5346
|
bottom
|
|
5308
5347
|
};
|
|
5309
5348
|
}
|
|
5310
|
-
const styleModule =
|
|
5349
|
+
const styleModule = /*@__PURE__*/ Facet.define();
|
|
5311
5350
|
var ChangedRange = class ChangedRange {
|
|
5312
5351
|
constructor(fromA, toA, fromB, toB) {
|
|
5313
5352
|
this.fromA = fromA;
|
|
@@ -5512,7 +5551,7 @@ var Tile = class {
|
|
|
5512
5551
|
covers(side) {
|
|
5513
5552
|
return true;
|
|
5514
5553
|
}
|
|
5515
|
-
coordsIn(pos, side) {
|
|
5554
|
+
coordsIn(pos, side, rtl) {
|
|
5516
5555
|
return null;
|
|
5517
5556
|
}
|
|
5518
5557
|
domPosFor(off, side) {
|
|
@@ -5693,10 +5732,10 @@ var LineTile = class LineTile extends CompositeTile {
|
|
|
5693
5732
|
let child = tile.children[i], end = off + child.length;
|
|
5694
5733
|
if (end >= pos) {
|
|
5695
5734
|
if (child.isComposite()) scan(child, pos - off);
|
|
5696
|
-
else if ((!after || after.isHidden && (side > 0 || forCoords && onSameLine(after, child))) && (end > pos || child.flags & 32)) {
|
|
5735
|
+
else if ((!after || after.isHidden && (side > 0 && !(after.flags & 32) || forCoords && onSameLine(after, child))) && (end > pos || child.flags & 32 && side <= 1)) {
|
|
5697
5736
|
after = child;
|
|
5698
5737
|
afterOff = pos - off;
|
|
5699
|
-
} else if (off < pos || child.flags & 16 && !child.isHidden) {
|
|
5738
|
+
} else if (off < pos || child.flags & 16 && !child.isHidden && side >= -1) {
|
|
5700
5739
|
before = child;
|
|
5701
5740
|
beforeOff = pos - off;
|
|
5702
5741
|
}
|
|
@@ -5711,10 +5750,10 @@ var LineTile = class LineTile extends CompositeTile {
|
|
|
5711
5750
|
offset: target == before ? beforeOff : afterOff
|
|
5712
5751
|
} : null;
|
|
5713
5752
|
}
|
|
5714
|
-
coordsIn(pos, side) {
|
|
5753
|
+
coordsIn(pos, side, rtl) {
|
|
5715
5754
|
let found = this.resolveInline(pos, side, true);
|
|
5716
5755
|
if (!found) return fallbackRect(this);
|
|
5717
|
-
return found.tile.coordsIn(Math.max(0, found.offset), side);
|
|
5756
|
+
return found.tile.coordsIn(Math.max(0, found.offset), side, rtl);
|
|
5718
5757
|
}
|
|
5719
5758
|
domIn(pos, side) {
|
|
5720
5759
|
let found = this.resolveInline(pos, side);
|
|
@@ -5776,7 +5815,7 @@ var TextTile = class TextTile extends Tile {
|
|
|
5776
5815
|
toString() {
|
|
5777
5816
|
return JSON.stringify(this.text);
|
|
5778
5817
|
}
|
|
5779
|
-
coordsIn(pos, side) {
|
|
5818
|
+
coordsIn(pos, side, rtl) {
|
|
5780
5819
|
let length = this.dom.nodeValue.length;
|
|
5781
5820
|
if (pos > length) pos = length;
|
|
5782
5821
|
let from = pos, to = pos, flatten = 0;
|
|
@@ -5796,7 +5835,7 @@ var TextTile = class TextTile extends Tile {
|
|
|
5796
5835
|
if (!rects.length) return null;
|
|
5797
5836
|
let rect = rects[(flatten ? flatten < 0 : side >= 0) ? 0 : rects.length - 1];
|
|
5798
5837
|
if (browser.safari && !flatten && rect.width == 0) rect = Array.prototype.find.call(rects, (r) => r.width) || rect;
|
|
5799
|
-
return
|
|
5838
|
+
return rtl == null ? rect : flattenRect(rect, (flatten ? flatten > 0 : side < 0) == rtl);
|
|
5800
5839
|
}
|
|
5801
5840
|
static of(text, dom) {
|
|
5802
5841
|
let tile = new TextTile(dom || document.createTextNode(text), text);
|
|
@@ -5869,8 +5908,9 @@ var WidgetBufferTile = class extends Tile {
|
|
|
5869
5908
|
get overrideDOMText() {
|
|
5870
5909
|
return Text.empty;
|
|
5871
5910
|
}
|
|
5872
|
-
coordsIn(pos) {
|
|
5873
|
-
|
|
5911
|
+
coordsIn(pos, side, rtl) {
|
|
5912
|
+
let rect = this.dom.getBoundingClientRect();
|
|
5913
|
+
return rtl == null ? rect : flattenRect(rect, side > 0 == rtl);
|
|
5874
5914
|
}
|
|
5875
5915
|
};
|
|
5876
5916
|
var TilePointer = class {
|
|
@@ -5882,18 +5922,20 @@ var TilePointer = class {
|
|
|
5882
5922
|
}
|
|
5883
5923
|
advance(dist, side, walker) {
|
|
5884
5924
|
let { tile, index, beforeBreak, parents } = this;
|
|
5885
|
-
while (dist || side > 0) if (!tile.isComposite())
|
|
5886
|
-
|
|
5887
|
-
(
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5925
|
+
while (dist || side > 0) if (!tile.isComposite()) {
|
|
5926
|
+
let len = tile.length;
|
|
5927
|
+
if (index < len && dist) {
|
|
5928
|
+
let take = Math.min(dist, len - index);
|
|
5929
|
+
if (walker) walker.skip(tile, index, index + take);
|
|
5930
|
+
dist -= take;
|
|
5931
|
+
index += take;
|
|
5932
|
+
}
|
|
5933
|
+
if (index == len) {
|
|
5934
|
+
beforeBreak = !!tile.breakAfter;
|
|
5935
|
+
({tile, index} = parents.pop());
|
|
5936
|
+
index++;
|
|
5937
|
+
} else if (!dist) break;
|
|
5938
|
+
} else if (beforeBreak) {
|
|
5897
5939
|
if (!dist) break;
|
|
5898
5940
|
if (walker) walker.break();
|
|
5899
5941
|
dist--;
|
|
@@ -5954,7 +5996,7 @@ var TileBuilder = class {
|
|
|
5954
5996
|
this.flushBuffer();
|
|
5955
5997
|
let parent = this.ensureMarks(marks, openStart);
|
|
5956
5998
|
let prev = parent.lastChild;
|
|
5957
|
-
if (prev && prev.isText() && !(prev.flags & 8)) {
|
|
5999
|
+
if (prev && prev.isText() && !(prev.flags & 8) && prev.length + text.length < 512) {
|
|
5958
6000
|
this.cache.reused.set(prev, 2);
|
|
5959
6001
|
let tile = parent.children[parent.children.length - 1] = new TextTile(prev.dom, prev.text + text);
|
|
5960
6002
|
tile.parent = parent;
|
|
@@ -5990,6 +6032,7 @@ var TileBuilder = class {
|
|
|
5990
6032
|
if (oldTile) this.cache.reused.set(oldTile, 2);
|
|
5991
6033
|
let text = new TextTile(composition.text, composition.text.nodeValue);
|
|
5992
6034
|
text.flags |= 8;
|
|
6035
|
+
this.pos = composition.range.toB;
|
|
5993
6036
|
head.append(text);
|
|
5994
6037
|
}
|
|
5995
6038
|
addInlineWidget(widget, marks, openStart) {
|
|
@@ -6073,7 +6116,8 @@ var TileBuilder = class {
|
|
|
6073
6116
|
}
|
|
6074
6117
|
for (let i = this.wrappers.length - 1; i >= 0; i--) if (this.wrappers[i].to < this.pos) this.wrappers.splice(i, 1);
|
|
6075
6118
|
for (let cur = this.blockWrappers; cur.value && cur.from <= this.pos; cur.next()) if (cur.to >= this.pos) {
|
|
6076
|
-
let
|
|
6119
|
+
let rank = cur.rank * 102 + cur.value.rank;
|
|
6120
|
+
let wrap = new OpenWrapper(cur.from, cur.to, cur.value, rank), i = this.wrappers.length;
|
|
6077
6121
|
while (i > 0 && (this.wrappers[i - 1].rank - wrap.rank || this.wrappers[i - 1].to - wrap.to) < 0) i--;
|
|
6078
6122
|
this.wrappers.splice(i, 0, wrap);
|
|
6079
6123
|
}
|
|
@@ -6166,7 +6210,7 @@ var TileCache = class {
|
|
|
6166
6210
|
find(cls, test, type = 2) {
|
|
6167
6211
|
let i = cls.bucket;
|
|
6168
6212
|
let bucket = this.buckets[i], off = this.index[i];
|
|
6169
|
-
for (let j =
|
|
6213
|
+
for (let j = 0; j < bucket.length; j++) {
|
|
6170
6214
|
let index = (j + off) % bucket.length, tile = bucket[index];
|
|
6171
6215
|
if ((!test || test(tile)) && !this.reused.has(tile)) {
|
|
6172
6216
|
bucket.splice(index, 1);
|
|
@@ -6186,7 +6230,7 @@ var TileCache = class {
|
|
|
6186
6230
|
i = 0;
|
|
6187
6231
|
}
|
|
6188
6232
|
let tile = widgets[i];
|
|
6189
|
-
if (!this.reused.has(tile) && (pass == 0 ? tile.widget.compare(widget) : tile.widget.constructor == widget.constructor && widget.updateDOM(tile.dom, this.view))) {
|
|
6233
|
+
if (!this.reused.has(tile) && (pass == 0 ? tile.widget.compare(widget) : tile.widget.constructor == widget.constructor && widget.updateDOM(tile.dom, this.view, tile.widget))) {
|
|
6190
6234
|
widgets.splice(i, 1);
|
|
6191
6235
|
if (i < this.index[0]) this.index[0]--;
|
|
6192
6236
|
if (tile.widget == widget && tile.length == length && (tile.flags & 497) == flags) {
|
|
@@ -6249,6 +6293,7 @@ var TileUpdate = class {
|
|
|
6249
6293
|
if (composition && next.fromA <= composition.range.fromA && next.toA >= composition.range.toA) {
|
|
6250
6294
|
this.forward(next.fromA, composition.range.fromA, composition.range.fromA < composition.range.toA ? 1 : -1);
|
|
6251
6295
|
this.emit(posB, composition.range.fromB);
|
|
6296
|
+
this.builder.flushBuffer();
|
|
6252
6297
|
this.cache.clear();
|
|
6253
6298
|
this.builder.addComposition(composition, compositionContext);
|
|
6254
6299
|
this.text.skip(composition.range.toB - composition.range.fromB);
|
|
@@ -6268,21 +6313,22 @@ var TileUpdate = class {
|
|
|
6268
6313
|
let activeMarks = getMarks(this.old), openMarks = this.openMarks;
|
|
6269
6314
|
this.old.advance(length, incEnd ? 1 : -1, {
|
|
6270
6315
|
skip: (tile, from, to) => {
|
|
6271
|
-
if (tile.isWidget())
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
widget.flags
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6316
|
+
if (tile.isWidget()) {
|
|
6317
|
+
if (this.openWidget) this.builder.continueWidget(to - from);
|
|
6318
|
+
else {
|
|
6319
|
+
let widget = to > 0 || from < tile.length ? WidgetTile.of(tile.widget, this.view, to - from, tile.flags & 496, this.cache.maybeReuse(tile)) : this.cache.reuse(tile);
|
|
6320
|
+
if (widget.flags & 256) {
|
|
6321
|
+
widget.flags &= -2;
|
|
6322
|
+
this.builder.addBlockWidget(widget);
|
|
6323
|
+
} else {
|
|
6324
|
+
this.builder.ensureLine(null);
|
|
6325
|
+
this.builder.addInlineWidget(widget, activeMarks, openMarks);
|
|
6326
|
+
openMarks = activeMarks.length;
|
|
6327
|
+
}
|
|
6281
6328
|
}
|
|
6282
|
-
}
|
|
6283
|
-
else if (tile.isText()) {
|
|
6329
|
+
} else if (tile.isText()) {
|
|
6284
6330
|
this.builder.ensureLine(null);
|
|
6285
|
-
if (!from && to == tile.length) this.builder.addText(tile.text, activeMarks, openMarks, this.cache.reuse(tile));
|
|
6331
|
+
if (!from && to == tile.length && !this.cache.reused.has(tile)) this.builder.addText(tile.text, activeMarks, openMarks, this.cache.reuse(tile));
|
|
6286
6332
|
else {
|
|
6287
6333
|
this.cache.add(tile);
|
|
6288
6334
|
this.builder.addText(tile.text.slice(from, to), activeMarks, openMarks);
|
|
@@ -6326,7 +6372,7 @@ var TileUpdate = class {
|
|
|
6326
6372
|
}
|
|
6327
6373
|
emit(from, to) {
|
|
6328
6374
|
let pendingLineAttrs = null;
|
|
6329
|
-
let b = this.builder, markCount =
|
|
6375
|
+
let b = this.builder, markCount = -1;
|
|
6330
6376
|
let openEnd = RangeSet.spans(this.decorations, from, to, {
|
|
6331
6377
|
point: (from, to, deco, active, openStart, index) => {
|
|
6332
6378
|
if (deco instanceof PointDecoration) {
|
|
@@ -6361,15 +6407,16 @@ var TileUpdate = class {
|
|
|
6361
6407
|
pos++;
|
|
6362
6408
|
} else {
|
|
6363
6409
|
b.ensureLine(pendingLineAttrs);
|
|
6364
|
-
b.addText(chars, active, openStart);
|
|
6410
|
+
b.addText(chars, active, pos == from ? openStart : active.length);
|
|
6365
6411
|
pos += chars.length;
|
|
6366
6412
|
}
|
|
6367
6413
|
pendingLineAttrs = null;
|
|
6368
6414
|
}
|
|
6415
|
+
markCount = active.length;
|
|
6369
6416
|
}
|
|
6370
6417
|
});
|
|
6371
|
-
|
|
6372
|
-
this.openWidget
|
|
6418
|
+
if (markCount > -1) this.openWidget = openEnd > markCount;
|
|
6419
|
+
if (!this.openWidget) b.addLineStartIfNotCovered(pendingLineAttrs);
|
|
6373
6420
|
this.openMarks = openEnd;
|
|
6374
6421
|
}
|
|
6375
6422
|
forward(from, to, side = 1) {
|
|
@@ -6387,8 +6434,9 @@ var TileUpdate = class {
|
|
|
6387
6434
|
if (parent == this.view.contentDOM) break;
|
|
6388
6435
|
if (tile instanceof MarkTile) marks.push(tile);
|
|
6389
6436
|
else if (tile === null || tile === void 0 ? void 0 : tile.isLine()) line = tile;
|
|
6437
|
+
else if (tile instanceof BlockWrapperTile);
|
|
6390
6438
|
else if (parent.nodeName == "DIV" && !line && parent != this.view.contentDOM) line = new LineTile(parent, lineBaseAttrs);
|
|
6391
|
-
else marks.push(MarkTile.of(new MarkDecoration({
|
|
6439
|
+
else if (!line) marks.push(MarkTile.of(new MarkDecoration({
|
|
6392
6440
|
tagName: parent.nodeName.toLowerCase(),
|
|
6393
6441
|
attributes: getAttrs(parent)
|
|
6394
6442
|
}), parent));
|
|
@@ -6451,9 +6499,9 @@ var NullWidget = class extends WidgetType {
|
|
|
6451
6499
|
return true;
|
|
6452
6500
|
}
|
|
6453
6501
|
};
|
|
6454
|
-
NullWidget.inline =
|
|
6455
|
-
NullWidget.block =
|
|
6456
|
-
const BreakWidget =
|
|
6502
|
+
NullWidget.inline = /*@__PURE__*/ new NullWidget("span");
|
|
6503
|
+
NullWidget.block = /*@__PURE__*/ new NullWidget("div");
|
|
6504
|
+
const BreakWidget = /*@__PURE__*/ new class extends WidgetType {
|
|
6457
6505
|
toDOM() {
|
|
6458
6506
|
return document.createElement("br");
|
|
6459
6507
|
}
|
|
@@ -6488,10 +6536,12 @@ var DocView = class {
|
|
|
6488
6536
|
update(update) {
|
|
6489
6537
|
var _a;
|
|
6490
6538
|
let changedRanges = update.changedRanges;
|
|
6491
|
-
if (this.minWidth > 0 && changedRanges.length)
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
|
|
6539
|
+
if (this.minWidth > 0 && changedRanges.length) {
|
|
6540
|
+
if (!changedRanges.every(({ fromA, toA }) => toA < this.minWidthFrom || fromA > this.minWidthTo)) this.minWidth = this.minWidthFrom = this.minWidthTo = 0;
|
|
6541
|
+
else {
|
|
6542
|
+
this.minWidthFrom = update.changes.mapPos(this.minWidthFrom, 1);
|
|
6543
|
+
this.minWidthTo = update.changes.mapPos(this.minWidthTo, 1);
|
|
6544
|
+
}
|
|
6495
6545
|
}
|
|
6496
6546
|
this.updateEditContextFormatting(update);
|
|
6497
6547
|
let readCompositionAt = -1;
|
|
@@ -6531,6 +6581,7 @@ var DocView = class {
|
|
|
6531
6581
|
if (composition || changes.length) {
|
|
6532
6582
|
let oldTile = this.tile;
|
|
6533
6583
|
let builder = new TileUpdate(this.view, oldTile, this.blockWrappers, this.decorations, this.dynamicDecorationMap);
|
|
6584
|
+
if (composition && Tile.get(composition.text)) builder.cache.reused.set(Tile.get(composition.text), 2);
|
|
6534
6585
|
this.tile = builder.run(changes, composition);
|
|
6535
6586
|
destroyDropped(oldTile, builder.cache.reused);
|
|
6536
6587
|
}
|
|
@@ -6650,8 +6701,10 @@ var DocView = class {
|
|
|
6650
6701
|
for (;;) {
|
|
6651
6702
|
let parent = node.parentNode;
|
|
6652
6703
|
if (parent == tile.dom) break;
|
|
6653
|
-
if (bias == 0 && parent.firstChild != parent.lastChild)
|
|
6654
|
-
|
|
6704
|
+
if (bias == 0 && parent.firstChild != parent.lastChild) {
|
|
6705
|
+
if (node == parent.firstChild) bias = -1;
|
|
6706
|
+
else bias = 1;
|
|
6707
|
+
}
|
|
6655
6708
|
node = parent;
|
|
6656
6709
|
}
|
|
6657
6710
|
if (bias < 0) after = node;
|
|
@@ -6670,7 +6723,7 @@ var DocView = class {
|
|
|
6670
6723
|
}
|
|
6671
6724
|
domAtPos(pos, side) {
|
|
6672
6725
|
let { tile, offset } = this.tile.resolveBlock(pos, side);
|
|
6673
|
-
if (tile.isWidget()) return tile.domPosFor(
|
|
6726
|
+
if (tile.isWidget()) return tile.domPosFor(offset, side);
|
|
6674
6727
|
return tile.domIn(offset, side);
|
|
6675
6728
|
}
|
|
6676
6729
|
inlineDOMNearPos(pos, side) {
|
|
@@ -6700,13 +6753,13 @@ var DocView = class {
|
|
|
6700
6753
|
else if (afterBad && before) after = null;
|
|
6701
6754
|
return before && side < 0 || !after ? before.domIn(beforeOff, side) : after.domIn(afterOff, side);
|
|
6702
6755
|
}
|
|
6703
|
-
coordsAt(pos, side) {
|
|
6756
|
+
coordsAt(pos, side, rtl) {
|
|
6704
6757
|
let { tile, offset } = this.tile.resolveBlock(pos, side);
|
|
6705
6758
|
if (tile.isWidget()) {
|
|
6706
6759
|
if (tile.widget instanceof BlockGapWidget) return null;
|
|
6707
6760
|
return tile.coordsInWidget(offset, side, true);
|
|
6708
6761
|
}
|
|
6709
|
-
return tile.coordsIn(offset, side);
|
|
6762
|
+
return tile.coordsIn(offset, side, rtl);
|
|
6710
6763
|
}
|
|
6711
6764
|
lineAt(pos, side) {
|
|
6712
6765
|
let { tile } = this.tile.resolveBlock(pos, side);
|
|
@@ -6874,7 +6927,7 @@ var DocView = class {
|
|
|
6874
6927
|
logException(this.view.state, e, "scroll handler");
|
|
6875
6928
|
}
|
|
6876
6929
|
let { range } = target;
|
|
6877
|
-
let rect = this.coordsAt(range.head, range.
|
|
6930
|
+
let rect = this.coordsAt(range.head, range.assoc || (range.head > range.anchor ? -1 : 1)), other;
|
|
6878
6931
|
if (!rect) return;
|
|
6879
6932
|
if (!range.empty && (other = this.coordsAt(range.anchor, range.anchor > range.head ? -1 : 1))) rect = {
|
|
6880
6933
|
left: Math.min(rect.left, other.left),
|
|
@@ -6891,6 +6944,14 @@ var DocView = class {
|
|
|
6891
6944
|
};
|
|
6892
6945
|
let { offsetWidth, offsetHeight } = this.view.scrollDOM;
|
|
6893
6946
|
scrollRectIntoView(this.view.scrollDOM, targetRect, range.head < range.anchor ? -1 : 1, target.x, target.y, Math.max(Math.min(target.xMargin, offsetWidth), -offsetWidth), Math.max(Math.min(target.yMargin, offsetHeight), -offsetHeight), this.view.textDirection == Direction.LTR);
|
|
6947
|
+
if (window.visualViewport && window.innerHeight - window.visualViewport.height > 1 && (rect.top > window.visualViewport.offsetTop + window.visualViewport.height || rect.bottom < window.visualViewport.offsetTop)) {
|
|
6948
|
+
let line = this.view.docView.lineAt(range.head, 1);
|
|
6949
|
+
if (line) {
|
|
6950
|
+
let stack = getScrollStack(line.dom);
|
|
6951
|
+
line.dom.scrollIntoView({ block: "nearest" });
|
|
6952
|
+
restoreScrollStack(stack, false);
|
|
6953
|
+
}
|
|
6954
|
+
}
|
|
6894
6955
|
}
|
|
6895
6956
|
lineHasWidget(pos) {
|
|
6896
6957
|
let scan = (child) => child.isWidget() || child.children.some(scan);
|
|
@@ -7044,7 +7105,7 @@ function groupAt(state, pos, bias = 1) {
|
|
|
7044
7105
|
if (categorize(line.text.slice(to, next)) != cat) break;
|
|
7045
7106
|
to = next;
|
|
7046
7107
|
}
|
|
7047
|
-
return EditorSelection.
|
|
7108
|
+
return EditorSelection.undirectionalRange(from + line.from, to + line.from);
|
|
7048
7109
|
}
|
|
7049
7110
|
function posAtCoordsImprecise(view, contentRect, block, x, y) {
|
|
7050
7111
|
let into = Math.round((x - contentRect.left) * view.defaultCharacterWidth);
|
|
@@ -7117,7 +7178,8 @@ function moveVertically(view, start, forward, distance) {
|
|
|
7117
7178
|
if (startPos == (forward ? view.state.doc.length : 0)) return EditorSelection.cursor(startPos, start.assoc);
|
|
7118
7179
|
let goal = start.goalColumn, startY;
|
|
7119
7180
|
let rect = view.contentDOM.getBoundingClientRect();
|
|
7120
|
-
let startCoords = view.coordsAtPos(startPos, start.assoc ||
|
|
7181
|
+
let startCoords = view.coordsAtPos(startPos, start.assoc || ((start.empty ? forward : start.head == start.from) ? 1 : -1));
|
|
7182
|
+
let docTop = view.documentTop;
|
|
7121
7183
|
if (startCoords) {
|
|
7122
7184
|
if (goal == null) goal = startCoords.left - rect.left;
|
|
7123
7185
|
startY = dir < 0 ? startCoords.top : startCoords.bottom;
|
|
@@ -7127,12 +7189,17 @@ function moveVertically(view, start, forward, distance) {
|
|
|
7127
7189
|
startY = (dir < 0 ? line.top : line.bottom) + docTop;
|
|
7128
7190
|
}
|
|
7129
7191
|
let resolvedGoal = rect.left + goal;
|
|
7130
|
-
let dist = distance !== null && distance !== void 0 ? distance :
|
|
7131
|
-
let
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
7192
|
+
let halfText = view.viewState.heightOracle.textHeight >> 1, dist = distance !== null && distance !== void 0 ? distance : halfText;
|
|
7193
|
+
for (let scan = 0;; scan += halfText) {
|
|
7194
|
+
let y = startY + (dist + scan) * dir;
|
|
7195
|
+
let pos = posAtCoords(view, {
|
|
7196
|
+
x: resolvedGoal,
|
|
7197
|
+
y
|
|
7198
|
+
}, false, dir);
|
|
7199
|
+
if (forward ? y > rect.bottom : y < rect.top) return EditorSelection.cursor(pos.pos, pos.assoc);
|
|
7200
|
+
let posCoords = view.coordsAtPos(pos.pos, pos.assoc), mid = posCoords ? (posCoords.top + posCoords.bottom) / 2 : 0;
|
|
7201
|
+
if (!posCoords || (forward ? mid > startY : mid < startY)) return EditorSelection.cursor(pos.pos, pos.assoc, void 0, goal);
|
|
7202
|
+
}
|
|
7136
7203
|
}
|
|
7137
7204
|
function skipAtomicRanges(atoms, pos, bias) {
|
|
7138
7205
|
for (;;) {
|
|
@@ -7157,7 +7224,10 @@ function skipAtomsForSelection(atoms, sel) {
|
|
|
7157
7224
|
} else {
|
|
7158
7225
|
let from = skipAtomicRanges(atoms, range.from, -1);
|
|
7159
7226
|
let to = skipAtomicRanges(atoms, range.to, 1);
|
|
7160
|
-
if (from != range.from || to != range.to)
|
|
7227
|
+
if (from != range.from || to != range.to) {
|
|
7228
|
+
if (range.undirectional) updated = EditorSelection.undirectionalRange(range.from, range.to);
|
|
7229
|
+
else updated = EditorSelection.range(range.from == range.anchor ? from : to, range.from == range.head ? from : to);
|
|
7230
|
+
}
|
|
7161
7231
|
}
|
|
7162
7232
|
if (updated) {
|
|
7163
7233
|
if (!ranges) ranges = sel.ranges.slice();
|
|
@@ -7185,7 +7255,8 @@ function posAtCoords(view, coords, precise, scanY) {
|
|
|
7185
7255
|
block = view.elementAtHeight(yOffset);
|
|
7186
7256
|
if (scanY == null) break;
|
|
7187
7257
|
if (block.type == BlockType.Text) {
|
|
7188
|
-
|
|
7258
|
+
if (scanY < 0 ? block.to < view.viewport.from : block.from > view.viewport.to) break;
|
|
7259
|
+
let rect = view.docView.coordsAt(scanY < 0 ? block.from : block.to, scanY > 0 ? -1 : 1);
|
|
7189
7260
|
if (rect && (scanY < 0 ? rect.top <= yOffset + docTop : rect.bottom >= yOffset + docTop)) break;
|
|
7190
7261
|
}
|
|
7191
7262
|
let halfLine = view.viewState.heightOracle.textHeight / 2;
|
|
@@ -7201,57 +7272,135 @@ function posAtCoords(view, coords, precise, scanY) {
|
|
|
7201
7272
|
if (block.type != BlockType.Text) return yOffset < (block.top + block.bottom) / 2 ? new PosAssoc(block.from, 1) : new PosAssoc(block.to, -1);
|
|
7202
7273
|
let line = view.docView.lineAt(block.from, 2);
|
|
7203
7274
|
if (!line || line.length != block.length) line = view.docView.lineAt(block.from, -2);
|
|
7204
|
-
return
|
|
7205
|
-
}
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7275
|
+
return new InlineCoordsScan(view, x, y, view.textDirectionAt(block.from)).scanTile(line, block.from);
|
|
7276
|
+
}
|
|
7277
|
+
var InlineCoordsScan = class {
|
|
7278
|
+
constructor(view, x, y, baseDir) {
|
|
7279
|
+
this.view = view;
|
|
7280
|
+
this.x = x;
|
|
7281
|
+
this.y = y;
|
|
7282
|
+
this.baseDir = baseDir;
|
|
7283
|
+
this.line = null;
|
|
7284
|
+
this.spans = null;
|
|
7285
|
+
}
|
|
7286
|
+
bidiSpansAt(pos) {
|
|
7287
|
+
if (!this.line || this.line.from > pos || this.line.to < pos) {
|
|
7288
|
+
this.line = this.view.state.doc.lineAt(pos);
|
|
7289
|
+
this.spans = this.view.bidiSpans(this.line);
|
|
7290
|
+
}
|
|
7291
|
+
return this;
|
|
7292
|
+
}
|
|
7293
|
+
baseDirAt(pos, side) {
|
|
7294
|
+
let { line, spans } = this.bidiSpansAt(pos);
|
|
7295
|
+
return spans[BidiSpan.find(spans, pos - line.from, -1, side)].level == this.baseDir;
|
|
7296
|
+
}
|
|
7297
|
+
dirAt(pos, side) {
|
|
7298
|
+
let { line, spans } = this.bidiSpansAt(pos);
|
|
7299
|
+
return spans[BidiSpan.find(spans, pos - line.from, -1, side)].dir;
|
|
7300
|
+
}
|
|
7301
|
+
bidiIn(from, to) {
|
|
7302
|
+
let { spans, line } = this.bidiSpansAt(from);
|
|
7303
|
+
return spans.length > 1 || spans.length && (spans[0].level != this.baseDir || spans[0].to + line.from < to);
|
|
7304
|
+
}
|
|
7305
|
+
scan(positions, getRects, recursed = false) {
|
|
7306
|
+
let lo = 0, hi = positions.length - 1, seen = /* @__PURE__ */ new Set();
|
|
7307
|
+
let bidi = this.bidiIn(positions[0], positions[hi]);
|
|
7308
|
+
let above, below;
|
|
7309
|
+
let closestI = -1, closestDx = 1e9, closestRect;
|
|
7310
|
+
search: while (lo < hi) {
|
|
7311
|
+
let dist = hi - lo, mid = lo + hi >> 1;
|
|
7312
|
+
adjust: if (seen.has(mid)) {
|
|
7313
|
+
for (let i = 1; i < dist; i++) {
|
|
7314
|
+
let scan = mid + i;
|
|
7315
|
+
if (scan >= hi) scan -= dist;
|
|
7316
|
+
if (!seen.has(scan)) {
|
|
7317
|
+
mid = scan;
|
|
7318
|
+
break adjust;
|
|
7319
|
+
}
|
|
7320
|
+
}
|
|
7321
|
+
break search;
|
|
7322
|
+
}
|
|
7323
|
+
seen.add(mid);
|
|
7324
|
+
let rects = getRects(mid), side = 0;
|
|
7325
|
+
if (rects) for (let i = 0; i < rects.length; i++) {
|
|
7326
|
+
let rect = rects[i];
|
|
7327
|
+
if (rect.width == 0 && rects.length > 1) continue;
|
|
7328
|
+
if (rect.bottom < this.y) {
|
|
7329
|
+
if (!above || above.bottom < rect.bottom) above = rect;
|
|
7330
|
+
side = 1;
|
|
7331
|
+
} else if (rect.top > this.y) {
|
|
7332
|
+
if (!below || below.top > rect.top) below = rect;
|
|
7333
|
+
side = -1;
|
|
7334
|
+
} else {
|
|
7335
|
+
let off = rect.left > this.x ? this.x - rect.left : rect.right < this.x ? this.x - rect.right : 0;
|
|
7336
|
+
let dx = Math.abs(off);
|
|
7337
|
+
if (dx < closestDx) {
|
|
7338
|
+
closestI = mid;
|
|
7339
|
+
closestDx = dx;
|
|
7340
|
+
closestRect = rect;
|
|
7341
|
+
}
|
|
7342
|
+
if (off) side = off < 0 == (this.baseDir == Direction.LTR) ? -1 : 1;
|
|
7343
|
+
}
|
|
7227
7344
|
}
|
|
7345
|
+
if (side == -1 && (!bidi || this.baseDirAt(positions[mid], 1))) hi = mid;
|
|
7346
|
+
else if (side == 1 && (!bidi || this.baseDirAt(positions[mid + 1], -1))) lo = mid + 1;
|
|
7228
7347
|
}
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
|
|
7348
|
+
if (!closestRect) {
|
|
7349
|
+
if (!below && !above) return {
|
|
7350
|
+
i: positions[0],
|
|
7351
|
+
after: false
|
|
7352
|
+
};
|
|
7353
|
+
let side = above && (!below || this.y - above.bottom < below.top - this.y) ? above : below;
|
|
7354
|
+
this.y = (side.top + side.bottom) / 2;
|
|
7355
|
+
return this.scan(positions, getRects, true);
|
|
7356
|
+
}
|
|
7357
|
+
if (closestDx && !recursed) {
|
|
7358
|
+
let { top, bottom } = closestRect;
|
|
7359
|
+
if (above && above.bottom > (top + top + bottom) / 3) {
|
|
7360
|
+
this.y = above.bottom - 1;
|
|
7361
|
+
return this.scan(positions, getRects, true);
|
|
7362
|
+
}
|
|
7363
|
+
if (below && below.top < (top + bottom + bottom) / 3) {
|
|
7364
|
+
this.y = below.top + 1;
|
|
7365
|
+
return this.scan(positions, getRects, true);
|
|
7366
|
+
}
|
|
7367
|
+
}
|
|
7368
|
+
let ltr = (bidi ? this.dirAt(positions[closestI], 1) : this.baseDir) == Direction.LTR;
|
|
7369
|
+
return {
|
|
7370
|
+
i: closestI,
|
|
7371
|
+
after: this.x > (closestRect.left + closestRect.right) / 2 == ltr
|
|
7372
|
+
};
|
|
7373
|
+
}
|
|
7374
|
+
scanText(tile, offset) {
|
|
7375
|
+
let positions = [];
|
|
7376
|
+
for (let i = 0; i < tile.length; i = findClusterBreak(tile.text, i)) positions.push(offset + i);
|
|
7377
|
+
positions.push(offset + tile.length);
|
|
7378
|
+
let scan = this.scan(positions, (i) => {
|
|
7379
|
+
let off = positions[i] - offset, end = positions[i + 1] - offset;
|
|
7380
|
+
return textRange(tile.dom, off, end).getClientRects();
|
|
7381
|
+
});
|
|
7382
|
+
return scan.after ? new PosAssoc(positions[scan.i + 1], -1) : new PosAssoc(positions[scan.i], 1);
|
|
7383
|
+
}
|
|
7384
|
+
scanTile(tile, offset) {
|
|
7239
7385
|
if (!tile.length) return new PosAssoc(offset, 1);
|
|
7240
|
-
|
|
7386
|
+
if (tile.children.length == 1) {
|
|
7387
|
+
let child = tile.children[0];
|
|
7388
|
+
if (child.isText()) return this.scanText(child, offset);
|
|
7389
|
+
else if (child.isComposite()) return this.scanTile(child, offset);
|
|
7390
|
+
}
|
|
7391
|
+
let positions = [offset];
|
|
7392
|
+
for (let i = 0, pos = offset; i < tile.children.length; i++) positions.push(pos += tile.children[i].length);
|
|
7393
|
+
let scan = this.scan(positions, (i) => {
|
|
7241
7394
|
let child = tile.children[i];
|
|
7242
|
-
if (child.flags & 48)
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
if (
|
|
7248
|
-
return
|
|
7395
|
+
if (child.flags & 48) return null;
|
|
7396
|
+
return (child.dom.nodeType == 1 ? child.dom : textRange(child.dom, 0, child.length)).getClientRects();
|
|
7397
|
+
});
|
|
7398
|
+
let child = tile.children[scan.i], pos = positions[scan.i];
|
|
7399
|
+
if (child.isText()) return this.scanText(child, pos);
|
|
7400
|
+
if (child.isComposite()) return this.scanTile(child, pos);
|
|
7401
|
+
return scan.after ? new PosAssoc(positions[scan.i + 1], -1) : new PosAssoc(pos, 1);
|
|
7249
7402
|
}
|
|
7250
|
-
}
|
|
7251
|
-
function dirAt(view, pos) {
|
|
7252
|
-
let line = view.state.doc.lineAt(pos);
|
|
7253
|
-
return view.bidiSpans(line)[BidiSpan.find(view.bidiSpans(line), pos - line.from, -1, 1)].dir;
|
|
7254
|
-
}
|
|
7403
|
+
};
|
|
7255
7404
|
const LineBreakPlaceholder = "";
|
|
7256
7405
|
var DOMReader = class {
|
|
7257
7406
|
constructor(points, view) {
|
|
@@ -7360,7 +7509,7 @@ var DOMChange = class {
|
|
|
7360
7509
|
this.bounds = null;
|
|
7361
7510
|
this.text = "";
|
|
7362
7511
|
this.domChanged = start > -1;
|
|
7363
|
-
let { impreciseHead: iHead, impreciseAnchor: iAnchor } = view.docView;
|
|
7512
|
+
let { impreciseHead: iHead, impreciseAnchor: iAnchor } = view.docView, curSel = view.state.selection;
|
|
7364
7513
|
if (view.state.readOnly && start > -1) this.newSel = null;
|
|
7365
7514
|
else if (start > -1 && (this.bounds = domBoundsAround(view.docView.tile, start, end, 0))) {
|
|
7366
7515
|
let selPoints = iHead || iAnchor ? [] : selectionPoints(view);
|
|
@@ -7370,10 +7519,10 @@ var DOMChange = class {
|
|
|
7370
7519
|
this.newSel = selectionFromPoints(selPoints, this.bounds.from);
|
|
7371
7520
|
} else {
|
|
7372
7521
|
let domSel = view.observer.selectionRange;
|
|
7373
|
-
let head = iHead && iHead.node == domSel.focusNode && iHead.offset == domSel.focusOffset || !contains(view.contentDOM, domSel.focusNode) ?
|
|
7374
|
-
let anchor = iAnchor && iAnchor.node == domSel.anchorNode && iAnchor.offset == domSel.anchorOffset || !contains(view.contentDOM, domSel.anchorNode) ?
|
|
7522
|
+
let head = iHead && iHead.node == domSel.focusNode && iHead.offset == domSel.focusOffset || !contains(view.contentDOM, domSel.focusNode) ? curSel.main.head : view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset);
|
|
7523
|
+
let anchor = iAnchor && iAnchor.node == domSel.anchorNode && iAnchor.offset == domSel.anchorOffset || !contains(view.contentDOM, domSel.anchorNode) ? curSel.main.anchor : view.docView.posFromDOM(domSel.anchorNode, domSel.anchorOffset);
|
|
7375
7524
|
let vp = view.viewport;
|
|
7376
|
-
if ((browser.ios || browser.chrome) &&
|
|
7525
|
+
if ((browser.ios || browser.chrome) && head != anchor && Math.min(head, anchor) <= curSel.main.from && Math.max(head, anchor) >= curSel.main.to && (vp.from > 0 || vp.to < view.state.doc.length)) {
|
|
7377
7526
|
let from = Math.min(head, anchor), to = Math.max(head, anchor);
|
|
7378
7527
|
let offFrom = vp.from - from, offTo = vp.to - to;
|
|
7379
7528
|
if ((offFrom == 0 || offFrom == 1 || from == 0) && (offTo == 0 || offTo == -1 || to == view.state.doc.length)) {
|
|
@@ -7381,8 +7530,12 @@ var DOMChange = class {
|
|
|
7381
7530
|
anchor = view.state.doc.length;
|
|
7382
7531
|
}
|
|
7383
7532
|
}
|
|
7384
|
-
if (view.inputState.composing > -1 &&
|
|
7385
|
-
else
|
|
7533
|
+
if (view.inputState.composing > -1 && curSel.ranges.length > 1) this.newSel = curSel.replaceRange(EditorSelection.range(anchor, head));
|
|
7534
|
+
else if (view.lineWrapping && anchor == head && !(curSel.main.empty && curSel.main.head == head) && view.inputState.lastTouchTime > Date.now() - 100) {
|
|
7535
|
+
let before = view.coordsAtPos(head, -1), assoc = 0;
|
|
7536
|
+
if (before) assoc = view.inputState.lastTouchY <= before.bottom ? -1 : 1;
|
|
7537
|
+
this.newSel = EditorSelection.create([EditorSelection.cursor(head, assoc)]);
|
|
7538
|
+
} else this.newSel = EditorSelection.single(anchor, head);
|
|
7386
7539
|
}
|
|
7387
7540
|
}
|
|
7388
7541
|
};
|
|
@@ -7420,7 +7573,7 @@ function domBoundsAround(tile, from, to, offset) {
|
|
|
7420
7573
|
}
|
|
7421
7574
|
function applyDOMChange(view, domChange) {
|
|
7422
7575
|
let change;
|
|
7423
|
-
let { newSel } = domChange, sel =
|
|
7576
|
+
let { newSel } = domChange, { state } = view, sel = state.selection.main;
|
|
7424
7577
|
let lastKey = view.inputState.lastKeyTime > Date.now() - 100 ? view.inputState.lastKeyCode : -1;
|
|
7425
7578
|
if (domChange.bounds) {
|
|
7426
7579
|
let { from, to } = domChange.bounds;
|
|
@@ -7429,38 +7582,33 @@ function applyDOMChange(view, domChange) {
|
|
|
7429
7582
|
preferredPos = sel.to;
|
|
7430
7583
|
preferredSide = "end";
|
|
7431
7584
|
}
|
|
7432
|
-
let
|
|
7433
|
-
if (
|
|
7434
|
-
|
|
7585
|
+
let cmp = state.doc.sliceString(from, to, LineBreakPlaceholder), selEnd, diff;
|
|
7586
|
+
if (!sel.empty && sel.from >= from && sel.to <= to && (domChange.typeOver || cmp != domChange.text) && cmp.slice(0, sel.from - from) == domChange.text.slice(0, sel.from - from) && cmp.slice(sel.to - from) == domChange.text.slice(selEnd = domChange.text.length - (cmp.length - (sel.to - from)))) change = {
|
|
7587
|
+
from: sel.from,
|
|
7588
|
+
to: sel.to,
|
|
7589
|
+
insert: Text.of(domChange.text.slice(sel.from - from, selEnd).split(LineBreakPlaceholder))
|
|
7590
|
+
};
|
|
7591
|
+
else if (diff = findDiff(cmp, domChange.text, preferredPos - from, preferredSide)) {
|
|
7592
|
+
if (browser.chrome && lastKey == 13 && diff.toB == diff.from + 2 && domChange.text.slice(diff.from, diff.toB) == "") diff.toB--;
|
|
7435
7593
|
change = {
|
|
7436
7594
|
from: from + diff.from,
|
|
7437
7595
|
to: from + diff.toA,
|
|
7438
7596
|
insert: Text.of(domChange.text.slice(diff.from, diff.toB).split(LineBreakPlaceholder))
|
|
7439
7597
|
};
|
|
7440
7598
|
}
|
|
7441
|
-
} else if (newSel && (!view.hasFocus &&
|
|
7599
|
+
} else if (newSel && (!view.hasFocus && state.facet(editable) || sameSelPos(newSel, sel))) newSel = null;
|
|
7442
7600
|
if (!change && !newSel) return false;
|
|
7443
|
-
if (
|
|
7444
|
-
from: sel.from,
|
|
7445
|
-
to: sel.to,
|
|
7446
|
-
insert: view.state.doc.slice(sel.from, sel.to)
|
|
7447
|
-
};
|
|
7448
|
-
else if ((browser.mac || browser.android) && change && change.from == change.to && change.from == sel.head - 1 && /^\. ?$/.test(change.insert.toString()) && view.contentDOM.getAttribute("autocorrect") == "off") {
|
|
7601
|
+
if ((browser.mac || browser.android) && change && change.from == change.to && change.from == sel.head - 1 && /^\. ?$/.test(change.insert.toString()) && view.contentDOM.getAttribute("autocorrect") == "off") {
|
|
7449
7602
|
if (newSel && change.insert.length == 2) newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
|
|
7450
7603
|
change = {
|
|
7451
7604
|
from: change.from,
|
|
7452
7605
|
to: change.to,
|
|
7453
7606
|
insert: Text.of([change.insert.toString().replace(".", " ")])
|
|
7454
7607
|
};
|
|
7455
|
-
} else if (
|
|
7608
|
+
} else if (state.doc.lineAt(sel.from).to < sel.to && view.docView.lineHasWidget(sel.to) && view.inputState.insertingTextAt > Date.now() - 50) change = {
|
|
7456
7609
|
from: sel.from,
|
|
7457
7610
|
to: sel.to,
|
|
7458
|
-
insert:
|
|
7459
|
-
};
|
|
7460
|
-
else if (view.state.doc.lineAt(sel.from).to < sel.to && view.docView.lineHasWidget(sel.to) && view.inputState.insertingTextAt > Date.now() - 50) change = {
|
|
7461
|
-
from: sel.from,
|
|
7462
|
-
to: sel.to,
|
|
7463
|
-
insert: view.state.toText(view.inputState.insertingText)
|
|
7611
|
+
insert: state.toText(view.inputState.insertingText)
|
|
7464
7612
|
};
|
|
7465
7613
|
else if (browser.chrome && change && change.from == change.to && change.from == sel.head && change.insert.toString() == "\n " && view.lineWrapping) {
|
|
7466
7614
|
if (newSel) newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
|
|
@@ -7476,7 +7624,7 @@ function applyDOMChange(view, domChange) {
|
|
|
7476
7624
|
if (view.inputState.lastSelectionTime > Date.now() - 50) {
|
|
7477
7625
|
if (view.inputState.lastSelectionOrigin == "select") scrollIntoView = true;
|
|
7478
7626
|
userEvent = view.inputState.lastSelectionOrigin;
|
|
7479
|
-
if (userEvent == "select.pointer") newSel = skipAtomsForSelection(
|
|
7627
|
+
if (userEvent == "select.pointer") newSel = skipAtomsForSelection(state.facet(atomicRanges).map((f) => f(view)), newSel);
|
|
7480
7628
|
}
|
|
7481
7629
|
view.dispatch({
|
|
7482
7630
|
selection: newSel,
|
|
@@ -7620,18 +7768,16 @@ var InputState = class {
|
|
|
7620
7768
|
this.view = view;
|
|
7621
7769
|
this.lastKeyCode = 0;
|
|
7622
7770
|
this.lastKeyTime = 0;
|
|
7771
|
+
this.touchActive = false;
|
|
7623
7772
|
this.lastTouchTime = 0;
|
|
7773
|
+
this.lastTouchX = 0;
|
|
7774
|
+
this.lastTouchY = 0;
|
|
7624
7775
|
this.lastFocusTime = 0;
|
|
7625
7776
|
this.lastScrollTop = 0;
|
|
7626
7777
|
this.lastScrollLeft = 0;
|
|
7778
|
+
this.lastWheelEvent = 0;
|
|
7627
7779
|
this.pendingIOSKey = void 0;
|
|
7628
|
-
|
|
7629
|
-
When enabled (>-1), tab presses are not given to key handlers,
|
|
7630
|
-
leaving the browser's default behavior. If >0, the mode expires
|
|
7631
|
-
at that timestamp, and any other keypress clears it.
|
|
7632
|
-
Esc enables temporary tab focus mode for two seconds when not
|
|
7633
|
-
otherwise handled.
|
|
7634
|
-
*/
|
|
7780
|
+
this.lastIOSMomentumScroll = 0;
|
|
7635
7781
|
this.tabFocusMode = -1;
|
|
7636
7782
|
this.lastSelectionOrigin = null;
|
|
7637
7783
|
this.lastSelectionTime = 0;
|
|
@@ -7694,9 +7840,19 @@ var InputState = class {
|
|
|
7694
7840
|
this.view.observer.delayAndroidKey(event.key, event.keyCode);
|
|
7695
7841
|
return true;
|
|
7696
7842
|
}
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7843
|
+
if (browser.ios && !event.synthetic && !event.altKey && !event.metaKey && (PendingKeys.some((key) => key.keyCode == event.keyCode) && !event.ctrlKey || EmacsyPendingKeys.indexOf(event.key) > -1 && event.ctrlKey)) {
|
|
7844
|
+
let mods = {
|
|
7845
|
+
ctrlKey: event.ctrlKey,
|
|
7846
|
+
altKey: event.altKey,
|
|
7847
|
+
metaKey: event.metaKey,
|
|
7848
|
+
shiftKey: event.shiftKey
|
|
7849
|
+
};
|
|
7850
|
+
if (mods.shiftKey && browser.ios && !/^(off|none)$/.test(this.view.contentDOM.autocapitalize) && iosVirtualKeyboardOpen(this.view.win)) mods.shiftKey = false;
|
|
7851
|
+
this.pendingIOSKey = {
|
|
7852
|
+
key: event.key,
|
|
7853
|
+
keyCode: event.keyCode,
|
|
7854
|
+
mods
|
|
7855
|
+
};
|
|
7700
7856
|
setTimeout(() => this.flushIOSKey(), 250);
|
|
7701
7857
|
return true;
|
|
7702
7858
|
}
|
|
@@ -7708,7 +7864,7 @@ var InputState = class {
|
|
|
7708
7864
|
if (!key) return false;
|
|
7709
7865
|
if (key.key == "Enter" && change && change.from < change.to && /^\S+$/.test(change.insert.toString())) return false;
|
|
7710
7866
|
this.pendingIOSKey = void 0;
|
|
7711
|
-
return dispatchKey(this.view.contentDOM, key.key, key.keyCode, key
|
|
7867
|
+
return dispatchKey(this.view.contentDOM, key.key, key.keyCode, key.mods);
|
|
7712
7868
|
}
|
|
7713
7869
|
ignoreDuringComposition(event) {
|
|
7714
7870
|
if (!/^key/.test(event.type) || event.synthetic) return false;
|
|
@@ -7733,6 +7889,10 @@ var InputState = class {
|
|
|
7733
7889
|
if (this.mouseSelection) this.mouseSelection.destroy();
|
|
7734
7890
|
}
|
|
7735
7891
|
};
|
|
7892
|
+
function iosVirtualKeyboardOpen(win) {
|
|
7893
|
+
if (!win.visualViewport) return false;
|
|
7894
|
+
return win.visualViewport.height * win.visualViewport.scale / win.document.documentElement.clientHeight < .85;
|
|
7895
|
+
}
|
|
7736
7896
|
function bindHandler(plugin, handler) {
|
|
7737
7897
|
return (view, event) => {
|
|
7738
7898
|
try {
|
|
@@ -7920,8 +8080,8 @@ function eventBelongsToEditor(view, event) {
|
|
|
7920
8080
|
for (let node = event.target, tile; node != view.contentDOM; node = node.parentNode) if (!node || node.nodeType == 11 || (tile = Tile.get(node)) && tile.isWidget() && !tile.isHidden && tile.widget.ignoreEvent(event)) return false;
|
|
7921
8081
|
return true;
|
|
7922
8082
|
}
|
|
7923
|
-
const handlers =
|
|
7924
|
-
const observers =
|
|
8083
|
+
const handlers = /*@__PURE__*/ Object.create(null);
|
|
8084
|
+
const observers = /*@__PURE__*/ Object.create(null);
|
|
7925
8085
|
const brokenClipboardAPI = browser.ie && browser.ie_version < 15 || browser.ios && browser.webkit_version < 604;
|
|
7926
8086
|
function capturePaste(view) {
|
|
7927
8087
|
let parent = view.dom.parentNode;
|
|
@@ -7976,8 +8136,13 @@ function doPaste(view, input) {
|
|
|
7976
8136
|
});
|
|
7977
8137
|
}
|
|
7978
8138
|
observers.scroll = (view) => {
|
|
7979
|
-
|
|
7980
|
-
|
|
8139
|
+
let iState = view.inputState;
|
|
8140
|
+
iState.lastScrollTop = view.scrollDOM.scrollTop;
|
|
8141
|
+
iState.lastScrollLeft = view.scrollDOM.scrollLeft;
|
|
8142
|
+
if (browser.ios && !iState.touchActive) iState.lastIOSMomentumScroll = Date.now();
|
|
8143
|
+
};
|
|
8144
|
+
observers.wheel = observers.mousewheel = (view) => {
|
|
8145
|
+
view.inputState.lastWheelEvent = Date.now();
|
|
7981
8146
|
};
|
|
7982
8147
|
handlers.keydown = (view, event) => {
|
|
7983
8148
|
view.inputState.setSelectionOrigin("select");
|
|
@@ -7985,12 +8150,21 @@ handlers.keydown = (view, event) => {
|
|
|
7985
8150
|
return false;
|
|
7986
8151
|
};
|
|
7987
8152
|
observers.touchstart = (view, e) => {
|
|
7988
|
-
view.inputState
|
|
7989
|
-
|
|
8153
|
+
let iState = view.inputState, touch = e.targetTouches[0];
|
|
8154
|
+
iState.touchActive = true;
|
|
8155
|
+
iState.lastTouchTime = Date.now();
|
|
8156
|
+
if (touch) {
|
|
8157
|
+
iState.lastTouchX = touch.clientX;
|
|
8158
|
+
iState.lastTouchY = touch.clientY;
|
|
8159
|
+
}
|
|
8160
|
+
iState.setSelectionOrigin("select.pointer");
|
|
7990
8161
|
};
|
|
7991
8162
|
observers.touchmove = (view) => {
|
|
7992
8163
|
view.inputState.setSelectionOrigin("select.pointer");
|
|
7993
8164
|
};
|
|
8165
|
+
observers.touchend = (view, e) => {
|
|
8166
|
+
view.inputState.touchActive = false;
|
|
8167
|
+
};
|
|
7994
8168
|
handlers.mousedown = (view, event) => {
|
|
7995
8169
|
view.observer.flush();
|
|
7996
8170
|
if (view.inputState.lastTouchTime > Date.now() - 2e3) return false;
|
|
@@ -8023,11 +8197,13 @@ function rangeForClick(view, pos, bias, type) {
|
|
|
8023
8197
|
let visual = view.docView.lineAt(pos, bias), line = view.state.doc.lineAt(visual ? visual.posAtEnd : pos);
|
|
8024
8198
|
let from = visual ? visual.posAtStart : line.from, to = visual ? visual.posAtEnd : line.to;
|
|
8025
8199
|
if (to < view.state.doc.length && to == line.to) to++;
|
|
8026
|
-
return EditorSelection.
|
|
8200
|
+
return EditorSelection.undirectionalRange(from, to);
|
|
8027
8201
|
}
|
|
8028
8202
|
}
|
|
8029
8203
|
const BadMouseDetail = browser.ie && browser.ie_version <= 11;
|
|
8030
|
-
let lastMouseDown = null
|
|
8204
|
+
let lastMouseDown = null;
|
|
8205
|
+
let lastMouseDownCount = 0;
|
|
8206
|
+
let lastMouseDownTime = 0;
|
|
8031
8207
|
function getClickType(event) {
|
|
8032
8208
|
if (!BadMouseDetail) return event.detail;
|
|
8033
8209
|
let last = lastMouseDown, lastTime = lastMouseDownTime;
|
|
@@ -8057,9 +8233,9 @@ function basicMouseSelection(view, event) {
|
|
|
8057
8233
|
if (start.pos != cur.pos && !extend) {
|
|
8058
8234
|
let startRange = rangeForClick(view, start.pos, start.assoc, type);
|
|
8059
8235
|
let from = Math.min(startRange.from, range.from), to = Math.max(startRange.to, range.to);
|
|
8060
|
-
range = from < range.from ? EditorSelection.range(from, to) : EditorSelection.range(to, from);
|
|
8236
|
+
range = from < range.from ? EditorSelection.range(from, to, range.assoc) : EditorSelection.range(to, from, range.assoc);
|
|
8061
8237
|
}
|
|
8062
|
-
if (extend) return startSel.replaceRange(startSel.main.extend(range.from, range.to));
|
|
8238
|
+
if (extend) return startSel.replaceRange(startSel.main.extend(range.from, range.to, range.assoc));
|
|
8063
8239
|
else if (multiple && type == 1 && startSel.ranges.length > 1 && (removed = removeRangeAround(startSel, cur.pos))) return removed;
|
|
8064
8240
|
else if (multiple) return startSel.addRange(range);
|
|
8065
8241
|
else return EditorSelection.create([range]);
|
|
@@ -8079,7 +8255,7 @@ handlers.dragstart = (view, event) => {
|
|
|
8079
8255
|
let tile = view.docView.tile.nearest(event.target);
|
|
8080
8256
|
if (tile && tile.isWidget()) {
|
|
8081
8257
|
let from = tile.posAtStart, to = from + tile.length;
|
|
8082
|
-
if (from >= range.to || to <= range.from) range = EditorSelection.
|
|
8258
|
+
if (from >= range.to || to <= range.from) range = EditorSelection.undirectionalRange(from, to);
|
|
8083
8259
|
}
|
|
8084
8260
|
}
|
|
8085
8261
|
let { inputState } = view;
|
|
@@ -8206,8 +8382,7 @@ function copiedRange(state) {
|
|
|
8206
8382
|
}
|
|
8207
8383
|
let lastLinewiseCopy = null;
|
|
8208
8384
|
handlers.copy = handlers.cut = (view, event) => {
|
|
8209
|
-
|
|
8210
|
-
if (domSel && !hasSelection(view.contentDOM, domSel)) return false;
|
|
8385
|
+
if (!hasSelection(view.contentDOM, view.observer.selectionRange)) return false;
|
|
8211
8386
|
let { text, ranges, linewise } = copiedRange(view.state);
|
|
8212
8387
|
if (!text && !linewise) return false;
|
|
8213
8388
|
lastLinewiseCopy = linewise ? text : null;
|
|
@@ -8226,7 +8401,7 @@ handlers.copy = handlers.cut = (view, event) => {
|
|
|
8226
8401
|
return false;
|
|
8227
8402
|
}
|
|
8228
8403
|
};
|
|
8229
|
-
const isFocusChange =
|
|
8404
|
+
const isFocusChange = /*@__PURE__*/ Annotation.define();
|
|
8230
8405
|
function focusChangeTransaction(state, focus) {
|
|
8231
8406
|
let effects = [];
|
|
8232
8407
|
for (let getEffect of state.facet(focusChangeEffect)) {
|
|
@@ -8317,7 +8492,7 @@ handlers.beforeinput = (view, event) => {
|
|
|
8317
8492
|
if (browser.safari && event.inputType == "insertText" && view.inputState.composing >= 0) setTimeout(() => observers.compositionend(view, event), 20);
|
|
8318
8493
|
return false;
|
|
8319
8494
|
};
|
|
8320
|
-
const appliedFirefoxHack =
|
|
8495
|
+
const appliedFirefoxHack = /*@__PURE__*/ new Set();
|
|
8321
8496
|
function firefoxCopyCutHack(doc) {
|
|
8322
8497
|
if (!appliedFirefoxHack.has(doc)) {
|
|
8323
8498
|
appliedFirefoxHack.add(doc);
|
|
@@ -8375,7 +8550,7 @@ var HeightOracle = class {
|
|
|
8375
8550
|
}
|
|
8376
8551
|
refresh(whiteSpace, lineHeight, charWidth, textHeight, lineLength, knownHeights) {
|
|
8377
8552
|
let lineWrapping = wrappingWhiteSpace.indexOf(whiteSpace) > -1;
|
|
8378
|
-
let changed = Math.abs(lineHeight - this.lineHeight) > .3 || this.lineWrapping != lineWrapping
|
|
8553
|
+
let changed = Math.abs(lineHeight - this.lineHeight) > .3 || this.lineWrapping != lineWrapping;
|
|
8379
8554
|
this.lineWrapping = lineWrapping;
|
|
8380
8555
|
this.lineHeight = lineHeight;
|
|
8381
8556
|
this.charWidth = charWidth;
|
|
@@ -8458,7 +8633,7 @@ var BlockInfo = class BlockInfo {
|
|
|
8458
8633
|
return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, content);
|
|
8459
8634
|
}
|
|
8460
8635
|
};
|
|
8461
|
-
var QueryType =
|
|
8636
|
+
var QueryType = /*@__PURE__*/ (function(QueryType) {
|
|
8462
8637
|
QueryType[QueryType["ByPos"] = 0] = "ByPos";
|
|
8463
8638
|
QueryType[QueryType["ByHeight"] = 1] = "ByHeight";
|
|
8464
8639
|
QueryType[QueryType["ByPosNoHeight"] = 2] = "ByPosNoHeight";
|
|
@@ -8519,20 +8694,21 @@ var HeightMap = class HeightMap {
|
|
|
8519
8694
|
static of(nodes) {
|
|
8520
8695
|
if (nodes.length == 1) return nodes[0];
|
|
8521
8696
|
let i = 0, j = nodes.length, before = 0, after = 0;
|
|
8522
|
-
for (;;) if (i == j)
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
|
|
8529
|
-
|
|
8530
|
-
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
|
|
8534
|
-
|
|
8535
|
-
|
|
8697
|
+
for (;;) if (i == j) {
|
|
8698
|
+
if (before > after * 2) {
|
|
8699
|
+
let split = nodes[i - 1];
|
|
8700
|
+
if (split.break) nodes.splice(--i, 1, split.left, null, split.right);
|
|
8701
|
+
else nodes.splice(--i, 1, split.left, split.right);
|
|
8702
|
+
j += 1 + split.break;
|
|
8703
|
+
before -= split.size;
|
|
8704
|
+
} else if (after > before * 2) {
|
|
8705
|
+
let split = nodes[j];
|
|
8706
|
+
if (split.break) nodes.splice(j, 1, split.left, null, split.right);
|
|
8707
|
+
else nodes.splice(j, 1, split.left, split.right);
|
|
8708
|
+
j += 2 + split.break;
|
|
8709
|
+
after -= split.size;
|
|
8710
|
+
} else break;
|
|
8711
|
+
} else if (before < after) {
|
|
8536
8712
|
let next = nodes[i++];
|
|
8537
8713
|
if (next) before += next.size;
|
|
8538
8714
|
} else {
|
|
@@ -8556,7 +8732,7 @@ function replace(old, val) {
|
|
|
8556
8732
|
return val;
|
|
8557
8733
|
}
|
|
8558
8734
|
HeightMap.prototype.size = 1;
|
|
8559
|
-
const SpaceDeco =
|
|
8735
|
+
const SpaceDeco = /*@__PURE__*/ Decoration.replace({});
|
|
8560
8736
|
var HeightMapBlock = class extends HeightMap {
|
|
8561
8737
|
constructor(length, height, deco) {
|
|
8562
8738
|
super(length, height);
|
|
@@ -9034,7 +9210,8 @@ var LineGapWidget = class extends WidgetType {
|
|
|
9034
9210
|
}
|
|
9035
9211
|
};
|
|
9036
9212
|
var ViewState = class {
|
|
9037
|
-
constructor(state) {
|
|
9213
|
+
constructor(view, state) {
|
|
9214
|
+
this.view = view;
|
|
9038
9215
|
this.state = state;
|
|
9039
9216
|
this.pixelViewport = {
|
|
9040
9217
|
left: 0,
|
|
@@ -9049,10 +9226,10 @@ var ViewState = class {
|
|
|
9049
9226
|
this.contentDOMHeight = 0;
|
|
9050
9227
|
this.editorHeight = 0;
|
|
9051
9228
|
this.editorWidth = 0;
|
|
9052
|
-
this.scrollTop = 0;
|
|
9053
|
-
this.scrolledToBottom = false;
|
|
9054
9229
|
this.scaleX = 1;
|
|
9055
9230
|
this.scaleY = 1;
|
|
9231
|
+
this.scrollOffset = 0;
|
|
9232
|
+
this.scrolledToBottom = false;
|
|
9056
9233
|
this.scrollAnchorPos = 0;
|
|
9057
9234
|
this.scrollAnchorHeight = -1;
|
|
9058
9235
|
this.scaler = IdScaler;
|
|
@@ -9062,7 +9239,8 @@ var ViewState = class {
|
|
|
9062
9239
|
this.defaultTextDirection = Direction.LTR;
|
|
9063
9240
|
this.visibleRanges = [];
|
|
9064
9241
|
this.mustEnforceCursorAssoc = false;
|
|
9065
|
-
|
|
9242
|
+
let guessWrapping = state.facet(contentAttributes).some((v) => typeof v != "function" && v.class == "cm-lineWrapping");
|
|
9243
|
+
this.heightOracle = new HeightOracle(guessWrapping);
|
|
9066
9244
|
this.stateDeco = staticDeco(state);
|
|
9067
9245
|
this.heightMap = HeightMap.empty().applyChanges(this.stateDeco, Text.empty, this.heightOracle.setDoc(state.doc), [new ChangedRange(0, 0, 0, state.doc.length)]);
|
|
9068
9246
|
for (let i = 0; i < 2; i++) {
|
|
@@ -9072,6 +9250,7 @@ var ViewState = class {
|
|
|
9072
9250
|
this.updateViewportLines();
|
|
9073
9251
|
this.lineGaps = this.ensureLineGaps([]);
|
|
9074
9252
|
this.lineGapDeco = Decoration.set(this.lineGaps.map((gap) => gap.draw(this, false)));
|
|
9253
|
+
this.scrollParent = view.scrollDOM;
|
|
9075
9254
|
this.computeVisibleRanges();
|
|
9076
9255
|
}
|
|
9077
9256
|
updateForViewport() {
|
|
@@ -9104,7 +9283,7 @@ var ViewState = class {
|
|
|
9104
9283
|
let contentChanges = update.changedRanges;
|
|
9105
9284
|
let heightChanges = ChangedRange.extendWithRanges(contentChanges, heightRelevantDecoChanges(prevDeco, this.stateDeco, update ? update.changes : ChangeSet.empty(this.state.doc.length)));
|
|
9106
9285
|
let prevHeight = this.heightMap.height;
|
|
9107
|
-
let scrollAnchor = this.scrolledToBottom ? null : this.scrollAnchorAt(this.
|
|
9286
|
+
let scrollAnchor = this.scrolledToBottom ? null : this.scrollAnchorAt(this.scrollOffset);
|
|
9108
9287
|
clearHeightChangeFlag();
|
|
9109
9288
|
this.heightMap = this.heightMap.applyChanges(this.stateDeco, update.startState.doc, this.heightOracle.setDoc(this.state.doc), heightChanges);
|
|
9110
9289
|
if (this.heightMap.height != prevHeight || heightChangeFlag) update.flags |= 2;
|
|
@@ -9126,12 +9305,12 @@ var ViewState = class {
|
|
|
9126
9305
|
if (scrollTarget) this.scrollTarget = scrollTarget;
|
|
9127
9306
|
if (!this.mustEnforceCursorAssoc && (update.selectionSet || update.focusChanged) && update.view.lineWrapping && update.state.selection.main.empty && update.state.selection.main.assoc && !update.state.facet(nativeSelectionHidden)) this.mustEnforceCursorAssoc = true;
|
|
9128
9307
|
}
|
|
9129
|
-
measure(
|
|
9130
|
-
let dom = view.contentDOM, style = window.getComputedStyle(dom);
|
|
9308
|
+
measure() {
|
|
9309
|
+
let { view } = this, dom = view.contentDOM, style = window.getComputedStyle(dom);
|
|
9131
9310
|
let oracle = this.heightOracle;
|
|
9132
9311
|
let whiteSpace = style.whiteSpace;
|
|
9133
9312
|
this.defaultTextDirection = style.direction == "rtl" ? Direction.RTL : Direction.LTR;
|
|
9134
|
-
let refresh = this.heightOracle.mustRefreshForWrapping(whiteSpace) || this.mustMeasureContent;
|
|
9313
|
+
let refresh = this.heightOracle.mustRefreshForWrapping(whiteSpace) || this.mustMeasureContent === "refresh";
|
|
9135
9314
|
let domRect = dom.getBoundingClientRect();
|
|
9136
9315
|
let measureContent = refresh || this.mustMeasureContent || this.contentDOMHeight != domRect.height;
|
|
9137
9316
|
this.contentDOMHeight = domRect.height;
|
|
@@ -9158,12 +9337,18 @@ var ViewState = class {
|
|
|
9158
9337
|
this.editorWidth = view.scrollDOM.clientWidth;
|
|
9159
9338
|
result |= 16;
|
|
9160
9339
|
}
|
|
9161
|
-
let
|
|
9162
|
-
if (
|
|
9340
|
+
let scrollParent = scrollableParents(this.view.contentDOM, false).y;
|
|
9341
|
+
if (scrollParent != this.scrollParent) {
|
|
9342
|
+
this.scrollParent = scrollParent;
|
|
9343
|
+
this.scrollAnchorHeight = -1;
|
|
9344
|
+
this.scrollOffset = 0;
|
|
9345
|
+
}
|
|
9346
|
+
let scrollOffset = this.getScrollOffset();
|
|
9347
|
+
if (this.scrollOffset != scrollOffset) {
|
|
9163
9348
|
this.scrollAnchorHeight = -1;
|
|
9164
|
-
this.
|
|
9349
|
+
this.scrollOffset = scrollOffset;
|
|
9165
9350
|
}
|
|
9166
|
-
this.scrolledToBottom = isScrolledToBottom(view.
|
|
9351
|
+
this.scrolledToBottom = isScrolledToBottom(this.scrollParent || view.win);
|
|
9167
9352
|
let pixelViewport = (this.printing ? fullPixelRange : visiblePixelRange)(dom, this.paddingTop);
|
|
9168
9353
|
let dTop = pixelViewport.top - this.pixelViewport.top, dBottom = pixelViewport.bottom - this.pixelViewport.bottom;
|
|
9169
9354
|
this.pixelViewport = pixelViewport;
|
|
@@ -9233,7 +9418,7 @@ var ViewState = class {
|
|
|
9233
9418
|
if (scrollTarget.y == "center") topPos = (block.top + block.bottom) / 2 - viewHeight / 2;
|
|
9234
9419
|
else if (scrollTarget.y == "start" || scrollTarget.y == "nearest" && head < viewport.from) topPos = block.top;
|
|
9235
9420
|
else topPos = block.bottom - viewHeight;
|
|
9236
|
-
viewport = new Viewport(map.lineAt(topPos -
|
|
9421
|
+
viewport = new Viewport(map.lineAt(topPos - 500, QueryType.ByHeight, oracle, 0, 0).from, map.lineAt(topPos + viewHeight + 500, QueryType.ByHeight, oracle, 0, 0).to);
|
|
9237
9422
|
}
|
|
9238
9423
|
}
|
|
9239
9424
|
return viewport;
|
|
@@ -9247,7 +9432,7 @@ var ViewState = class {
|
|
|
9247
9432
|
let { top } = this.heightMap.lineAt(from, QueryType.ByPos, this.heightOracle, 0, 0);
|
|
9248
9433
|
let { bottom } = this.heightMap.lineAt(to, QueryType.ByPos, this.heightOracle, 0, 0);
|
|
9249
9434
|
let { visibleTop, visibleBottom } = this;
|
|
9250
|
-
return (from == 0 || top <= visibleTop - Math.max(10, Math.min(-bias, 250))) && (to == this.state.doc.length || bottom >= visibleBottom + Math.max(10, Math.min(bias, 250))) && top > visibleTop -
|
|
9435
|
+
return (from == 0 || top <= visibleTop - Math.max(10, Math.min(-bias, 250))) && (to == this.state.doc.length || bottom >= visibleBottom + Math.max(10, Math.min(bias, 250))) && top > visibleTop - 2e3 && bottom < visibleBottom + 2e3;
|
|
9251
9436
|
}
|
|
9252
9437
|
mapLineGaps(gaps, changes) {
|
|
9253
9438
|
if (!gaps.length || changes.empty) return gaps;
|
|
@@ -9370,9 +9555,12 @@ var ViewState = class {
|
|
|
9370
9555
|
lineBlockAtHeight(height) {
|
|
9371
9556
|
return height >= this.viewportLines[0].top && height <= this.viewportLines[this.viewportLines.length - 1].bottom && this.viewportLines.find((l) => l.top <= height && l.bottom >= height) || scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(height), QueryType.ByHeight, this.heightOracle, 0, 0), this.scaler);
|
|
9372
9557
|
}
|
|
9373
|
-
|
|
9374
|
-
|
|
9375
|
-
|
|
9558
|
+
getScrollOffset() {
|
|
9559
|
+
return (this.scrollParent == this.view.scrollDOM ? this.scrollParent.scrollTop : (this.scrollParent ? this.scrollParent.getBoundingClientRect().top : 0) - this.view.contentDOM.getBoundingClientRect().top) * this.scaleY;
|
|
9560
|
+
}
|
|
9561
|
+
scrollAnchorAt(scrollOffset) {
|
|
9562
|
+
let block = this.lineBlockAtHeight(scrollOffset + 8);
|
|
9563
|
+
return block.from >= this.viewport.from || this.viewportLines[0].top - scrollOffset > 200 ? block : this.viewportLines[0];
|
|
9376
9564
|
}
|
|
9377
9565
|
elementAtHeight(height) {
|
|
9378
9566
|
return scaleBlock(this.heightMap.blockAt(this.scaler.fromDOM(height), this.heightOracle, 0, 0), this.scaler);
|
|
@@ -9510,9 +9698,11 @@ function scaleBlock(block, scaler) {
|
|
|
9510
9698
|
let bTop = scaler.toDOM(block.top), bBottom = scaler.toDOM(block.bottom);
|
|
9511
9699
|
return new BlockInfo(block.from, block.length, bTop, bBottom - bTop, Array.isArray(block._content) ? block._content.map((b) => scaleBlock(b, scaler)) : block._content);
|
|
9512
9700
|
}
|
|
9513
|
-
const theme =
|
|
9514
|
-
const darkTheme =
|
|
9515
|
-
const baseThemeID =
|
|
9701
|
+
const theme = /*@__PURE__*/ Facet.define({ combine: (strs) => strs.join(" ") });
|
|
9702
|
+
const darkTheme = /*@__PURE__*/ Facet.define({ combine: (values) => values.indexOf(true) > -1 });
|
|
9703
|
+
const baseThemeID = /*@__PURE__*/ StyleModule.newName();
|
|
9704
|
+
const baseLightID = /*@__PURE__*/ StyleModule.newName();
|
|
9705
|
+
const baseDarkID = /*@__PURE__*/ StyleModule.newName();
|
|
9516
9706
|
const lightDarkIDs = {
|
|
9517
9707
|
"&light": "." + baseLightID,
|
|
9518
9708
|
"&dark": "." + baseDarkID
|
|
@@ -9526,7 +9716,7 @@ function buildTheme(main, spec, scopes) {
|
|
|
9526
9716
|
}) : main + " " + sel;
|
|
9527
9717
|
} });
|
|
9528
9718
|
}
|
|
9529
|
-
const baseTheme$1 =
|
|
9719
|
+
const baseTheme$1 = /*@__PURE__*/ buildTheme("." + baseThemeID, {
|
|
9530
9720
|
"&": {
|
|
9531
9721
|
position: "relative !important",
|
|
9532
9722
|
boxSizing: "border-box",
|
|
@@ -9572,6 +9762,7 @@ const baseTheme$1 = /* @__PURE__ */ buildTheme("." + baseThemeID, {
|
|
|
9572
9762
|
padding: "0 2px 0 6px"
|
|
9573
9763
|
},
|
|
9574
9764
|
".cm-layer": {
|
|
9765
|
+
userSelect: "none",
|
|
9575
9766
|
position: "absolute",
|
|
9576
9767
|
left: 0,
|
|
9577
9768
|
top: 0,
|
|
@@ -9601,6 +9792,21 @@ const baseTheme$1 = /* @__PURE__ */ buildTheme("." + baseThemeID, {
|
|
|
9601
9792
|
},
|
|
9602
9793
|
".cm-cursor": { display: "none" },
|
|
9603
9794
|
"&dark .cm-cursor": { borderLeftColor: "#ddd" },
|
|
9795
|
+
".cm-selectionHandle": {
|
|
9796
|
+
backgroundColor: "currentColor",
|
|
9797
|
+
width: "1.5px"
|
|
9798
|
+
},
|
|
9799
|
+
".cm-selectionHandle-start::before, .cm-selectionHandle-end::before": {
|
|
9800
|
+
content: "\"\"",
|
|
9801
|
+
backgroundColor: "inherit",
|
|
9802
|
+
borderRadius: "50%",
|
|
9803
|
+
width: "8px",
|
|
9804
|
+
height: "8px",
|
|
9805
|
+
position: "absolute",
|
|
9806
|
+
left: "-3.25px"
|
|
9807
|
+
},
|
|
9808
|
+
".cm-selectionHandle-start::before": { top: "-8px" },
|
|
9809
|
+
".cm-selectionHandle-end::before": { bottom: "-8px" },
|
|
9604
9810
|
".cm-dropCursor": { position: "absolute" },
|
|
9605
9811
|
"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor": { display: "block" },
|
|
9606
9812
|
".cm-iso": { unicodeBidi: "isolate" },
|
|
@@ -9661,6 +9867,8 @@ const baseTheme$1 = /* @__PURE__ */ buildTheme("." + baseThemeID, {
|
|
|
9661
9867
|
backgroundColor: "#f5f5f5",
|
|
9662
9868
|
color: "black"
|
|
9663
9869
|
},
|
|
9870
|
+
".cm-panels-top": { top: "0" },
|
|
9871
|
+
".cm-panels-bottom": { bottom: "0" },
|
|
9664
9872
|
"&light .cm-panels-top": { borderBottom: "1px solid #ddd" },
|
|
9665
9873
|
"&light .cm-panels-bottom": { borderTop: "1px solid #ddd" },
|
|
9666
9874
|
"&dark .cm-panels": {
|
|
@@ -10041,18 +10249,20 @@ var DOMObserver = class {
|
|
|
10041
10249
|
}
|
|
10042
10250
|
addWindowListeners(win) {
|
|
10043
10251
|
win.addEventListener("resize", this.onResize);
|
|
10044
|
-
if (this.printQuery)
|
|
10045
|
-
|
|
10046
|
-
|
|
10252
|
+
if (this.printQuery) {
|
|
10253
|
+
if (this.printQuery.addEventListener) this.printQuery.addEventListener("change", this.onPrint);
|
|
10254
|
+
else this.printQuery.addListener(this.onPrint);
|
|
10255
|
+
} else win.addEventListener("beforeprint", this.onPrint);
|
|
10047
10256
|
win.addEventListener("scroll", this.onScroll);
|
|
10048
10257
|
win.document.addEventListener("selectionchange", this.onSelectionChange);
|
|
10049
10258
|
}
|
|
10050
10259
|
removeWindowListeners(win) {
|
|
10051
10260
|
win.removeEventListener("scroll", this.onScroll);
|
|
10052
10261
|
win.removeEventListener("resize", this.onResize);
|
|
10053
|
-
if (this.printQuery)
|
|
10054
|
-
|
|
10055
|
-
|
|
10262
|
+
if (this.printQuery) {
|
|
10263
|
+
if (this.printQuery.removeEventListener) this.printQuery.removeEventListener("change", this.onPrint);
|
|
10264
|
+
else this.printQuery.removeListener(this.onPrint);
|
|
10265
|
+
} else win.removeEventListener("beforeprint", this.onPrint);
|
|
10056
10266
|
win.document.removeEventListener("selectionchange", this.onSelectionChange);
|
|
10057
10267
|
}
|
|
10058
10268
|
update(update) {
|
|
@@ -10215,7 +10425,6 @@ var EditContextManager = class {
|
|
|
10215
10425
|
};
|
|
10216
10426
|
for (let event in this.handlers) context.addEventListener(event, this.handlers[event]);
|
|
10217
10427
|
this.measureReq = { read: (view) => {
|
|
10218
|
-
this.editContext.updateControlBounds(view.contentDOM.getBoundingClientRect());
|
|
10219
10428
|
let sel = getSelection(view.root);
|
|
10220
10429
|
if (sel && sel.rangeCount) this.editContext.updateSelectionBounds(sel.getRangeAt(0).getBoundingClientRect());
|
|
10221
10430
|
} };
|
|
@@ -10225,14 +10434,16 @@ var EditContextManager = class {
|
|
|
10225
10434
|
update.changes.iterChanges((fromA, toA, _fromB, _toB, insert) => {
|
|
10226
10435
|
if (abort) return;
|
|
10227
10436
|
let dLen = insert.length - (toA - fromA);
|
|
10228
|
-
if (pending && toA >= pending.to)
|
|
10229
|
-
pending
|
|
10230
|
-
|
|
10231
|
-
|
|
10232
|
-
|
|
10233
|
-
|
|
10234
|
-
|
|
10235
|
-
|
|
10437
|
+
if (pending && toA >= pending.to) {
|
|
10438
|
+
if (pending.from == fromA && pending.to == toA && pending.insert.eq(insert)) {
|
|
10439
|
+
pending = this.pendingContextChange = null;
|
|
10440
|
+
off += dLen;
|
|
10441
|
+
this.to += dLen;
|
|
10442
|
+
return;
|
|
10443
|
+
} else {
|
|
10444
|
+
pending = null;
|
|
10445
|
+
this.revertPending(update.state);
|
|
10446
|
+
}
|
|
10236
10447
|
}
|
|
10237
10448
|
fromA += off;
|
|
10238
10449
|
toA += off;
|
|
@@ -10286,7 +10497,7 @@ var EditContextManager = class {
|
|
|
10286
10497
|
}
|
|
10287
10498
|
rangeIsValid(state) {
|
|
10288
10499
|
let { head } = state.selection.main;
|
|
10289
|
-
return !(this.from > 0 && head - this.from < 500 || this.to < state.doc.length && this.to - head < 500 || this.to - this.from >
|
|
10500
|
+
return !(this.from > 0 && head - this.from < 500 || this.to < state.doc.length && this.to - head < 500 || this.to - this.from > 3e4);
|
|
10290
10501
|
}
|
|
10291
10502
|
toEditorPos(contextPos, clipLen = this.to - this.from) {
|
|
10292
10503
|
contextPos = Math.min(contextPos, clipLen);
|
|
@@ -10412,7 +10623,7 @@ var EditorView = class EditorView {
|
|
|
10412
10623
|
this.dispatchTransactions = config.dispatchTransactions || dispatch && ((trs) => trs.forEach((tr) => dispatch(tr, this))) || ((trs) => this.update(trs));
|
|
10413
10624
|
this.dispatch = this.dispatch.bind(this);
|
|
10414
10625
|
this._root = config.root || getRoot(config.parent) || document;
|
|
10415
|
-
this.viewState = new ViewState(config.state || EditorState.create(config));
|
|
10626
|
+
this.viewState = new ViewState(this, config.state || EditorState.create(config));
|
|
10416
10627
|
if (config.scrollTo && config.scrollTo.is(scrollIntoView)) this.viewState.scrollTarget = config.scrollTo.value.clip(this.viewState.state);
|
|
10417
10628
|
this.plugins = this.state.facet(viewPlugin).map((spec) => new PluginInstance(spec));
|
|
10418
10629
|
for (let plugin of this.plugins) plugin.update(this);
|
|
@@ -10425,7 +10636,7 @@ var EditorView = class EditorView {
|
|
|
10425
10636
|
this.updateState = 0;
|
|
10426
10637
|
this.requestMeasure();
|
|
10427
10638
|
if ((_a = document.fonts) === null || _a === void 0 ? void 0 : _a.ready) document.fonts.ready.then(() => {
|
|
10428
|
-
this.viewState.mustMeasureContent =
|
|
10639
|
+
this.viewState.mustMeasureContent = "refresh";
|
|
10429
10640
|
this.requestMeasure();
|
|
10430
10641
|
});
|
|
10431
10642
|
}
|
|
@@ -10478,7 +10689,8 @@ var EditorView = class EditorView {
|
|
|
10478
10689
|
if (scrollTarget) scrollTarget = scrollTarget.map(tr.changes);
|
|
10479
10690
|
if (tr.scrollIntoView) {
|
|
10480
10691
|
let { main } = tr.state.selection;
|
|
10481
|
-
|
|
10692
|
+
let { x, y } = this.state.facet(EditorView.cursorScrollMargin);
|
|
10693
|
+
scrollTarget = new ScrollTarget(main.empty ? main : EditorSelection.cursor(main.head, main.head > main.anchor ? -1 : 1), "nearest", "nearest", y, x);
|
|
10482
10694
|
}
|
|
10483
10695
|
for (let e of tr.effects) if (e.is(scrollIntoView)) scrollTarget = e.value.clip(this.state);
|
|
10484
10696
|
}
|
|
@@ -10528,7 +10740,7 @@ var EditorView = class EditorView {
|
|
|
10528
10740
|
let hadFocus = this.hasFocus;
|
|
10529
10741
|
try {
|
|
10530
10742
|
for (let plugin of this.plugins) plugin.destroy(this);
|
|
10531
|
-
this.viewState = new ViewState(newState);
|
|
10743
|
+
this.viewState = new ViewState(this, newState);
|
|
10532
10744
|
this.plugins = newState.facet(viewPlugin).map((spec) => new PluginInstance(spec));
|
|
10533
10745
|
this.pluginMap.clear();
|
|
10534
10746
|
for (let plugin of this.plugins) plugin.update(this);
|
|
@@ -10588,22 +10800,24 @@ var EditorView = class EditorView {
|
|
|
10588
10800
|
this.measureScheduled = 0;
|
|
10589
10801
|
if (flush) this.observer.forceFlush();
|
|
10590
10802
|
let updated = null;
|
|
10591
|
-
let
|
|
10803
|
+
let scroll = this.viewState.scrollParent, scrollOffset = this.viewState.getScrollOffset();
|
|
10592
10804
|
let { scrollAnchorPos, scrollAnchorHeight } = this.viewState;
|
|
10593
|
-
if (Math.abs(
|
|
10805
|
+
if (Math.abs(scrollOffset - this.viewState.scrollOffset) > 1) scrollAnchorHeight = -1;
|
|
10594
10806
|
this.viewState.scrollAnchorHeight = -1;
|
|
10595
10807
|
try {
|
|
10596
10808
|
for (let i = 0;; i++) {
|
|
10597
|
-
if (scrollAnchorHeight < 0)
|
|
10598
|
-
|
|
10599
|
-
|
|
10600
|
-
|
|
10601
|
-
|
|
10602
|
-
|
|
10603
|
-
|
|
10809
|
+
if (scrollAnchorHeight < 0) {
|
|
10810
|
+
if (isScrolledToBottom(scroll || this.win)) {
|
|
10811
|
+
scrollAnchorPos = -1;
|
|
10812
|
+
scrollAnchorHeight = this.viewState.heightMap.height;
|
|
10813
|
+
} else {
|
|
10814
|
+
let block = this.viewState.scrollAnchorAt(scrollOffset);
|
|
10815
|
+
scrollAnchorPos = block.from;
|
|
10816
|
+
scrollAnchorHeight = block.top;
|
|
10817
|
+
}
|
|
10604
10818
|
}
|
|
10605
10819
|
this.updateState = 1;
|
|
10606
|
-
let changed = this.viewState.measure(
|
|
10820
|
+
let changed = this.viewState.measure();
|
|
10607
10821
|
if (!changed && !this.measureRequests.length && this.viewState.scrollTarget == null) break;
|
|
10608
10822
|
if (i > 5) {
|
|
10609
10823
|
console.warn(this.measureRequests.length ? "Measure loop restarted more than 5 times" : "Viewport failed to stabilize");
|
|
@@ -10639,18 +10853,21 @@ var EditorView = class EditorView {
|
|
|
10639
10853
|
}
|
|
10640
10854
|
if (redrawn) this.docView.updateSelection(true);
|
|
10641
10855
|
if (!update.viewportChanged && this.measureRequests.length == 0) {
|
|
10642
|
-
if (this.viewState.editorHeight)
|
|
10643
|
-
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
continue;
|
|
10647
|
-
} else {
|
|
10648
|
-
let diff = (scrollAnchorPos < 0 ? this.viewState.heightMap.height : this.viewState.lineBlockAt(scrollAnchorPos).top) - scrollAnchorHeight;
|
|
10649
|
-
if (diff > 1 || diff < -1) {
|
|
10650
|
-
scrollTop = scrollTop + diff;
|
|
10651
|
-
sDOM.scrollTop = scrollTop / this.scaleY;
|
|
10856
|
+
if (this.viewState.editorHeight) {
|
|
10857
|
+
if (this.viewState.scrollTarget) {
|
|
10858
|
+
this.docView.scrollIntoView(this.viewState.scrollTarget);
|
|
10859
|
+
this.viewState.scrollTarget = null;
|
|
10652
10860
|
scrollAnchorHeight = -1;
|
|
10653
10861
|
continue;
|
|
10862
|
+
} else {
|
|
10863
|
+
let diff = ((scrollAnchorPos < 0 ? this.viewState.heightMap.height : this.viewState.lineBlockAt(scrollAnchorPos).top) - scrollAnchorHeight) / this.scaleY;
|
|
10864
|
+
if ((diff > 1 || diff < -1) && !(browser.ios && this.inputState.lastIOSMomentumScroll > Date.now() - 100) && (scroll == this.scrollDOM || this.hasFocus || Math.max(this.inputState.lastWheelEvent, this.inputState.lastTouchTime) > Date.now() - 100)) {
|
|
10865
|
+
scrollOffset = scrollOffset + diff;
|
|
10866
|
+
if (scroll) scroll.scrollTop += diff;
|
|
10867
|
+
else this.win.scrollBy(0, diff);
|
|
10868
|
+
scrollAnchorHeight = -1;
|
|
10869
|
+
continue;
|
|
10870
|
+
}
|
|
10654
10871
|
}
|
|
10655
10872
|
}
|
|
10656
10873
|
break;
|
|
@@ -10922,11 +11139,9 @@ var EditorView = class EditorView {
|
|
|
10922
11139
|
*/
|
|
10923
11140
|
coordsAtPos(pos, side = 1) {
|
|
10924
11141
|
this.readMeasured();
|
|
10925
|
-
let rect = this.docView.coordsAt(pos, side);
|
|
10926
|
-
if (!rect || rect.left == rect.right) return rect;
|
|
10927
11142
|
let line = this.state.doc.lineAt(pos), order = this.bidiSpans(line);
|
|
10928
11143
|
let span = order[BidiSpan.find(order, pos - line.from, -1, side)];
|
|
10929
|
-
return
|
|
11144
|
+
return this.docView.coordsAt(pos, side, span.dir == Direction.RTL);
|
|
10930
11145
|
}
|
|
10931
11146
|
/**
|
|
10932
11147
|
Return the rectangle around a given character. If `pos` does not
|
|
@@ -11052,7 +11267,8 @@ var EditorView = class EditorView {
|
|
|
11052
11267
|
cause it to scroll the given position or range into view.
|
|
11053
11268
|
*/
|
|
11054
11269
|
static scrollIntoView(pos, options = {}) {
|
|
11055
|
-
|
|
11270
|
+
var _a, _b, _c, _d;
|
|
11271
|
+
return scrollIntoView.of(new ScrollTarget(typeof pos == "number" ? EditorSelection.cursor(pos) : pos, (_a = options.y) !== null && _a !== void 0 ? _a : "nearest", (_b = options.x) !== null && _b !== void 0 ? _b : "nearest", (_c = options.yMargin) !== null && _c !== void 0 ? _c : 5, (_d = options.xMargin) !== null && _d !== void 0 ? _d : 5));
|
|
11056
11272
|
}
|
|
11057
11273
|
/**
|
|
11058
11274
|
Return an effect that resets the editor to its current (at the
|
|
@@ -11115,7 +11331,7 @@ var EditorView = class EditorView {
|
|
|
11115
11331
|
}
|
|
11116
11332
|
/**
|
|
11117
11333
|
Create a theme extension. The first argument can be a
|
|
11118
|
-
[`style-mod`](https://
|
|
11334
|
+
[`style-mod`](https://code.haverbeke.berlin/marijn/style-mod#documentation)
|
|
11119
11335
|
style spec providing the styles for the theme. These will be
|
|
11120
11336
|
prefixed with a generated class for the style.
|
|
11121
11337
|
|
|
@@ -11160,7 +11376,7 @@ var EditorView = class EditorView {
|
|
|
11160
11376
|
};
|
|
11161
11377
|
/**
|
|
11162
11378
|
Facet to add a [style
|
|
11163
|
-
module](https://
|
|
11379
|
+
module](https://code.haverbeke.berlin/marijn/style-mod#documentation) to
|
|
11164
11380
|
an editor view. The view will ensure that the module is
|
|
11165
11381
|
mounted in its [document
|
|
11166
11382
|
root](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).
|
|
@@ -11307,11 +11523,27 @@ supported.)
|
|
|
11307
11523
|
*/
|
|
11308
11524
|
EditorView.bidiIsolatedRanges = bidiIsolatedRanges;
|
|
11309
11525
|
/**
|
|
11526
|
+
Can be used to specify the distance that scrolling cursor into
|
|
11527
|
+
view keeps it away from the sides of the editor, either as a
|
|
11528
|
+
single pixel number or two different values for the different
|
|
11529
|
+
axes. Defaults to 5 pixels on both axes.
|
|
11530
|
+
*/
|
|
11531
|
+
EditorView.cursorScrollMargin = /*@__PURE__*/ Facet.define({ combine: (inputs) => {
|
|
11532
|
+
let x = 5, y = 5;
|
|
11533
|
+
for (let i of inputs) if (typeof i == "number") x = y = i;
|
|
11534
|
+
else ({x, y} = i);
|
|
11535
|
+
return {
|
|
11536
|
+
x,
|
|
11537
|
+
y
|
|
11538
|
+
};
|
|
11539
|
+
} });
|
|
11540
|
+
/**
|
|
11310
11541
|
Facet that allows extensions to provide additional scroll
|
|
11311
11542
|
margins (space around the sides of the scrolling element that
|
|
11312
11543
|
should be considered invisible). This can be useful when the
|
|
11313
11544
|
plugin introduces elements that cover part of that element (for
|
|
11314
|
-
example a horizontally fixed gutter).
|
|
11545
|
+
example a horizontally fixed gutter). Not to be confused with
|
|
11546
|
+
[`cursorScrollMargin`](https://codemirror.net/6/docs/ref/#view.EditorView^cursorScrollMargin).
|
|
11315
11547
|
*/
|
|
11316
11548
|
EditorView.scrollMargins = scrollMargins;
|
|
11317
11549
|
/**
|
|
@@ -11326,7 +11558,7 @@ Provides a Content Security Policy nonce to use when creating
|
|
|
11326
11558
|
the style sheets for the editor. Holds the empty string when no
|
|
11327
11559
|
nonce has been provided.
|
|
11328
11560
|
*/
|
|
11329
|
-
EditorView.cspNonce =
|
|
11561
|
+
EditorView.cspNonce = /*@__PURE__*/ Facet.define({ combine: (values) => values.length ? values[0] : "" });
|
|
11330
11562
|
/**
|
|
11331
11563
|
Facet that provides additional DOM attributes for the editor's
|
|
11332
11564
|
editable DOM element.
|
|
@@ -11341,7 +11573,7 @@ EditorView.editorAttributes = editorAttributes;
|
|
|
11341
11573
|
An extension that enables line wrapping in the editor (by
|
|
11342
11574
|
setting CSS `white-space` to `pre-wrap` in the content).
|
|
11343
11575
|
*/
|
|
11344
|
-
EditorView.lineWrapping =
|
|
11576
|
+
EditorView.lineWrapping = /*@__PURE__*/ EditorView.contentAttributes.of({ "class": "cm-lineWrapping" });
|
|
11345
11577
|
/**
|
|
11346
11578
|
State effect used to include screen reader announcements in a
|
|
11347
11579
|
transaction. These will be added to the DOM in a visually hidden
|
|
@@ -11350,7 +11582,7 @@ describe effects that are visually obvious but may not be
|
|
|
11350
11582
|
noticed by screen reader users (such as moving to the next
|
|
11351
11583
|
search match).
|
|
11352
11584
|
*/
|
|
11353
|
-
EditorView.announce =
|
|
11585
|
+
EditorView.announce = /*@__PURE__*/ StateEffect.define();
|
|
11354
11586
|
const MaxBidiLine = 4096;
|
|
11355
11587
|
const BadMeasure = {};
|
|
11356
11588
|
var CachedOrder = class CachedOrder {
|
|
@@ -11379,8 +11611,9 @@ function attrsFromFacet(view, facet, base) {
|
|
|
11379
11611
|
}
|
|
11380
11612
|
return base;
|
|
11381
11613
|
}
|
|
11382
|
-
|
|
11383
|
-
|
|
11614
|
+
browser.mac || browser.windows || browser.linux;
|
|
11615
|
+
browser.gecko && browser.gecko_version;
|
|
11616
|
+
/x/.unicode;
|
|
11384
11617
|
/**
|
|
11385
11618
|
A gutter marker represents a bit of information attached to a line
|
|
11386
11619
|
in a specific gutter. Your own custom markers have to extend this
|
|
@@ -11410,7 +11643,6 @@ GutterMarker.prototype.toDOM = void 0;
|
|
|
11410
11643
|
GutterMarker.prototype.mapMode = MapMode.TrackBefore;
|
|
11411
11644
|
GutterMarker.prototype.startSide = GutterMarker.prototype.endSide = -1;
|
|
11412
11645
|
GutterMarker.prototype.point = true;
|
|
11413
|
-
|
|
11414
11646
|
//#endregion
|
|
11415
11647
|
//#region src/components/editor/use-format-code.ts
|
|
11416
11648
|
const DEFAULT_PRETTIER_OPTIONS = {
|
|
@@ -11442,7 +11674,6 @@ const useFormatCode = ({ fragment, prettierOptions } = {}) => {
|
|
|
11442
11674
|
return formatted;
|
|
11443
11675
|
}, [prettierConfig, fragment]);
|
|
11444
11676
|
};
|
|
11445
|
-
|
|
11446
11677
|
//#endregion
|
|
11447
11678
|
//#region src/components/editor/core.tsx
|
|
11448
11679
|
const Core = ({ value, theme, height, className, prettierOptions, fragment, raw, onChange, onSave: _onSave, onError, ...props }) => {
|
|
@@ -11486,7 +11717,8 @@ const Core = ({ value, theme, height, className, prettierOptions, fragment, raw,
|
|
|
11486
11717
|
const onKeyDown = useCallback((e) => {
|
|
11487
11718
|
if ((e.metaKey || e.ctrlKey) && e.key === "s") {
|
|
11488
11719
|
e.preventDefault();
|
|
11489
|
-
|
|
11720
|
+
const currentValue = editorRef.current?.view?.state.doc.toString() || value;
|
|
11721
|
+
onSave(currentValue);
|
|
11490
11722
|
}
|
|
11491
11723
|
}, [onSave, value]);
|
|
11492
11724
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -11506,7 +11738,6 @@ const Core = ({ value, theme, height, className, prettierOptions, fragment, raw,
|
|
|
11506
11738
|
})
|
|
11507
11739
|
});
|
|
11508
11740
|
};
|
|
11509
|
-
|
|
11510
11741
|
//#endregion
|
|
11511
11742
|
//#region src/components/editor/tiptap.tsx
|
|
11512
11743
|
const Tiptap = ({ value = "", placeholder = "Enter text...", className, onChange }) => {
|
|
@@ -11527,11 +11758,10 @@ const Tiptap = ({ value = "", placeholder = "Enter text...", className, onChange
|
|
|
11527
11758
|
py-2`, "prose prose-sm max-w-none text-sm text-gray-800", "[&_.tiptap]:outline-none", "[&_.tiptap_p.is-editor-empty:first-child::before]:pointer-events-none", "[&_.tiptap_p.is-editor-empty:first-child::before]:float-left", "[&_.tiptap_p.is-editor-empty:first-child::before]:h-0", "[&_.tiptap_p.is-editor-empty:first-child::before]:text-gray-400", "[&_.tiptap_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]", className)
|
|
11528
11759
|
});
|
|
11529
11760
|
};
|
|
11530
|
-
|
|
11531
11761
|
//#endregion
|
|
11532
11762
|
//#region src/components/dnd/panel/selection.ts
|
|
11533
|
-
var import_lib$1 = /* @__PURE__ */ __toESM(require_lib$1());
|
|
11534
11763
|
var import_lib = require_lib();
|
|
11764
|
+
var import_lib$1 = /* @__PURE__ */ __toESM(require_lib$1(), 1);
|
|
11535
11765
|
const removeIndices = (items, indices) => {
|
|
11536
11766
|
return items.filter((_, index) => !indices.has(index));
|
|
11537
11767
|
};
|
|
@@ -11557,7 +11787,6 @@ const moveSelectedIndices = (items, indices, direction) => {
|
|
|
11557
11787
|
indices: nextIndices
|
|
11558
11788
|
};
|
|
11559
11789
|
};
|
|
11560
|
-
|
|
11561
11790
|
//#endregion
|
|
11562
11791
|
//#region src/components/dnd/panel/items.tsx
|
|
11563
11792
|
const BulkActionsBar = ({ count, onDuplicate, onMoveUp, onMoveDown, onDelete, onClear }) => {
|
|
@@ -11634,7 +11863,8 @@ const Items = ({ value, render, onChange, onChildChange }) => {
|
|
|
11634
11863
|
if (!import_lib$1.isObjectProperty(prop) || !import_lib$1.isIdentifier(prop.key) || !import_lib$1.isJSXElement(prop.value)) return;
|
|
11635
11864
|
const propertyName = prop.key.name;
|
|
11636
11865
|
try {
|
|
11637
|
-
const
|
|
11866
|
+
const jsxCode = generateCode(prop.value);
|
|
11867
|
+
const nodes = extract(jsxCode);
|
|
11638
11868
|
const bindings = [];
|
|
11639
11869
|
const bindingContainer = nodes.find((node) => node.bindings?.some((b) => b.property === "children"));
|
|
11640
11870
|
if (bindingContainer) bindings.push(bindingContainer);
|
|
@@ -11693,7 +11923,7 @@ const Items = ({ value, render, onChange, onChildChange }) => {
|
|
|
11693
11923
|
const nextElements = removeIndices(allElements, indices);
|
|
11694
11924
|
onChange?.(generateCode(import_lib$1.arrayExpression(nextElements)));
|
|
11695
11925
|
};
|
|
11696
|
-
const deletePrimitive = (index) => deleteSelectedPrimitives(new Set([index]));
|
|
11926
|
+
const deletePrimitive = (index) => deleteSelectedPrimitives(/* @__PURE__ */ new Set([index]));
|
|
11697
11927
|
const addPrimitive = () => {
|
|
11698
11928
|
const first = primitiveItems[0];
|
|
11699
11929
|
if (!first) return;
|
|
@@ -11767,10 +11997,11 @@ const Items = ({ value, render, onChange, onChildChange }) => {
|
|
|
11767
11997
|
};
|
|
11768
11998
|
const deleteSelectedItems = (indices) => {
|
|
11769
11999
|
if (objectItems.length - indices.size < 1) return;
|
|
11770
|
-
const
|
|
12000
|
+
const nextItems = removeIndices(objectItems, indices);
|
|
12001
|
+
const nextValue = arrayExpressionToCode(nextItems.map((item) => item.originalElement));
|
|
11771
12002
|
onChange?.(nextValue);
|
|
11772
12003
|
};
|
|
11773
|
-
const deleteItem = (index) => deleteSelectedItems(new Set([index]));
|
|
12004
|
+
const deleteItem = (index) => deleteSelectedItems(/* @__PURE__ */ new Set([index]));
|
|
11774
12005
|
const cloneObjectItemElement = (source) => {
|
|
11775
12006
|
const clonedElement = clone(source.originalElement);
|
|
11776
12007
|
clonedElement.properties.forEach((prop) => {
|
|
@@ -12041,7 +12272,6 @@ const Items = ({ value, render, onChange, onChildChange }) => {
|
|
|
12041
12272
|
]
|
|
12042
12273
|
});
|
|
12043
12274
|
};
|
|
12044
|
-
|
|
12045
12275
|
//#endregion
|
|
12046
12276
|
//#region src/components/dnd/panel/children.tsx
|
|
12047
12277
|
const Children = ({ value, onChange, onNodeChange }) => {
|
|
@@ -12071,9 +12301,10 @@ const Children = ({ value, onChange, onNodeChange }) => {
|
|
|
12071
12301
|
const nextItems = removeIndices(items, indices);
|
|
12072
12302
|
onChange?.(JSON.stringify(nextItems));
|
|
12073
12303
|
};
|
|
12074
|
-
const deleteItem = (index) => deleteSelectedItems(new Set([index]));
|
|
12304
|
+
const deleteItem = (index) => deleteSelectedItems(/* @__PURE__ */ new Set([index]));
|
|
12075
12305
|
const addItem = () => {
|
|
12076
|
-
const
|
|
12306
|
+
const template = items[0] || createDefaultItem();
|
|
12307
|
+
const newItem = cloneDataAttrNode(template);
|
|
12077
12308
|
const nextItems = [...items, newItem];
|
|
12078
12309
|
onChange?.(JSON.stringify(nextItems));
|
|
12079
12310
|
};
|
|
@@ -12234,7 +12465,6 @@ const Children = ({ value, onChange, onNodeChange }) => {
|
|
|
12234
12465
|
]
|
|
12235
12466
|
});
|
|
12236
12467
|
};
|
|
12237
|
-
|
|
12238
12468
|
//#endregion
|
|
12239
12469
|
//#region src/components/dnd/panel/icon-map.ts
|
|
12240
12470
|
const ICON_MAP = {
|
|
@@ -12276,7 +12506,6 @@ const ICON_MAP = {
|
|
|
12276
12506
|
User,
|
|
12277
12507
|
X
|
|
12278
12508
|
};
|
|
12279
|
-
|
|
12280
12509
|
//#endregion
|
|
12281
12510
|
//#region src/components/dnd/panel/field.tsx
|
|
12282
12511
|
const isColorProperty = (propertyName) => {
|
|
@@ -12608,7 +12837,6 @@ const Field = ({ binding, id, value, onChange }) => {
|
|
|
12608
12837
|
children: validationError
|
|
12609
12838
|
})] });
|
|
12610
12839
|
};
|
|
12611
|
-
|
|
12612
12840
|
//#endregion
|
|
12613
12841
|
//#region src/components/dnd/panel/node.tsx
|
|
12614
12842
|
const Node = ({ data, onChange }) => {
|
|
@@ -12647,35 +12875,9 @@ const Node = ({ data, onChange }) => {
|
|
|
12647
12875
|
})
|
|
12648
12876
|
});
|
|
12649
12877
|
};
|
|
12650
|
-
|
|
12651
12878
|
//#endregion
|
|
12652
12879
|
//#region src/components/dnd/panel/panel.tsx
|
|
12653
|
-
const Panel = ({ item,
|
|
12654
|
-
const { dataAttrNodes, updatedCode, parseError } = useMemo(() => {
|
|
12655
|
-
if (!item?.code) return {
|
|
12656
|
-
dataAttrNodes: [],
|
|
12657
|
-
updatedCode: "",
|
|
12658
|
-
parseError: false
|
|
12659
|
-
};
|
|
12660
|
-
try {
|
|
12661
|
-
const updatedCode = fillIds(item.code);
|
|
12662
|
-
return {
|
|
12663
|
-
dataAttrNodes: extract(updatedCode).filter((node) => node.tagName !== "section"),
|
|
12664
|
-
updatedCode: updatedCode !== item.code ? updatedCode : item.code,
|
|
12665
|
-
parseError: false
|
|
12666
|
-
};
|
|
12667
|
-
} catch (e) {
|
|
12668
|
-
console.warn("⚠️ Parsing error", e);
|
|
12669
|
-
return {
|
|
12670
|
-
dataAttrNodes: [],
|
|
12671
|
-
updatedCode: "",
|
|
12672
|
-
parseError: true
|
|
12673
|
-
};
|
|
12674
|
-
}
|
|
12675
|
-
}, [item?.code]);
|
|
12676
|
-
useEffect(() => {
|
|
12677
|
-
if (parseError) Toast.error("Failed to parse this section", { description: "Check the console for details." });
|
|
12678
|
-
}, [parseError]);
|
|
12880
|
+
const Panel = ({ item, onDelete, onMoveUp, onMoveDown, canMoveUp = false, canMoveDown = false, fields, onFieldChange }) => {
|
|
12679
12881
|
if (!item) return /* @__PURE__ */ jsx(Typography.Paragraph, {
|
|
12680
12882
|
className: cn("p-4 text-sm text-gray-500"),
|
|
12681
12883
|
children: "Please select a section."
|
|
@@ -12688,34 +12890,41 @@ const Panel = ({ item, onChange, onDelete }) => {
|
|
|
12688
12890
|
children: [/* @__PURE__ */ jsx(Typography.Title, {
|
|
12689
12891
|
className: "text-lg font-semibold",
|
|
12690
12892
|
children: item.name
|
|
12691
|
-
}),
|
|
12692
|
-
|
|
12693
|
-
|
|
12694
|
-
|
|
12893
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
12894
|
+
className: "flex items-center gap-1",
|
|
12895
|
+
children: [
|
|
12896
|
+
onMoveUp && /* @__PURE__ */ jsx(Button, {
|
|
12897
|
+
icon: /* @__PURE__ */ jsx(ChevronUp, {}),
|
|
12898
|
+
disabled: !canMoveUp,
|
|
12899
|
+
onClick: onMoveUp,
|
|
12900
|
+
"aria-label": "Move section up"
|
|
12901
|
+
}),
|
|
12902
|
+
onMoveDown && /* @__PURE__ */ jsx(Button, {
|
|
12903
|
+
icon: /* @__PURE__ */ jsx(ChevronDown, {}),
|
|
12904
|
+
disabled: !canMoveDown,
|
|
12905
|
+
onClick: onMoveDown,
|
|
12906
|
+
"aria-label": "Move section down"
|
|
12907
|
+
}),
|
|
12908
|
+
onDelete && /* @__PURE__ */ jsx(Button, {
|
|
12909
|
+
danger: true,
|
|
12910
|
+
icon: /* @__PURE__ */ jsx(Trash, {}),
|
|
12911
|
+
onClick: () => onDelete(item.id),
|
|
12912
|
+
"aria-label": "Delete section"
|
|
12913
|
+
})
|
|
12914
|
+
]
|
|
12695
12915
|
})]
|
|
12696
12916
|
}),
|
|
12697
|
-
!
|
|
12917
|
+
!fields.length && /* @__PURE__ */ jsx(Typography.Text, {
|
|
12698
12918
|
className: "text-xs text-gray-400",
|
|
12699
12919
|
children: "No editable elements."
|
|
12700
12920
|
}),
|
|
12701
|
-
|
|
12921
|
+
fields.map((node, index) => /* @__PURE__ */ jsx(Node, {
|
|
12702
12922
|
data: node,
|
|
12703
|
-
onChange:
|
|
12704
|
-
const result = update(updatedCode, id, label, value);
|
|
12705
|
-
if (!result.success) {
|
|
12706
|
-
Toast.error("Failed to update this field", { description: "Check the console for details." });
|
|
12707
|
-
return;
|
|
12708
|
-
}
|
|
12709
|
-
onChange?.({
|
|
12710
|
-
...item,
|
|
12711
|
-
code: result.code
|
|
12712
|
-
});
|
|
12713
|
-
}
|
|
12923
|
+
onChange: onFieldChange
|
|
12714
12924
|
}, `${item.id}-${index}`))
|
|
12715
12925
|
]
|
|
12716
12926
|
});
|
|
12717
12927
|
};
|
|
12718
|
-
|
|
12719
12928
|
//#endregion
|
|
12720
12929
|
//#region src/components/dnd/dnd.tsx
|
|
12721
12930
|
const conditionalModifiers = (args) => {
|
|
@@ -12732,6 +12941,7 @@ const Dnd$1 = ({ value: _value, props, modules = {}, onChange: _onChange, classN
|
|
|
12732
12941
|
const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 10 } }));
|
|
12733
12942
|
const value = _value || DEFAULT_TEMPLATE;
|
|
12734
12943
|
const sections = useMemo(() => extractSections(value), [value]);
|
|
12944
|
+
const selectedItem = useMemo(() => sections.find((s) => s.id === selectedId), [sections, selectedId]);
|
|
12735
12945
|
const [previewCache] = useState(() => createSectionPreviewCache());
|
|
12736
12946
|
const previews = useMemo(() => previewCache.compute(value, sections), [
|
|
12737
12947
|
previewCache,
|
|
@@ -12770,7 +12980,8 @@ const Dnd$1 = ({ value: _value, props, modules = {}, onChange: _onChange, classN
|
|
|
12770
12980
|
const prevIndex = sections.findIndex((s) => s.id === active.id);
|
|
12771
12981
|
const nextIndex = sections.findIndex((s) => s.id === over.id);
|
|
12772
12982
|
if (prevIndex >= 0 && nextIndex >= 0) {
|
|
12773
|
-
const
|
|
12983
|
+
const nextSections = arrayMove(sections, prevIndex, nextIndex);
|
|
12984
|
+
const nextCode = replaceSections(value, nextSections.map((s) => s.code));
|
|
12774
12985
|
_onChange?.(nextCode);
|
|
12775
12986
|
setCode(nextCode);
|
|
12776
12987
|
}
|
|
@@ -12782,7 +12993,8 @@ const Dnd$1 = ({ value: _value, props, modules = {}, onChange: _onChange, classN
|
|
|
12782
12993
|
name: item.name,
|
|
12783
12994
|
code: item.code
|
|
12784
12995
|
};
|
|
12785
|
-
const
|
|
12996
|
+
const nextSections = [...sections, newSection];
|
|
12997
|
+
const nextCode = replaceSections(value, nextSections.map((s) => s.code));
|
|
12786
12998
|
_onChange?.(nextCode);
|
|
12787
12999
|
setCode(nextCode);
|
|
12788
13000
|
};
|
|
@@ -12793,6 +13005,16 @@ const Dnd$1 = ({ value: _value, props, modules = {}, onChange: _onChange, classN
|
|
|
12793
13005
|
_onChange?.(nextCode);
|
|
12794
13006
|
setCode(nextCode);
|
|
12795
13007
|
};
|
|
13008
|
+
const moveSection = (id, direction) => {
|
|
13009
|
+
const index = sections.findIndex((s) => s.id === id);
|
|
13010
|
+
const targetIndex = direction === "up" ? index - 1 : index + 1;
|
|
13011
|
+
if (index < 0 || targetIndex < 0 || targetIndex >= sections.length) return;
|
|
13012
|
+
const nextSections = arrayMove(sections, index, targetIndex);
|
|
13013
|
+
const nextCode = replaceSections(value, nextSections.map((s) => s.code));
|
|
13014
|
+
_onChange?.(nextCode);
|
|
13015
|
+
setCode(nextCode);
|
|
13016
|
+
setSelectedId(String(targetIndex));
|
|
13017
|
+
};
|
|
12796
13018
|
const onCopy = (id) => {
|
|
12797
13019
|
const sectionIndex = sections.findIndex((s) => s.id === id);
|
|
12798
13020
|
const sectionToCopy = sections[sectionIndex];
|
|
@@ -12818,43 +13040,115 @@ const Dnd$1 = ({ value: _value, props, modules = {}, onChange: _onChange, classN
|
|
|
12818
13040
|
setSelectedId((prev) => prev === id ? null : id);
|
|
12819
13041
|
};
|
|
12820
13042
|
const onChange = (next) => {
|
|
12821
|
-
const
|
|
13043
|
+
const nextSections = sections.map((s) => s.id === next.id ? {
|
|
12822
13044
|
...s,
|
|
12823
13045
|
...next
|
|
12824
|
-
} : s)
|
|
13046
|
+
} : s);
|
|
13047
|
+
const nextCode = replaceSections(value, nextSections.map((s) => s.code));
|
|
12825
13048
|
_onChange?.(nextCode);
|
|
12826
13049
|
setCode(nextCode);
|
|
12827
13050
|
};
|
|
13051
|
+
const selectedCode = selectedItem?.code;
|
|
13052
|
+
const { fields, updatedCode, parseError } = useMemo(() => {
|
|
13053
|
+
if (!selectedCode) return {
|
|
13054
|
+
fields: [],
|
|
13055
|
+
updatedCode: "",
|
|
13056
|
+
parseError: false
|
|
13057
|
+
};
|
|
13058
|
+
try {
|
|
13059
|
+
const updated = fillIds(selectedCode);
|
|
13060
|
+
return {
|
|
13061
|
+
fields: extract(updated).filter((node) => node.tagName !== "section"),
|
|
13062
|
+
updatedCode: updated !== selectedCode ? updated : selectedCode,
|
|
13063
|
+
parseError: false
|
|
13064
|
+
};
|
|
13065
|
+
} catch (e) {
|
|
13066
|
+
console.warn("⚠️ Parsing error", e);
|
|
13067
|
+
return {
|
|
13068
|
+
fields: [],
|
|
13069
|
+
updatedCode: "",
|
|
13070
|
+
parseError: true
|
|
13071
|
+
};
|
|
13072
|
+
}
|
|
13073
|
+
}, [selectedCode]);
|
|
13074
|
+
useEffect(() => {
|
|
13075
|
+
if (parseError) Toast.error("Failed to parse this section", { description: "Check the console for details." });
|
|
13076
|
+
}, [parseError]);
|
|
13077
|
+
const onFieldChange = ({ id, label, value: fieldValue }) => {
|
|
13078
|
+
const result = update(updatedCode, id, label, fieldValue);
|
|
13079
|
+
if (!result.success) {
|
|
13080
|
+
Toast.error("Failed to update this field", { description: "Check the console for details." });
|
|
13081
|
+
return;
|
|
13082
|
+
}
|
|
13083
|
+
if (selectedItem) onChange({
|
|
13084
|
+
...selectedItem,
|
|
13085
|
+
code: result.code
|
|
13086
|
+
});
|
|
13087
|
+
};
|
|
13088
|
+
const bindings = useMemo(() => {
|
|
13089
|
+
return fields.flatMap((node) => {
|
|
13090
|
+
const dataId = node.dataAttributes.find((a) => a.name === "data-id")?.value;
|
|
13091
|
+
const bindingAttr = node.dataAttributes.find((a) => a.name === "data-binding")?.value;
|
|
13092
|
+
if (!dataId || !bindingAttr) return [];
|
|
13093
|
+
return (node.bindings ?? parseBinding(bindingAttr)).map((binding) => ({
|
|
13094
|
+
id: dataId,
|
|
13095
|
+
label: binding.label,
|
|
13096
|
+
property: binding.property,
|
|
13097
|
+
type: binding.type,
|
|
13098
|
+
options: binding.options,
|
|
13099
|
+
value: getCurrentValue(node, binding.property),
|
|
13100
|
+
onChange: (value) => onFieldChange({
|
|
13101
|
+
id: dataId,
|
|
13102
|
+
label: binding.label,
|
|
13103
|
+
value
|
|
13104
|
+
})
|
|
13105
|
+
}));
|
|
13106
|
+
});
|
|
13107
|
+
}, [fields]);
|
|
12828
13108
|
useEffect(() => {
|
|
12829
13109
|
if (frame?.scripts?.length) preloadScripts(frame.scripts);
|
|
12830
13110
|
}, [frame?.scripts]);
|
|
12831
|
-
const renderPaletteItems = (onAdd) => {
|
|
13111
|
+
const renderPaletteItems = (onAdd, forMobileDrawer = false) => {
|
|
12832
13112
|
const paletteItems = items?.length ? items : DRAGGABLE_ITEMS;
|
|
12833
13113
|
if (renderPalette) return renderPalette({
|
|
12834
13114
|
items: paletteItems,
|
|
12835
13115
|
onAdd,
|
|
12836
|
-
DraggableItem
|
|
13116
|
+
DraggableItem,
|
|
13117
|
+
isMobile: forMobileDrawer
|
|
12837
13118
|
});
|
|
12838
13119
|
return /* @__PURE__ */ jsx(Space, {
|
|
12839
13120
|
orientation: "vertical",
|
|
12840
13121
|
align: "start",
|
|
12841
13122
|
children: paletteItems.map((item) => /* @__PURE__ */ jsx(DefaultDraggableItem, {
|
|
12842
13123
|
item,
|
|
12843
|
-
onAdd
|
|
13124
|
+
onAdd,
|
|
13125
|
+
tapToAdd: forMobileDrawer
|
|
12844
13126
|
}, item.id))
|
|
12845
13127
|
});
|
|
12846
13128
|
};
|
|
12847
13129
|
const renderPanelContent = () => {
|
|
12848
|
-
const
|
|
13130
|
+
const selectedIndex = sections.findIndex((s) => s.id === selectedId);
|
|
13131
|
+
const canMoveUp = selectedIndex > 0;
|
|
13132
|
+
const canMoveDown = selectedIndex >= 0 && selectedIndex < sections.length - 1;
|
|
12849
13133
|
if (renderPanel) return renderPanel({
|
|
12850
13134
|
item: selectedItem,
|
|
12851
13135
|
onChange,
|
|
12852
|
-
onDelete
|
|
13136
|
+
onDelete,
|
|
13137
|
+
onMoveUp: () => moveSection(selectedId, "up"),
|
|
13138
|
+
onMoveDown: () => moveSection(selectedId, "down"),
|
|
13139
|
+
canMoveUp,
|
|
13140
|
+
canMoveDown,
|
|
13141
|
+
bindings
|
|
12853
13142
|
});
|
|
12854
13143
|
return /* @__PURE__ */ jsx(Panel, {
|
|
12855
13144
|
item: selectedItem,
|
|
12856
|
-
|
|
12857
|
-
|
|
13145
|
+
onDelete,
|
|
13146
|
+
onMoveUp: () => moveSection(selectedId, "up"),
|
|
13147
|
+
onMoveDown: () => moveSection(selectedId, "down"),
|
|
13148
|
+
canMoveUp,
|
|
13149
|
+
canMoveDown,
|
|
13150
|
+
fields,
|
|
13151
|
+
onFieldChange
|
|
12858
13152
|
});
|
|
12859
13153
|
};
|
|
12860
13154
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(DndContext, {
|
|
@@ -12934,7 +13228,7 @@ const Dnd$1 = ({ value: _value, props, modules = {}, onChange: _onChange, classN
|
|
|
12934
13228
|
children: renderPaletteItems((item) => {
|
|
12935
13229
|
addItem(item);
|
|
12936
13230
|
setMobilePaletteOpen(false);
|
|
12937
|
-
})
|
|
13231
|
+
}, true)
|
|
12938
13232
|
}),
|
|
12939
13233
|
/* @__PURE__ */ jsx(Drawer, {
|
|
12940
13234
|
open: isMobile && Boolean(selectedId),
|
|
@@ -12956,12 +13250,10 @@ const Dnd$1 = ({ value: _value, props, modules = {}, onChange: _onChange, classN
|
|
|
12956
13250
|
}) })]
|
|
12957
13251
|
}) });
|
|
12958
13252
|
};
|
|
12959
|
-
|
|
12960
13253
|
//#endregion
|
|
12961
13254
|
//#region src/components/dnd/index.ts
|
|
12962
13255
|
const Dnd = Dnd$1;
|
|
12963
13256
|
Dnd.DraggableItem = DraggableItem;
|
|
12964
|
-
|
|
12965
13257
|
//#endregion
|
|
12966
13258
|
//#region src/components/editor/editor.tsx
|
|
12967
13259
|
const Editor$1 = ({ defaultValue, value: _value, debounce = 1e3, onChange: _onChange, renderEditor, fragment, prettierOptions, ...props }) => {
|
|
@@ -13000,12 +13292,10 @@ const Editor$1 = ({ defaultValue, value: _value, debounce = 1e3, onChange: _onCh
|
|
|
13000
13292
|
...props
|
|
13001
13293
|
});
|
|
13002
13294
|
};
|
|
13003
|
-
|
|
13004
13295
|
//#endregion
|
|
13005
13296
|
//#region src/components/editor/index.ts
|
|
13006
13297
|
const Editor = Editor$1;
|
|
13007
13298
|
Editor.Core = Core;
|
|
13008
|
-
|
|
13009
13299
|
//#endregion
|
|
13010
13300
|
//#region src/components/error/error.tsx
|
|
13011
13301
|
const Error$2 = ({ message, title = "An error occurred", className, onReset }) => {
|
|
@@ -13054,7 +13344,6 @@ const Error$2 = ({ message, title = "An error occurred", className, onReset }) =
|
|
|
13054
13344
|
]
|
|
13055
13345
|
});
|
|
13056
13346
|
};
|
|
13057
|
-
|
|
13058
13347
|
//#endregion
|
|
13059
13348
|
//#region src/components/error/boundary.tsx
|
|
13060
13349
|
var ErrorBoundary = class extends React.Component {
|
|
@@ -13093,7 +13382,6 @@ var ErrorBoundary = class extends React.Component {
|
|
|
13093
13382
|
return this.props.children;
|
|
13094
13383
|
}
|
|
13095
13384
|
};
|
|
13096
|
-
|
|
13097
13385
|
//#endregion
|
|
13098
13386
|
//#region src/components/error/guard.tsx
|
|
13099
13387
|
const Guard = ({ children, onError }) => {
|
|
@@ -13144,7 +13432,6 @@ const Guard = ({ children, onError }) => {
|
|
|
13144
13432
|
children
|
|
13145
13433
|
});
|
|
13146
13434
|
};
|
|
13147
|
-
|
|
13148
13435
|
//#endregion
|
|
13149
13436
|
//#region src/components/error/runtime.tsx
|
|
13150
13437
|
const Runtime = ({ open = true, reset }) => {
|
|
@@ -13163,14 +13450,12 @@ const Runtime = ({ open = true, reset }) => {
|
|
|
13163
13450
|
title: "Runtime Error"
|
|
13164
13451
|
});
|
|
13165
13452
|
};
|
|
13166
|
-
|
|
13167
13453
|
//#endregion
|
|
13168
13454
|
//#region src/components/error/index.ts
|
|
13169
13455
|
const Error$1 = Error$2;
|
|
13170
13456
|
Error$1.Boundary = ErrorBoundary;
|
|
13171
13457
|
Error$1.Runtime = Runtime;
|
|
13172
13458
|
Error$1.Guard = Guard;
|
|
13173
|
-
|
|
13174
13459
|
//#endregion
|
|
13175
13460
|
//#region src/components/preview/client.tsx
|
|
13176
13461
|
const Client = ({ code: _code = "", className, showError, props = {}, modules = {}, frame, provider }) => {
|
|
@@ -13238,7 +13523,6 @@ const Client = ({ code: _code = "", className, showError, props = {}, modules =
|
|
|
13238
13523
|
})
|
|
13239
13524
|
}), /* @__PURE__ */ jsx(Error$1.Runtime, { open: isError })] });
|
|
13240
13525
|
};
|
|
13241
|
-
|
|
13242
13526
|
//#endregion
|
|
13243
13527
|
//#region src/components/preview/preview.tsx
|
|
13244
13528
|
const Preview = ({ code, props = {}, modules = {}, dynamicTailwind = false, provider, ...restProps }) => {
|
|
@@ -13310,7 +13594,6 @@ const Preview = ({ code, props = {}, modules = {}, dynamicTailwind = false, prov
|
|
|
13310
13594
|
...restProps
|
|
13311
13595
|
});
|
|
13312
13596
|
};
|
|
13313
|
-
|
|
13314
13597
|
//#endregion
|
|
13315
13598
|
//#region src/index.tsx
|
|
13316
13599
|
const App = ({ children }) => {
|
|
@@ -13322,7 +13605,7 @@ App.Renderer = LiveRenderer;
|
|
|
13322
13605
|
App.Error = Error$1;
|
|
13323
13606
|
App.Editor = Editor;
|
|
13324
13607
|
App.Dnd = Dnd;
|
|
13325
|
-
|
|
13326
13608
|
//#endregion
|
|
13327
13609
|
export { Dnd as LiveDnd, Editor as LiveEditor, Error$1 as LiveError, Preview as LivePreview, App as LiveProvider, App as default, LiveRenderer };
|
|
13328
|
-
|
|
13610
|
+
|
|
13611
|
+
//# sourceMappingURL=index.js.map
|