@aiao/code-editor-vue 0.0.21 → 0.0.22

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 CHANGED
@@ -1,2 +1,2 @@
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}
1
+ .aiao-code-editor[data-v-9b1829ca]{width:100%;height:100%;font-size:.875rem;display:block;overflow:hidden}.aiao-code-editor[data-v-9b1829ca] .cm-editor{height:100%}.aiao-code-editor[data-v-9b1829ca] .cm-scroller{overflow:auto}
2
2
  /*$vite$:1*/
package/dist/index.js CHANGED
@@ -6,47 +6,79 @@ 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
- //#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({
9
+ //#region src/CodeEditor.vue?vue&type=script&setup=true&lang.ts
10
+ var w = /*@__PURE__*/ n({
16
11
  __name: "CodeEditor",
17
12
  props: {
18
13
  autoFocus: {
19
14
  type: Boolean,
15
+ required: !1,
20
16
  default: !1
21
17
  },
22
18
  disabled: {
23
19
  type: Boolean,
20
+ required: !1,
24
21
  default: !1
25
22
  },
26
23
  highlightWhitespace: {
27
24
  type: Boolean,
25
+ required: !1,
28
26
  default: !1
29
27
  },
30
- indentUnit: { default: " " },
28
+ indentUnit: {
29
+ type: String,
30
+ required: !1,
31
+ default: " "
32
+ },
31
33
  indentWithTab: {
32
34
  type: Boolean,
35
+ required: !1,
33
36
  default: !1
34
37
  },
35
- language: { default: "sql" },
36
- languages: { default: () => u },
38
+ language: {
39
+ type: String,
40
+ required: !1,
41
+ default: "sql"
42
+ },
43
+ languages: {
44
+ type: Array,
45
+ required: !1,
46
+ default: () => u
47
+ },
37
48
  lineWrapping: {
38
49
  type: Boolean,
50
+ required: !1,
39
51
  default: !1
40
52
  },
41
- placeholder: { default: "" },
53
+ placeholder: {
54
+ type: String,
55
+ required: !1,
56
+ default: ""
57
+ },
42
58
  readonly: {
43
59
  type: Boolean,
60
+ required: !1,
44
61
  default: !1
45
62
  },
46
- root: {},
47
- setup: { default: "basic" },
48
- theme: { default: "light" },
49
- value: { default: "" }
63
+ root: {
64
+ type: null,
65
+ required: !1
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
+ }
50
82
  },
51
83
  emits: [
52
84
  "blur",
@@ -54,23 +86,26 @@ var w = /*#__PURE__*/ ((e, t) => {
54
86
  "focus",
55
87
  "update:value"
56
88
  ],
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,
89
+ setup(t, { expose: n, emit: r }) {
90
+ n();
91
+ let o = t, u = r, w = s(null), T = c(null), E = e(() => ({
92
+ "aria-disabled": o.disabled || void 0,
60
93
  class: "aiao-code-editor"
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 = {
94
+ })), D = new h(), O = new h(), 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 = m.define(), R = {
62
95
  basic: S,
63
96
  minimal: C
64
- }, V = 0;
97
+ }, z = 0;
65
98
  i(() => {
66
- let e = E.value;
99
+ let e = w.value;
67
100
  if (!e) return;
68
101
  let t = new v({
69
102
  parent: e,
70
103
  state: g.create({
71
- doc: w.value,
104
+ doc: o.value,
72
105
  extensions: [
73
- k.of(U()),
106
+ D.of(V()),
107
+ O.of([]),
108
+ k.of([]),
74
109
  A.of([]),
75
110
  j.of([]),
76
111
  M.of([]),
@@ -78,92 +113,139 @@ var w = /*#__PURE__*/ ((e, t) => {
78
113
  P.of([]),
79
114
  F.of([]),
80
115
  I.of([]),
81
- L.of([]),
82
- R.of([]),
83
116
  v.domEventObservers({
84
- blur: () => T("blur"),
85
- focus: () => T("focus")
117
+ blur: () => u("blur"),
118
+ focus: () => u("focus")
86
119
  }),
87
120
  v.updateListener.of((e) => {
88
- let t = e.transactions.some((e) => e.annotation(z));
121
+ let t = e.transactions.some((e) => e.annotation(L));
89
122
  if (!e.docChanged || t) return;
90
123
  let n = e.state.doc.toString();
91
- T("update:value", n), T("change", n);
124
+ u("update:value", n), u("change", n);
92
125
  })
93
126
  ]
94
127
  }),
95
- ...w.root ? { root: w.root } : {}
128
+ ...o.root ? { root: o.root } : {}
96
129
  });
97
- D.value = t, W(), G(), q(), J(), Y(), X(), Z(), w.autoFocus && t.focus();
130
+ T.value = t, H(), U(), G(), K(), q(), J(), Y(), o.autoFocus && t.focus();
98
131
  }), a(() => {
99
- V += 1;
100
- let e = D.value;
101
- D.value = null, e?.destroy();
102
- }), l(() => w.value, (e) => {
103
- let t = D.value;
132
+ z += 1;
133
+ let e = T.value;
134
+ T.value = null, e?.destroy();
135
+ }), l(() => o.value, (e) => {
136
+ let t = T.value;
104
137
  !t || t.state.doc.toString() === e || t.dispatch({
105
- annotations: z.of(!0),
138
+ annotations: L.of(!0),
106
139
  changes: {
107
140
  from: 0,
108
141
  insert: e,
109
142
  to: t.state.doc.length
110
143
  }
111
144
  });
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);
113
- function H() {
114
- D.value?.dispatch({ effects: k.reconfigure(U()) });
145
+ }), l(() => o.setup, B), l(() => o.theme, H), l([() => o.language, () => o.languages], U), l([() => o.readonly, () => o.disabled], G), l(() => o.placeholder, K), l([() => o.indentWithTab, () => o.indentUnit], q), l(() => o.lineWrapping, J), l(() => o.highlightWhitespace, Y);
146
+ function B() {
147
+ T.value?.dispatch({ effects: D.reconfigure(V()) });
115
148
  }
116
- function U() {
117
- return w.setup === null ? [] : B[w.setup];
149
+ function V() {
150
+ return o.setup === null ? [] : R[o.setup];
118
151
  }
119
- function W() {
120
- D.value?.dispatch({ effects: j.reconfigure(w.theme === "dark" ? _ : []) });
152
+ function H() {
153
+ T.value?.dispatch({ effects: k.reconfigure(o.theme === "dark" ? _ : []) });
121
154
  }
122
- function G() {
123
- let e = ++V, t = D.value;
155
+ function U() {
156
+ let e = ++z, t = T.value;
124
157
  if (!t) return;
125
- let n = w.language;
126
- if (!n || n === "plaintext" || w.languages.length === 0) {
127
- t.dispatch({ effects: A.reconfigure([]) });
158
+ let n = o.language;
159
+ if (!n || n === "plaintext" || o.languages.length === 0) {
160
+ t.dispatch({ effects: O.reconfigure([]) });
128
161
  return;
129
162
  }
130
- let r = d(n, w.languages);
163
+ let r = d(n, o.languages);
131
164
  if (!r) {
132
- console.error(`[CodeEditor] Language '${n}' not found.`), t.dispatch({ effects: A.reconfigure([]) });
165
+ console.error(`[CodeEditor] Language '${n}' not found.`), t.dispatch({ effects: O.reconfigure([]) });
133
166
  return;
134
167
  }
135
168
  r.load().then((n) => {
136
- K(e, t) && t.dispatch({ effects: A.reconfigure(n.extension) });
169
+ W(e, t) && t.dispatch({ effects: O.reconfigure(n.extension) });
137
170
  }, (r) => {
138
- K(e, t) && (console.error(`[CodeEditor] Failed to load language '${n}':`, r), t.dispatch({ effects: A.reconfigure([]) }));
171
+ W(e, t) && (console.error(`[CodeEditor] Failed to load language '${n}':`, r), t.dispatch({ effects: O.reconfigure([]) }));
139
172
  });
140
173
  }
141
- function K(e, t) {
142
- return e === V && D.value === t;
174
+ function W(e, t) {
175
+ return e === z && T.value === t;
143
176
  }
144
- function q() {
145
- let e = D.value;
177
+ function G() {
178
+ let e = T.value;
146
179
  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))] });
180
+ let t = o.readonly || o.disabled;
181
+ e.dispatch({ effects: [A.reconfigure(g.readOnly.of(t)), j.reconfigure(v.editable.of(!t))] });
149
182
  }
150
- function J() {
151
- D.value?.dispatch({ effects: P.reconfigure(w.placeholder ? x(w.placeholder) : []) });
183
+ function K() {
184
+ T.value?.dispatch({ effects: M.reconfigure(o.placeholder ? x(o.placeholder) : []) });
152
185
  }
153
- function Y() {
154
- D.value?.dispatch({ effects: [F.reconfigure(w.indentWithTab ? b.of([f]) : []), I.reconfigure(w.indentUnit ? p.of(w.indentUnit) : [])] });
186
+ function q() {
187
+ T.value?.dispatch({ effects: [N.reconfigure(o.indentWithTab ? b.of([f]) : []), P.reconfigure(o.indentUnit ? p.of(o.indentUnit) : [])] });
155
188
  }
156
- function X() {
157
- D.value?.dispatch({ effects: L.reconfigure(w.lineWrapping ? v.lineWrapping : []) });
189
+ function J() {
190
+ T.value?.dispatch({ effects: F.reconfigure(o.lineWrapping ? v.lineWrapping : []) });
158
191
  }
159
- function Z() {
160
- D.value?.dispatch({ effects: R.reconfigure(w.highlightWhitespace ? y() : []) });
192
+ function Y() {
193
+ T.value?.dispatch({ effects: I.reconfigure(o.highlightWhitespace ? y() : []) });
161
194
  }
162
- return (e, n) => (o(), t("div", r(O.value, {
163
- ref_key: "editorRef",
164
- ref: E
165
- }), null, 16));
195
+ let X = {
196
+ props: o,
197
+ emit: u,
198
+ editorRef: w,
199
+ viewRef: T,
200
+ hostAttributes: E,
201
+ setupConf: D,
202
+ languageConf: O,
203
+ themeConf: k,
204
+ readonlyConf: A,
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;
166
234
  }
167
- }), [["__scopeId", "data-v-64632146"]]);
235
+ }), T = (e, t) => {
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
+ ]);
168
250
  //#endregion
169
- export { w as CodeEditor };
251
+ export { D as CodeEditor };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiao/code-editor-vue",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
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.21"
42
+ "@aiao/code-editor": "0.0.22"
43
43
  }
44
44
  }