@cocoar/vue-script-editor 1.9.0-script-editor.4 → 1.9.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/README.md +22 -0
- package/dist/CoarScriptEditor.vue.d.ts +9 -2
- package/dist/CoarScriptEditor.vue.d.ts.map +1 -1
- package/dist/composables/useMonacoEditor.d.ts +6 -0
- package/dist/composables/useMonacoEditor.d.ts.map +1 -1
- package/dist/constrained/LockedLineScanner.d.ts +26 -0
- package/dist/constrained/LockedLineScanner.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +129 -85
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -169,9 +169,12 @@ For server-side validation, submit-gating, or tests:
|
|
|
169
169
|
import {
|
|
170
170
|
hasLockedMarkers,
|
|
171
171
|
getEditableSegments,
|
|
172
|
+
getSlots,
|
|
173
|
+
getSlot,
|
|
172
174
|
isEverySegmentNonEmpty,
|
|
173
175
|
validateSource,
|
|
174
176
|
countLockedLines,
|
|
177
|
+
SLOT_MARKER_PATTERN,
|
|
175
178
|
} from '@cocoar/vue-script-editor';
|
|
176
179
|
|
|
177
180
|
if (isEverySegmentNonEmpty(code)) submit(code);
|
|
@@ -180,6 +183,24 @@ const v = validateSource(code);
|
|
|
180
183
|
// v.ok, v.lockedLineCount, v.segmentCount, v.warnings: string[]
|
|
181
184
|
```
|
|
182
185
|
|
|
186
|
+
### Named slots
|
|
187
|
+
|
|
188
|
+
Mark an editable region with `@slot:NAME` on a `// @locked` line to name it. `getSlots(source)` returns a `{ slotName: bodyContent }` dictionary; `getSlot(source, name)` returns a single body (or `undefined` if the slot is not declared). The slot marker sits on a locked line so the user cannot delete it.
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
const template = `function fn1(x) { // @locked @slot:fn1
|
|
192
|
+
return x + 1;
|
|
193
|
+
} // @locked
|
|
194
|
+
|
|
195
|
+
function fn2(x) { // @locked @slot:fn2
|
|
196
|
+
} // @locked`;
|
|
197
|
+
|
|
198
|
+
const slots = getSlots(template);
|
|
199
|
+
// { fn1: ' return x + 1;', fn2: '' }
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Empty string = slot exists but body is whitespace-only. Server-side parsers (e.g. a C# Jint host) can mirror the same regex via `SLOT_MARKER_PATTERN`. See the [full docs](https://docs.cocoar.dev/cocoar-ui-vue/components/script-editor) for the C# port.
|
|
203
|
+
|
|
183
204
|
See the full docs page for the deeper helpers (`scanLockedLines`, `computeProtectedRanges`,
|
|
184
205
|
`editIsProtected`, `snapOffsetAwayFromLocked`).
|
|
185
206
|
|
|
@@ -200,6 +221,7 @@ See the full docs page for the deeper helpers (`scanLockedLines`, `computeProtec
|
|
|
200
221
|
| `name` | `string` | `''` | Informational `data-name` (the editor is not a native form control). |
|
|
201
222
|
| `height` | `string \| number` | `undefined` | CSS string (`"160px"`, `"40vh"`) or pixels as number. |
|
|
202
223
|
| `variant` | `'editor' \| 'inline'` | `'editor'` | UI preset: full chrome vs compact form-field look. |
|
|
224
|
+
| `lineNumbers` | `boolean` | `undefined` | Explicit toggle for the line-number gutter. Overrides the variant default. |
|
|
203
225
|
| `scriptMode` | `boolean` | `false` | Suppress TS/JS diagnostics for script-body code. **Global side-effect**. |
|
|
204
226
|
| `preamble` | `string` | `''` | Hidden + locked per-editor type context (not in `modelValue`). |
|
|
205
227
|
| `minimap` | `boolean` | `false` | Show the Monaco minimap gutter. |
|
|
@@ -54,6 +54,12 @@ export interface CoarScriptEditorProps {
|
|
|
54
54
|
* - `'inline'`: compact form-field look — no line numbers, no gutter, tight padding
|
|
55
55
|
*/
|
|
56
56
|
variant?: CoarScriptEditorVariant;
|
|
57
|
+
/**
|
|
58
|
+
* Explicitly toggle line numbers, overriding the variant default (`'editor'` → on,
|
|
59
|
+
* `'inline'` → off). Leave undefined to inherit from the variant. When off, a small
|
|
60
|
+
* decoration column keeps the text from touching the left border.
|
|
61
|
+
*/
|
|
62
|
+
lineNumbers?: boolean;
|
|
57
63
|
/**
|
|
58
64
|
* When true, suppresses diagnostic codes that flag "script body" constructs in TS/JS
|
|
59
65
|
* (top-level return/await/export, implicit any, etc). **Global side-effect** — affects
|
|
@@ -96,6 +102,9 @@ declare const _default: import('vue').DefineComponent<CoarScriptEditorProps, {
|
|
|
96
102
|
onFocused?: (() => any) | undefined;
|
|
97
103
|
onBlurred?: (() => any) | undefined;
|
|
98
104
|
}>, {
|
|
105
|
+
lineNumbers: boolean;
|
|
106
|
+
minimap: boolean;
|
|
107
|
+
placeholder: string;
|
|
99
108
|
overflowWidgetsDomNode: HTMLElement | null;
|
|
100
109
|
modelValue: string;
|
|
101
110
|
authoring: boolean;
|
|
@@ -103,7 +112,6 @@ declare const _default: import('vue').DefineComponent<CoarScriptEditorProps, {
|
|
|
103
112
|
readonly: boolean;
|
|
104
113
|
disabled: boolean;
|
|
105
114
|
error: boolean;
|
|
106
|
-
placeholder: string;
|
|
107
115
|
required: boolean;
|
|
108
116
|
autofocus: boolean;
|
|
109
117
|
id: string;
|
|
@@ -112,7 +120,6 @@ declare const _default: import('vue').DefineComponent<CoarScriptEditorProps, {
|
|
|
112
120
|
variant: CoarScriptEditorVariant;
|
|
113
121
|
scriptMode: boolean;
|
|
114
122
|
preamble: string;
|
|
115
|
-
minimap: boolean;
|
|
116
123
|
theme: CoarScriptEditorTheme;
|
|
117
124
|
extraLibs: CoarScriptEditorExtraLib[];
|
|
118
125
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoarScriptEditor.vue.d.ts","sourceRoot":"","sources":["../src/CoarScriptEditor.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CoarScriptEditor.vue.d.ts","sourceRoot":"","sources":["../src/CoarScriptEditor.vue"],"names":[],"mappings":"AA+UA,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC7B,MAA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CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,qBAAqB,CAAC;IAC9B,sFAAsF;IACtF,SAAS,CAAC,EAAE,wBAAwB,EAAE,CAAC;IACvC;;;;;;;OAOG;IACH,sBAAsB,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC7C;;;;;;;;;;;;;;;;iBA3Be,OAAO;aAcX,OAAO;iBApCH,MAAM;4BAgDK,WAAW,GAAG,IAAI;gBAhE9B,MAAM;eAOP,OAAO;cACR,wBAAwB;cAExB,OAAO;cAEP,OAAO;WAEV,OAAO;cAIJ,OAAO;eAEN,OAAO;QAEd,MAAM;UAEJ,MAAM;YAEJ,MAAM,GAAG,MAAM;aAMd,uBAAuB;gBAYpB,OAAO;cAOT,MAAM;WAET,qBAAqB;eAEjB,wBAAwB,EAAE;;;;AAuNxC,wBAWG"}
|
|
@@ -11,6 +11,12 @@ export interface UseMonacoEditorOptions {
|
|
|
11
11
|
minimap: () => boolean;
|
|
12
12
|
theme: () => CoarScriptEditorTheme;
|
|
13
13
|
variant?: () => CoarScriptEditorVariant;
|
|
14
|
+
/**
|
|
15
|
+
* Explicitly toggle line numbers. When undefined, defers to the variant default
|
|
16
|
+
* (`'editor'` → on, `'inline'` → off). When line numbers are off, a small decoration
|
|
17
|
+
* column still renders as a visual left-margin so the text does not touch the border.
|
|
18
|
+
*/
|
|
19
|
+
lineNumbers?: () => boolean | undefined;
|
|
14
20
|
/**
|
|
15
21
|
* Hidden + locked prefix prepended to the model content for per-editor type context.
|
|
16
22
|
* `setHiddenAreas` hides it from view, and an internal guard rejects any edit whose
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMonacoEditor.d.ts","sourceRoot":"","sources":["../../src/composables/useMonacoEditor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAsC,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AACnE,OAAO,EAIL,KAAK,qBA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ACzC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,qBAAqB,KAAK,IAAI,CAAC;CACvE;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAAC,CAAC;IAClE,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC;IACtD;;OAEG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;;;OAIG;IACH,oBAAoB,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;CAC7C;AAsDD,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,qBAAqB,CAuQtF"}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* `// @lockedx` do not trigger.
|
|
14
14
|
*/
|
|
15
15
|
export declare const LOCKED_MARKER_TEXT = "// @locked";
|
|
16
|
+
export declare const SLOT_MARKER_PATTERN: string;
|
|
16
17
|
export interface LockedLine {
|
|
17
18
|
/** 0-based line index within the source. */
|
|
18
19
|
lineIndex: number;
|
|
@@ -39,6 +40,12 @@ export interface LockedLine {
|
|
|
39
40
|
snapBefore: number | null;
|
|
40
41
|
/** Valid snap target after the locked line (start of the next line), or null if this is the last line with no trailing `\n`. */
|
|
41
42
|
snapAfter: number | null;
|
|
43
|
+
/**
|
|
44
|
+
* Name parsed from an `@slot:NAME` attribute on this locked line. When present, the
|
|
45
|
+
* editable segment immediately following this line (up to the next locked line or EOF)
|
|
46
|
+
* is a named slot whose content can be retrieved via `getSlot(source, name)`.
|
|
47
|
+
*/
|
|
48
|
+
slotName?: string;
|
|
42
49
|
}
|
|
43
50
|
/** Contiguous protected range, produced by merging adjacent locked lines. */
|
|
44
51
|
export interface ProtectedRange {
|
|
@@ -101,6 +108,25 @@ export interface SourceValidation {
|
|
|
101
108
|
* want to surface soft warnings (e.g. during template authoring) without refusing to mount.
|
|
102
109
|
*/
|
|
103
110
|
export declare function validateSource(source: string): SourceValidation;
|
|
111
|
+
/**
|
|
112
|
+
* Return every named slot as a dictionary keyed by slot name. Slot content is the text of
|
|
113
|
+
* the editable segment immediately following the locked line that carries the
|
|
114
|
+
* `@slot:NAME` attribute, with leading and trailing blank lines stripped.
|
|
115
|
+
*
|
|
116
|
+
* A slot's content is `''` when the segment is empty or contains only whitespace — a
|
|
117
|
+
* consumer can gate "was this body filled in?" on `slots[name].trim().length > 0`.
|
|
118
|
+
*
|
|
119
|
+
* Duplicate slot names: first occurrence wins. Later duplicates are silently ignored so
|
|
120
|
+
* the dictionary key maps deterministically to one piece of source — surface duplicates
|
|
121
|
+
* via `validateSource()` during template authoring if you want to catch them.
|
|
122
|
+
*/
|
|
123
|
+
export declare function getSlots(source: string): Record<string, string>;
|
|
124
|
+
/**
|
|
125
|
+
* Content of a single named slot, or `undefined` if no locked line in the source declares
|
|
126
|
+
* that slot name. `undefined` deliberately distinguishes "slot not declared" from "slot
|
|
127
|
+
* declared but empty" (returns `''`).
|
|
128
|
+
*/
|
|
129
|
+
export declare function getSlot(source: string, name: string): string | undefined;
|
|
104
130
|
/**
|
|
105
131
|
* Returns the text of each *editable* block — the stretches of consecutive non-locked
|
|
106
132
|
* lines. If the source has no locked lines, returns a single-element array with the full
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LockedLineScanner.d.ts","sourceRoot":"","sources":["../../src/constrained/LockedLineScanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"LockedLineScanner.d.ts","sourceRoot":"","sources":["../../src/constrained/LockedLineScanner.ts"],"names":[],"mapp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AAE,MAAM,CAAA;CAAE,EAC9C,MAAM,EAAE,SAAS,cAAc,EAAE,GAChC,OAAO,CAET;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,SAAS,cAAc,EAAE,GAChC,MAAM,CAYR;AAED,wDAAwD;AACxD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED,MAAM,WAAW,gBAAgB;IAC/B,0FAA0F;IAC1F,EAAE,EAAE,OAAO,CAAC;IACZ,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAoB/D;AAeD;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAqB/D;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGxE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAuB5D"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export type { CoarScriptEditorLanguage, CoarScriptEditorVariant, } from './compo
|
|
|
4
4
|
export type { CoarScriptEditorExtraLib } from './composables/useExtraLibs';
|
|
5
5
|
export type { CoarScriptEditorTheme } from './theme';
|
|
6
6
|
export { COAR_THEME_LIGHT, COAR_THEME_DARK, ensureCoarThemes, detectAutoTheme, watchAutoTheme, } from './theme';
|
|
7
|
-
export { scanLockedLines, computeProtectedRanges, hasLockedMarkers, getEditableSegments, overlapsProtectedRange, editIsProtected, snapOffsetAwayFromLocked, countLockedLines, isEverySegmentNonEmpty, validateSource, LOCKED_MARKER_TEXT, type LockedLine, type ProtectedRange, type SourceValidation, } from './constrained/LockedLineScanner';
|
|
7
|
+
export { scanLockedLines, computeProtectedRanges, hasLockedMarkers, getEditableSegments, getSlots, getSlot, overlapsProtectedRange, editIsProtected, snapOffsetAwayFromLocked, countLockedLines, isEverySegmentNonEmpty, validateSource, LOCKED_MARKER_TEXT, SLOT_MARKER_PATTERN, type LockedLine, type ProtectedRange, type SourceValidation, } from './constrained/LockedLineScanner';
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACrE,YAAY,EACV,qBAAqB,EACrB,4BAA4B,EAC5B,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,+BAA+B,CAAC;AACvC,YAAY,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,YAAY,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,cAAc,GACf,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,wBAAwB,EACxB,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,kBAAkB,EAClB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACtB,MAAM,iCAAiC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACrE,YAAY,EACV,qBAAqB,EACrB,4BAA4B,EAC5B,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,+BAA+B,CAAC;AACvC,YAAY,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,YAAY,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,cAAc,GACf,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,EACnB,QAAQ,EACR,OAAO,EACP,sBAAsB,EACtB,eAAe,EACf,wBAAwB,EACxB,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACtB,MAAM,iCAAiC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -80,13 +80,10 @@ var x = {
|
|
|
80
80
|
7027,
|
|
81
81
|
2304,
|
|
82
82
|
1208
|
|
83
|
-
], C = {
|
|
83
|
+
], C = "'Cascadia Code', 'Consolas', 'Monaco', 'Courier New', monospace", w = 13, T = 1.5, E = !0, D = {
|
|
84
84
|
editor: {
|
|
85
|
-
lineNumbers: "on",
|
|
86
85
|
glyphMargin: !0,
|
|
87
86
|
folding: !0,
|
|
88
|
-
lineDecorationsWidth: 10,
|
|
89
|
-
lineNumbersMinChars: 3,
|
|
90
87
|
renderLineHighlight: "line",
|
|
91
88
|
contextmenu: !0,
|
|
92
89
|
overviewRulerLanes: 3,
|
|
@@ -103,11 +100,8 @@ var x = {
|
|
|
103
100
|
wordWrap: "off"
|
|
104
101
|
},
|
|
105
102
|
inline: {
|
|
106
|
-
lineNumbers: "off",
|
|
107
103
|
glyphMargin: !1,
|
|
108
104
|
folding: !1,
|
|
109
|
-
lineDecorationsWidth: 0,
|
|
110
|
-
lineNumbersMinChars: 0,
|
|
111
105
|
renderLineHighlight: "none",
|
|
112
106
|
contextmenu: !1,
|
|
113
107
|
overviewRulerLanes: 0,
|
|
@@ -125,25 +119,36 @@ var x = {
|
|
|
125
119
|
wordWrap: "on"
|
|
126
120
|
}
|
|
127
121
|
};
|
|
128
|
-
function
|
|
122
|
+
function O(e, t) {
|
|
123
|
+
return t ?? e === "editor" ? {
|
|
124
|
+
lineNumbers: "on",
|
|
125
|
+
lineNumbersMinChars: 3,
|
|
126
|
+
lineDecorationsWidth: 10
|
|
127
|
+
} : {
|
|
128
|
+
lineNumbers: "off",
|
|
129
|
+
lineNumbersMinChars: 0,
|
|
130
|
+
lineDecorationsWidth: 12
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function k(e) {
|
|
129
134
|
return e ? `${e}\n` : "";
|
|
130
135
|
}
|
|
131
|
-
function
|
|
136
|
+
function A(e) {
|
|
132
137
|
return e ? e.split("\n").length : 0;
|
|
133
138
|
}
|
|
134
|
-
function
|
|
135
|
-
return t ?
|
|
139
|
+
function j(e, t) {
|
|
140
|
+
return t ? k(t) + e : e;
|
|
136
141
|
}
|
|
137
|
-
function
|
|
142
|
+
function M(e, t) {
|
|
138
143
|
if (!t) return e;
|
|
139
|
-
let n =
|
|
144
|
+
let n = k(t);
|
|
140
145
|
return e.startsWith(n) ? e.slice(n.length) : e;
|
|
141
146
|
}
|
|
142
|
-
function
|
|
143
|
-
let n =
|
|
147
|
+
function N(e, t) {
|
|
148
|
+
let n = A(t), r = n === 0 ? [] : [new f.Range(1, 1, n, 2 ** 53 - 1)];
|
|
144
149
|
e.setHiddenAreas(r);
|
|
145
150
|
}
|
|
146
|
-
function
|
|
151
|
+
function P(e, t) {
|
|
147
152
|
if (!t || e !== "typescript" && e !== "javascript") return;
|
|
148
153
|
let n = e === "javascript" ? f.languages.typescript.javascriptDefaults : f.languages.typescript.typescriptDefaults, r = typeof n.getDiagnosticsOptions == "function" ? n.getDiagnosticsOptions() : {}, i = new Set(r.diagnosticCodesToIgnore ?? []);
|
|
149
154
|
for (let e of S) i.add(e);
|
|
@@ -152,7 +157,7 @@ function k(e, t) {
|
|
|
152
157
|
diagnosticCodesToIgnore: Array.from(i)
|
|
153
158
|
});
|
|
154
159
|
}
|
|
155
|
-
function
|
|
160
|
+
function F(e) {
|
|
156
161
|
let t = l(null), n = l(null), r = !1, i = null, a = null, s = null, c = null, u = !1;
|
|
157
162
|
function p() {
|
|
158
163
|
return e.variant?.() ?? "editor";
|
|
@@ -166,8 +171,8 @@ function A(e) {
|
|
|
166
171
|
if (u || !e.host.value) return;
|
|
167
172
|
u = !0, g(f);
|
|
168
173
|
let o = e.language(), c = e.preamble?.() ?? "";
|
|
169
|
-
|
|
170
|
-
let l = f.editor.createModel(
|
|
174
|
+
P(o, e.scriptMode?.() ?? !1);
|
|
175
|
+
let l = f.editor.createModel(j(e.initialValue(), c), o, f.Uri.parse(`file:///coar-script-editor/${b()}.${x[o]}`));
|
|
171
176
|
n.value = l;
|
|
172
177
|
let d = e.overflowWidgetsDomNode?.() ?? null, h = f.editor.create(e.host.value, {
|
|
173
178
|
model: l,
|
|
@@ -176,18 +181,22 @@ function A(e) {
|
|
|
176
181
|
minimap: { enabled: e.minimap() },
|
|
177
182
|
automaticLayout: !0,
|
|
178
183
|
scrollBeyondLastLine: !1,
|
|
179
|
-
|
|
184
|
+
fontFamily: C,
|
|
185
|
+
fontSize: w,
|
|
186
|
+
lineHeight: T,
|
|
187
|
+
fontLigatures: E,
|
|
180
188
|
tabSize: 2,
|
|
181
189
|
fixedOverflowWidgets: !0,
|
|
182
|
-
...
|
|
190
|
+
...D[p()],
|
|
191
|
+
...O(p(), e.lineNumbers?.()),
|
|
183
192
|
...d ? { overflowWidgetsDomNode: d } : {}
|
|
184
193
|
});
|
|
185
|
-
t.value = h,
|
|
194
|
+
t.value = h, N(h, c), m();
|
|
186
195
|
let _ = !1;
|
|
187
196
|
i = h.onDidChangeModelContent((n) => {
|
|
188
197
|
let i = e.preamble?.() ?? "";
|
|
189
198
|
if (i && !n.isFlush && !n.isUndoing) {
|
|
190
|
-
let e =
|
|
199
|
+
let e = k(i).length;
|
|
191
200
|
if (n.changes.some((t) => t.rangeOffset < e)) {
|
|
192
201
|
h.trigger("coar-script-editor-preamble", "undo", null);
|
|
193
202
|
return;
|
|
@@ -196,7 +205,7 @@ function A(e) {
|
|
|
196
205
|
r || _ || (_ = !0, queueMicrotask(() => {
|
|
197
206
|
if (_ = !1, !t.value) return;
|
|
198
207
|
let n = h.getValue();
|
|
199
|
-
e.onContentChange(
|
|
208
|
+
e.onContentChange(M(n, e.preamble?.() ?? ""));
|
|
200
209
|
}));
|
|
201
210
|
}), e.onFocused && (a = h.onDidFocusEditorWidget(() => e.onFocused?.())), e.onBlurred && (s = h.onDidBlurEditorWidget(() => e.onBlurred?.())), e.autofocus?.() && queueMicrotask(() => t.value?.focus()), e.onEditorReady?.(h);
|
|
202
211
|
}
|
|
@@ -211,11 +220,11 @@ function A(e) {
|
|
|
211
220
|
function _(n) {
|
|
212
221
|
let i = t.value;
|
|
213
222
|
if (!i) return;
|
|
214
|
-
let a = e.preamble?.() ?? "", o =
|
|
223
|
+
let a = e.preamble?.() ?? "", o = j(n, a);
|
|
215
224
|
if (i.getValue() !== o) {
|
|
216
225
|
r = !0;
|
|
217
226
|
try {
|
|
218
|
-
i.setValue(o),
|
|
227
|
+
i.setValue(o), N(i, a);
|
|
219
228
|
} finally {
|
|
220
229
|
r = !1;
|
|
221
230
|
}
|
|
@@ -232,14 +241,17 @@ function A(e) {
|
|
|
232
241
|
}
|
|
233
242
|
return d(() => e.language(), (t) => {
|
|
234
243
|
let r = n.value;
|
|
235
|
-
r && f.editor.setModelLanguage(r, t),
|
|
236
|
-
}), d(() => e.readonly(), (e) => t.value?.updateOptions({ readOnly: e })), d(() => e.minimap(), (e) => t.value?.updateOptions({ minimap: { enabled: e } })), e.variant && d(() => p(), (
|
|
244
|
+
r && f.editor.setModelLanguage(r, t), P(t, e.scriptMode?.() ?? !1);
|
|
245
|
+
}), d(() => e.readonly(), (e) => t.value?.updateOptions({ readOnly: e })), d(() => e.minimap(), (e) => t.value?.updateOptions({ minimap: { enabled: e } })), e.variant && d(() => p(), (n) => t.value?.updateOptions({
|
|
246
|
+
...D[n],
|
|
247
|
+
...O(n, e.lineNumbers?.())
|
|
248
|
+
})), e.lineNumbers && d(() => e.lineNumbers(), (e) => t.value?.updateOptions(O(p(), e))), e.scriptMode && d(() => e.scriptMode(), (t) => P(e.language(), t)), e.preamble && d(() => e.preamble(), (e, n) => {
|
|
237
249
|
let i = t.value;
|
|
238
250
|
if (!i) return;
|
|
239
|
-
let a =
|
|
251
|
+
let a = j(M(i.getValue(), n ?? ""), e);
|
|
240
252
|
r = !0;
|
|
241
253
|
try {
|
|
242
|
-
i.setValue(a),
|
|
254
|
+
i.setValue(a), N(i, e);
|
|
243
255
|
} finally {
|
|
244
256
|
r = !1;
|
|
245
257
|
}
|
|
@@ -254,7 +266,7 @@ function A(e) {
|
|
|
254
266
|
}
|
|
255
267
|
//#endregion
|
|
256
268
|
//#region src/composables/useExtraLibs.ts
|
|
257
|
-
function
|
|
269
|
+
function I(e) {
|
|
258
270
|
let t = [], n = /* @__PURE__ */ new Set(), r = !1;
|
|
259
271
|
function i() {
|
|
260
272
|
for (; t.length;) t.pop()?.dispose();
|
|
@@ -272,27 +284,32 @@ function j(e) {
|
|
|
272
284
|
}
|
|
273
285
|
//#endregion
|
|
274
286
|
//#region src/constrained/LockedLineScanner.ts
|
|
275
|
-
var
|
|
276
|
-
function
|
|
277
|
-
return
|
|
287
|
+
var L = /\/\/\s*@locked\b/, R = /\/\/\s*@locked\b[^\n]*?@slot:([A-Za-z_][A-Za-z0-9_-]*)/, ee = "// @locked", z = R.source;
|
|
288
|
+
function B(e) {
|
|
289
|
+
return L.test(e);
|
|
278
290
|
}
|
|
279
|
-
function
|
|
291
|
+
function V(e) {
|
|
280
292
|
let t = [], n = e.length, r = 0, i = 0;
|
|
281
293
|
for (let a = 0; a <= n; a++) if (a === n || e[a] === "\n") {
|
|
282
294
|
let o = a, s = o > i && e[o - 1] === "\r" ? o - 1 : o, c = e.slice(i, s);
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
295
|
+
if (L.test(c)) {
|
|
296
|
+
let e = c.match(R);
|
|
297
|
+
t.push({
|
|
298
|
+
lineIndex: r,
|
|
299
|
+
lineStart: i,
|
|
300
|
+
lineEnd: o,
|
|
301
|
+
protectedStart: i,
|
|
302
|
+
protectedEnd: o,
|
|
303
|
+
snapBefore: i === 0 ? null : i - 1,
|
|
304
|
+
snapAfter: o >= n ? null : o + 1,
|
|
305
|
+
...e ? { slotName: e[1] } : {}
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
i = a + 1, r++;
|
|
292
309
|
}
|
|
293
310
|
return t;
|
|
294
311
|
}
|
|
295
|
-
function
|
|
312
|
+
function H(e) {
|
|
296
313
|
if (e.length === 0) return [];
|
|
297
314
|
let t = [...e].sort((e, t) => e.protectedStart - t.protectedStart), n = [], r = {
|
|
298
315
|
start: t[0].protectedStart,
|
|
@@ -311,27 +328,27 @@ function I(e) {
|
|
|
311
328
|
}
|
|
312
329
|
return n.push(r), n;
|
|
313
330
|
}
|
|
314
|
-
function
|
|
331
|
+
function U(e, t) {
|
|
315
332
|
return e.rangeStart <= t.end && e.rangeEnd >= t.start;
|
|
316
333
|
}
|
|
317
|
-
function
|
|
318
|
-
return t.some((t) =>
|
|
334
|
+
function W(e, t) {
|
|
335
|
+
return t.some((t) => U(e, t));
|
|
319
336
|
}
|
|
320
|
-
function
|
|
337
|
+
function G(e, t) {
|
|
321
338
|
for (let n of t) if (e >= n.start && e <= n.end) {
|
|
322
339
|
let t = n.snapBefore, r = n.snapAfter;
|
|
323
340
|
return t == null && r == null ? 0 : t == null ? r : r == null || e - t < r - e ? t : r;
|
|
324
341
|
}
|
|
325
342
|
return e;
|
|
326
343
|
}
|
|
327
|
-
function
|
|
328
|
-
return
|
|
344
|
+
function K(e) {
|
|
345
|
+
return V(e).length;
|
|
329
346
|
}
|
|
330
|
-
function
|
|
331
|
-
return
|
|
347
|
+
function q(e) {
|
|
348
|
+
return Q(e).every((e) => e.trim().length > 0);
|
|
332
349
|
}
|
|
333
|
-
function
|
|
334
|
-
let t =
|
|
350
|
+
function J(e) {
|
|
351
|
+
let t = V(e), n = Q(e), r = [];
|
|
335
352
|
return t.length > 0 && t[0].lineIndex === 0 && r.push("Source starts with a locked line — there is no space above for auto-import or helpers."), t.length > 0 && n.every((e) => e.length === 0) && r.push("Source has locked lines but no editable space between or around them."), {
|
|
336
353
|
ok: r.length === 0,
|
|
337
354
|
lockedLineCount: t.length,
|
|
@@ -339,8 +356,30 @@ function H(e) {
|
|
|
339
356
|
warnings: r
|
|
340
357
|
};
|
|
341
358
|
}
|
|
342
|
-
function
|
|
343
|
-
let t =
|
|
359
|
+
function Y(e) {
|
|
360
|
+
let t = e.split("\n"), n = 0, r = t.length;
|
|
361
|
+
for (; n < r && t[n].trim() === "";) n++;
|
|
362
|
+
for (; r > n && t[r - 1].trim() === "";) r--;
|
|
363
|
+
return t.slice(n, r).join("\n");
|
|
364
|
+
}
|
|
365
|
+
function X(e) {
|
|
366
|
+
let t = V(e);
|
|
367
|
+
if (t.length === 0) return {};
|
|
368
|
+
let n = e.split("\n"), r = {};
|
|
369
|
+
for (let e = 0; e < t.length; e++) {
|
|
370
|
+
let i = t[e];
|
|
371
|
+
if (!i.slotName || Object.prototype.hasOwnProperty.call(r, i.slotName)) continue;
|
|
372
|
+
let a = i.lineIndex + 1, o = t[e + 1], s = o ? o.lineIndex : n.length, c = n.slice(a, s).join("\n");
|
|
373
|
+
r[i.slotName] = Y(c);
|
|
374
|
+
}
|
|
375
|
+
return r;
|
|
376
|
+
}
|
|
377
|
+
function Z(e, t) {
|
|
378
|
+
let n = X(e);
|
|
379
|
+
return Object.prototype.hasOwnProperty.call(n, t) ? n[t] : void 0;
|
|
380
|
+
}
|
|
381
|
+
function Q(e) {
|
|
382
|
+
let t = V(e);
|
|
344
383
|
if (t.length === 0) return [e];
|
|
345
384
|
let n = new Set(t.map((e) => e.lineIndex)), r = e.split("\n"), i = [], a = [];
|
|
346
385
|
for (let e = 0; e < r.length; e++) n.has(e) ? a.length > 0 || i.length === 0 ? (i.push(a.join("\n")), a = []) : i.push("") : a.push(r[e]);
|
|
@@ -348,7 +387,7 @@ function U(e) {
|
|
|
348
387
|
}
|
|
349
388
|
//#endregion
|
|
350
389
|
//#region src/constrained/ChangeGuard.ts
|
|
351
|
-
var
|
|
390
|
+
var te = class {
|
|
352
391
|
disposables = [];
|
|
353
392
|
lockedLines;
|
|
354
393
|
protectedRanges;
|
|
@@ -356,7 +395,7 @@ var W = class {
|
|
|
356
395
|
this.editor = e, this.authoring = t, this.callbacks = n;
|
|
357
396
|
let r = e.getModel();
|
|
358
397
|
if (!r) throw Error("ChangeGuard requires the editor to have an attached model");
|
|
359
|
-
this.lockedLines =
|
|
398
|
+
this.lockedLines = V(r.getValue()), this.protectedRanges = H(this.lockedLines), this.disposables.push(r.onDidChangeContent((e) => this.handleChange(e)));
|
|
360
399
|
}
|
|
361
400
|
dispose() {
|
|
362
401
|
for (; this.disposables.length;) this.disposables.pop()?.dispose();
|
|
@@ -369,14 +408,14 @@ var W = class {
|
|
|
369
408
|
}
|
|
370
409
|
refresh() {
|
|
371
410
|
let e = this.editor.getModel();
|
|
372
|
-
e && (this.lockedLines =
|
|
411
|
+
e && (this.lockedLines = V(e.getValue()), this.protectedRanges = H(this.lockedLines), this.callbacks.onLinesUpdated?.(this.lockedLines));
|
|
373
412
|
}
|
|
374
413
|
handleChange(e) {
|
|
375
414
|
let t = this.editor.getModel();
|
|
376
415
|
if (!t) return;
|
|
377
416
|
let n = e.isFlush || e.isUndoing || this.authoring();
|
|
378
417
|
if (e.isFlush && t.pushStackElement(), !n) {
|
|
379
|
-
let t = e.changes.find((e) =>
|
|
418
|
+
let t = e.changes.find((e) => W({
|
|
380
419
|
rangeStart: e.rangeOffset,
|
|
381
420
|
rangeEnd: e.rangeOffset + e.rangeLength
|
|
382
421
|
}, this.protectedRanges));
|
|
@@ -391,9 +430,9 @@ var W = class {
|
|
|
391
430
|
return;
|
|
392
431
|
}
|
|
393
432
|
}
|
|
394
|
-
this.lockedLines =
|
|
433
|
+
this.lockedLines = V(t.getValue()), this.protectedRanges = H(this.lockedLines), this.callbacks.onLinesUpdated?.(this.lockedLines), this.callbacks.onContentChanged?.(t.getValue());
|
|
395
434
|
}
|
|
396
|
-
},
|
|
435
|
+
}, ne = class {
|
|
397
436
|
disposables = [];
|
|
398
437
|
correcting = !1;
|
|
399
438
|
constructor(e, t, n) {
|
|
@@ -415,7 +454,7 @@ var W = class {
|
|
|
415
454
|
if (n.length === 0) return;
|
|
416
455
|
let r = t[0].constructor, i = [], a = !1;
|
|
417
456
|
for (let o of t) {
|
|
418
|
-
let t = e.getOffsetAt(o.getStartPosition()), s = e.getOffsetAt(o.getEndPosition()), c =
|
|
457
|
+
let t = e.getOffsetAt(o.getStartPosition()), s = e.getOffsetAt(o.getEndPosition()), c = G(t, n), l = G(s, n);
|
|
419
458
|
if (c === t && l === s) {
|
|
420
459
|
i.push(o);
|
|
421
460
|
continue;
|
|
@@ -432,7 +471,7 @@ var W = class {
|
|
|
432
471
|
}
|
|
433
472
|
}
|
|
434
473
|
}
|
|
435
|
-
},
|
|
474
|
+
}, re = class {
|
|
436
475
|
disposables = [];
|
|
437
476
|
filtering = !1;
|
|
438
477
|
constructor(e, t) {
|
|
@@ -453,7 +492,7 @@ var W = class {
|
|
|
453
492
|
if (this.authoring()) return;
|
|
454
493
|
let e = this.editor.getModel();
|
|
455
494
|
if (!e) return;
|
|
456
|
-
let t = e.getValue(), n = new Set(
|
|
495
|
+
let t = e.getValue(), n = new Set(V(t).map((e) => e.lineIndex + 1));
|
|
457
496
|
if (n.size === 0) return;
|
|
458
497
|
let r = f.editor.getModelMarkers({ resource: e.uri });
|
|
459
498
|
if (r.length === 0) return;
|
|
@@ -487,8 +526,8 @@ var W = class {
|
|
|
487
526
|
this.filtering = !1;
|
|
488
527
|
}
|
|
489
528
|
}
|
|
490
|
-
},
|
|
491
|
-
function
|
|
529
|
+
}, ie = "coar-script-editor-locked-line", ae = "coar-script-editor-locked-marker", oe = /\/\/\s*@locked\b/g;
|
|
530
|
+
function $(e) {
|
|
492
531
|
let t = null, n = null, r = null, i = null;
|
|
493
532
|
function a() {
|
|
494
533
|
t?.dispose(), t = null, n?.dispose(), n = null, r?.dispose(), r = null, i?.clear(), i = null;
|
|
@@ -507,12 +546,12 @@ function X(e) {
|
|
|
507
546
|
endColumn: i + 1
|
|
508
547
|
},
|
|
509
548
|
options: {
|
|
510
|
-
className:
|
|
549
|
+
className: ie,
|
|
511
550
|
isWholeLine: !0,
|
|
512
551
|
stickiness: 1
|
|
513
552
|
}
|
|
514
553
|
});
|
|
515
|
-
let a = n.getLineContent(t), o = new RegExp(
|
|
554
|
+
let a = n.getLineContent(t), o = new RegExp(oe.source, "g"), s;
|
|
516
555
|
for (; (s = o.exec(a)) !== null;) r.push({
|
|
517
556
|
range: {
|
|
518
557
|
startLineNumber: t,
|
|
@@ -521,7 +560,7 @@ function X(e) {
|
|
|
521
560
|
endColumn: s.index + s[0].length + 1
|
|
522
561
|
},
|
|
523
562
|
options: {
|
|
524
|
-
inlineClassName:
|
|
563
|
+
inlineClassName: ae,
|
|
525
564
|
stickiness: 1,
|
|
526
565
|
hoverMessage: { value: "Locked line marker" }
|
|
527
566
|
}
|
|
@@ -534,14 +573,14 @@ function X(e) {
|
|
|
534
573
|
formatOnType: !1,
|
|
535
574
|
formatOnPaste: !1,
|
|
536
575
|
linkedEditing: !1
|
|
537
|
-
}), t = new
|
|
576
|
+
}), t = new te(i, e.authoring, {
|
|
538
577
|
onReject: e.onReject,
|
|
539
578
|
onLinesUpdated: (e) => {
|
|
540
579
|
s(i, e), r?.refresh();
|
|
541
580
|
}
|
|
542
|
-
}), n = new
|
|
581
|
+
}), n = new ne(i, () => t?.getProtectedRanges() ?? [], e.authoring), r = new re(i, e.authoring), s(i, t.getLockedLines()), n.snapCurrent();
|
|
543
582
|
}
|
|
544
|
-
d([e.editor, () =>
|
|
583
|
+
d([e.editor, () => B(e.value())], ([e, n]) => {
|
|
545
584
|
if (!e) {
|
|
546
585
|
a();
|
|
547
586
|
return;
|
|
@@ -560,13 +599,13 @@ function X(e) {
|
|
|
560
599
|
}
|
|
561
600
|
//#endregion
|
|
562
601
|
//#region src/composables/useFormFieldContext.ts
|
|
563
|
-
var
|
|
564
|
-
function
|
|
565
|
-
return r(
|
|
602
|
+
var se = Symbol.for("coar:form-field");
|
|
603
|
+
function ce() {
|
|
604
|
+
return r(se, void 0);
|
|
566
605
|
}
|
|
567
606
|
//#endregion
|
|
568
607
|
//#region src/CoarScriptEditor.vue?vue&type=script&setup=true&lang.ts
|
|
569
|
-
var
|
|
608
|
+
var le = [
|
|
570
609
|
"id",
|
|
571
610
|
"aria-invalid",
|
|
572
611
|
"aria-describedby",
|
|
@@ -574,7 +613,7 @@ var $ = [
|
|
|
574
613
|
"aria-required",
|
|
575
614
|
"data-placeholder",
|
|
576
615
|
"data-name"
|
|
577
|
-
],
|
|
616
|
+
], ue = /* @__PURE__ */ n({
|
|
578
617
|
__name: "CoarScriptEditor",
|
|
579
618
|
props: {
|
|
580
619
|
modelValue: { default: "" },
|
|
@@ -608,6 +647,10 @@ var $ = [
|
|
|
608
647
|
name: { default: "" },
|
|
609
648
|
height: { default: void 0 },
|
|
610
649
|
variant: { default: "editor" },
|
|
650
|
+
lineNumbers: {
|
|
651
|
+
type: Boolean,
|
|
652
|
+
default: void 0
|
|
653
|
+
},
|
|
611
654
|
scriptMode: {
|
|
612
655
|
type: Boolean,
|
|
613
656
|
default: !1
|
|
@@ -628,7 +671,7 @@ var $ = [
|
|
|
628
671
|
"blurred"
|
|
629
672
|
],
|
|
630
673
|
setup(n, { expose: r, emit: o }) {
|
|
631
|
-
let l = n, f = o, p = c(null), m = l.modelValue, h =
|
|
674
|
+
let l = n, f = o, p = c(null), m = l.modelValue, h = ce(), g = `coar-script-editor-${u()}`, _ = e(() => l.id || h?.inputId.value || g), v = e(() => l.error || (h?.hasError.value ?? !1)), y = e(() => h?.messageId.value), b = e(() => l.disabled || (h?.disabled.value ?? !1)), x = c(!1), S = c(l.modelValue.length === 0), C = e(() => ({
|
|
632
675
|
"coar-script-editor": !0,
|
|
633
676
|
"coar-script-editor--authoring": l.authoring,
|
|
634
677
|
"coar-script-editor--inline": l.variant === "inline",
|
|
@@ -638,7 +681,7 @@ var $ = [
|
|
|
638
681
|
})), w = e(() => l.height === void 0 || l.height === "" ? {} : {
|
|
639
682
|
height: typeof l.height == "number" ? `${l.height}px` : l.height,
|
|
640
683
|
minHeight: "0"
|
|
641
|
-
}), { editor: T, model: E, setValue: D } =
|
|
684
|
+
}), { editor: T, model: E, setValue: D } = F({
|
|
642
685
|
host: p,
|
|
643
686
|
initialValue: () => l.modelValue,
|
|
644
687
|
language: () => l.language,
|
|
@@ -646,6 +689,7 @@ var $ = [
|
|
|
646
689
|
minimap: () => l.minimap,
|
|
647
690
|
theme: () => l.theme,
|
|
648
691
|
variant: () => l.variant,
|
|
692
|
+
lineNumbers: () => l.lineNumbers,
|
|
649
693
|
preamble: () => l.preamble,
|
|
650
694
|
scriptMode: () => l.scriptMode,
|
|
651
695
|
autofocus: () => l.autofocus,
|
|
@@ -660,10 +704,10 @@ var $ = [
|
|
|
660
704
|
x.value = !1, f("blurred");
|
|
661
705
|
}
|
|
662
706
|
});
|
|
663
|
-
return
|
|
707
|
+
return I({
|
|
664
708
|
language: () => l.language,
|
|
665
709
|
libs: () => l.extraLibs
|
|
666
|
-
}),
|
|
710
|
+
}), $({
|
|
667
711
|
editor: T,
|
|
668
712
|
value: () => l.modelValue,
|
|
669
713
|
authoring: () => l.authoring,
|
|
@@ -686,8 +730,8 @@ var $ = [
|
|
|
686
730
|
"aria-required": n.required ? "true" : void 0,
|
|
687
731
|
"data-placeholder": n.placeholder || void 0,
|
|
688
732
|
"data-name": n.name || void 0
|
|
689
|
-
}, null, 14,
|
|
733
|
+
}, null, 14, le));
|
|
690
734
|
}
|
|
691
735
|
});
|
|
692
736
|
//#endregion
|
|
693
|
-
export { m as COAR_THEME_DARK, p as COAR_THEME_LIGHT,
|
|
737
|
+
export { m as COAR_THEME_DARK, p as COAR_THEME_LIGHT, ue as CoarScriptEditor, ee as LOCKED_MARKER_TEXT, z as SLOT_MARKER_PATTERN, H as computeProtectedRanges, K as countLockedLines, _ as detectAutoTheme, W as editIsProtected, g as ensureCoarThemes, Q as getEditableSegments, Z as getSlot, X as getSlots, B as hasLockedMarkers, q as isEverySegmentNonEmpty, U as overlapsProtectedRange, V as scanLockedLines, G as snapOffsetAwayFromLocked, J as validateSource, y as watchAutoTheme };
|
package/package.json
CHANGED