@jetlinks-web/components 2.6.12 → 3.0.0-rc

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.
@@ -42,7 +42,7 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
42
42
  "onDesc": "setup-const"
43
43
  } */
44
44
  import { unref as _unref, toDisplayString as _toDisplayString, createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, createTextVNode as _createTextVNode, withCtx as _withCtx, createVNode as _createVNode, normalizeClass as _normalizeClass, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
45
- const _withScopeId = n => (_pushScopeId("data-v-1744797585363"), n = n(), _popScopeId(), n);
45
+ const _withScopeId = n => (_pushScopeId("data-v-1745819698356"), n = n(), _popScopeId(), n);
46
46
  const _hoisted_1 = { class: "jetlinks-table-sort-content" };
47
47
  const _hoisted_2 = { class: "jetlinks-table-sort-title" };
48
48
  const _hoisted_3 = { class: "table-sort-body" };
@@ -9,7 +9,7 @@
9
9
  } */
10
10
  import { defineComponent as _defineComponent } from 'vue';
11
11
  import { unref as _unref, renderSlot as _renderSlot, createElementVNode as _createElementVNode, normalizeStyle as _normalizeStyle, openBlock as _openBlock, createElementBlock as _createElementBlock, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
12
- const _withScopeId = n => (_pushScopeId("data-v-1744797583796"), n = n(), _popScopeId(), n);
12
+ const _withScopeId = n => (_pushScopeId("data-v-1745819696751"), n = n(), _popScopeId(), n);
13
13
  const _hoisted_1 = { class: "full-page-warp-content" };
14
14
  import { ref, inject } from 'vue';
15
15
  import { useElementBounding } from '@vueuse/core';
@@ -23,7 +23,7 @@
23
23
  } */
24
24
  import { defineComponent as _defineComponent } from 'vue';
25
25
  import { unref as _unref, createVNode as _createVNode, withCtx as _withCtx, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, createBlock as _createBlock, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
26
- const _withScopeId = n => (_pushScopeId("data-v-1744797585097"), n = n(), _popScopeId(), n);
26
+ const _withScopeId = n => (_pushScopeId("data-v-1745819698180"), n = n(), _popScopeId(), n);
27
27
  const _hoisted_1 = {
28
28
  key: 0,
29
29
  style: { "width": "240px" }
@@ -17,7 +17,7 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
17
17
  /* Analyzed bindings: {
18
18
  "columns": "props",
19
19
  "type": "props",
20
- "target": "setup-maybe-ref",
20
+ "target": "setup-ref",
21
21
  "class": "props",
22
22
  "request": "props",
23
23
  "historyRequest": "props",
@@ -56,7 +56,7 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
56
56
  "searchRef": "setup-ref",
57
57
  "searchRefContentRef": "setup-ref",
58
58
  "width": "setup-maybe-ref",
59
- "q": "setup-maybe-ref",
59
+ "q": "setup-ref",
60
60
  "hasOnceSearch": "setup-ref",
61
61
  "expand": "setup-ref",
62
62
  "layout": "setup-ref",
@@ -103,7 +103,6 @@ const _hoisted_12 = { class: "JSearch-footer--btns" };
103
103
  import SearchItem from '../Item.js';
104
104
  import { optionsMapKey, typeOptions } from '../setting';
105
105
  import { useElementSize } from '@vueuse/core';
106
- import { useRouteQuery } from '@vueuse/router';
107
106
  import { ref, reactive, watch, provide } from 'vue';
108
107
  import SaveHistory from './SaveHistory.js';
109
108
  import History from './History.js';
@@ -171,8 +170,8 @@ const __sfc_main__ = _defineComponent({
171
170
  const searchRef = ref(null);
172
171
  const searchRefContentRef = ref(null);
173
172
  const { width } = useElementSize(searchRef);
174
- const q = useRouteQuery('q');
175
- const target = useRouteQuery('target');
173
+ const q = ref('q');
174
+ const target = ref('target');
176
175
  const hasOnceSearch = ref(false);
177
176
  // 是否展开更多筛选
178
177
  const expand = ref(false);
@@ -487,11 +486,11 @@ const __sfc_main__ = _defineComponent({
487
486
  }),
488
487
  _createVNode(SaveHistory, {
489
488
  terms: termsData,
490
- target: _unref(target),
489
+ target: target.value,
491
490
  request: __props.request
492
491
  }, null, 8 /* PROPS */, ["terms", "target", "request"]),
493
492
  _createVNode(History, {
494
- target: _unref(target),
493
+ target: target.value,
495
494
  request: __props.historyRequest,
496
495
  "delete-request": __props.deleteRequest,
497
496
  "delete-key": __props.deleteKey,
package/es/Search/Item.js CHANGED
@@ -80,7 +80,7 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
80
80
  } */
81
81
  import { defineComponent as _defineComponent } from 'vue';
82
82
  import { unref as _unref, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, toDisplayString as _toDisplayString, createElementBlock as _createElementBlock, createVNode as _createVNode, Fragment as _Fragment, normalizeStyle as _normalizeStyle, mergeProps as _mergeProps, resolveDynamicComponent as _resolveDynamicComponent, withCtx as _withCtx, createElementVNode as _createElementVNode, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
83
- const _withScopeId = n => (_pushScopeId("data-v-1744797584295"), n = n(), _popScopeId(), n);
83
+ const _withScopeId = n => (_pushScopeId("data-v-1745819697261"), n = n(), _popScopeId(), n);
84
84
  const _hoisted_1 = { class: "JSearch-item" };
85
85
  const _hoisted_2 = {
86
86
  key: 0,
@@ -34,7 +34,6 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
34
34
  "watch": "setup-const",
35
35
  "computed": "setup-const",
36
36
  "componentsType": "setup-maybe-ref",
37
- "MonacoEditor": "setup-maybe-ref",
38
37
  "Select": "setup-maybe-ref",
39
38
  "DatePicker": "setup-maybe-ref",
40
39
  "TimePicker": "setup-maybe-ref",
@@ -42,27 +41,21 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
42
41
  "InputNumber": "setup-maybe-ref",
43
42
  "InputPassword": "setup-maybe-ref",
44
43
  "Upload": "setup-maybe-ref",
45
- "Modal": "setup-maybe-ref",
46
44
  "omit": "setup-maybe-ref",
47
45
  "emit": "setup-const",
48
46
  "props": "setup-reactive-const",
49
47
  "typeMap": "setup-maybe-ref",
50
48
  "myValue": "setup-ref",
51
- "modalVisible": "setup-ref",
52
49
  "objectValue": "setup-ref",
53
50
  "bindProps": "setup-ref",
54
- "handleItemModalSubmit": "setup-const",
55
- "onChange": "setup-const",
56
- "monacoCancel": "setup-const"
51
+ "onChange": "setup-const"
57
52
  } */
58
53
  import { defineComponent as _defineComponent } from 'vue';
59
- import { unref as _unref, mergeProps as _mergeProps, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, resolveComponent as _resolveComponent, createVNode as _createVNode, withCtx as _withCtx, createElementVNode as _createElementVNode, createElementBlock as _createElementBlock } from "vue";
54
+ import { unref as _unref, mergeProps as _mergeProps, openBlock as _openBlock, createBlock as _createBlock, resolveComponent as _resolveComponent, createVNode as _createVNode, withCtx as _withCtx, createElementBlock as _createElementBlock } from "vue";
60
55
  const _hoisted_1 = { class: "value-item-warp" };
61
- const _hoisted_2 = { style: { "width": "100%", "height": "300px" } };
62
56
  import { ref, watch, computed } from 'vue';
63
57
  import { componentsType } from './util';
64
- import { MonacoEditor } from '../index';
65
- import { Select, DatePicker, TimePicker, Input, InputNumber, InputPassword, Upload, Modal, } from 'ant-design-vue';
58
+ import { Select, DatePicker, TimePicker, Input, InputNumber, InputPassword, Upload, } from 'ant-design-vue';
66
59
  import { omit } from "lodash-es";
67
60
  const __sfc_main__ = _defineComponent({
68
61
  ...{
@@ -106,25 +99,14 @@ const __sfc_main__ = _defineComponent({
106
99
  const props = __props;
107
100
  const typeMap = new Map(Object.entries(componentsType));
108
101
  const myValue = ref(undefined);
109
- const modalVisible = ref(false);
110
102
  const objectValue = ref('');
111
103
  const bindProps = computed(() => {
112
104
  return Object.assign(omit(props, ['extraProps']), props.extraProps);
113
105
  });
114
- const handleItemModalSubmit = () => {
115
- myValue.value = objectValue.value.replace(/[\r\n]\s*/g, '');
116
- modalVisible.value = false;
117
- emit('update:modelValue', objectValue.value);
118
- emit('change', objectValue.value);
119
- };
120
106
  const onChange = (e) => {
121
107
  emit('update:modelValue', myValue.value);
122
108
  emit('change', e && e.target ? e.target.value : e);
123
109
  };
124
- const monacoCancel = () => {
125
- modalVisible.value = false;
126
- objectValue.value = props.modelValue;
127
- };
128
110
  const handleFileChange = async (info) => {
129
111
  if (info.file.status === 'done') {
130
112
  let url = _optionalChain([info, 'access', _2 => _2.file, 'access', _3 => _3.response, 'optionalAccess', _4 => _4.result, 'optionalAccess', _5 => _5.accessUrl]);
@@ -204,22 +186,14 @@ const __sfc_main__ = _defineComponent({
204
186
  ? (_openBlock(), _createBlock(_unref(Input), _mergeProps({
205
187
  key: 6,
206
188
  value: myValue.value,
207
- "onUpdate:value": _cache[8] || (_cache[8] = ($event) => ((myValue).value = $event)),
189
+ "onUpdate:value": _cache[7] || (_cache[7] = ($event) => ((myValue).value = $event)),
208
190
  allowClear: ""
209
- }, bindProps.value, { onChange: onChange }), {
210
- addonAfter: _withCtx(() => [
211
- _createVNode(_component_AIcon, {
212
- type: "FormOutlined",
213
- onClick: _cache[7] || (_cache[7] = ($event) => (modalVisible.value = true))
214
- })
215
- ]),
216
- _: 1 /* STABLE */
217
- }, 16 /* FULL_PROPS */, ["value"]))
191
+ }, bindProps.value, { onChange: onChange }), null, 16 /* FULL_PROPS */, ["value"]))
218
192
  : (_unref(typeMap).get(__props.itemType) === 'file')
219
193
  ? (_openBlock(), _createBlock(_unref(Input), _mergeProps({
220
194
  key: 7,
221
195
  value: myValue.value,
222
- "onUpdate:value": _cache[9] || (_cache[9] = ($event) => ((myValue).value = $event)),
196
+ "onUpdate:value": _cache[8] || (_cache[8] = ($event) => ((myValue).value = $event)),
223
197
  allowClear: "",
224
198
  placeholder: "请输入链接"
225
199
  }, bindProps.value, { onChange: onChange }), {
@@ -243,39 +217,17 @@ const __sfc_main__ = _defineComponent({
243
217
  ? (_openBlock(), _createBlock(_unref(InputPassword), _mergeProps({
244
218
  key: 8,
245
219
  value: myValue.value,
246
- "onUpdate:value": _cache[10] || (_cache[10] = ($event) => ((myValue).value = $event)),
220
+ "onUpdate:value": _cache[9] || (_cache[9] = ($event) => ((myValue).value = $event)),
247
221
  allowClear: "",
248
222
  type: "password"
249
223
  }, bindProps.value, { onChange: onChange }), null, 16 /* FULL_PROPS */, ["value"]))
250
224
  : (_openBlock(), _createBlock(_unref(Input), _mergeProps({
251
225
  key: 9,
252
226
  value: myValue.value,
253
- "onUpdate:value": _cache[11] || (_cache[11] = ($event) => ((myValue).value = $event)),
227
+ "onUpdate:value": _cache[10] || (_cache[10] = ($event) => ((myValue).value = $event)),
254
228
  allowClear: "",
255
229
  type: "text"
256
- }, bindProps.value, { onChange: onChange }), null, 16 /* FULL_PROPS */, ["value"])),
257
- _createCommentVNode(" 代码编辑器弹窗 "),
258
- _createVNode(_unref(Modal), {
259
- visible: modalVisible.value,
260
- "onUpdate:visible": _cache[13] || (_cache[13] = ($event) => ((modalVisible).value = $event)),
261
- zIndex: 1100,
262
- "cancel-text": "取消",
263
- "ok-text": "确认",
264
- title: "编辑",
265
- width: "700px",
266
- onCancel: monacoCancel,
267
- onOk: handleItemModalSubmit
268
- }, {
269
- default: _withCtx(() => [
270
- _createElementVNode("div", _hoisted_2, [
271
- _createVNode(_unref(MonacoEditor), {
272
- modelValue: objectValue.value,
273
- "onUpdate:modelValue": _cache[12] || (_cache[12] = ($event) => ((objectValue).value = $event))
274
- }, null, 8 /* PROPS */, ["modelValue"])
275
- ])
276
- ]),
277
- _: 1 /* STABLE */
278
- }, 8 /* PROPS */, ["visible"])
230
+ }, bindProps.value, { onChange: onChange }), null, 16 /* FULL_PROPS */, ["value"]))
279
231
  ]));
280
232
  };
281
233
  }
package/es/components.js CHANGED
@@ -8,7 +8,6 @@ export { default as Ellipsis } from './Ellipsis';
8
8
  export { default as Empty } from './Empty';
9
9
  export { default as FullPage } from './FullPage';
10
10
  export { default as AIcon } from './Icon';
11
- export { default as MonacoEditor } from './MonacoEditor';
12
11
  export { default as PermissionButton } from './PermissionButton';
13
12
  export { default as ProLayout, PageContainer } from './ProLayout';
14
13
  export { default as ProTable } from './ProTable';
@@ -5089,10 +5089,6 @@ span.ant-radio + * {
5089
5089
  height: 100%;
5090
5090
  overflow-x: hidden;
5091
5091
  }
5092
- .j-monaco-editor {
5093
- min-height: 50px;
5094
- height: 100%;
5095
- }
5096
5092
  .j-scrollbar {
5097
5093
  overflow: hidden;
5098
5094
  position: relative;
@@ -7,7 +7,6 @@
7
7
  @import '../CardSelect/style/index.less';
8
8
  @import '../DragModal/style/index.less';
9
9
  @import "../EditTable/style/index.less";
10
- @import "../MonacoEditor/style/index.less";
11
10
  @import '../Scrollbar/style/index.less';
12
11
  @import '../Title/style/index.less';
13
12
  @import '../RadioButton/style/index.less';
package/es/style.js CHANGED
@@ -6,7 +6,6 @@ import './Search/style';
6
6
  import './CardSelect/style';
7
7
  import './DragModal/style';
8
8
  import './EditTable/style';
9
- import './MonacoEditor/style';
10
9
  import './Scrollbar/style';
11
10
  import './Title/style';
12
11
  import './RadioButton/style';
@@ -42,7 +42,7 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
42
42
  "onDesc": "setup-const"
43
43
  } */
44
44
  import { unref as _unref, toDisplayString as _toDisplayString, createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, createTextVNode as _createTextVNode, withCtx as _withCtx, createVNode as _createVNode, normalizeClass as _normalizeClass, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
45
- const _withScopeId = n => (_pushScopeId("data-v-1744797585382"), n = n(), _popScopeId(), n);
45
+ const _withScopeId = n => (_pushScopeId("data-v-1745819698332"), n = n(), _popScopeId(), n);
46
46
  const _hoisted_1 = { class: "jetlinks-table-sort-content" };
47
47
  const _hoisted_2 = { class: "jetlinks-table-sort-title" };
48
48
  const _hoisted_3 = { class: "table-sort-body" };
@@ -9,7 +9,7 @@
9
9
  } */
10
10
  import { defineComponent as _defineComponent } from 'vue';
11
11
  import { unref as _unref, renderSlot as _renderSlot, createElementVNode as _createElementVNode, normalizeStyle as _normalizeStyle, openBlock as _openBlock, createElementBlock as _createElementBlock, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
12
- const _withScopeId = n => (_pushScopeId("data-v-1744797583803"), n = n(), _popScopeId(), n);
12
+ const _withScopeId = n => (_pushScopeId("data-v-1745819696744"), n = n(), _popScopeId(), n);
13
13
  const _hoisted_1 = { class: "full-page-warp-content" };
14
14
  import { ref, inject } from 'vue';
15
15
  import { useElementBounding } from '@vueuse/core';
@@ -23,7 +23,7 @@
23
23
  } */
24
24
  import { defineComponent as _defineComponent } from 'vue';
25
25
  import { unref as _unref, createVNode as _createVNode, withCtx as _withCtx, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, createBlock as _createBlock, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
26
- const _withScopeId = n => (_pushScopeId("data-v-1744797585115"), n = n(), _popScopeId(), n);
26
+ const _withScopeId = n => (_pushScopeId("data-v-1745819698162"), n = n(), _popScopeId(), n);
27
27
  const _hoisted_1 = {
28
28
  key: 0,
29
29
  style: { "width": "240px" }
@@ -17,7 +17,7 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
17
17
  /* Analyzed bindings: {
18
18
  "columns": "props",
19
19
  "type": "props",
20
- "target": "setup-maybe-ref",
20
+ "target": "setup-ref",
21
21
  "class": "props",
22
22
  "request": "props",
23
23
  "historyRequest": "props",
@@ -56,7 +56,7 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
56
56
  "searchRef": "setup-ref",
57
57
  "searchRefContentRef": "setup-ref",
58
58
  "width": "setup-maybe-ref",
59
- "q": "setup-maybe-ref",
59
+ "q": "setup-ref",
60
60
  "hasOnceSearch": "setup-ref",
61
61
  "expand": "setup-ref",
62
62
  "layout": "setup-ref",
@@ -103,7 +103,6 @@ const _hoisted_12 = { class: "JSearch-footer--btns" };
103
103
  import SearchItem from '../Item.js';
104
104
  import { optionsMapKey, typeOptions } from '../setting';
105
105
  import { useElementSize } from '@vueuse/core';
106
- import { useRouteQuery } from '@vueuse/router';
107
106
  import { ref, reactive, watch, provide } from 'vue';
108
107
  import SaveHistory from './SaveHistory.js';
109
108
  import History from './History.js';
@@ -171,8 +170,8 @@ const __sfc_main__ = _defineComponent({
171
170
  const searchRef = ref(null);
172
171
  const searchRefContentRef = ref(null);
173
172
  const { width } = useElementSize(searchRef);
174
- const q = useRouteQuery('q');
175
- const target = useRouteQuery('target');
173
+ const q = ref('q');
174
+ const target = ref('target');
176
175
  const hasOnceSearch = ref(false);
177
176
  // 是否展开更多筛选
178
177
  const expand = ref(false);
@@ -487,11 +486,11 @@ const __sfc_main__ = _defineComponent({
487
486
  }),
488
487
  _createVNode(SaveHistory, {
489
488
  terms: termsData,
490
- target: _unref(target),
489
+ target: target.value,
491
490
  request: __props.request
492
491
  }, null, 8 /* PROPS */, ["terms", "target", "request"]),
493
492
  _createVNode(History, {
494
- target: _unref(target),
493
+ target: target.value,
495
494
  request: __props.historyRequest,
496
495
  "delete-request": __props.deleteRequest,
497
496
  "delete-key": __props.deleteKey,
@@ -80,7 +80,7 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
80
80
  } */
81
81
  import { defineComponent as _defineComponent } from 'vue';
82
82
  import { unref as _unref, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, toDisplayString as _toDisplayString, createElementBlock as _createElementBlock, createVNode as _createVNode, Fragment as _Fragment, normalizeStyle as _normalizeStyle, mergeProps as _mergeProps, resolveDynamicComponent as _resolveDynamicComponent, withCtx as _withCtx, createElementVNode as _createElementVNode, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
83
- const _withScopeId = n => (_pushScopeId("data-v-1744797584354"), n = n(), _popScopeId(), n);
83
+ const _withScopeId = n => (_pushScopeId("data-v-1745819697205"), n = n(), _popScopeId(), n);
84
84
  const _hoisted_1 = { class: "JSearch-item" };
85
85
  const _hoisted_2 = {
86
86
  key: 0,
@@ -34,7 +34,6 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
34
34
  "watch": "setup-const",
35
35
  "computed": "setup-const",
36
36
  "componentsType": "setup-maybe-ref",
37
- "MonacoEditor": "setup-maybe-ref",
38
37
  "Select": "setup-maybe-ref",
39
38
  "DatePicker": "setup-maybe-ref",
40
39
  "TimePicker": "setup-maybe-ref",
@@ -42,27 +41,21 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
42
41
  "InputNumber": "setup-maybe-ref",
43
42
  "InputPassword": "setup-maybe-ref",
44
43
  "Upload": "setup-maybe-ref",
45
- "Modal": "setup-maybe-ref",
46
44
  "omit": "setup-maybe-ref",
47
45
  "emit": "setup-const",
48
46
  "props": "setup-reactive-const",
49
47
  "typeMap": "setup-maybe-ref",
50
48
  "myValue": "setup-ref",
51
- "modalVisible": "setup-ref",
52
49
  "objectValue": "setup-ref",
53
50
  "bindProps": "setup-ref",
54
- "handleItemModalSubmit": "setup-const",
55
- "onChange": "setup-const",
56
- "monacoCancel": "setup-const"
51
+ "onChange": "setup-const"
57
52
  } */
58
53
  import { defineComponent as _defineComponent } from 'vue';
59
- import { unref as _unref, mergeProps as _mergeProps, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, resolveComponent as _resolveComponent, createVNode as _createVNode, withCtx as _withCtx, createElementVNode as _createElementVNode, createElementBlock as _createElementBlock } from "vue";
54
+ import { unref as _unref, mergeProps as _mergeProps, openBlock as _openBlock, createBlock as _createBlock, resolveComponent as _resolveComponent, createVNode as _createVNode, withCtx as _withCtx, createElementBlock as _createElementBlock } from "vue";
60
55
  const _hoisted_1 = { class: "value-item-warp" };
61
- const _hoisted_2 = { style: { "width": "100%", "height": "300px" } };
62
56
  import { ref, watch, computed } from 'vue';
63
57
  import { componentsType } from './util';
64
- import { MonacoEditor } from '../index';
65
- import { Select, DatePicker, TimePicker, Input, InputNumber, InputPassword, Upload, Modal, } from 'ant-design-vue';
58
+ import { Select, DatePicker, TimePicker, Input, InputNumber, InputPassword, Upload, } from 'ant-design-vue';
66
59
  import { omit } from "lodash-es";
67
60
  const __sfc_main__ = _defineComponent({
68
61
  ...{
@@ -106,25 +99,14 @@ const __sfc_main__ = _defineComponent({
106
99
  const props = __props;
107
100
  const typeMap = new Map(Object.entries(componentsType));
108
101
  const myValue = ref(undefined);
109
- const modalVisible = ref(false);
110
102
  const objectValue = ref('');
111
103
  const bindProps = computed(() => {
112
104
  return Object.assign(omit(props, ['extraProps']), props.extraProps);
113
105
  });
114
- const handleItemModalSubmit = () => {
115
- myValue.value = objectValue.value.replace(/[\r\n]\s*/g, '');
116
- modalVisible.value = false;
117
- emit('update:modelValue', objectValue.value);
118
- emit('change', objectValue.value);
119
- };
120
106
  const onChange = (e) => {
121
107
  emit('update:modelValue', myValue.value);
122
108
  emit('change', e && e.target ? e.target.value : e);
123
109
  };
124
- const monacoCancel = () => {
125
- modalVisible.value = false;
126
- objectValue.value = props.modelValue;
127
- };
128
110
  const handleFileChange = async (info) => {
129
111
  if (info.file.status === 'done') {
130
112
  let url = _optionalChain([info, 'access', _2 => _2.file, 'access', _3 => _3.response, 'optionalAccess', _4 => _4.result, 'optionalAccess', _5 => _5.accessUrl]);
@@ -204,22 +186,14 @@ const __sfc_main__ = _defineComponent({
204
186
  ? (_openBlock(), _createBlock(_unref(Input), _mergeProps({
205
187
  key: 6,
206
188
  value: myValue.value,
207
- "onUpdate:value": _cache[8] || (_cache[8] = ($event) => ((myValue).value = $event)),
189
+ "onUpdate:value": _cache[7] || (_cache[7] = ($event) => ((myValue).value = $event)),
208
190
  allowClear: ""
209
- }, bindProps.value, { onChange: onChange }), {
210
- addonAfter: _withCtx(() => [
211
- _createVNode(_component_AIcon, {
212
- type: "FormOutlined",
213
- onClick: _cache[7] || (_cache[7] = ($event) => (modalVisible.value = true))
214
- })
215
- ]),
216
- _: 1 /* STABLE */
217
- }, 16 /* FULL_PROPS */, ["value"]))
191
+ }, bindProps.value, { onChange: onChange }), null, 16 /* FULL_PROPS */, ["value"]))
218
192
  : (_unref(typeMap).get(__props.itemType) === 'file')
219
193
  ? (_openBlock(), _createBlock(_unref(Input), _mergeProps({
220
194
  key: 7,
221
195
  value: myValue.value,
222
- "onUpdate:value": _cache[9] || (_cache[9] = ($event) => ((myValue).value = $event)),
196
+ "onUpdate:value": _cache[8] || (_cache[8] = ($event) => ((myValue).value = $event)),
223
197
  allowClear: "",
224
198
  placeholder: "请输入链接"
225
199
  }, bindProps.value, { onChange: onChange }), {
@@ -243,39 +217,17 @@ const __sfc_main__ = _defineComponent({
243
217
  ? (_openBlock(), _createBlock(_unref(InputPassword), _mergeProps({
244
218
  key: 8,
245
219
  value: myValue.value,
246
- "onUpdate:value": _cache[10] || (_cache[10] = ($event) => ((myValue).value = $event)),
220
+ "onUpdate:value": _cache[9] || (_cache[9] = ($event) => ((myValue).value = $event)),
247
221
  allowClear: "",
248
222
  type: "password"
249
223
  }, bindProps.value, { onChange: onChange }), null, 16 /* FULL_PROPS */, ["value"]))
250
224
  : (_openBlock(), _createBlock(_unref(Input), _mergeProps({
251
225
  key: 9,
252
226
  value: myValue.value,
253
- "onUpdate:value": _cache[11] || (_cache[11] = ($event) => ((myValue).value = $event)),
227
+ "onUpdate:value": _cache[10] || (_cache[10] = ($event) => ((myValue).value = $event)),
254
228
  allowClear: "",
255
229
  type: "text"
256
- }, bindProps.value, { onChange: onChange }), null, 16 /* FULL_PROPS */, ["value"])),
257
- _createCommentVNode(" 代码编辑器弹窗 "),
258
- _createVNode(_unref(Modal), {
259
- visible: modalVisible.value,
260
- "onUpdate:visible": _cache[13] || (_cache[13] = ($event) => ((modalVisible).value = $event)),
261
- zIndex: 1100,
262
- "cancel-text": "取消",
263
- "ok-text": "确认",
264
- title: "编辑",
265
- width: "700px",
266
- onCancel: monacoCancel,
267
- onOk: handleItemModalSubmit
268
- }, {
269
- default: _withCtx(() => [
270
- _createElementVNode("div", _hoisted_2, [
271
- _createVNode(_unref(MonacoEditor), {
272
- modelValue: objectValue.value,
273
- "onUpdate:modelValue": _cache[12] || (_cache[12] = ($event) => ((objectValue).value = $event))
274
- }, null, 8 /* PROPS */, ["modelValue"])
275
- ])
276
- ]),
277
- _: 1 /* STABLE */
278
- }, 8 /* PROPS */, ["visible"])
230
+ }, bindProps.value, { onChange: onChange }), null, 16 /* FULL_PROPS */, ["value"]))
279
231
  ]));
280
232
  };
281
233
  }
package/lib/components.js CHANGED
@@ -101,12 +101,6 @@ Object.defineProperty(exports, "Markdown", {
101
101
  return _Markdown.default;
102
102
  }
103
103
  });
104
- Object.defineProperty(exports, "MonacoEditor", {
105
- enumerable: true,
106
- get: function get() {
107
- return _MonacoEditor.default;
108
- }
109
- });
110
104
  Object.defineProperty(exports, "PageContainer", {
111
105
  enumerable: true,
112
106
  get: function get() {
@@ -171,7 +165,6 @@ var _Ellipsis = _interopRequireDefault(require("./Ellipsis"));
171
165
  var _Empty = _interopRequireDefault(require("./Empty"));
172
166
  var _FullPage = _interopRequireDefault(require("./FullPage"));
173
167
  var _Icon = _interopRequireDefault(require("./Icon"));
174
- var _MonacoEditor = _interopRequireDefault(require("./MonacoEditor"));
175
168
  var _PermissionButton = _interopRequireDefault(require("./PermissionButton"));
176
169
  var _ProLayout = _interopRequireWildcard(require("./ProLayout"));
177
170
  var _ProTable = _interopRequireDefault(require("./ProTable"));
@@ -4,7 +4,6 @@
4
4
  @import "../EditTable/style/index-pure.less";
5
5
  @import "../Ellipsis/style/index-pure.less";
6
6
  @import "../FlameGraph/style/index-pure.less";
7
- @import "../MonacoEditor/style/index-pure.less";
8
7
  @import "../RadioButton/style/index-pure.less";
9
8
  @import "../Scrollbar/style/index-pure.less";
10
9
  @import "../Title/style/index-pure.less";
@@ -5089,10 +5089,6 @@ span.ant-radio + * {
5089
5089
  height: 100%;
5090
5090
  overflow-x: hidden;
5091
5091
  }
5092
- .j-monaco-editor {
5093
- min-height: 50px;
5094
- height: 100%;
5095
- }
5096
5092
  .j-scrollbar {
5097
5093
  overflow: hidden;
5098
5094
  position: relative;
@@ -7,7 +7,6 @@
7
7
  @import '../CardSelect/style/index.less';
8
8
  @import '../DragModal/style/index.less';
9
9
  @import "../EditTable/style/index.less";
10
- @import "../MonacoEditor/style/index.less";
11
10
  @import '../Scrollbar/style/index.less';
12
11
  @import '../Title/style/index.less';
13
12
  @import '../RadioButton/style/index.less';
package/lib/style.js CHANGED
@@ -8,7 +8,6 @@ require("./Search/style");
8
8
  require("./CardSelect/style");
9
9
  require("./DragModal/style");
10
10
  require("./EditTable/style");
11
- require("./MonacoEditor/style");
12
11
  require("./Scrollbar/style");
13
12
  require("./Title/style");
14
13
  require("./RadioButton/style");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetlinks-web/components",
3
- "version": "2.6.12",
3
+ "version": "3.0.0-rc",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -159,8 +159,8 @@
159
159
  "webpack-merge": "^5.0.0",
160
160
  "webpackbar": "^5.0.2",
161
161
  "@jetlinks-web/constants": "^1.0.9",
162
- "@jetlinks-web/utils": "^1.2.9",
163
- "@jetlinks-web/hooks": "^1.0.25"
162
+ "@jetlinks-web/hooks": "^1.0.28",
163
+ "@jetlinks-web/utils": "^1.2.12"
164
164
  },
165
165
  "publishConfig": {
166
166
  "registry": "https://registry.npmjs.org/",
@@ -1,242 +0,0 @@
1
- function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) {
2
- const op = ops[i];
3
- const fn = ops[i + 1];
4
- i += 2;
5
- if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
6
- return undefined;
7
- }
8
- if (op === 'access' || op === 'optionalAccess') {
9
- lastAccessLHS = value;
10
- value = fn(value);
11
- }
12
- else if (op === 'call' || op === 'optionalCall') {
13
- value = fn((...args) => value.call(lastAccessLHS, ...args));
14
- lastAccessLHS = undefined;
15
- }
16
- } return value; }
17
- /* Analyzed bindings: {
18
- "modelValue": "props",
19
- "theme": "props",
20
- "language": "props",
21
- "codeTips": "props",
22
- "init": "props",
23
- "registrationTips": "props",
24
- "registrationTypescript": "props",
25
- "blurFormat": "props",
26
- "readOnly": "props",
27
- "options": "props",
28
- "ref": "setup-const",
29
- "onMounted": "setup-const",
30
- "watch": "setup-const",
31
- "onUnmounted": "setup-const",
32
- "toRaw": "setup-const",
33
- "nextTick": "setup-const",
34
- "monaco": "setup-const",
35
- "omit": "setup-maybe-ref",
36
- "props": "setup-reactive-const",
37
- "emit": "setup-const",
38
- "dom": "setup-ref",
39
- "instance": "setup-let",
40
- "monacoProviderRef": "setup-ref",
41
- "monacoTypescriptProviderRef": "setup-ref",
42
- "handleSuggestions": "setup-const",
43
- "disposeRegister": "setup-const",
44
- "registerCompletionItemProvider": "setup-const",
45
- "disposeTypescript": "setup-const",
46
- "registerTypescript": "setup-const",
47
- "editorFormat": "setup-const",
48
- "insert": "setup-const"
49
- } */
50
- import { openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
51
- import { ref, onMounted, watch, onUnmounted, nextTick } from 'vue';
52
- import * as monaco from 'monaco-editor';
53
- import { omit } from 'lodash-es';
54
- const __sfc_main__ = Object.assign({
55
- name: 'JMonacoEditor'
56
- }, {
57
- props: {
58
- modelValue: [String, Number],
59
- theme: { type: String, default: 'vs-dark' },
60
- language: { type: String, default: 'json' },
61
- codeTips: { type: Array, default: () => [] },
62
- init: { type: Function, default: undefined },
63
- registrationTips: { type: Object, default: () => ({}) },
64
- registrationTypescript: { type: Object, default: () => ({}) },
65
- blurFormat: { type: Boolean, default: true },
66
- readOnly: { type: Boolean, default: false },
67
- options: { type: Object, default: () => ({}) },
68
- },
69
- emits: [
70
- 'update:modelValue',
71
- 'blur',
72
- 'focus',
73
- 'change',
74
- 'errorChange',
75
- ],
76
- setup(__props, { expose: __expose, emit: __emit }) {
77
- const props = __props;
78
- const emit = __emit;
79
- const dom = ref();
80
- let instance;
81
- const monacoProviderRef = ref();
82
- const monacoTypescriptProviderRef = ref();
83
- // codeTipItem.dispose() // 销毁自定义提示
84
- const handleSuggestions = (suggestions, range) => {
85
- return Array.isArray(suggestions)
86
- ? suggestions.map((item) => ({ ...item, range }))
87
- : [];
88
- };
89
- const disposeRegister = () => {
90
- _optionalChain([monacoProviderRef, 'access', _ => _.value, 'optionalAccess', _2 => _2.dispose, 'call', _3 => _3()]);
91
- monacoProviderRef.value = null;
92
- };
93
- /**
94
- * 代码提示注册
95
- */
96
- const registerCompletionItemProvider = () => {
97
- disposeRegister();
98
- if (monaco.languages && _optionalChain([props, 'access', _4 => _4.registrationTips, 'optionalAccess', _5 => _5.suggestions])) {
99
- const { name, suggestions } = props.registrationTips;
100
- monacoProviderRef.value =
101
- monaco.languages.registerCompletionItemProvider(name || 'json', {
102
- provideCompletionItems: function (model, position) {
103
- const word = model.getWordUntilPosition(position); // 获取提示代码范围位置
104
- const range = {
105
- startLineNumber: position.lineNumber,
106
- endLineNumber: position.lineNumber,
107
- startColumn: word.startColumn,
108
- endColumn: word.endColumn,
109
- };
110
- return {
111
- suggestions: handleSuggestions(suggestions, range),
112
- };
113
- },
114
- });
115
- }
116
- };
117
- const disposeTypescript = () => {
118
- _optionalChain([monacoTypescriptProviderRef, 'access', _6 => _6.value, 'optionalAccess', _7 => _7.dispose, 'call', _8 => _8()]);
119
- monacoTypescriptProviderRef.value = null;
120
- };
121
- const registerTypescript = () => {
122
- disposeTypescript();
123
- if (monaco.languages && _optionalChain([props, 'access', _9 => _9.registrationTypescript, 'optionalAccess', _10 => _10.typescript])) {
124
- const { name, typescript } = props.registrationTypescript;
125
- monacoTypescriptProviderRef.value =
126
- monaco.languages.typescript.javascriptDefaults.addExtraLib(typescript);
127
- }
128
- };
129
- /**
130
- * 代码格式化
131
- */
132
- const editorFormat = () => {
133
- if (!instance)
134
- return;
135
- setTimeout(() => {
136
- _optionalChain([instance, 'access', _11 => _11.getAction, 'call', _12 => _12('editor.action.formatDocument'), 'optionalAccess', _13 => _13.run, 'call', _14 => _14()]);
137
- }, 300);
138
- if (props.hasOwnProperty('readOnly')) {
139
- setTimeout(() => {
140
- instance.updateOptions({
141
- readOnly: props.readOnly !== false,
142
- });
143
- }, 400);
144
- }
145
- };
146
- monaco.editor.onDidChangeMarkers(([uri]) => {
147
- const markers = monaco.editor.getModelMarkers({ resource: uri });
148
- emit('errorChange', markers);
149
- });
150
- onMounted(async () => {
151
- const _model = monaco.editor.createModel(props.modelValue, props.language);
152
- instance = monaco.editor.create(dom.value, {
153
- model: _model,
154
- tabSize: 2,
155
- automaticLayout: true,
156
- scrollBeyondLastLine: false,
157
- theme: props.theme,
158
- formatOnPaste: true,
159
- ...(omit(props.options, ['readOnly']) || {}),
160
- });
161
- instance.onDidChangeModelContent(() => {
162
- //
163
- const value = instance.getValue();
164
- nextTick(() => {
165
- emit('update:modelValue', value);
166
- emit('change', value);
167
- });
168
- });
169
- instance.onDidBlurEditorText(() => {
170
- emit('blur');
171
- if (props.blurFormat) {
172
- editorFormat();
173
- }
174
- });
175
- instance.onDidFocusEditorText(() => {
176
- emit('focus');
177
- });
178
- if (props.modelValue) {
179
- setTimeout(() => {
180
- editorFormat();
181
- }, 200);
182
- }
183
- _optionalChain([props, 'access', _15 => _15.init, 'optionalCall', _16 => _16(instance, monaco)]);
184
- });
185
- /**
186
- * 光标位置插入内容
187
- * @param {String} val
188
- * @param position
189
- */
190
- const insert = (val, position) => {
191
- if (!instance)
192
- return;
193
- const _position = position || instance.getPosition();
194
- const value = instance.getValue();
195
- if (position && position.lineNumber) {
196
- instance.setPosition(position);
197
- }
198
- instance.executeEdits(value, [
199
- {
200
- range: new monaco.Range(_optionalChain([_position, 'optionalAccess', _17 => _17.lineNumber]), _optionalChain([_position, 'optionalAccess', _18 => _18.column]), _optionalChain([_position, 'optionalAccess', _19 => _19.lineNumber]), _optionalChain([_position, 'optionalAccess', _20 => _20.column])),
201
- text: val,
202
- },
203
- ]);
204
- };
205
- watch(() => props.modelValue, (val) => {
206
- if (!instance ||
207
- (instance &&
208
- props.modelValue === instance.getValue()))
209
- return;
210
- // setValue之前获取光标位置
211
- const position = instance.getPosition();
212
- // setValue之后光标位置改变
213
- instance.setValue(val);
214
- // 设置光标位置为setValue之前的位置
215
- instance.setPosition(position);
216
- editorFormat();
217
- });
218
- watch(() => JSON.stringify(props.registrationTips), () => {
219
- registerCompletionItemProvider();
220
- }, { immediate: true });
221
- watch(() => JSON.stringify(props.registrationTypescript), () => {
222
- registerTypescript();
223
- }, { immediate: true });
224
- onUnmounted(() => {
225
- disposeRegister();
226
- disposeTypescript();
227
- _optionalChain([instance, 'access', _21 => _21.editor, 'optionalAccess', _22 => _22.dispose, 'optionalCall', _23 => _23()]);
228
- });
229
- __expose({
230
- editorFormat,
231
- insert,
232
- });
233
- return (_ctx, _cache) => {
234
- return (_openBlock(), _createElementBlock("div", {
235
- ref_key: "dom",
236
- ref: dom,
237
- class: "j-monaco-editor"
238
- }, null, 512 /* NEED_PATCH */));
239
- };
240
- }
241
- });
242
- export default __sfc_main__;
@@ -1,5 +0,0 @@
1
- import Monaco from './Monaco.js';
2
- Monaco.install = function (app) {
3
- app.component(Monaco.name, Monaco);
4
- };
5
- export default Monaco;
@@ -1,4 +0,0 @@
1
- .j-monaco-editor {
2
- min-height: 50px;
3
- height: 100%;
4
- }
@@ -1 +0,0 @@
1
- import './index.less';
@@ -1,4 +0,0 @@
1
- .j-monaco-editor {
2
- min-height: 50px;
3
- height: 100%;
4
- }
@@ -1,242 +0,0 @@
1
- function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) {
2
- const op = ops[i];
3
- const fn = ops[i + 1];
4
- i += 2;
5
- if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
6
- return undefined;
7
- }
8
- if (op === 'access' || op === 'optionalAccess') {
9
- lastAccessLHS = value;
10
- value = fn(value);
11
- }
12
- else if (op === 'call' || op === 'optionalCall') {
13
- value = fn((...args) => value.call(lastAccessLHS, ...args));
14
- lastAccessLHS = undefined;
15
- }
16
- } return value; }
17
- /* Analyzed bindings: {
18
- "modelValue": "props",
19
- "theme": "props",
20
- "language": "props",
21
- "codeTips": "props",
22
- "init": "props",
23
- "registrationTips": "props",
24
- "registrationTypescript": "props",
25
- "blurFormat": "props",
26
- "readOnly": "props",
27
- "options": "props",
28
- "ref": "setup-const",
29
- "onMounted": "setup-const",
30
- "watch": "setup-const",
31
- "onUnmounted": "setup-const",
32
- "toRaw": "setup-const",
33
- "nextTick": "setup-const",
34
- "monaco": "setup-const",
35
- "omit": "setup-maybe-ref",
36
- "props": "setup-reactive-const",
37
- "emit": "setup-const",
38
- "dom": "setup-ref",
39
- "instance": "setup-let",
40
- "monacoProviderRef": "setup-ref",
41
- "monacoTypescriptProviderRef": "setup-ref",
42
- "handleSuggestions": "setup-const",
43
- "disposeRegister": "setup-const",
44
- "registerCompletionItemProvider": "setup-const",
45
- "disposeTypescript": "setup-const",
46
- "registerTypescript": "setup-const",
47
- "editorFormat": "setup-const",
48
- "insert": "setup-const"
49
- } */
50
- import { openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
51
- import { ref, onMounted, watch, onUnmounted, nextTick } from 'vue';
52
- import * as monaco from 'monaco-editor';
53
- import { omit } from 'lodash-es';
54
- const __sfc_main__ = Object.assign({
55
- name: 'JMonacoEditor'
56
- }, {
57
- props: {
58
- modelValue: [String, Number],
59
- theme: { type: String, default: 'vs-dark' },
60
- language: { type: String, default: 'json' },
61
- codeTips: { type: Array, default: () => [] },
62
- init: { type: Function, default: undefined },
63
- registrationTips: { type: Object, default: () => ({}) },
64
- registrationTypescript: { type: Object, default: () => ({}) },
65
- blurFormat: { type: Boolean, default: true },
66
- readOnly: { type: Boolean, default: false },
67
- options: { type: Object, default: () => ({}) },
68
- },
69
- emits: [
70
- 'update:modelValue',
71
- 'blur',
72
- 'focus',
73
- 'change',
74
- 'errorChange',
75
- ],
76
- setup(__props, { expose: __expose, emit: __emit }) {
77
- const props = __props;
78
- const emit = __emit;
79
- const dom = ref();
80
- let instance;
81
- const monacoProviderRef = ref();
82
- const monacoTypescriptProviderRef = ref();
83
- // codeTipItem.dispose() // 销毁自定义提示
84
- const handleSuggestions = (suggestions, range) => {
85
- return Array.isArray(suggestions)
86
- ? suggestions.map((item) => ({ ...item, range }))
87
- : [];
88
- };
89
- const disposeRegister = () => {
90
- _optionalChain([monacoProviderRef, 'access', _ => _.value, 'optionalAccess', _2 => _2.dispose, 'call', _3 => _3()]);
91
- monacoProviderRef.value = null;
92
- };
93
- /**
94
- * 代码提示注册
95
- */
96
- const registerCompletionItemProvider = () => {
97
- disposeRegister();
98
- if (monaco.languages && _optionalChain([props, 'access', _4 => _4.registrationTips, 'optionalAccess', _5 => _5.suggestions])) {
99
- const { name, suggestions } = props.registrationTips;
100
- monacoProviderRef.value =
101
- monaco.languages.registerCompletionItemProvider(name || 'json', {
102
- provideCompletionItems: function (model, position) {
103
- const word = model.getWordUntilPosition(position); // 获取提示代码范围位置
104
- const range = {
105
- startLineNumber: position.lineNumber,
106
- endLineNumber: position.lineNumber,
107
- startColumn: word.startColumn,
108
- endColumn: word.endColumn,
109
- };
110
- return {
111
- suggestions: handleSuggestions(suggestions, range),
112
- };
113
- },
114
- });
115
- }
116
- };
117
- const disposeTypescript = () => {
118
- _optionalChain([monacoTypescriptProviderRef, 'access', _6 => _6.value, 'optionalAccess', _7 => _7.dispose, 'call', _8 => _8()]);
119
- monacoTypescriptProviderRef.value = null;
120
- };
121
- const registerTypescript = () => {
122
- disposeTypescript();
123
- if (monaco.languages && _optionalChain([props, 'access', _9 => _9.registrationTypescript, 'optionalAccess', _10 => _10.typescript])) {
124
- const { name, typescript } = props.registrationTypescript;
125
- monacoTypescriptProviderRef.value =
126
- monaco.languages.typescript.javascriptDefaults.addExtraLib(typescript);
127
- }
128
- };
129
- /**
130
- * 代码格式化
131
- */
132
- const editorFormat = () => {
133
- if (!instance)
134
- return;
135
- setTimeout(() => {
136
- _optionalChain([instance, 'access', _11 => _11.getAction, 'call', _12 => _12('editor.action.formatDocument'), 'optionalAccess', _13 => _13.run, 'call', _14 => _14()]);
137
- }, 300);
138
- if (props.hasOwnProperty('readOnly')) {
139
- setTimeout(() => {
140
- instance.updateOptions({
141
- readOnly: props.readOnly !== false,
142
- });
143
- }, 400);
144
- }
145
- };
146
- monaco.editor.onDidChangeMarkers(([uri]) => {
147
- const markers = monaco.editor.getModelMarkers({ resource: uri });
148
- emit('errorChange', markers);
149
- });
150
- onMounted(async () => {
151
- const _model = monaco.editor.createModel(props.modelValue, props.language);
152
- instance = monaco.editor.create(dom.value, {
153
- model: _model,
154
- tabSize: 2,
155
- automaticLayout: true,
156
- scrollBeyondLastLine: false,
157
- theme: props.theme,
158
- formatOnPaste: true,
159
- ...(omit(props.options, ['readOnly']) || {}),
160
- });
161
- instance.onDidChangeModelContent(() => {
162
- //
163
- const value = instance.getValue();
164
- nextTick(() => {
165
- emit('update:modelValue', value);
166
- emit('change', value);
167
- });
168
- });
169
- instance.onDidBlurEditorText(() => {
170
- emit('blur');
171
- if (props.blurFormat) {
172
- editorFormat();
173
- }
174
- });
175
- instance.onDidFocusEditorText(() => {
176
- emit('focus');
177
- });
178
- if (props.modelValue) {
179
- setTimeout(() => {
180
- editorFormat();
181
- }, 200);
182
- }
183
- _optionalChain([props, 'access', _15 => _15.init, 'optionalCall', _16 => _16(instance, monaco)]);
184
- });
185
- /**
186
- * 光标位置插入内容
187
- * @param {String} val
188
- * @param position
189
- */
190
- const insert = (val, position) => {
191
- if (!instance)
192
- return;
193
- const _position = position || instance.getPosition();
194
- const value = instance.getValue();
195
- if (position && position.lineNumber) {
196
- instance.setPosition(position);
197
- }
198
- instance.executeEdits(value, [
199
- {
200
- range: new monaco.Range(_optionalChain([_position, 'optionalAccess', _17 => _17.lineNumber]), _optionalChain([_position, 'optionalAccess', _18 => _18.column]), _optionalChain([_position, 'optionalAccess', _19 => _19.lineNumber]), _optionalChain([_position, 'optionalAccess', _20 => _20.column])),
201
- text: val,
202
- },
203
- ]);
204
- };
205
- watch(() => props.modelValue, (val) => {
206
- if (!instance ||
207
- (instance &&
208
- props.modelValue === instance.getValue()))
209
- return;
210
- // setValue之前获取光标位置
211
- const position = instance.getPosition();
212
- // setValue之后光标位置改变
213
- instance.setValue(val);
214
- // 设置光标位置为setValue之前的位置
215
- instance.setPosition(position);
216
- editorFormat();
217
- });
218
- watch(() => JSON.stringify(props.registrationTips), () => {
219
- registerCompletionItemProvider();
220
- }, { immediate: true });
221
- watch(() => JSON.stringify(props.registrationTypescript), () => {
222
- registerTypescript();
223
- }, { immediate: true });
224
- onUnmounted(() => {
225
- disposeRegister();
226
- disposeTypescript();
227
- _optionalChain([instance, 'access', _21 => _21.editor, 'optionalAccess', _22 => _22.dispose, 'optionalCall', _23 => _23()]);
228
- });
229
- __expose({
230
- editorFormat,
231
- insert,
232
- });
233
- return (_ctx, _cache) => {
234
- return (_openBlock(), _createElementBlock("div", {
235
- ref_key: "dom",
236
- ref: dom,
237
- class: "j-monaco-editor"
238
- }, null, 512 /* NEED_PATCH */));
239
- };
240
- }
241
- });
242
- export default __sfc_main__;
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _Monaco = _interopRequireDefault(require("./Monaco.js"));
9
- _Monaco.default.install = function (app) {
10
- app.component(_Monaco.default.name, _Monaco.default);
11
- };
12
- var _default = exports.default = _Monaco.default;
@@ -1,4 +0,0 @@
1
- .j-monaco-editor {
2
- min-height: 50px;
3
- height: 100%;
4
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
-
3
- require("./index.less");
@@ -1,4 +0,0 @@
1
- .j-monaco-editor {
2
- min-height: 50px;
3
- height: 100%;
4
- }