@zephyr_zz/zephyr-ui 0.0.19 → 0.0.20
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/types/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { App } from 'vue';
|
|
2
2
|
import { default as ZzButton } from './button';
|
|
3
3
|
import { default as ZephyrEditor } from './editor';
|
|
4
|
-
|
|
4
|
+
import { default as ZephyrWrapper } from './wrapper';
|
|
5
|
+
export { ZzButton, ZephyrEditor, ZephyrWrapper };
|
|
5
6
|
declare const _default: {
|
|
6
7
|
install(app: App): void;
|
|
7
8
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { VNode } from 'vue';
|
|
2
|
+
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
3
|
+
is: {
|
|
4
|
+
type: (StringConstructor | ObjectConstructor | FunctionConstructor)[];
|
|
5
|
+
default: null;
|
|
6
|
+
};
|
|
7
|
+
show: {
|
|
8
|
+
type: BooleanConstructor;
|
|
9
|
+
default: boolean;
|
|
10
|
+
};
|
|
11
|
+
isProps: {
|
|
12
|
+
type: ObjectConstructor;
|
|
13
|
+
default: () => {};
|
|
14
|
+
};
|
|
15
|
+
}>, () => VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}> | VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}>[] | null | undefined, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
20
|
+
is: {
|
|
21
|
+
type: (StringConstructor | ObjectConstructor | FunctionConstructor)[];
|
|
22
|
+
default: null;
|
|
23
|
+
};
|
|
24
|
+
show: {
|
|
25
|
+
type: BooleanConstructor;
|
|
26
|
+
default: boolean;
|
|
27
|
+
};
|
|
28
|
+
isProps: {
|
|
29
|
+
type: ObjectConstructor;
|
|
30
|
+
default: () => {};
|
|
31
|
+
};
|
|
32
|
+
}>> & Readonly<{}>, {
|
|
33
|
+
is: string | Function | Record<string, any>;
|
|
34
|
+
show: boolean;
|
|
35
|
+
isProps: Record<string, any>;
|
|
36
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
37
|
+
export default _default;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
2
|
+
is: {
|
|
3
|
+
type: (StringConstructor | ObjectConstructor | FunctionConstructor)[];
|
|
4
|
+
default: null;
|
|
5
|
+
};
|
|
6
|
+
show: {
|
|
7
|
+
type: BooleanConstructor;
|
|
8
|
+
default: boolean;
|
|
9
|
+
};
|
|
10
|
+
isProps: {
|
|
11
|
+
type: ObjectConstructor;
|
|
12
|
+
default: () => {};
|
|
13
|
+
};
|
|
14
|
+
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
15
|
+
is: {
|
|
16
|
+
type: (StringConstructor | ObjectConstructor | FunctionConstructor)[];
|
|
17
|
+
default: null;
|
|
18
|
+
};
|
|
19
|
+
show: {
|
|
20
|
+
type: BooleanConstructor;
|
|
21
|
+
default: boolean;
|
|
22
|
+
};
|
|
23
|
+
isProps: {
|
|
24
|
+
type: ObjectConstructor;
|
|
25
|
+
default: () => {};
|
|
26
|
+
};
|
|
27
|
+
}>> & Readonly<{}>, {
|
|
28
|
+
is: string | Function | Record<string, any>;
|
|
29
|
+
show: boolean;
|
|
30
|
+
isProps: Record<string, any>;
|
|
31
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
|
|
32
|
+
wrapperRef: HTMLDivElement;
|
|
33
|
+
}, HTMLDivElement>, Partial<Record<string, (_: {}) => any>> & {
|
|
34
|
+
default?(_: {}): any;
|
|
35
|
+
}>;
|
|
36
|
+
export default _default;
|
|
37
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
38
|
+
new (): {
|
|
39
|
+
$slots: S;
|
|
40
|
+
};
|
|
41
|
+
};
|
package/dist/zephyr-ui.es.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
import './index.css';
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import * as
|
|
4
|
-
import { shikiToMonaco as
|
|
5
|
-
import { createHighlighter as
|
|
6
|
-
const
|
|
2
|
+
import { defineComponent as v, createElementBlock as B, openBlock as C, normalizeClass as W, renderSlot as _, ref as $, onMounted as S, onUnmounted as Z, isVNode as O, h as j, nextTick as H, getCurrentScope as I, onScopeDispose as M, getCurrentInstance as R, computed as k, shallowRef as w, watch as L, toValue as V, createElementVNode as A, createCommentVNode as N, createVNode as D, unref as T, normalizeProps as G, guardReactiveProps as F, createSlots as U, renderList as q, withCtx as J } from "vue";
|
|
3
|
+
import * as p from "monaco-editor-core";
|
|
4
|
+
import { shikiToMonaco as Q } from "@shikijs/monaco";
|
|
5
|
+
import { createHighlighter as X } from "shiki";
|
|
6
|
+
const Y = {
|
|
7
7
|
name: "ZzButton"
|
|
8
|
-
},
|
|
9
|
-
...
|
|
8
|
+
}, K = /* @__PURE__ */ v({
|
|
9
|
+
...Y,
|
|
10
10
|
props: {
|
|
11
11
|
type: {
|
|
12
12
|
type: String,
|
|
13
13
|
default: "primary"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
|
-
setup(
|
|
17
|
-
return (e,
|
|
18
|
-
class:
|
|
16
|
+
setup(t) {
|
|
17
|
+
return (e, n) => (C(), B("button", {
|
|
18
|
+
class: W(["zz-button", `zz-button--${t.type}`])
|
|
19
19
|
}, [
|
|
20
|
-
|
|
20
|
+
_(e.$slots, "default", {}, void 0, !0)
|
|
21
21
|
], 2));
|
|
22
22
|
}
|
|
23
|
-
}),
|
|
24
|
-
const
|
|
25
|
-
for (const [
|
|
26
|
-
i
|
|
27
|
-
return
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
}), E = (t, e) => {
|
|
24
|
+
const n = t.__vccOpts || t;
|
|
25
|
+
for (const [i, a] of e)
|
|
26
|
+
n[i] = a;
|
|
27
|
+
return n;
|
|
28
|
+
}, b = /* @__PURE__ */ E(K, [["__scopeId", "data-v-7c55743a"]]);
|
|
29
|
+
b.install = (t) => {
|
|
30
|
+
t.component("ZzButton", b);
|
|
31
31
|
};
|
|
32
|
-
class
|
|
32
|
+
class ee {
|
|
33
33
|
highlighter = null;
|
|
34
34
|
constructor() {
|
|
35
35
|
}
|
|
36
36
|
async init() {
|
|
37
37
|
try {
|
|
38
|
-
const e = await
|
|
38
|
+
const e = await X({
|
|
39
39
|
themes: ["github-dark", "vitesse-dark"],
|
|
40
40
|
// 示例
|
|
41
41
|
langs: ["ts", "vue"]
|
|
@@ -59,29 +59,29 @@ class b {
|
|
|
59
59
|
}
|
|
60
60
|
// 注册语言
|
|
61
61
|
registerLanguage(e) {
|
|
62
|
-
return new Promise((
|
|
62
|
+
return new Promise((n, i) => {
|
|
63
63
|
try {
|
|
64
|
-
this.highlighter && !this.getLanguages().includes(e) && this.highlighter.loadLanguage(e),
|
|
65
|
-
} catch (
|
|
66
|
-
|
|
64
|
+
this.highlighter && !this.getLanguages().includes(e) && this.highlighter.loadLanguage(e), n(!0);
|
|
65
|
+
} catch (a) {
|
|
66
|
+
i(a);
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
// 注册主题
|
|
71
71
|
registerTheme(e) {
|
|
72
|
-
return new Promise((
|
|
72
|
+
return new Promise((n, i) => {
|
|
73
73
|
try {
|
|
74
|
-
this.highlighter && !this.getThemes().includes(e) && this.highlighter.loadTheme(e),
|
|
75
|
-
} catch (
|
|
76
|
-
|
|
74
|
+
this.highlighter && !this.getThemes().includes(e) && this.highlighter.loadTheme(e), n(!0);
|
|
75
|
+
} catch (a) {
|
|
76
|
+
i(a);
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
const
|
|
81
|
+
const te = {
|
|
82
82
|
name: "ZephyrEditor"
|
|
83
|
-
},
|
|
84
|
-
...
|
|
83
|
+
}, oe = /* @__PURE__ */ v({
|
|
84
|
+
...te,
|
|
85
85
|
props: {
|
|
86
86
|
modelValue: {
|
|
87
87
|
type: String,
|
|
@@ -93,69 +93,246 @@ const x = {
|
|
|
93
93
|
}
|
|
94
94
|
},
|
|
95
95
|
emits: ["update:modelValue", "load"],
|
|
96
|
-
setup(
|
|
97
|
-
const
|
|
98
|
-
let
|
|
99
|
-
const
|
|
100
|
-
let
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
},
|
|
104
|
-
if (
|
|
105
|
-
return
|
|
106
|
-
|
|
107
|
-
}).catch((
|
|
108
|
-
console.error(
|
|
96
|
+
setup(t, { expose: e, emit: n }) {
|
|
97
|
+
const i = t, a = n;
|
|
98
|
+
let r = null;
|
|
99
|
+
const u = $(null);
|
|
100
|
+
let s = null;
|
|
101
|
+
const c = (o, h) => {
|
|
102
|
+
s && p.languages.registerCompletionItemProvider(o, h);
|
|
103
|
+
}, l = (o) => {
|
|
104
|
+
if (r)
|
|
105
|
+
return r.registerTheme(o).then(() => {
|
|
106
|
+
p.editor.setTheme(o);
|
|
107
|
+
}).catch((h) => {
|
|
108
|
+
console.error(h);
|
|
109
109
|
});
|
|
110
|
-
},
|
|
111
|
-
if (
|
|
112
|
-
return
|
|
113
|
-
|
|
110
|
+
}, d = (o) => {
|
|
111
|
+
if (r)
|
|
112
|
+
return r.registerLanguage(o).then(() => {
|
|
113
|
+
p.languages.register(o);
|
|
114
114
|
});
|
|
115
115
|
};
|
|
116
|
-
return
|
|
117
|
-
if (
|
|
118
|
-
|
|
116
|
+
return S(async () => {
|
|
117
|
+
if (u.value) {
|
|
118
|
+
r = new ee();
|
|
119
119
|
try {
|
|
120
|
-
await
|
|
121
|
-
const
|
|
122
|
-
if (!
|
|
123
|
-
|
|
124
|
-
value:
|
|
125
|
-
...
|
|
126
|
-
}),
|
|
127
|
-
|
|
128
|
-
}),
|
|
129
|
-
} catch (
|
|
130
|
-
console.log("editor is init failed",
|
|
120
|
+
await r.init();
|
|
121
|
+
const o = r.getHighlighter();
|
|
122
|
+
if (!o) return;
|
|
123
|
+
i.options?.language && (await r.registerLanguage(i.options?.language), p.languages.register({ id: i.options?.language })), i.options?.theme && (await r.registerTheme(i.options?.theme), p.editor.setTheme(i.options?.theme)), Q(o, p), s = p.editor.create(u.value, {
|
|
124
|
+
value: i.modelValue,
|
|
125
|
+
...i.options || {}
|
|
126
|
+
}), s.onDidChangeModelContent(() => {
|
|
127
|
+
a("update:modelValue", s?.getValue());
|
|
128
|
+
}), a("load", { state: "success", editor: s, highlighter: r, highlighterInstance: o });
|
|
129
|
+
} catch (o) {
|
|
130
|
+
console.log("editor is init failed", o), a("load", { state: "error", error: o });
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
}),
|
|
134
|
-
|
|
133
|
+
}), Z(() => {
|
|
134
|
+
s && s.dispose();
|
|
135
135
|
}), e({
|
|
136
136
|
// 注册提示词
|
|
137
|
-
registerCompletionItemProvider:
|
|
137
|
+
registerCompletionItemProvider: c,
|
|
138
138
|
// 注册/切换主题
|
|
139
|
-
changeTheme:
|
|
139
|
+
changeTheme: l,
|
|
140
140
|
// 注册语言
|
|
141
|
-
registerLanguage:
|
|
142
|
-
}), (
|
|
141
|
+
registerLanguage: d
|
|
142
|
+
}), (o, h) => (C(), B("div", {
|
|
143
143
|
class: "zephyr-editor_container",
|
|
144
144
|
ref_key: "monacoEditorRef",
|
|
145
|
-
ref:
|
|
145
|
+
ref: u
|
|
146
146
|
}, null, 512));
|
|
147
147
|
}
|
|
148
|
-
}),
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
}), z = /* @__PURE__ */ E(oe, [["__scopeId", "data-v-3ceef597"]]);
|
|
149
|
+
z.install = (t) => {
|
|
150
|
+
t.component("ZzButton", z);
|
|
151
151
|
};
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
const ne = /* @__PURE__ */ v({
|
|
153
|
+
name: "wrapperHelper",
|
|
154
|
+
props: {
|
|
155
|
+
is: {
|
|
156
|
+
type: [String, Object, Function],
|
|
157
|
+
default: null
|
|
158
|
+
},
|
|
159
|
+
show: {
|
|
160
|
+
type: Boolean,
|
|
161
|
+
default: !0
|
|
162
|
+
},
|
|
163
|
+
isProps: {
|
|
164
|
+
type: Object,
|
|
165
|
+
default: () => ({})
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
setup(t, {
|
|
169
|
+
slots: e
|
|
170
|
+
}) {
|
|
171
|
+
return () => {
|
|
172
|
+
const {
|
|
173
|
+
is: n,
|
|
174
|
+
show: i,
|
|
175
|
+
isProps: a
|
|
176
|
+
} = t;
|
|
177
|
+
if (!i) return null;
|
|
178
|
+
if (!n) return e.default?.();
|
|
179
|
+
let r = null, u = {
|
|
180
|
+
...a
|
|
181
|
+
}, s = {};
|
|
182
|
+
if (O(n))
|
|
183
|
+
r = n.type, u = {
|
|
184
|
+
...n.props,
|
|
185
|
+
...a
|
|
186
|
+
}, s = n.children || {};
|
|
187
|
+
else if (typeof n == "function") {
|
|
188
|
+
const l = n();
|
|
189
|
+
O(l) ? (r = l.type, u = {
|
|
190
|
+
...l.props,
|
|
191
|
+
...a
|
|
192
|
+
}, s = l.children || {}) : r = l;
|
|
193
|
+
} else (typeof n == "object" || typeof n == "string") && (r = n);
|
|
194
|
+
const c = {};
|
|
195
|
+
e.default && (c.default = () => e.default());
|
|
196
|
+
for (const l in e)
|
|
197
|
+
l !== "default" && (c[l] = () => e[l]());
|
|
198
|
+
return typeof s == "object" && Object.assign(c, s), j(r, u, c);
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
function re(t, e) {
|
|
203
|
+
return I() ? (M(t, e), !0) : !1;
|
|
204
|
+
}
|
|
205
|
+
const ie = typeof window < "u" && typeof document < "u";
|
|
206
|
+
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
207
|
+
function se(t) {
|
|
208
|
+
return Array.isArray(t) ? t : [t];
|
|
209
|
+
}
|
|
210
|
+
function ae(t) {
|
|
211
|
+
return R();
|
|
212
|
+
}
|
|
213
|
+
function ue(t, e = !0, n) {
|
|
214
|
+
ae() ? S(t, n) : e ? t() : H(t);
|
|
215
|
+
}
|
|
216
|
+
const P = ie ? window : void 0;
|
|
217
|
+
function g(t) {
|
|
218
|
+
var e;
|
|
219
|
+
const n = V(t);
|
|
220
|
+
return (e = n?.$el) !== null && e !== void 0 ? e : n;
|
|
221
|
+
}
|
|
222
|
+
// @__NO_SIDE_EFFECTS__
|
|
223
|
+
function le() {
|
|
224
|
+
const t = w(!1), e = R();
|
|
225
|
+
return e && S(() => {
|
|
226
|
+
t.value = !0;
|
|
227
|
+
}, e), t;
|
|
228
|
+
}
|
|
229
|
+
// @__NO_SIDE_EFFECTS__
|
|
230
|
+
function ce(t) {
|
|
231
|
+
const e = /* @__PURE__ */ le();
|
|
232
|
+
return k(() => (e.value, !!t()));
|
|
233
|
+
}
|
|
234
|
+
function de(t, e, n = {}) {
|
|
235
|
+
const { window: i = P, ...a } = n;
|
|
236
|
+
let r;
|
|
237
|
+
const u = /* @__PURE__ */ ce(() => i && "ResizeObserver" in i), s = () => {
|
|
238
|
+
r && (r.disconnect(), r = void 0);
|
|
239
|
+
}, c = L(k(() => {
|
|
240
|
+
const d = V(t);
|
|
241
|
+
return Array.isArray(d) ? d.map((o) => g(o)) : [g(d)];
|
|
242
|
+
}), (d) => {
|
|
243
|
+
if (s(), u.value && i) {
|
|
244
|
+
r = new ResizeObserver(e);
|
|
245
|
+
for (const o of d) o && r.observe(o, a);
|
|
246
|
+
}
|
|
247
|
+
}, {
|
|
248
|
+
immediate: !0,
|
|
249
|
+
flush: "post"
|
|
250
|
+
}), l = () => {
|
|
251
|
+
s(), c();
|
|
252
|
+
};
|
|
253
|
+
return re(l), {
|
|
254
|
+
isSupported: u,
|
|
255
|
+
stop: l
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
function he(t, e = {
|
|
259
|
+
width: 0,
|
|
260
|
+
height: 0
|
|
261
|
+
}, n = {}) {
|
|
262
|
+
const { window: i = P, box: a = "content-box" } = n, r = k(() => {
|
|
263
|
+
var o;
|
|
264
|
+
return (o = g(t)) === null || o === void 0 || (o = o.namespaceURI) === null || o === void 0 ? void 0 : o.includes("svg");
|
|
265
|
+
}), u = w(e.width), s = w(e.height), { stop: c } = de(t, ([o]) => {
|
|
266
|
+
const h = a === "border-box" ? o.borderBoxSize : a === "content-box" ? o.contentBoxSize : o.devicePixelContentBoxSize;
|
|
267
|
+
if (i && r.value) {
|
|
268
|
+
const m = g(t);
|
|
269
|
+
if (m) {
|
|
270
|
+
const f = m.getBoundingClientRect();
|
|
271
|
+
u.value = f.width, s.value = f.height;
|
|
272
|
+
}
|
|
273
|
+
} else if (h) {
|
|
274
|
+
const m = se(h);
|
|
275
|
+
u.value = m.reduce((f, { inlineSize: y }) => f + y, 0), s.value = m.reduce((f, { blockSize: y }) => f + y, 0);
|
|
276
|
+
} else
|
|
277
|
+
u.value = o.contentRect.width, s.value = o.contentRect.height;
|
|
278
|
+
}, n);
|
|
279
|
+
ue(() => {
|
|
280
|
+
const o = g(t);
|
|
281
|
+
o && (u.value = "offsetWidth" in o ? o.offsetWidth : e.width, s.value = "offsetHeight" in o ? o.offsetHeight : e.height);
|
|
282
|
+
});
|
|
283
|
+
const l = L(() => g(t), (o) => {
|
|
284
|
+
u.value = o ? e.width : 0, s.value = o ? e.height : 0;
|
|
285
|
+
});
|
|
286
|
+
function d() {
|
|
287
|
+
c(), l();
|
|
288
|
+
}
|
|
289
|
+
return {
|
|
290
|
+
width: u,
|
|
291
|
+
height: s,
|
|
292
|
+
stop: d
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
const pe = { class: "zephyr-ui_wrapper" }, fe = {
|
|
296
|
+
name: "ZephyrWrapper"
|
|
297
|
+
}, x = /* @__PURE__ */ v({
|
|
298
|
+
...fe,
|
|
299
|
+
props: {
|
|
300
|
+
is: { type: [String, Object, Function], default: null },
|
|
301
|
+
show: { type: Boolean, default: !0 },
|
|
302
|
+
isProps: { type: Object, default: () => ({}) }
|
|
303
|
+
},
|
|
304
|
+
setup(t) {
|
|
305
|
+
const e = t, n = $(), { height: i } = he(n);
|
|
306
|
+
return (a, r) => (C(), B("div", pe, [
|
|
307
|
+
A("div", {
|
|
308
|
+
class: "zephyr-wrapper_container",
|
|
309
|
+
ref_key: "wrapperRef",
|
|
310
|
+
ref: n
|
|
311
|
+
}, [
|
|
312
|
+
D(T(ne), G(F(e)), U({ _: 2 }, [
|
|
313
|
+
q(Object.keys(a.$slots), (u, s) => ({
|
|
314
|
+
name: u,
|
|
315
|
+
fn: J(() => [
|
|
316
|
+
_(a.$slots, u)
|
|
317
|
+
])
|
|
318
|
+
}))
|
|
319
|
+
]), 1040)
|
|
320
|
+
], 512),
|
|
321
|
+
T(i) ? N("", !0) : _(a.$slots, "default", { key: 0 })
|
|
322
|
+
]));
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
x.install = (t) => {
|
|
326
|
+
t.component("ZephyrWrapper", x);
|
|
327
|
+
};
|
|
328
|
+
const ge = [b, z, x], _e = {
|
|
329
|
+
install(t) {
|
|
330
|
+
ge.forEach((e) => t.component(e.name || "ZzButton", e));
|
|
155
331
|
}
|
|
156
332
|
};
|
|
157
333
|
export {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
334
|
+
z as ZephyrEditor,
|
|
335
|
+
x as ZephyrWrapper,
|
|
336
|
+
b as ZzButton,
|
|
337
|
+
_e as default
|
|
161
338
|
};
|
package/dist/zephyr-ui.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
/*$vite$:1*/`,document.head.appendChild(
|
|
1
|
+
(function(u,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("monaco-editor-core"),require("@shikijs/monaco"),require("shiki")):typeof define=="function"&&define.amd?define(["exports","vue","monaco-editor-core","@shikijs/monaco","shiki"],e):(u=typeof globalThis<"u"?globalThis:u||self,e(u.ZephyrUI={},u.Vue,u.monaco,u.monaco$1,u.shiki))})(this,(function(u,e,O,T,j){"use strict";var C=document.createElement("style");C.textContent=`.zz-button[data-v-7c55743a]{padding:8px 16px;border:none;border-radius:4px;cursor:pointer;font-weight:500;transition:.2s}.zz-button--primary[data-v-7c55743a]{background:#409eff;color:#fff}.zz-button--success[data-v-7c55743a]{background:#67c23a;color:#fff}.zz-button--warning[data-v-7c55743a]{background:#e6a23c;color:#fff}.zz-button--danger[data-v-7c55743a]{background:#f56c6c;color:#fff}.zephyr-editor_container[data-v-3ceef597]{width:100%;height:100%}
|
|
2
|
+
/*$vite$:1*/`,document.head.appendChild(C);function x(o){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const r in o)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(o,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>o[r]})}}return t.default=o,Object.freeze(t)}const p=x(O),$={name:"ZzButton"},E=e.defineComponent({...$,props:{type:{type:String,default:"primary"}},setup(o){return(t,r)=>(e.openBlock(),e.createElementBlock("button",{class:e.normalizeClass(["zz-button",`zz-button--${o.type}`])},[e.renderSlot(t.$slots,"default",{},void 0,!0)],2))}}),S=(o,t)=>{const r=o.__vccOpts||o;for(const[i,c]of t)r[i]=c;return r},w=S(E,[["__scopeId","data-v-7c55743a"]]);w.install=o=>{o.component("ZzButton",w)};class R{highlighter=null;constructor(){}async init(){try{const t=await j.createHighlighter({themes:["github-dark","vitesse-dark"],langs:["ts","vue"]});this.highlighter=t}catch(t){console.log("高亮器初始化失败",t)}}getHighlighter(){return this.highlighter}getLanguages(){return this.highlighter?.getLoadedLanguages()||[]}getThemes(){return this.highlighter?.getLoadedThemes()||[]}registerLanguage(t){return new Promise((r,i)=>{try{this.highlighter&&!this.getLanguages().includes(t)&&this.highlighter.loadLanguage(t),r(!0)}catch(c){i(c)}})}registerTheme(t){return new Promise((r,i)=>{try{this.highlighter&&!this.getThemes().includes(t)&&this.highlighter.loadTheme(t),r(!0)}catch(c){i(c)}})}}const V={name:"ZephyrEditor"},v=e.defineComponent({...V,props:{modelValue:{type:String,default:""},options:{type:Object,default:null}},emits:["update:modelValue","load"],setup(o,{expose:t,emit:r}){const i=o,c=r;let s=null;const l=e.ref(null);let a=null;const f=(n,g)=>{a&&p.languages.registerCompletionItemProvider(n,g)},d=n=>{if(s)return s.registerTheme(n).then(()=>{p.editor.setTheme(n)}).catch(g=>{console.error(g)})},h=n=>{if(s)return s.registerLanguage(n).then(()=>{p.languages.register(n)})};return e.onMounted(async()=>{if(l.value){s=new R;try{await s.init();const n=s.getHighlighter();if(!n)return;i.options?.language&&(await s.registerLanguage(i.options?.language),p.languages.register({id:i.options?.language})),i.options?.theme&&(await s.registerTheme(i.options?.theme),p.editor.setTheme(i.options?.theme)),T.shikiToMonaco(n,p),a=p.editor.create(l.value,{value:i.modelValue,...i.options||{}}),a.onDidChangeModelContent(()=>{c("update:modelValue",a?.getValue())}),c("load",{state:"success",editor:a,highlighter:s,highlighterInstance:n})}catch(n){console.log("editor is init failed",n),c("load",{state:"error",error:n})}}}),e.onUnmounted(()=>{a&&a.dispose()}),t({registerCompletionItemProvider:f,changeTheme:d,registerLanguage:h}),(n,g)=>(e.openBlock(),e.createElementBlock("div",{class:"zephyr-editor_container",ref_key:"monacoEditorRef",ref:l},null,512))}}),b=S(v,[["__scopeId","data-v-3ceef597"]]);b.install=o=>{o.component("ZzButton",b)};const P=e.defineComponent({name:"wrapperHelper",props:{is:{type:[String,Object,Function],default:null},show:{type:Boolean,default:!0},isProps:{type:Object,default:()=>({})}},setup(o,{slots:t}){return()=>{const{is:r,show:i,isProps:c}=o;if(!i)return null;if(!r)return t.default?.();let s=null,l={...c},a={};if(e.isVNode(r))s=r.type,l={...r.props,...c},a=r.children||{};else if(typeof r=="function"){const d=r();e.isVNode(d)?(s=d.type,l={...d.props,...c},a=d.children||{}):s=d}else(typeof r=="object"||typeof r=="string")&&(s=r);const f={};t.default&&(f.default=()=>t.default());for(const d in t)d!=="default"&&(f[d]=()=>t[d]());return typeof a=="object"&&Object.assign(f,a),e.h(s,l,f)}}});function Z(o,t){return e.getCurrentScope()?(e.onScopeDispose(o,t),!0):!1}const L=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;function M(o){return Array.isArray(o)?o:[o]}function W(o){return e.getCurrentInstance()}function I(o,t=!0,r){W()?e.onMounted(o,r):t?o():e.nextTick(o)}const B=L?window:void 0;function m(o){var t;const r=e.toValue(o);return(t=r?.$el)!==null&&t!==void 0?t:r}function H(){const o=e.shallowRef(!1),t=e.getCurrentInstance();return t&&e.onMounted(()=>{o.value=!0},t),o}function N(o){const t=H();return e.computed(()=>(t.value,!!o()))}function A(o,t,r={}){const{window:i=B,...c}=r;let s;const l=N(()=>i&&"ResizeObserver"in i),a=()=>{s&&(s.disconnect(),s=void 0)},f=e.watch(e.computed(()=>{const h=e.toValue(o);return Array.isArray(h)?h.map(n=>m(n)):[m(h)]}),h=>{if(a(),l.value&&i){s=new ResizeObserver(t);for(const n of h)n&&s.observe(n,c)}},{immediate:!0,flush:"post"}),d=()=>{a(),f()};return Z(d),{isSupported:l,stop:d}}function D(o,t={width:0,height:0},r={}){const{window:i=B,box:c="content-box"}=r,s=e.computed(()=>{var n;return(n=m(o))===null||n===void 0||(n=n.namespaceURI)===null||n===void 0?void 0:n.includes("svg")}),l=e.shallowRef(t.width),a=e.shallowRef(t.height),{stop:f}=A(o,([n])=>{const g=c==="border-box"?n.borderBoxSize:c==="content-box"?n.contentBoxSize:n.devicePixelContentBoxSize;if(i&&s.value){const _=m(o);if(_){const y=_.getBoundingClientRect();l.value=y.width,a.value=y.height}}else if(g){const _=M(g);l.value=_.reduce((y,{inlineSize:k})=>y+k,0),a.value=_.reduce((y,{blockSize:k})=>y+k,0)}else l.value=n.contentRect.width,a.value=n.contentRect.height},r);I(()=>{const n=m(o);n&&(l.value="offsetWidth"in n?n.offsetWidth:t.width,a.value="offsetHeight"in n?n.offsetHeight:t.height)});const d=e.watch(()=>m(o),n=>{l.value=n?t.width:0,a.value=n?t.height:0});function h(){f(),d()}return{width:l,height:a,stop:h}}const q={class:"zephyr-ui_wrapper"},G={name:"ZephyrWrapper"},z=e.defineComponent({...G,props:{is:{type:[String,Object,Function],default:null},show:{type:Boolean,default:!0},isProps:{type:Object,default:()=>({})}},setup(o){const t=o,r=e.ref(),{height:i}=D(r);return(c,s)=>(e.openBlock(),e.createElementBlock("div",q,[e.createElementVNode("div",{class:"zephyr-wrapper_container",ref_key:"wrapperRef",ref:r},[e.createVNode(e.unref(P),e.normalizeProps(e.guardReactiveProps(t)),e.createSlots({_:2},[e.renderList(Object.keys(c.$slots),(l,a)=>({name:l,fn:e.withCtx(()=>[e.renderSlot(c.$slots,l)])}))]),1040)],512),e.unref(i)?e.createCommentVNode("",!0):e.renderSlot(c.$slots,"default",{key:0})]))}});z.install=o=>{o.component("ZephyrWrapper",z)};const U=[w,b,z],F={install(o){U.forEach(t=>o.component(t.name||"ZzButton",t))}};u.ZephyrEditor=b,u.ZephyrWrapper=z,u.ZzButton=w,u.default=F,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"types": "./dist/types/index.d.ts"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
|
-
"version": "0.0.
|
|
14
|
+
"version": "0.0.20",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"scripts": {
|
|
17
17
|
"dev": "vite",
|
|
@@ -20,13 +20,16 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@shikijs/monaco": "1.29.2",
|
|
23
|
+
"@vueuse/core": "^14.0.0",
|
|
23
24
|
"monaco-editor-core": "0.52.2",
|
|
24
25
|
"shiki": "1.29.2"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"@types/node": "^24.6.0",
|
|
28
29
|
"@vitejs/plugin-vue": "^6.0.1",
|
|
30
|
+
"@vitejs/plugin-vue-jsx": "^5.1.1",
|
|
29
31
|
"@vue/tsconfig": "^0.8.1",
|
|
32
|
+
"element-plus": "^2.11.5",
|
|
30
33
|
"sass": "^1.93.2",
|
|
31
34
|
"sass-embedded": "^1.93.2",
|
|
32
35
|
"typescript": "~5.9.3",
|