@jetlinks-web/components 2.6.11 → 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.
Files changed (40) hide show
  1. package/es/EditTable/Body.js +0 -1
  2. package/es/EditTable/components/Search/sort.js +1 -1
  3. package/es/EditTable/style/body.less +1 -0
  4. package/es/EditTable/style/index.css +4 -3
  5. package/es/EditTable/style/table.less +3 -3
  6. package/es/FullPage/FullPage.js +1 -1
  7. package/es/Search/Advanced/SaveHistory.js +1 -1
  8. package/es/Search/Advanced/index.js +6 -7
  9. package/es/Search/Item.js +1 -1
  10. package/es/ValueItem/ValueItem.js +9 -57
  11. package/es/components.js +0 -1
  12. package/es/style/index.css +4 -7
  13. package/es/style/index.less +0 -1
  14. package/es/style.js +0 -1
  15. package/lib/EditTable/Body.js +0 -1
  16. package/lib/EditTable/components/Search/sort.js +1 -1
  17. package/lib/EditTable/style/body.less +1 -0
  18. package/lib/EditTable/style/index.css +4 -3
  19. package/lib/EditTable/style/table.less +3 -3
  20. package/lib/FullPage/FullPage.js +1 -1
  21. package/lib/Search/Advanced/SaveHistory.js +1 -1
  22. package/lib/Search/Advanced/index.js +6 -7
  23. package/lib/Search/Item.js +1 -1
  24. package/lib/ValueItem/ValueItem.js +9 -57
  25. package/lib/components.js +0 -7
  26. package/lib/style/components.less +0 -1
  27. package/lib/style/index.css +4 -7
  28. package/lib/style/index.less +0 -1
  29. package/lib/style.js +0 -1
  30. package/package.json +4 -4
  31. package/es/MonacoEditor/Monaco.js +0 -242
  32. package/es/MonacoEditor/index.js +0 -5
  33. package/es/MonacoEditor/style/index.css +0 -4
  34. package/es/MonacoEditor/style/index.js +0 -1
  35. package/es/MonacoEditor/style/index.less +0 -4
  36. package/lib/MonacoEditor/Monaco.js +0 -242
  37. package/lib/MonacoEditor/index.js +0 -12
  38. package/lib/MonacoEditor/style/index.css +0 -4
  39. package/lib/MonacoEditor/style/index.js +0 -3
  40. package/lib/MonacoEditor/style/index.less +0 -4
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";
@@ -4858,9 +4858,9 @@ span.ant-radio + * {
4858
4858
  }
4859
4859
  .jetlinks-edit-table-wrapper .jetlinks-edit-table .jetlinks-table-horizontal-scroll {
4860
4860
  width: 100%;
4861
- height: 10px;
4862
- min-height: 10px;
4863
- max-height: 10px;
4861
+ height: 15px;
4862
+ min-height: 15px;
4863
+ max-height: 15px;
4864
4864
  display: flex;
4865
4865
  }
4866
4866
  .jetlinks-edit-table-wrapper .jetlinks-edit-table .jetlinks-table-horizontal-scroll .jetlinks-table-horizontal-scroll-bar {
@@ -4892,6 +4892,7 @@ span.ant-radio + * {
4892
4892
  }
4893
4893
  .jetlinks-edit-table-body-viewport .jetlinks-edit-table-center .jetlinks-edit-table-row {
4894
4894
  width: 100%;
4895
+ display: flex;
4895
4896
  align-items: center;
4896
4897
  transition: top 0.2s, height 0.2s, background-color 0.1s;
4897
4898
  border-bottom: 1px solid #ebebeb;
@@ -5088,10 +5089,6 @@ span.ant-radio + * {
5088
5089
  height: 100%;
5089
5090
  overflow-x: hidden;
5090
5091
  }
5091
- .j-monaco-editor {
5092
- min-height: 50px;
5093
- height: 100%;
5094
- }
5095
5092
  .j-scrollbar {
5096
5093
  overflow: hidden;
5097
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.11",
3
+ "version": "3.0.0-rc",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -158,9 +158,9 @@
158
158
  "webpack-dev-server": "^4.0.0",
159
159
  "webpack-merge": "^5.0.0",
160
160
  "webpackbar": "^5.0.2",
161
- "@jetlinks-web/utils": "^1.2.9",
162
- "@jetlinks-web/hooks": "^1.0.25",
163
- "@jetlinks-web/constants": "^1.0.9"
161
+ "@jetlinks-web/constants": "^1.0.9",
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
- }