@web-utils/component 3.7.0 → 3.7.2

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.
@@ -1,28 +1,43 @@
1
- var u = Object.defineProperty;
2
- var d = Object.getOwnPropertySymbols;
3
- var c = Object.prototype.hasOwnProperty, f = Object.prototype.propertyIsEnumerable;
4
- var r = (t, e, i) => e in t ? u(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i, h = (t, e) => {
5
- for (var i in e || (e = {}))
6
- c.call(e, i) && r(t, i, e[i]);
7
- if (d)
8
- for (var i of d(e))
9
- f.call(e, i) && r(t, i, e[i]);
10
- return t;
1
+ var y = Object.defineProperty;
2
+ var u = Object.getOwnPropertySymbols;
3
+ var _ = Object.prototype.hasOwnProperty, M = Object.prototype.propertyIsEnumerable;
4
+ var c = (e, t, i) => t in e ? y(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i, f = (e, t) => {
5
+ for (var i in t || (t = {}))
6
+ _.call(t, i) && c(e, i, t[i]);
7
+ if (u)
8
+ for (var i of u(t))
9
+ M.call(t, i) && c(e, i, t[i]);
10
+ return e;
11
11
  };
12
+ var a = (e, t, i) => new Promise((d, s) => {
13
+ var r = (n) => {
14
+ try {
15
+ l(i.next(n));
16
+ } catch (h) {
17
+ s(h);
18
+ }
19
+ }, p = (n) => {
20
+ try {
21
+ l(i.throw(n));
22
+ } catch (h) {
23
+ s(h);
24
+ }
25
+ }, l = (n) => n.done ? d(n.value) : Promise.resolve(n.value).then(r, p);
26
+ l((i = i.apply(e, t)).next());
27
+ });
12
28
  import * as o from "monaco-editor/esm/vs/editor/editor.api";
13
- import "monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution";
14
- import { c as l } from "../chunks/json-beautifier.Bp3GslGm.mjs";
15
- import { NOOP as a } from "@web-utils/core";
16
- import { n as g } from "../chunks/_plugin-vue2_normalizer.CeySl7Fu.mjs";
17
- const m = {
29
+ import { c as g } from "../chunks/json-beautifier.Bp3GslGm.mjs";
30
+ import { NOOP as m } from "@web-utils/core";
31
+ import { n as E } from "../chunks/_plugin-vue2_normalizer.CeySl7Fu.mjs";
32
+ const v = {
18
33
  name: "MonacoEditor",
19
34
  props: {
20
35
  diffEditor: { type: Boolean, default: !1 },
21
- // 是否使用diff模式
36
+ // 是否使用 diff 模式
22
37
  width: { type: [String, Number], default: "100%" },
23
38
  height: { type: [String, Number], default: "100%" },
24
39
  original: String,
25
- // 只有在diff模式下有效
40
+ // 只有在 diff 模式下有效
26
41
  value: [String, Object],
27
42
  language: { type: String, default: "javascript" },
28
43
  theme: { type: String, default: "vs" },
@@ -33,13 +48,18 @@ const m = {
33
48
  return {};
34
49
  }
35
50
  },
36
- editorMounted: { type: Function, default: a },
37
- editorBeforeMount: { type: Function, default: a },
51
+ editorMounted: { type: Function, default: m },
52
+ editorBeforeMount: { type: Function, default: m },
38
53
  keyIndex: { type: String }
39
54
  },
55
+ data() {
56
+ return {
57
+ fullscreen: !1
58
+ };
59
+ },
40
60
  computed: {
41
61
  style() {
42
- return {
62
+ return this.fullscreen ? {} : {
43
63
  width: /^\d+$/.test(this.width) ? `${this.width}px` : this.width,
44
64
  height: /^\d+$/.test(this.height) ? `${this.height}px` : this.height,
45
65
  position: "relative"
@@ -49,20 +69,20 @@ const m = {
49
69
  watch: {
50
70
  options: {
51
71
  deep: !0,
52
- handler(t) {
53
- var e;
54
- (e = this.editor) == null || e.updateOptions(t);
72
+ handler(e) {
73
+ var t;
74
+ (t = this.editor) == null || t.updateOptions(e);
55
75
  }
56
76
  },
57
77
  keyIndex() {
58
- let t = this.value;
59
- typeof t == "object" && (t = l(t)), this.editor && t !== this._getValue() && this._setValue(t);
78
+ let e = this.value;
79
+ typeof e == "object" && (e = g(e)), this.editor && e !== this._getValue() && this._setValue(e);
60
80
  },
61
81
  language() {
62
82
  if (this.editor)
63
83
  if (this.diffEditor) {
64
- const { original: t, modified: e } = this.editor.getModel();
65
- o.editor.setModelLanguage(t, this.language), o.editor.setModelLanguage(e, this.language);
84
+ const { original: e, modified: t } = this.editor.getModel();
85
+ o.editor.setModelLanguage(e, this.language), o.editor.setModelLanguage(t, this.language);
66
86
  } else
67
87
  o.editor.setModelLanguage(this.editor.getModel(), this.language);
68
88
  },
@@ -71,30 +91,59 @@ const m = {
71
91
  },
72
92
  style() {
73
93
  this.$nextTick(() => {
74
- var t;
75
- (t = this.editor) == null || t.layout();
94
+ var e;
95
+ (e = this.editor) == null || e.layout();
76
96
  });
77
97
  },
78
- value(t) {
79
- this.editor && t !== this._getValue() && this._setValue(t);
98
+ value(e) {
99
+ this.editor && e !== this._getValue() && this._setValue(e);
80
100
  }
81
101
  },
82
102
  mounted() {
83
- this.initMonaco();
103
+ this.initMonaco(), window.addEventListener("resize", this.onResize);
84
104
  },
85
105
  beforeDestroy() {
86
- var t;
87
- (t = this.editor) == null || t.dispose();
106
+ var e;
107
+ window.removeEventListener("resize", this.onResize), (e = this.editor) == null || e.dispose();
88
108
  },
89
109
  methods: {
90
110
  initMonaco() {
91
- const { value: t, language: e, theme: i, readOnly: n, options: s } = this;
92
- Object.assign(s, this._editorBeforeMount()), this.editor = o.editor[this.diffEditor ? "createDiffEditor" : "create"](this.$el, h({
93
- value: typeof t == "string" ? t : l(t),
94
- language: e,
111
+ const { value: e, language: t, theme: i, readOnly: d, options: s } = this;
112
+ Object.assign(s, this._editorBeforeMount()), this.editor = o.editor[this.diffEditor ? "createDiffEditor" : "create"](this.$el, f({
113
+ value: typeof e == "string" ? e : g(e),
114
+ language: t,
95
115
  theme: i,
96
- readOnly: n
97
- }, s)), this.diffEditor && this._setModel(this.value, this.original), this._editorMounted(this.editor);
116
+ readOnly: d
117
+ }, s)), this.diffEditor && this._setModel(this.value, this.original), this._editorMounted(this.editor), this.editor.addAction({
118
+ id: "f1",
119
+ label: "full screen",
120
+ keybindings: [o.KeyCode.F1],
121
+ run: (r) => {
122
+ this.toggleFullScreen();
123
+ }
124
+ }), this.editor.addAction({
125
+ id: "escape",
126
+ label: "exit full screen",
127
+ keybindings: [o.KeyCode.Escape],
128
+ run: (r) => {
129
+ this.fullscreen = !1;
130
+ }
131
+ });
132
+ },
133
+ toggleFullScreen() {
134
+ return a(this, null, function* () {
135
+ this.fullscreen = !this.fullscreen;
136
+ });
137
+ },
138
+ onResize() {
139
+ return a(this, null, function* () {
140
+ yield this.$nextTick();
141
+ const e = this.$el;
142
+ this.editor.layout({
143
+ width: e.clientWidth,
144
+ height: e.clientHeight
145
+ });
146
+ });
98
147
  },
99
148
  _handleFullScreen() {
100
149
  this.isMaximum ? this.minEditor() : this.maxEditor();
@@ -102,17 +151,17 @@ const m = {
102
151
  // 放大
103
152
  maxEditor() {
104
153
  this.isMaximum = !0;
105
- const t = this.$el;
154
+ const e = this.$el;
106
155
  this.originSize = {
107
- width: t.clientWidth,
108
- height: t.clientHeight
109
- }, t.classList.add("editor-fullscreen"), this.editor.layout({
156
+ width: e.clientWidth,
157
+ height: e.clientHeight
158
+ }, e.classList.add("editor-fullscreen"), this.editor.layout({
110
159
  height: document.body.clientHeight,
111
160
  width: document.body.clientWidth
112
161
  }), document.addEventListener("keyup", this.handleEsc);
113
162
  },
114
- handleEsc(t) {
115
- t.keyCode === 27 && this.minEditor();
163
+ handleEsc(e) {
164
+ e.keyCode === 27 && this.minEditor();
116
165
  },
117
166
  // 缩小
118
167
  minEditor() {
@@ -124,41 +173,41 @@ const m = {
124
173
  _getEditor() {
125
174
  return this.editor ? this.diffEditor ? this.editor.modifiedEditor : this.editor : null;
126
175
  },
127
- _setModel(t, e) {
128
- const { language: i } = this, n = o.editor.createModel(e, i), s = o.editor.createModel(t, i);
176
+ _setModel(e, t) {
177
+ const { language: i } = this, d = o.editor.createModel(t, i), s = o.editor.createModel(e, i);
129
178
  this.editor.setModel({
130
- original: n,
179
+ original: d,
131
180
  modified: s
132
181
  });
133
182
  },
134
- _setValue(t) {
135
- const e = this._getEditor();
136
- if (e) return e.setValue(t);
183
+ _setValue(e) {
184
+ const t = this._getEditor();
185
+ if (t) return t.setValue(e);
137
186
  },
138
187
  _getValue() {
139
- const t = this._getEditor();
140
- return t ? t.getValue() : "";
188
+ const e = this._getEditor();
189
+ return e ? e.getValue() : "";
141
190
  },
142
191
  _editorBeforeMount() {
143
192
  return this.editorBeforeMount(o) || {};
144
193
  },
145
- _editorMounted(t) {
146
- this.editorMounted(t, o), this.diffEditor ? t.onDidUpdateDiff((e) => {
194
+ _editorMounted(e) {
195
+ this.editorMounted(e, o), this.diffEditor ? e.onDidUpdateDiff((t) => {
147
196
  const i = this._getValue();
148
- this._emitChange(i, e);
149
- }) : t.onDidChangeModelContent((e) => {
197
+ this._emitChange(i, t);
198
+ }) : e.onDidChangeModelContent((t) => {
150
199
  const i = this._getValue();
151
- this._emitChange(i, e);
200
+ this._emitChange(i, t);
152
201
  });
153
202
  },
154
- _emitChange(t, e) {
155
- this.$emit("change", t, e), this.$emit("input", t);
203
+ _emitChange(e, t) {
204
+ this.$emit("change", e, t), this.$emit("input", e);
156
205
  }
157
206
  },
158
- render(t) {
159
- const e = this.options.fullScreen;
160
- return t("div", { class: "monaco_editor_container", style: this.style }, [
161
- e ? t("i", {
207
+ render(e) {
208
+ const t = this.options.fullScreen;
209
+ return e("div", { class: ["monaco_editor_container", this.fullscreen ? "fullscreen" : ""], style: this.style }, [
210
+ t ? e("i", {
162
211
  class: "el-icon-full-screen",
163
212
  style: {
164
213
  width: "1.2em",
@@ -173,16 +222,16 @@ const m = {
173
222
  }) : ""
174
223
  ]);
175
224
  }
176
- }, p = null, _ = null;
177
- var y = /* @__PURE__ */ g(
178
- m,
179
- p,
180
- _,
225
+ }, w = null, x = null;
226
+ var S = /* @__PURE__ */ E(
227
+ v,
228
+ w,
229
+ x,
181
230
  !1,
182
231
  null,
183
232
  null
184
233
  );
185
- const w = y.exports;
234
+ const V = S.exports;
186
235
  export {
187
- w as default
236
+ V as default
188
237
  };
@@ -0,0 +1 @@
1
+ .monaco_editor_container.fullscreen{z-index:9999;background:#fff;width:100%;height:100%;position:fixed;top:0;left:0}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@web-utils/component",
3
3
  "description": "Web Components",
4
- "version": "3.7.0",
4
+ "version": "3.7.2",
5
5
  "author": "Simple",
6
6
  "license": "MIT",
7
7
  "type": "module",
@@ -24,6 +24,7 @@
24
24
  "bpmn-js-token-simulation": "^0.38.1",
25
25
  "codemirror": "^5.65.15",
26
26
  "countup.js": "^2.8.2",
27
+ "cronosjs": "^1.7.1",
27
28
  "dayjs": "^1.11.13",
28
29
  "diagram-js": "15.3.0",
29
30
  "echarts": "^5.6.0",