cmat 0.0.86 → 0.0.88
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/fesm2022/cmat-components-adapter.mjs +9 -9
- package/fesm2022/cmat-components-adapter.mjs.map +1 -1
- package/fesm2022/cmat-components-breadcrumb.mjs +98 -80
- package/fesm2022/cmat-components-breadcrumb.mjs.map +1 -1
- package/fesm2022/cmat-components-card.mjs +26 -34
- package/fesm2022/cmat-components-card.mjs.map +1 -1
- package/fesm2022/cmat-components-carousel.mjs +467 -556
- package/fesm2022/cmat-components-carousel.mjs.map +1 -1
- package/fesm2022/cmat-components-cascade.mjs +270 -259
- package/fesm2022/cmat-components-cascade.mjs.map +1 -1
- package/fesm2022/cmat-components-chip-input.mjs +200 -116
- package/fesm2022/cmat-components-chip-input.mjs.map +1 -1
- package/fesm2022/cmat-components-code-editor.mjs +85 -38
- package/fesm2022/cmat-components-code-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-color-picker.mjs +841 -0
- package/fesm2022/cmat-components-color-picker.mjs.map +1 -0
- package/fesm2022/cmat-components-custom-formly.mjs +1395 -838
- package/fesm2022/cmat-components-custom-formly.mjs.map +1 -1
- package/fesm2022/cmat-components-data-picker.mjs +996 -0
- package/fesm2022/cmat-components-data-picker.mjs.map +1 -0
- package/fesm2022/cmat-components-date-range.mjs +310 -264
- package/fesm2022/cmat-components-date-range.mjs.map +1 -1
- package/fesm2022/cmat-components-date-time-display.mjs +16 -20
- package/fesm2022/cmat-components-date-time-display.mjs.map +1 -1
- package/fesm2022/cmat-components-drawer.mjs +120 -137
- package/fesm2022/cmat-components-drawer.mjs.map +1 -1
- package/fesm2022/cmat-components-empty-state.mjs +17 -24
- package/fesm2022/cmat-components-empty-state.mjs.map +1 -1
- package/fesm2022/cmat-components-file-preview.mjs +18 -24
- package/fesm2022/cmat-components-file-preview.mjs.map +1 -1
- package/fesm2022/cmat-components-filter-toolbar.mjs +30 -39
- package/fesm2022/cmat-components-filter-toolbar.mjs.map +1 -1
- package/fesm2022/cmat-components-form-actions.mjs +12 -12
- package/fesm2022/cmat-components-form-actions.mjs.map +1 -1
- package/fesm2022/cmat-components-fullscreen.mjs +10 -10
- package/fesm2022/cmat-components-fullscreen.mjs.map +1 -1
- package/fesm2022/cmat-components-highlight.mjs +48 -41
- package/fesm2022/cmat-components-highlight.mjs.map +1 -1
- package/fesm2022/cmat-components-image-viewer.mjs +104 -107
- package/fesm2022/cmat-components-image-viewer.mjs.map +1 -1
- package/fesm2022/cmat-components-inline-loading.mjs +12 -15
- package/fesm2022/cmat-components-inline-loading.mjs.map +1 -1
- package/fesm2022/cmat-components-json-editor.mjs +118 -75
- package/fesm2022/cmat-components-json-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-knob-input.mjs +196 -178
- package/fesm2022/cmat-components-knob-input.mjs.map +1 -1
- package/fesm2022/cmat-components-masonry.mjs +26 -41
- package/fesm2022/cmat-components-masonry.mjs.map +1 -1
- package/fesm2022/cmat-components-material-color-picker.mjs +81 -80
- package/fesm2022/cmat-components-material-color-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-material-datetimepicker.mjs +1212 -1287
- package/fesm2022/cmat-components-material-datetimepicker.mjs.map +1 -1
- package/fesm2022/cmat-components-navigation.mjs +467 -450
- package/fesm2022/cmat-components-navigation.mjs.map +1 -1
- package/fesm2022/cmat-components-opt-input.mjs +143 -132
- package/fesm2022/cmat-components-opt-input.mjs.map +1 -1
- package/fesm2022/cmat-components-org-chart.mjs +68 -83
- package/fesm2022/cmat-components-org-chart.mjs.map +1 -1
- package/fesm2022/cmat-components-page-header.mjs +18 -24
- package/fesm2022/cmat-components-page-header.mjs.map +1 -1
- package/fesm2022/cmat-components-pagination.mjs +220 -136
- package/fesm2022/cmat-components-pagination.mjs.map +1 -1
- package/fesm2022/cmat-components-password-strength.mjs +262 -215
- package/fesm2022/cmat-components-password-strength.mjs.map +1 -1
- package/fesm2022/cmat-components-popover.mjs +227 -195
- package/fesm2022/cmat-components-popover.mjs.map +1 -1
- package/fesm2022/cmat-components-progress-bar.mjs +15 -34
- package/fesm2022/cmat-components-progress-bar.mjs.map +1 -1
- package/fesm2022/cmat-components-qrcode.mjs +95 -88
- package/fesm2022/cmat-components-qrcode.mjs.map +1 -1
- package/fesm2022/cmat-components-rating.mjs +70 -67
- package/fesm2022/cmat-components-rating.mjs.map +1 -1
- package/fesm2022/cmat-components-rich-text-editor.mjs +23 -26
- package/fesm2022/cmat-components-rich-text-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-select-search.mjs +190 -159
- package/fesm2022/cmat-components-select-search.mjs.map +1 -1
- package/fesm2022/cmat-components-select-table.mjs +276 -213
- package/fesm2022/cmat-components-select-table.mjs.map +1 -1
- package/fesm2022/cmat-components-select-tree.mjs +178 -128
- package/fesm2022/cmat-components-select-tree.mjs.map +1 -1
- package/fesm2022/cmat-components-skeleton.mjs +44 -28
- package/fesm2022/cmat-components-skeleton.mjs.map +1 -1
- package/fesm2022/cmat-components-speed-dial.mjs +107 -163
- package/fesm2022/cmat-components-speed-dial.mjs.map +1 -1
- package/fesm2022/cmat-components-status-tag.mjs +29 -36
- package/fesm2022/cmat-components-status-tag.mjs.map +1 -1
- package/fesm2022/cmat-components-table-toolbar.mjs +14 -18
- package/fesm2022/cmat-components-table-toolbar.mjs.map +1 -1
- package/fesm2022/cmat-components-timeline.mjs +111 -118
- package/fesm2022/cmat-components-timeline.mjs.map +1 -1
- package/fesm2022/cmat-components-toast.mjs +65 -66
- package/fesm2022/cmat-components-toast.mjs.map +1 -1
- package/fesm2022/cmat-components-transfer-picker.mjs +130 -160
- package/fesm2022/cmat-components-transfer-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-treetable.mjs +32 -39
- package/fesm2022/cmat-components-treetable.mjs.map +1 -1
- package/fesm2022/cmat-components-upload.mjs +186 -176
- package/fesm2022/cmat-components-upload.mjs.map +1 -1
- package/fesm2022/cmat-directives-animate-on-scroll.mjs +25 -28
- package/fesm2022/cmat-directives-animate-on-scroll.mjs.map +1 -1
- package/fesm2022/cmat-directives-arrow-cursor.mjs +85 -92
- package/fesm2022/cmat-directives-arrow-cursor.mjs.map +1 -1
- package/fesm2022/cmat-directives-autofocus.mjs +3 -3
- package/fesm2022/cmat-directives-autofocus.mjs.map +1 -1
- package/fesm2022/cmat-directives-data-exporter.mjs +49 -50
- package/fesm2022/cmat-directives-data-exporter.mjs.map +1 -1
- package/fesm2022/cmat-directives-debounce.mjs +16 -19
- package/fesm2022/cmat-directives-debounce.mjs.map +1 -1
- package/fesm2022/cmat-directives-digit-only.mjs +60 -69
- package/fesm2022/cmat-directives-digit-only.mjs.map +1 -1
- package/fesm2022/cmat-directives-equal-validator.mjs +3 -3
- package/fesm2022/cmat-directives-equal-validator.mjs.map +1 -1
- package/fesm2022/cmat-directives-seamless-auto-scroll.mjs +31 -30
- package/fesm2022/cmat-directives-seamless-auto-scroll.mjs.map +1 -1
- package/fesm2022/cmat-lib-mock-api.mjs +6 -6
- package/fesm2022/cmat-lib-mock-api.mjs.map +1 -1
- package/fesm2022/cmat-pipes-bytes.mjs +3 -3
- package/fesm2022/cmat-pipes-bytes.mjs.map +1 -1
- package/fesm2022/cmat-pipes-date-format.mjs +3 -3
- package/fesm2022/cmat-pipes-date-format.mjs.map +1 -1
- package/fesm2022/cmat-pipes-find-by-key.mjs +3 -3
- package/fesm2022/cmat-pipes-find-by-key.mjs.map +1 -1
- package/fesm2022/cmat-pipes-group-by.mjs +3 -3
- package/fesm2022/cmat-pipes-group-by.mjs.map +1 -1
- package/fesm2022/cmat-pipes-keys.mjs +3 -3
- package/fesm2022/cmat-pipes-keys.mjs.map +1 -1
- package/fesm2022/cmat-pipes-secure.mjs +7 -13
- package/fesm2022/cmat-pipes-secure.mjs.map +1 -1
- package/fesm2022/cmat-pipes-uppercase.mjs +3 -3
- package/fesm2022/cmat-pipes-uppercase.mjs.map +1 -1
- package/fesm2022/cmat-services-alert.mjs +26 -27
- package/fesm2022/cmat-services-alert.mjs.map +1 -1
- package/fesm2022/cmat-services-config.mjs +14 -23
- package/fesm2022/cmat-services-config.mjs.map +1 -1
- package/fesm2022/cmat-services-confirmation.mjs +8 -8
- package/fesm2022/cmat-services-confirmation.mjs.map +1 -1
- package/fesm2022/cmat-services-data.mjs +6 -10
- package/fesm2022/cmat-services-data.mjs.map +1 -1
- package/fesm2022/cmat-services-export-as.mjs +3 -3
- package/fesm2022/cmat-services-export-as.mjs.map +1 -1
- package/fesm2022/cmat-services-loading.mjs +30 -47
- package/fesm2022/cmat-services-loading.mjs.map +1 -1
- package/fesm2022/cmat-services-local-storage.mjs +3 -3
- package/fesm2022/cmat-services-local-storage.mjs.map +1 -1
- package/fesm2022/cmat-services-media-watcher.mjs +43 -34
- package/fesm2022/cmat-services-media-watcher.mjs.map +1 -1
- package/fesm2022/cmat-services-platform.mjs +3 -3
- package/fesm2022/cmat-services-platform.mjs.map +1 -1
- package/fesm2022/cmat-services-splash-screen.mjs +3 -3
- package/fesm2022/cmat-services-splash-screen.mjs.map +1 -1
- package/fesm2022/cmat-services-title.mjs +3 -3
- package/fesm2022/cmat-services-title.mjs.map +1 -1
- package/fesm2022/cmat-services-translation.mjs +11 -11
- package/fesm2022/cmat-services-translation.mjs.map +1 -1
- package/fesm2022/cmat-services-utils.mjs +4 -4
- package/fesm2022/cmat-services-utils.mjs.map +1 -1
- package/fesm2022/cmat.mjs +9229 -7508
- package/fesm2022/cmat.mjs.map +1 -1
- package/icons/material-icons/heroicons-outline.svg +3 -0
- package/icons/material-icons/heroicons-solid.svg +3 -0
- package/package.json +10 -1
- package/styles/components/bundle.scss +21 -0
- package/styles/overrides/angular-material.scss +22 -1
- package/tailwind/plugins/theming.js +183 -183
- package/types/cmat-components-breadcrumb.d.ts +40 -37
- package/types/cmat-components-card.d.ts +11 -13
- package/types/cmat-components-carousel.d.ts +87 -113
- package/types/cmat-components-cascade.d.ts +84 -65
- package/types/cmat-components-chip-input.d.ts +29 -24
- package/types/cmat-components-code-editor.d.ts +28 -12
- package/types/cmat-components-color-picker.d.ts +236 -0
- package/types/cmat-components-custom-formly.d.ts +316 -184
- package/types/cmat-components-data-picker.d.ts +372 -0
- package/types/cmat-components-date-range.d.ts +31 -36
- package/types/cmat-components-date-time-display.d.ts +8 -8
- package/types/cmat-components-drawer.d.ts +30 -32
- package/types/cmat-components-empty-state.d.ts +9 -10
- package/types/cmat-components-file-preview.d.ts +9 -9
- package/types/cmat-components-filter-toolbar.d.ts +15 -15
- package/types/cmat-components-form-actions.d.ts +5 -5
- package/types/cmat-components-fullscreen.d.ts +5 -5
- package/types/cmat-components-highlight.d.ts +13 -14
- package/types/cmat-components-image-viewer.d.ts +29 -33
- package/types/cmat-components-inline-loading.d.ts +6 -6
- package/types/cmat-components-json-editor.d.ts +15 -17
- package/types/cmat-components-knob-input.d.ts +58 -55
- package/types/cmat-components-masonry.d.ts +9 -12
- package/types/cmat-components-material-color-picker.d.ts +16 -21
- package/types/cmat-components-material-datetimepicker.d.ts +174 -216
- package/types/cmat-components-navigation.d.ts +34 -39
- package/types/cmat-components-opt-input.d.ts +35 -33
- package/types/cmat-components-org-chart.d.ts +8 -9
- package/types/cmat-components-page-header.d.ts +9 -9
- package/types/cmat-components-pagination.d.ts +36 -40
- package/types/cmat-components-password-strength.d.ts +58 -64
- package/types/cmat-components-popover.d.ts +22 -32
- package/types/cmat-components-progress-bar.d.ts +7 -10
- package/types/cmat-components-qrcode.d.ts +22 -22
- package/types/cmat-components-rating.d.ts +17 -19
- package/types/cmat-components-rich-text-editor.d.ts +11 -12
- package/types/cmat-components-select-search.d.ts +48 -36
- package/types/cmat-components-select-table.d.ts +38 -34
- package/types/cmat-components-select-tree.d.ts +17 -15
- package/types/cmat-components-skeleton.d.ts +27 -10
- package/types/cmat-components-speed-dial.d.ts +24 -33
- package/types/cmat-components-status-tag.d.ts +19 -9
- package/types/cmat-components-table-toolbar.d.ts +7 -7
- package/types/cmat-components-timeline.d.ts +33 -34
- package/types/cmat-components-toast.d.ts +26 -30
- package/types/cmat-components-transfer-picker.d.ts +51 -56
- package/types/cmat-components-treetable.d.ts +12 -13
- package/types/cmat-components-upload.d.ts +33 -38
- package/types/cmat-components-x6-angular-shape.d.ts +1 -1
- package/types/cmat-directives-animate-on-scroll.d.ts +7 -7
- package/types/cmat-directives-arrow-cursor.d.ts +18 -20
- package/types/cmat-directives-data-exporter.d.ts +10 -10
- package/types/cmat-directives-debounce.d.ts +5 -5
- package/types/cmat-directives-digit-only.d.ts +13 -13
- package/types/cmat-directives-seamless-auto-scroll.d.ts +7 -7
- package/types/cmat-pipes-secure.d.ts +1 -3
- package/types/cmat-services-alert.d.ts +11 -12
- package/types/cmat-services-config.d.ts +2 -7
- package/types/cmat-services-confirmation.d.ts +2 -2
- package/types/cmat-services-data.d.ts +0 -1
- package/types/cmat-services-loading.d.ts +14 -22
- package/types/cmat-services-media-watcher.d.ts +5 -5
- package/types/cmat-services-translation.d.ts +4 -5
- package/types/cmat.d.ts +2167 -1746
|
@@ -1,56 +1,103 @@
|
|
|
1
|
-
import { DOCUMENT } from '@angular/common';
|
|
2
1
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { inject,
|
|
4
|
-
import { EditorComponent } from 'ngx-monaco-editor-v2';
|
|
2
|
+
import { input, output, computed, inject, DOCUMENT, effect, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
5
3
|
|
|
4
|
+
let NEXT_ID = 0;
|
|
6
5
|
class CmatCodeEditorComponent {
|
|
7
6
|
constructor() {
|
|
8
|
-
this.
|
|
9
|
-
this.
|
|
10
|
-
|
|
11
|
-
this.
|
|
12
|
-
|
|
7
|
+
this.id = `cmat-code-editor-${NEXT_ID++}`;
|
|
8
|
+
this.value = input('', /* @ts-ignore */
|
|
9
|
+
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
10
|
+
this.language = input('typescript', /* @ts-ignore */
|
|
11
|
+
...(ngDevMode ? [{ debugName: "language" }] : /* istanbul ignore next */ []));
|
|
12
|
+
this.height = input('320px', /* @ts-ignore */
|
|
13
|
+
...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
|
|
14
|
+
this.readOnly = input(false, /* @ts-ignore */
|
|
15
|
+
...(ngDevMode ? [{ debugName: "readOnly" }] : /* istanbul ignore next */ []));
|
|
16
|
+
this.valueChange = output();
|
|
17
|
+
this.options = input({
|
|
13
18
|
minimap: { enabled: false },
|
|
14
19
|
fontSize: 14,
|
|
15
20
|
automaticLayout: true,
|
|
16
21
|
scrollBeyondLastLine: false,
|
|
17
22
|
wordWrap: 'on'
|
|
18
|
-
}
|
|
23
|
+
}, /* @ts-ignore */
|
|
24
|
+
...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
|
|
25
|
+
this.model = computed(() => ({
|
|
26
|
+
value: this.value(),
|
|
27
|
+
language: this.language(),
|
|
28
|
+
uri: `inmemory://${this.id}`
|
|
29
|
+
}), /* @ts-ignore */
|
|
30
|
+
...(ngDevMode ? [{ debugName: "model" }] : /* istanbul ignore next */ []));
|
|
31
|
+
this.editorOptions = computed(() => ({
|
|
32
|
+
...this.options(),
|
|
33
|
+
readOnly: this.readOnly(),
|
|
34
|
+
theme: this.options()?.theme ?? (this._isDarkTheme ? 'vs-dark' : 'vs')
|
|
35
|
+
}), /* @ts-ignore */
|
|
36
|
+
...(ngDevMode ? [{ debugName: "editorOptions" }] : /* istanbul ignore next */ []));
|
|
37
|
+
this._editorInstance = null;
|
|
38
|
+
this._contentChangeDisposable = null;
|
|
39
|
+
this._isUpdatingFromOutside = false;
|
|
19
40
|
this._document = inject(DOCUMENT);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
// 同步外部 value 变化到编辑器
|
|
42
|
+
effect(() => {
|
|
43
|
+
const newVal = this.value();
|
|
44
|
+
const editor = this._editorInstance;
|
|
45
|
+
if (editor) {
|
|
46
|
+
// 防止在模型未就绪时操作
|
|
47
|
+
if (!editor.getModel())
|
|
48
|
+
return;
|
|
49
|
+
const currentVal = editor.getValue();
|
|
50
|
+
// 只有当值真正不同且不是由内部输入引起时才设置
|
|
51
|
+
if (currentVal !== newVal && !this._isUpdatingFromOutside) {
|
|
52
|
+
// 保存光标位置
|
|
53
|
+
const position = editor.getPosition();
|
|
54
|
+
this._isUpdatingFromOutside = true;
|
|
55
|
+
editor.setValue(newVal);
|
|
56
|
+
// 恢复光标位置
|
|
57
|
+
if (position) {
|
|
58
|
+
editor.setPosition(position);
|
|
59
|
+
}
|
|
60
|
+
this._isUpdatingFromOutside = false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
33
64
|
}
|
|
34
65
|
get _isDarkTheme() {
|
|
35
66
|
return this._document.documentElement.classList.contains('dark') || this._document.body.classList.contains('dark');
|
|
36
67
|
}
|
|
37
|
-
|
|
38
|
-
|
|
68
|
+
ngOnDestroy() {
|
|
69
|
+
if (this._contentChangeDisposable) {
|
|
70
|
+
this._contentChangeDisposable.dispose();
|
|
71
|
+
this._contentChangeDisposable = null;
|
|
72
|
+
}
|
|
73
|
+
this._editorInstance = null;
|
|
74
|
+
}
|
|
75
|
+
onEditorInit(editor) {
|
|
76
|
+
this._editorInstance = editor;
|
|
77
|
+
// 1. 初始化时设置值
|
|
78
|
+
const initialValue = this.value();
|
|
79
|
+
if (initialValue) {
|
|
80
|
+
editor.setValue(initialValue);
|
|
81
|
+
}
|
|
82
|
+
this._contentChangeDisposable = editor.onDidChangeModelContent(() => {
|
|
83
|
+
// 如果是外部更新引起的,不发出事件,避免循环
|
|
84
|
+
if (this._isUpdatingFromOutside) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
// 直接从编辑器实例获取最新值
|
|
88
|
+
const newValue = editor.getValue();
|
|
89
|
+
this.valueChange.emit(newValue);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: CmatCodeEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
93
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.2", type: CmatCodeEditorComponent, isStandalone: true, selector: "cmat-code-editor", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, language: { classPropertyName: "language", publicName: "language", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, readOnly: { classPropertyName: "readOnly", publicName: "readOnly", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange" }, ngImport: i0, template: "<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n@defer (on viewport) {\r\n <div class=\"rounded-2xl border border-default bg-card p-2 shadow-sm\">\r\n <ngx-monaco-editor \r\n class=\"block\" \r\n [style.height]=\"height()\" \r\n [options]=\"editorOptions()\" \r\n [model]=\"model()\"\r\n (onInit)=\"onEditorInit($event)\"\r\n ></ngx-monaco-editor>\r\n </div>\r\n} @placeholder {\r\n <div class=\"flex items-center justify-center rounded-2xl border border-dashed border-default bg-card px-4 py-6 text-sm text-secondary shadow-sm\" [style.minHeight]=\"height()\">\r\n \u4EE3\u7801\u7F16\u8F91\u5668\u52A0\u8F7D\u4E2D...\r\n </div>\r\n}", styles: [":host{display:block}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, deferBlockDependencies: [() => [/* @ts-ignore */
|
|
94
|
+
import('ngx-monaco-editor-v2').then(m => m.EditorComponent)]] }); }
|
|
39
95
|
}
|
|
40
|
-
i0.ɵɵ
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}], language: [{
|
|
46
|
-
type: Input
|
|
47
|
-
}], height: [{
|
|
48
|
-
type: Input
|
|
49
|
-
}], readOnly: [{
|
|
50
|
-
type: Input
|
|
51
|
-
}], options: [{
|
|
52
|
-
type: Input
|
|
53
|
-
}] } });
|
|
96
|
+
i0.ɵɵngDeclareClassMetadataAsync({ minVersion: "18.0.0", version: "22.0.2", ngImport: i0, type: CmatCodeEditorComponent, resolveDeferredDeps: () => [/* @ts-ignore */
|
|
97
|
+
import('ngx-monaco-editor-v2').then(m => m.EditorComponent)], resolveMetadata: EditorComponent => ({ decorators: [{
|
|
98
|
+
type: Component,
|
|
99
|
+
args: [{ selector: 'cmat-code-editor', changeDetection: ChangeDetectionStrategy.OnPush, imports: [EditorComponent], template: "<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n@defer (on viewport) {\r\n <div class=\"rounded-2xl border border-default bg-card p-2 shadow-sm\">\r\n <ngx-monaco-editor \r\n class=\"block\" \r\n [style.height]=\"height()\" \r\n [options]=\"editorOptions()\" \r\n [model]=\"model()\"\r\n (onInit)=\"onEditorInit($event)\"\r\n ></ngx-monaco-editor>\r\n </div>\r\n} @placeholder {\r\n <div class=\"flex items-center justify-center rounded-2xl border border-dashed border-default bg-card px-4 py-6 text-sm text-secondary shadow-sm\" [style.minHeight]=\"height()\">\r\n \u4EE3\u7801\u7F16\u8F91\u5668\u52A0\u8F7D\u4E2D...\r\n </div>\r\n}", styles: [":host{display:block}\n"] }]
|
|
100
|
+
}], ctorParameters: () => [], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], language: [{ type: i0.Input, args: [{ isSignal: true, alias: "language", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], readOnly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readOnly", required: false }] }], valueChange: [{ type: i0.Output, args: ["valueChange"] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } }) });
|
|
54
101
|
|
|
55
102
|
/**
|
|
56
103
|
* Generated bundle index. Do not edit.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cmat-components-code-editor.mjs","sources":["../../../projects/cmat/components/code-editor/code-editor.component.ts","../../../projects/cmat/components/code-editor/code-editor.component.html","../../../projects/cmat/components/code-editor/cmat-components-code-editor.ts"],"sourcesContent":["import { DOCUMENT } from '@angular/
|
|
1
|
+
{"version":3,"file":"cmat-components-code-editor.mjs","sources":["../../../projects/cmat/components/code-editor/code-editor.component.ts","../../../projects/cmat/components/code-editor/code-editor.component.html","../../../projects/cmat/components/code-editor/cmat-components-code-editor.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, computed, effect, input, output, OnDestroy, inject, DOCUMENT } from '@angular/core';\r\nimport type { editor, IDisposable } from 'monaco-editor';\r\nimport { EditorComponent } from 'ngx-monaco-editor-v2';\r\n\r\nlet NEXT_ID = 0;\r\n\r\n@Component({\r\n selector: 'cmat-code-editor',\r\n templateUrl: './code-editor.component.html',\r\n styleUrls: ['./code-editor.component.scss'],\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n imports: [EditorComponent]\r\n})\r\nexport class CmatCodeEditorComponent implements OnDestroy {\r\n readonly id = `cmat-code-editor-${NEXT_ID++}`;\r\n\r\n readonly value = input<string>('');\r\n readonly language = input<string>('typescript');\r\n readonly height = input<string>('320px');\r\n readonly readOnly = input<boolean>(false);\r\n\r\n readonly valueChange = output<string>();\r\n\r\n readonly options = input<Record<string, unknown>>({\r\n minimap: { enabled: false },\r\n fontSize: 14,\r\n automaticLayout: true,\r\n scrollBeyondLastLine: false,\r\n wordWrap: 'on'\r\n });\r\n\r\n readonly model = computed(() => ({\r\n value: this.value(),\r\n language: this.language(),\r\n uri: `inmemory://${this.id}`\r\n }));\r\n\r\n readonly editorOptions = computed(() => ({\r\n ...this.options(),\r\n readOnly: this.readOnly(),\r\n theme: this.options()?.theme ?? (this._isDarkTheme ? 'vs-dark' : 'vs')\r\n }));\r\n\r\n private _editorInstance: editor.IStandaloneCodeEditor | null = null;\r\n private _contentChangeDisposable: IDisposable | null = null;\r\n private _isUpdatingFromOutside = false;\r\n private readonly _document = inject(DOCUMENT);\r\n\r\n constructor() {\r\n // 同步外部 value 变化到编辑器\r\n effect(() => {\r\n const newVal = this.value();\r\n const editor = this._editorInstance;\r\n\r\n if (editor) {\r\n // 防止在模型未就绪时操作\r\n if (!editor.getModel()) return;\r\n\r\n const currentVal = editor.getValue();\r\n\r\n // 只有当值真正不同且不是由内部输入引起时才设置\r\n if (currentVal !== newVal && !this._isUpdatingFromOutside) {\r\n // 保存光标位置\r\n const position = editor.getPosition();\r\n\r\n this._isUpdatingFromOutside = true;\r\n editor.setValue(newVal);\r\n\r\n // 恢复光标位置\r\n if (position) {\r\n editor.setPosition(position);\r\n }\r\n this._isUpdatingFromOutside = false;\r\n }\r\n }\r\n });\r\n }\r\n\r\n private get _isDarkTheme(): boolean {\r\n return this._document.documentElement.classList.contains('dark') || this._document.body.classList.contains('dark');\r\n }\r\n\r\n ngOnDestroy(): void {\r\n if (this._contentChangeDisposable) {\r\n this._contentChangeDisposable.dispose();\r\n this._contentChangeDisposable = null;\r\n }\r\n this._editorInstance = null;\r\n }\r\n\r\n onEditorInit(editor: editor.IStandaloneCodeEditor): void {\r\n this._editorInstance = editor;\r\n\r\n // 1. 初始化时设置值\r\n const initialValue = this.value();\r\n if (initialValue) {\r\n editor.setValue(initialValue);\r\n }\r\n\r\n this._contentChangeDisposable = editor.onDidChangeModelContent(() => {\r\n // 如果是外部更新引起的,不发出事件,避免循环\r\n if (this._isUpdatingFromOutside) {\r\n return;\r\n }\r\n\r\n // 直接从编辑器实例获取最新值\r\n const newValue = editor.getValue();\r\n this.valueChange.emit(newValue);\r\n });\r\n }\r\n\r\n\r\n}","<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n@defer (on viewport) {\r\n <div class=\"rounded-2xl border border-default bg-card p-2 shadow-sm\">\r\n <ngx-monaco-editor \r\n class=\"block\" \r\n [style.height]=\"height()\" \r\n [options]=\"editorOptions()\" \r\n [model]=\"model()\"\r\n (onInit)=\"onEditorInit($event)\"\r\n ></ngx-monaco-editor>\r\n </div>\r\n} @placeholder {\r\n <div class=\"flex items-center justify-center rounded-2xl border border-dashed border-default bg-card px-4 py-6 text-sm text-secondary shadow-sm\" [style.minHeight]=\"height()\">\r\n 代码编辑器加载中...\r\n </div>\r\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAIA,IAAI,OAAO,GAAG,CAAC;MASF,uBAAuB,CAAA;AAmChC,IAAA,WAAA,GAAA;AAlCS,QAAA,IAAA,CAAA,EAAE,GAAG,CAAA,iBAAA,EAAoB,OAAO,EAAE,EAAE;QAEpC,IAAA,CAAA,KAAK,GAAG,KAAK,CAAS,EAAE;kFAAC;QACzB,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAS,YAAY;qFAAC;QACtC,IAAA,CAAA,MAAM,GAAG,KAAK,CAAS,OAAO;mFAAC;QAC/B,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAU,KAAK;qFAAC;QAEhC,IAAA,CAAA,WAAW,GAAG,MAAM,EAAU;QAE9B,IAAA,CAAA,OAAO,GAAG,KAAK,CAA0B;AAC9C,YAAA,OAAO,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;AAC3B,YAAA,QAAQ,EAAE,EAAE;AACZ,YAAA,eAAe,EAAE,IAAI;AACrB,YAAA,oBAAoB,EAAE,KAAK;AAC3B,YAAA,QAAQ,EAAE;AACb,SAAA;oFAAC;AAEO,QAAA,IAAA,CAAA,KAAK,GAAG,QAAQ,CAAC,OAAO;AAC7B,YAAA,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE;AACnB,YAAA,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE;AACzB,YAAA,GAAG,EAAE,CAAA,WAAA,EAAc,IAAI,CAAC,EAAE,CAAA;SAC7B,CAAC;kFAAC;AAEM,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