@zephyr_zz/zephyr-ui 0.0.16 → 0.0.18

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 +1 @@
1
- .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}
1
+ .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-96a99f7a]{width:100%;height:100%}
@@ -0,0 +1,11 @@
1
+ import { BundledLanguage, BundledTheme, HighlighterGeneric } from 'shiki';
2
+ export declare class Highlighter {
3
+ private highlighter;
4
+ constructor();
5
+ init(): Promise<void>;
6
+ getHighlighter(): HighlighterGeneric<BundledLanguage, BundledTheme> | null;
7
+ getLanguages(): string[];
8
+ getThemes(): string[];
9
+ registerLanguage(lang: BundledLanguage): Promise<unknown>;
10
+ registerTheme(theme: BundledTheme): Promise<unknown>;
11
+ }
@@ -0,0 +1,37 @@
1
+ import { PropType } from 'vue';
2
+ import { Highlighter } from './Highlighter';
3
+ import * as monaco from 'monaco-editor-core';
4
+ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
5
+ modelValue: {
6
+ type: StringConstructor;
7
+ default: string;
8
+ };
9
+ options: {
10
+ type: PropType<monaco.editor.IStandaloneEditorConstructionOptions>;
11
+ default: null;
12
+ };
13
+ }>, {
14
+ getText: () => string;
15
+ getEditor: () => monaco.editor.IStandaloneCodeEditor | null;
16
+ registerCompletionItemProvider: (languageSelector: monaco.languages.LanguageSelector, provider: monaco.languages.CompletionItemProvider) => void;
17
+ getHighlighter: () => Highlighter | null;
18
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
19
+ "update:modelValue": (...args: any[]) => void;
20
+ }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
21
+ modelValue: {
22
+ type: StringConstructor;
23
+ default: string;
24
+ };
25
+ options: {
26
+ type: PropType<monaco.editor.IStandaloneEditorConstructionOptions>;
27
+ default: null;
28
+ };
29
+ }>> & Readonly<{
30
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
31
+ }>, {
32
+ modelValue: string;
33
+ options: monaco.editor.IStandaloneEditorConstructionOptions;
34
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
35
+ monacoEditorRef: HTMLDivElement;
36
+ }, HTMLDivElement>;
37
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import { default as ZephyrEditor } from './ZephyrEditor.vue';
2
+ export default ZephyrEditor;
@@ -1,6 +1,7 @@
1
1
  import { App } from 'vue';
2
2
  import { default as ZzButton } from './button';
3
- export { ZzButton };
3
+ import { default as ZephyrEditor } from './editor';
4
+ export { ZzButton, ZephyrEditor };
4
5
  declare const _default: {
5
6
  install(app: App): void;
6
7
  };
@@ -1,9 +1,12 @@
1
1
  import './index.css';
2
- import { defineComponent as c, createElementBlock as r, openBlock as l, normalizeClass as p, renderSlot as u } from "vue";
3
- const _ = {
2
+ import { defineComponent as d, createElementBlock as m, openBlock as p, normalizeClass as v, renderSlot as z, ref as E, onMounted as L, onUnmounted as T } from "vue";
3
+ import * as l from "monaco-editor-core";
4
+ import { shikiToMonaco as k } from "@shikijs/monaco";
5
+ import { createHighlighter as w } from "shiki";
6
+ const B = {
4
7
  name: "ZzButton"
5
- }, m = /* @__PURE__ */ c({
6
- ..._,
8
+ }, Z = /* @__PURE__ */ d({
9
+ ...B,
7
10
  props: {
8
11
  type: {
9
12
  type: String,
@@ -11,27 +14,138 @@ const _ = {
11
14
  }
12
15
  },
13
16
  setup(t) {
14
- return (o, n) => (l(), r("button", {
15
- class: p(["zz-button", `zz-button--${t.type}`])
17
+ return (e, r) => (p(), m("button", {
18
+ class: v(["zz-button", `zz-button--${t.type}`])
16
19
  }, [
17
- u(o.$slots, "default", {}, void 0, !0)
20
+ z(e.$slots, "default", {}, void 0, !0)
18
21
  ], 2));
19
22
  }
20
- }), d = (t, o) => {
21
- const n = t.__vccOpts || t;
22
- for (const [s, a] of o)
23
- n[s] = a;
24
- return n;
25
- }, e = /* @__PURE__ */ d(m, [["__scopeId", "data-v-7c55743a"]]);
26
- e.install = (t) => {
27
- t.component("ZzButton", e);
23
+ }), f = (t, e) => {
24
+ const r = t.__vccOpts || t;
25
+ for (const [o, n] of e)
26
+ r[o] = n;
27
+ return r;
28
+ }, h = /* @__PURE__ */ f(Z, [["__scopeId", "data-v-7c55743a"]]);
29
+ h.install = (t) => {
30
+ t.component("ZzButton", h);
28
31
  };
29
- const f = [e], z = {
32
+ class x {
33
+ highlighter = null;
34
+ constructor() {
35
+ }
36
+ async init() {
37
+ try {
38
+ const e = await w({
39
+ themes: ["github-dark", "vitesse-dark"],
40
+ // 示例
41
+ langs: ["ts", "vue"]
42
+ });
43
+ this.highlighter = e;
44
+ } catch (e) {
45
+ console.log("高亮器初始化失败", e);
46
+ }
47
+ }
48
+ // 获取高亮器
49
+ getHighlighter() {
50
+ return this.highlighter;
51
+ }
52
+ // 获取高亮器注册的语言
53
+ getLanguages() {
54
+ return this.highlighter?.getLoadedLanguages() || [];
55
+ }
56
+ // 获取高亮器注册的主题
57
+ getThemes() {
58
+ return this.highlighter?.getLoadedThemes() || [];
59
+ }
60
+ // 注册语言
61
+ registerLanguage(e) {
62
+ return new Promise((r, o) => {
63
+ try {
64
+ this.highlighter && !this.getLanguages().includes(e) && this.highlighter.loadLanguage(e), r(!0);
65
+ } catch (n) {
66
+ o(n);
67
+ }
68
+ });
69
+ }
70
+ // 注册主题
71
+ registerTheme(e) {
72
+ return new Promise((r, o) => {
73
+ try {
74
+ this.highlighter && !this.getThemes().includes(e) && this.highlighter.loadTheme(e), r(!0);
75
+ } catch (n) {
76
+ o(n);
77
+ }
78
+ });
79
+ }
80
+ }
81
+ const C = {
82
+ name: "ZephyrEditor"
83
+ }, V = /* @__PURE__ */ d({
84
+ ...C,
85
+ props: {
86
+ modelValue: {
87
+ type: String,
88
+ default: ""
89
+ },
90
+ options: {
91
+ type: Object,
92
+ default: null
93
+ }
94
+ },
95
+ emits: ["update:modelValue"],
96
+ setup(t, { expose: e, emit: r }) {
97
+ const o = t, n = r;
98
+ let a = null;
99
+ const g = E(null);
100
+ let i = null;
101
+ const _ = () => i?.getValue() || "", y = (s, c) => {
102
+ i && l.languages.registerCompletionItemProvider(s, c);
103
+ };
104
+ return L(async () => {
105
+ if (g.value) {
106
+ a || (a = new x());
107
+ try {
108
+ await a.init();
109
+ const s = a.getHighlighter();
110
+ if (!s) return;
111
+ o.options?.language && (await a.registerLanguage(o.options?.language), l.languages.register({ id: o.options?.language })), o.options?.theme && await a.registerTheme(o.options?.theme), k(s, l), i = l.editor.create(g.value, {
112
+ value: o.modelValue,
113
+ ...o.options || {}
114
+ }), i.onDidChangeModelContent(() => {
115
+ n("update:modelValue", i?.getValue());
116
+ });
117
+ } catch (s) {
118
+ console.log("editor is init failed", s);
119
+ }
120
+ }
121
+ }), T(() => {
122
+ i && i.dispose();
123
+ }), e({
124
+ // 获取编辑器内容
125
+ getText: _,
126
+ // 获取当前实例
127
+ getEditor: () => i,
128
+ // 注册提示词
129
+ registerCompletionItemProvider: y,
130
+ // 获取高亮器
131
+ getHighlighter: () => a
132
+ }), (s, c) => (p(), m("div", {
133
+ class: "zephyr-editor_container",
134
+ ref_key: "monacoEditorRef",
135
+ ref: g
136
+ }, null, 512));
137
+ }
138
+ }), u = /* @__PURE__ */ f(V, [["__scopeId", "data-v-96a99f7a"]]);
139
+ u.install = (t) => {
140
+ t.component("ZzButton", u);
141
+ };
142
+ const b = [h, u], $ = {
30
143
  install(t) {
31
- f.forEach((o) => t.component(o.name || "ZzButton", o));
144
+ b.forEach((e) => t.component(e.name || "ZzButton", e));
32
145
  }
33
146
  };
34
147
  export {
35
- e as ZzButton,
36
- z as default
148
+ u as ZephyrEditor,
149
+ h as ZzButton,
150
+ $ as default
37
151
  };
@@ -1,2 +1,2 @@
1
- (function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.ZephyrUI={},e.Vue))})(this,(function(e,t){"use strict";var r=document.createElement("style");r.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}
2
- /*$vite$:1*/`,document.head.appendChild(r);const u={name:"ZzButton"},d=t.defineComponent({...u,props:{type:{type:String,default:"primary"}},setup(n){return(o,c)=>(t.openBlock(),t.createElementBlock("button",{class:t.normalizeClass(["zz-button",`zz-button--${n.type}`])},[t.renderSlot(o.$slots,"default",{},void 0,!0)],2))}}),a=((n,o)=>{const c=n.__vccOpts||n;for(const[i,p]of o)c[i]=p;return c})(d,[["__scopeId","data-v-7c55743a"]]);a.install=n=>{n.component("ZzButton",a)};const s=[a],f={install(n){s.forEach(o=>n.component(o.name||"ZzButton",o))}};e.ZzButton=a,e.default=f,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
1
+ (function(i,n){typeof exports=="object"&&typeof module<"u"?n(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"],n):(i=typeof globalThis<"u"?globalThis:i||self,n(i.ZephyrUI={},i.Vue,i.monaco,i.monaco$1,i.shiki))})(this,(function(i,n,_,y,z){"use strict";var f=document.createElement("style");f.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-96a99f7a]{width:100%;height:100%}
2
+ /*$vite$:1*/`,document.head.appendChild(f);function b(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const u=b(_),k={name:"ZzButton"},v=n.defineComponent({...k,props:{type:{type:String,default:"primary"}},setup(t){return(e,r)=>(n.openBlock(),n.createElementBlock("button",{class:n.normalizeClass(["zz-button",`zz-button--${t.type}`])},[n.renderSlot(e.$slots,"default",{},void 0,!0)],2))}}),p=(t,e)=>{const r=t.__vccOpts||t;for(const[o,s]of e)r[o]=s;return r},g=p(v,[["__scopeId","data-v-7c55743a"]]);g.install=t=>{t.component("ZzButton",g)};class T{highlighter=null;constructor(){}async init(){try{const e=await z.createHighlighter({themes:["github-dark","vitesse-dark"],langs:["ts","vue"]});this.highlighter=e}catch(e){console.log("高亮器初始化失败",e)}}getHighlighter(){return this.highlighter}getLanguages(){return this.highlighter?.getLoadedLanguages()||[]}getThemes(){return this.highlighter?.getLoadedThemes()||[]}registerLanguage(e){return new Promise((r,o)=>{try{this.highlighter&&!this.getLanguages().includes(e)&&this.highlighter.loadLanguage(e),r(!0)}catch(s){o(s)}})}registerTheme(e){return new Promise((r,o)=>{try{this.highlighter&&!this.getThemes().includes(e)&&this.highlighter.loadTheme(e),r(!0)}catch(s){o(s)}})}}const w={name:"ZephyrEditor"},E=n.defineComponent({...w,props:{modelValue:{type:String,default:""},options:{type:Object,default:null}},emits:["update:modelValue"],setup(t,{expose:e,emit:r}){const o=t,s=r;let c=null;const h=n.ref(null);let a=null;const j=()=>a?.getValue()||"",x=(l,m)=>{a&&u.languages.registerCompletionItemProvider(l,m)};return n.onMounted(async()=>{if(h.value){c||(c=new T);try{await c.init();const l=c.getHighlighter();if(!l)return;o.options?.language&&(await c.registerLanguage(o.options?.language),u.languages.register({id:o.options?.language})),o.options?.theme&&await c.registerTheme(o.options?.theme),y.shikiToMonaco(l,u),a=u.editor.create(h.value,{value:o.modelValue,...o.options||{}}),a.onDidChangeModelContent(()=>{s("update:modelValue",a?.getValue())})}catch(l){console.log("editor is init failed",l)}}}),n.onUnmounted(()=>{a&&a.dispose()}),e({getText:j,getEditor:()=>a,registerCompletionItemProvider:x,getHighlighter:()=>c}),(l,m)=>(n.openBlock(),n.createElementBlock("div",{class:"zephyr-editor_container",ref_key:"monacoEditorRef",ref:h},null,512))}}),d=p(E,[["__scopeId","data-v-96a99f7a"]]);d.install=t=>{t.component("ZzButton",d)};const B=[g,d],Z={install(t){B.forEach(e=>t.component(e.name||"ZzButton",e))}};i.ZephyrEditor=d,i.ZzButton=g,i.default=Z,Object.defineProperties(i,{__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.16",
14
+ "version": "0.0.18",
15
15
  "type": "module",
16
16
  "scripts": {
17
17
  "dev": "vite",
@@ -19,18 +19,21 @@
19
19
  "preview": "vite preview"
20
20
  },
21
21
  "dependencies": {
22
- "sass": "^1.93.2",
23
- "vue": "^3.5.22"
22
+ "@shikijs/monaco": "1.29.2",
23
+ "monaco-editor-core": "0.52.2",
24
+ "shiki": "1.29.2"
24
25
  },
25
26
  "devDependencies": {
26
27
  "@types/node": "^24.6.0",
27
28
  "@vitejs/plugin-vue": "^6.0.1",
28
29
  "@vue/tsconfig": "^0.8.1",
30
+ "sass": "^1.93.2",
29
31
  "sass-embedded": "^1.93.2",
30
32
  "typescript": "~5.9.3",
31
33
  "vite": "^7.1.7",
32
34
  "vite-plugin-dts": "^4.5.4",
33
35
  "vite-plugin-libcss": "^1.1.2",
36
+ "vue": "^3.5.22",
34
37
  "vue-tsc": "^3.1.0"
35
38
  },
36
39
  "files": [