@aiao/code-editor-vue 0.0.22 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1 -1
- package/dist/index.js +73 -155
- package/package.json +2 -2
package/dist/index.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.aiao-code-editor[data-v-
|
|
1
|
+
.aiao-code-editor[data-v-64632146]{width:100%;height:100%;font-size:.875rem;display:block;overflow:hidden}.aiao-code-editor[data-v-64632146] .cm-editor{height:100%}.aiao-code-editor[data-v-64632146] .cm-scroller{overflow:auto}
|
|
2
2
|
/*$vite$:1*/
|
package/dist/index.js
CHANGED
|
@@ -6,79 +6,47 @@ import { Annotation as m, Compartment as h, EditorState as g } from "@codemirror
|
|
|
6
6
|
import { oneDark as _ } from "@codemirror/theme-one-dark";
|
|
7
7
|
import { EditorView as v, highlightWhitespace as y, keymap as b, placeholder as x } from "@codemirror/view";
|
|
8
8
|
import { basicSetup as S, minimalSetup as C } from "codemirror";
|
|
9
|
-
//#
|
|
10
|
-
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/CodeEditor.vue
|
|
11
|
+
var w = /*#__PURE__*/ ((e, t) => {
|
|
12
|
+
let n = e.__vccOpts || e;
|
|
13
|
+
for (let [e, r] of t) n[e] = r;
|
|
14
|
+
return n;
|
|
15
|
+
})(/* @__PURE__ */ n({
|
|
11
16
|
__name: "CodeEditor",
|
|
12
17
|
props: {
|
|
13
18
|
autoFocus: {
|
|
14
19
|
type: Boolean,
|
|
15
|
-
required: !1,
|
|
16
20
|
default: !1
|
|
17
21
|
},
|
|
18
22
|
disabled: {
|
|
19
23
|
type: Boolean,
|
|
20
|
-
required: !1,
|
|
21
24
|
default: !1
|
|
22
25
|
},
|
|
23
26
|
highlightWhitespace: {
|
|
24
27
|
type: Boolean,
|
|
25
|
-
required: !1,
|
|
26
28
|
default: !1
|
|
27
29
|
},
|
|
28
|
-
indentUnit: {
|
|
29
|
-
type: String,
|
|
30
|
-
required: !1,
|
|
31
|
-
default: " "
|
|
32
|
-
},
|
|
30
|
+
indentUnit: { default: " " },
|
|
33
31
|
indentWithTab: {
|
|
34
32
|
type: Boolean,
|
|
35
|
-
required: !1,
|
|
36
33
|
default: !1
|
|
37
34
|
},
|
|
38
|
-
language: {
|
|
39
|
-
|
|
40
|
-
required: !1,
|
|
41
|
-
default: "sql"
|
|
42
|
-
},
|
|
43
|
-
languages: {
|
|
44
|
-
type: Array,
|
|
45
|
-
required: !1,
|
|
46
|
-
default: () => u
|
|
47
|
-
},
|
|
35
|
+
language: { default: "sql" },
|
|
36
|
+
languages: { default: () => u },
|
|
48
37
|
lineWrapping: {
|
|
49
38
|
type: Boolean,
|
|
50
|
-
required: !1,
|
|
51
39
|
default: !1
|
|
52
40
|
},
|
|
53
|
-
placeholder: {
|
|
54
|
-
type: String,
|
|
55
|
-
required: !1,
|
|
56
|
-
default: ""
|
|
57
|
-
},
|
|
41
|
+
placeholder: { default: "" },
|
|
58
42
|
readonly: {
|
|
59
43
|
type: Boolean,
|
|
60
|
-
required: !1,
|
|
61
44
|
default: !1
|
|
62
45
|
},
|
|
63
|
-
root: {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
setup: {
|
|
68
|
-
type: [String, null],
|
|
69
|
-
required: !1,
|
|
70
|
-
default: "basic"
|
|
71
|
-
},
|
|
72
|
-
theme: {
|
|
73
|
-
type: String,
|
|
74
|
-
required: !1,
|
|
75
|
-
default: "light"
|
|
76
|
-
},
|
|
77
|
-
value: {
|
|
78
|
-
type: String,
|
|
79
|
-
required: !1,
|
|
80
|
-
default: ""
|
|
81
|
-
}
|
|
46
|
+
root: {},
|
|
47
|
+
setup: { default: "basic" },
|
|
48
|
+
theme: { default: "light" },
|
|
49
|
+
value: { default: "" }
|
|
82
50
|
},
|
|
83
51
|
emits: [
|
|
84
52
|
"blur",
|
|
@@ -86,26 +54,23 @@ var w = /*@__PURE__*/ n({
|
|
|
86
54
|
"focus",
|
|
87
55
|
"update:value"
|
|
88
56
|
],
|
|
89
|
-
setup(
|
|
90
|
-
n()
|
|
91
|
-
|
|
92
|
-
"aria-disabled": o.disabled || void 0,
|
|
57
|
+
setup(n, { emit: u }) {
|
|
58
|
+
let w = n, T = u, E = s(null), D = c(null), O = e(() => ({
|
|
59
|
+
"aria-disabled": w.disabled || void 0,
|
|
93
60
|
class: "aiao-code-editor"
|
|
94
|
-
})),
|
|
61
|
+
})), k = new h(), A = new h(), j = new h(), M = new h(), N = new h(), P = new h(), F = new h(), I = new h(), L = new h(), R = new h(), z = m.define(), B = {
|
|
95
62
|
basic: S,
|
|
96
63
|
minimal: C
|
|
97
|
-
},
|
|
64
|
+
}, V = 0;
|
|
98
65
|
i(() => {
|
|
99
|
-
let e =
|
|
66
|
+
let e = E.value;
|
|
100
67
|
if (!e) return;
|
|
101
68
|
let t = new v({
|
|
102
69
|
parent: e,
|
|
103
70
|
state: g.create({
|
|
104
|
-
doc:
|
|
71
|
+
doc: w.value,
|
|
105
72
|
extensions: [
|
|
106
|
-
|
|
107
|
-
O.of([]),
|
|
108
|
-
k.of([]),
|
|
73
|
+
k.of(U()),
|
|
109
74
|
A.of([]),
|
|
110
75
|
j.of([]),
|
|
111
76
|
M.of([]),
|
|
@@ -113,139 +78,92 @@ var w = /*@__PURE__*/ n({
|
|
|
113
78
|
P.of([]),
|
|
114
79
|
F.of([]),
|
|
115
80
|
I.of([]),
|
|
81
|
+
L.of([]),
|
|
82
|
+
R.of([]),
|
|
116
83
|
v.domEventObservers({
|
|
117
|
-
blur: () =>
|
|
118
|
-
focus: () =>
|
|
84
|
+
blur: () => T("blur"),
|
|
85
|
+
focus: () => T("focus")
|
|
119
86
|
}),
|
|
120
87
|
v.updateListener.of((e) => {
|
|
121
|
-
let t = e.transactions.some((e) => e.annotation(
|
|
88
|
+
let t = e.transactions.some((e) => e.annotation(z));
|
|
122
89
|
if (!e.docChanged || t) return;
|
|
123
90
|
let n = e.state.doc.toString();
|
|
124
|
-
|
|
91
|
+
T("update:value", n), T("change", n);
|
|
125
92
|
})
|
|
126
93
|
]
|
|
127
94
|
}),
|
|
128
|
-
...
|
|
95
|
+
...w.root ? { root: w.root } : {}
|
|
129
96
|
});
|
|
130
|
-
|
|
97
|
+
D.value = t, W(), G(), q(), J(), Y(), X(), Z(), w.autoFocus && t.focus();
|
|
131
98
|
}), a(() => {
|
|
132
|
-
|
|
133
|
-
let e =
|
|
134
|
-
|
|
135
|
-
}), l(() =>
|
|
136
|
-
let t =
|
|
99
|
+
V += 1;
|
|
100
|
+
let e = D.value;
|
|
101
|
+
D.value = null, e?.destroy();
|
|
102
|
+
}), l(() => w.value, (e) => {
|
|
103
|
+
let t = D.value;
|
|
137
104
|
!t || t.state.doc.toString() === e || t.dispatch({
|
|
138
|
-
annotations:
|
|
105
|
+
annotations: z.of(!0),
|
|
139
106
|
changes: {
|
|
140
107
|
from: 0,
|
|
141
108
|
insert: e,
|
|
142
109
|
to: t.state.doc.length
|
|
143
110
|
}
|
|
144
111
|
});
|
|
145
|
-
}), l(() =>
|
|
146
|
-
function B() {
|
|
147
|
-
T.value?.dispatch({ effects: D.reconfigure(V()) });
|
|
148
|
-
}
|
|
149
|
-
function V() {
|
|
150
|
-
return o.setup === null ? [] : R[o.setup];
|
|
151
|
-
}
|
|
112
|
+
}), l(() => w.setup, H), l(() => w.theme, W), l([() => w.language, () => w.languages], G), l([() => w.readonly, () => w.disabled], q), l(() => w.placeholder, J), l([() => w.indentWithTab, () => w.indentUnit], Y), l(() => w.lineWrapping, X), l(() => w.highlightWhitespace, Z);
|
|
152
113
|
function H() {
|
|
153
|
-
|
|
114
|
+
D.value?.dispatch({ effects: k.reconfigure(U()) });
|
|
154
115
|
}
|
|
155
116
|
function U() {
|
|
156
|
-
|
|
117
|
+
return w.setup === null ? [] : B[w.setup];
|
|
118
|
+
}
|
|
119
|
+
function W() {
|
|
120
|
+
D.value?.dispatch({ effects: j.reconfigure(w.theme === "dark" ? _ : []) });
|
|
121
|
+
}
|
|
122
|
+
function G() {
|
|
123
|
+
let e = ++V, t = D.value;
|
|
157
124
|
if (!t) return;
|
|
158
|
-
let n =
|
|
159
|
-
if (!n || n === "plaintext" ||
|
|
160
|
-
t.dispatch({ effects:
|
|
125
|
+
let n = w.language;
|
|
126
|
+
if (!n || n === "plaintext" || w.languages.length === 0) {
|
|
127
|
+
t.dispatch({ effects: A.reconfigure([]) });
|
|
161
128
|
return;
|
|
162
129
|
}
|
|
163
|
-
let r = d(n,
|
|
130
|
+
let r = d(n, w.languages);
|
|
164
131
|
if (!r) {
|
|
165
|
-
console.error(`[CodeEditor] Language '${n}' not found.`), t.dispatch({ effects:
|
|
132
|
+
console.error(`[CodeEditor] Language '${n}' not found.`), t.dispatch({ effects: A.reconfigure([]) });
|
|
166
133
|
return;
|
|
167
134
|
}
|
|
168
135
|
r.load().then((n) => {
|
|
169
|
-
|
|
136
|
+
K(e, t) && t.dispatch({ effects: A.reconfigure(n.extension) });
|
|
170
137
|
}, (r) => {
|
|
171
|
-
|
|
138
|
+
K(e, t) && (console.error(`[CodeEditor] Failed to load language '${n}':`, r), t.dispatch({ effects: A.reconfigure([]) }));
|
|
172
139
|
});
|
|
173
140
|
}
|
|
174
|
-
function
|
|
175
|
-
return e ===
|
|
176
|
-
}
|
|
177
|
-
function G() {
|
|
178
|
-
let e = T.value;
|
|
179
|
-
if (!e) return;
|
|
180
|
-
let t = o.readonly || o.disabled;
|
|
181
|
-
e.dispatch({ effects: [A.reconfigure(g.readOnly.of(t)), j.reconfigure(v.editable.of(!t))] });
|
|
182
|
-
}
|
|
183
|
-
function K() {
|
|
184
|
-
T.value?.dispatch({ effects: M.reconfigure(o.placeholder ? x(o.placeholder) : []) });
|
|
141
|
+
function K(e, t) {
|
|
142
|
+
return e === V && D.value === t;
|
|
185
143
|
}
|
|
186
144
|
function q() {
|
|
187
|
-
|
|
145
|
+
let e = D.value;
|
|
146
|
+
if (!e) return;
|
|
147
|
+
let t = w.readonly || w.disabled;
|
|
148
|
+
e.dispatch({ effects: [M.reconfigure(g.readOnly.of(t)), N.reconfigure(v.editable.of(!t))] });
|
|
188
149
|
}
|
|
189
150
|
function J() {
|
|
190
|
-
|
|
151
|
+
D.value?.dispatch({ effects: P.reconfigure(w.placeholder ? x(w.placeholder) : []) });
|
|
191
152
|
}
|
|
192
153
|
function Y() {
|
|
193
|
-
|
|
154
|
+
D.value?.dispatch({ effects: [F.reconfigure(w.indentWithTab ? b.of([f]) : []), I.reconfigure(w.indentUnit ? p.of(w.indentUnit) : [])] });
|
|
194
155
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
editableConf: j,
|
|
206
|
-
placeholderConf: M,
|
|
207
|
-
indentWithTabConf: N,
|
|
208
|
-
indentUnitConf: P,
|
|
209
|
-
lineWrappingConf: F,
|
|
210
|
-
highlightWhitespaceConf: I,
|
|
211
|
-
External: L,
|
|
212
|
-
setupExtensions: R,
|
|
213
|
-
get languageRequest() {
|
|
214
|
-
return z;
|
|
215
|
-
},
|
|
216
|
-
set languageRequest(e) {
|
|
217
|
-
z = e;
|
|
218
|
-
},
|
|
219
|
-
updateSetup: B,
|
|
220
|
-
getSetupExtension: V,
|
|
221
|
-
updateTheme: H,
|
|
222
|
-
updateLanguage: U,
|
|
223
|
-
isCurrentLanguageRequest: W,
|
|
224
|
-
updateReadonly: G,
|
|
225
|
-
updatePlaceholder: K,
|
|
226
|
-
updateIndent: q,
|
|
227
|
-
updateLineWrapping: J,
|
|
228
|
-
updateHighlightWhitespace: Y
|
|
229
|
-
};
|
|
230
|
-
return Object.defineProperty(X, "__isScriptSetup", {
|
|
231
|
-
enumerable: !1,
|
|
232
|
-
value: !0
|
|
233
|
-
}), X;
|
|
156
|
+
function X() {
|
|
157
|
+
D.value?.dispatch({ effects: L.reconfigure(w.lineWrapping ? v.lineWrapping : []) });
|
|
158
|
+
}
|
|
159
|
+
function Z() {
|
|
160
|
+
D.value?.dispatch({ effects: R.reconfigure(w.highlightWhitespace ? y() : []) });
|
|
161
|
+
}
|
|
162
|
+
return (e, n) => (o(), t("div", r(O.value, {
|
|
163
|
+
ref_key: "editorRef",
|
|
164
|
+
ref: E
|
|
165
|
+
}), null, 16));
|
|
234
166
|
}
|
|
235
|
-
}),
|
|
236
|
-
let n = e.__vccOpts || e;
|
|
237
|
-
for (let [e, r] of t) n[e] = r;
|
|
238
|
-
return n;
|
|
239
|
-
};
|
|
240
|
-
//#endregion
|
|
241
|
-
//#region src/CodeEditor.vue
|
|
242
|
-
function E(e, n, i, a, s, c) {
|
|
243
|
-
return o(), t("div", r(a.hostAttributes, { ref: "editorRef" }), null, 16);
|
|
244
|
-
}
|
|
245
|
-
var D = /*#__PURE__*/ T(w, [
|
|
246
|
-
["render", E],
|
|
247
|
-
["__scopeId", "data-v-9b1829ca"],
|
|
248
|
-
["__file", "/private/tmp/aiao-release-027.kcmOWl/aiao/packages/code-editor-vue/src/CodeEditor.vue"]
|
|
249
|
-
]);
|
|
167
|
+
}), [["__scopeId", "data-v-64632146"]]);
|
|
250
168
|
//#endregion
|
|
251
|
-
export {
|
|
169
|
+
export { w as CodeEditor };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiao/code-editor-vue",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
"@codemirror/theme-one-dark": "^6.1.3",
|
|
40
40
|
"@codemirror/view": "^6.43.5",
|
|
41
41
|
"codemirror": "^6.0.1",
|
|
42
|
-
"@aiao/code-editor": "0.0.
|
|
42
|
+
"@aiao/code-editor": "0.0.23"
|
|
43
43
|
}
|
|
44
44
|
}
|