@acorex/components 21.0.0-next.3 → 21.0.0-next.31
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/accordion/index.d.ts +0 -1
- package/autocomplete/index.d.ts +23 -9
- package/button/index.d.ts +38 -17
- package/chips/index.d.ts +3 -8
- package/code-editor/README.md +291 -1
- package/code-editor/index.d.ts +260 -12
- package/command/index.d.ts +1 -0
- package/conversation2/README.md +426 -0
- package/conversation2/index.d.ts +6139 -0
- package/data-table/index.d.ts +79 -7
- package/dialog/index.d.ts +1 -1
- package/drawer/README.md +2 -2
- package/drawer/index.d.ts +33 -57
- package/drawer-legacy/README.md +3 -0
- package/drawer-legacy/index.d.ts +86 -0
- package/editor/README.md +3 -0
- package/editor/index.d.ts +79 -0
- package/fesm2022/acorex-components-accordion.mjs +19 -24
- package/fesm2022/acorex-components-accordion.mjs.map +1 -1
- package/fesm2022/acorex-components-action-sheet.mjs +12 -12
- package/fesm2022/acorex-components-action-sheet.mjs.map +1 -1
- package/fesm2022/acorex-components-alert.mjs +14 -14
- package/fesm2022/acorex-components-alert.mjs.map +1 -1
- package/fesm2022/acorex-components-aspect-ratio.mjs +4 -4
- package/fesm2022/acorex-components-aspect-ratio.mjs.map +1 -1
- package/fesm2022/acorex-components-audio-wave.mjs +12 -11
- package/fesm2022/acorex-components-audio-wave.mjs.map +1 -1
- package/fesm2022/acorex-components-autocomplete.mjs +30 -13
- package/fesm2022/acorex-components-autocomplete.mjs.map +1 -1
- package/fesm2022/acorex-components-avatar.mjs +13 -13
- package/fesm2022/acorex-components-avatar.mjs.map +1 -1
- package/fesm2022/acorex-components-badge.mjs +10 -10
- package/fesm2022/acorex-components-badge.mjs.map +1 -1
- package/fesm2022/acorex-components-bottom-navigation.mjs +12 -12
- package/fesm2022/acorex-components-bottom-navigation.mjs.map +1 -1
- package/fesm2022/acorex-components-breadcrumbs.mjs +12 -12
- package/fesm2022/acorex-components-breadcrumbs.mjs.map +1 -1
- package/fesm2022/acorex-components-button-group.mjs +17 -19
- package/fesm2022/acorex-components-button-group.mjs.map +1 -1
- package/fesm2022/acorex-components-button.mjs +78 -29
- package/fesm2022/acorex-components-button.mjs.map +1 -1
- package/fesm2022/acorex-components-calendar.mjs +18 -18
- package/fesm2022/acorex-components-calendar.mjs.map +1 -1
- package/fesm2022/acorex-components-check-box.mjs +11 -11
- package/fesm2022/acorex-components-check-box.mjs.map +1 -1
- package/fesm2022/acorex-components-chips.mjs +12 -14
- package/fesm2022/acorex-components-chips.mjs.map +1 -1
- package/fesm2022/acorex-components-circular-progress.mjs +13 -11
- package/fesm2022/acorex-components-circular-progress.mjs.map +1 -1
- package/fesm2022/acorex-components-code-editor.mjs +494 -162
- package/fesm2022/acorex-components-code-editor.mjs.map +1 -1
- package/fesm2022/acorex-components-collapse.mjs +13 -28
- package/fesm2022/acorex-components-collapse.mjs.map +1 -1
- package/fesm2022/acorex-components-color-box.mjs +11 -11
- package/fesm2022/acorex-components-color-box.mjs.map +1 -1
- package/fesm2022/acorex-components-color-palette.mjs +32 -32
- package/fesm2022/acorex-components-color-palette.mjs.map +1 -1
- package/fesm2022/acorex-components-command.mjs +18 -11
- package/fesm2022/acorex-components-command.mjs.map +1 -1
- package/fesm2022/acorex-components-comment.mjs +34 -34
- package/fesm2022/acorex-components-comment.mjs.map +1 -1
- package/fesm2022/acorex-components-conversation.mjs +56 -65
- package/fesm2022/acorex-components-conversation.mjs.map +1 -1
- package/fesm2022/acorex-components-conversation2.mjs +17641 -0
- package/fesm2022/acorex-components-conversation2.mjs.map +1 -0
- package/fesm2022/acorex-components-cron-job.mjs +53 -53
- package/fesm2022/acorex-components-cron-job.mjs.map +1 -1
- package/fesm2022/acorex-components-data-list.mjs +5 -5
- package/fesm2022/acorex-components-data-list.mjs.map +1 -1
- package/fesm2022/acorex-components-data-pager.mjs +53 -41
- package/fesm2022/acorex-components-data-pager.mjs.map +1 -1
- package/fesm2022/acorex-components-data-table.mjs +462 -105
- package/fesm2022/acorex-components-data-table.mjs.map +1 -1
- package/fesm2022/acorex-components-datetime-box.mjs +10 -10
- package/fesm2022/acorex-components-datetime-box.mjs.map +1 -1
- package/fesm2022/acorex-components-datetime-input.mjs +8 -8
- package/fesm2022/acorex-components-datetime-input.mjs.map +1 -1
- package/fesm2022/acorex-components-datetime-picker.mjs +11 -11
- package/fesm2022/acorex-components-datetime-picker.mjs.map +1 -1
- package/fesm2022/acorex-components-decorators.mjs +96 -54
- package/fesm2022/acorex-components-decorators.mjs.map +1 -1
- package/fesm2022/acorex-components-dialog.mjs +26 -16
- package/fesm2022/acorex-components-dialog.mjs.map +1 -1
- package/fesm2022/acorex-components-drawer-legacy.mjs +218 -0
- package/fesm2022/acorex-components-drawer-legacy.mjs.map +1 -0
- package/fesm2022/acorex-components-drawer.mjs +66 -150
- package/fesm2022/acorex-components-drawer.mjs.map +1 -1
- package/fesm2022/acorex-components-dropdown-button.mjs +9 -9
- package/fesm2022/acorex-components-dropdown-button.mjs.map +1 -1
- package/fesm2022/acorex-components-dropdown.mjs +18 -16
- package/fesm2022/acorex-components-dropdown.mjs.map +1 -1
- package/fesm2022/acorex-components-editor.mjs +195 -0
- package/fesm2022/acorex-components-editor.mjs.map +1 -0
- package/fesm2022/acorex-components-file-explorer.mjs +28 -28
- package/fesm2022/acorex-components-file-explorer.mjs.map +1 -1
- package/fesm2022/acorex-components-flow-chart.mjs +18 -18
- package/fesm2022/acorex-components-flow-chart.mjs.map +1 -1
- package/fesm2022/acorex-components-form.mjs +52 -35
- package/fesm2022/acorex-components-form.mjs.map +1 -1
- package/fesm2022/acorex-components-grid-layout-builder.mjs +14 -15
- package/fesm2022/acorex-components-grid-layout-builder.mjs.map +1 -1
- package/fesm2022/acorex-components-image-editor.mjs +166 -126
- package/fesm2022/acorex-components-image-editor.mjs.map +1 -1
- package/fesm2022/acorex-components-image.mjs +10 -10
- package/fesm2022/acorex-components-image.mjs.map +1 -1
- package/fesm2022/acorex-components-json-viewer.mjs +9 -9
- package/fesm2022/acorex-components-json-viewer.mjs.map +1 -1
- package/fesm2022/acorex-components-kanban.mjs +9 -7
- package/fesm2022/acorex-components-kanban.mjs.map +1 -1
- package/fesm2022/acorex-components-kbd.mjs +8 -8
- package/fesm2022/acorex-components-kbd.mjs.map +1 -1
- package/fesm2022/acorex-components-label.mjs +9 -9
- package/fesm2022/acorex-components-label.mjs.map +1 -1
- package/fesm2022/acorex-components-list.mjs +10 -10
- package/fesm2022/acorex-components-list.mjs.map +1 -1
- package/fesm2022/acorex-components-loading-dialog.mjs +22 -13
- package/fesm2022/acorex-components-loading-dialog.mjs.map +1 -1
- package/fesm2022/acorex-components-loading.mjs +23 -23
- package/fesm2022/acorex-components-loading.mjs.map +1 -1
- package/fesm2022/acorex-components-map.mjs +16 -15
- package/fesm2022/acorex-components-map.mjs.map +1 -1
- package/fesm2022/acorex-components-media-viewer.mjs +78 -97
- package/fesm2022/acorex-components-media-viewer.mjs.map +1 -1
- package/fesm2022/acorex-components-menu.mjs +24 -24
- package/fesm2022/acorex-components-menu.mjs.map +1 -1
- package/fesm2022/{acorex-components-modal-acorex-components-modal-h5Y-qcbh.mjs → acorex-components-modal-acorex-components-modal-BmmAkCKJ.mjs} +24 -24
- package/fesm2022/acorex-components-modal-acorex-components-modal-BmmAkCKJ.mjs.map +1 -0
- package/fesm2022/acorex-components-modal-modal-content.component-5GqTzNOs.mjs +214 -0
- package/fesm2022/acorex-components-modal-modal-content.component-5GqTzNOs.mjs.map +1 -0
- package/fesm2022/acorex-components-modal.mjs +1 -1
- package/fesm2022/acorex-components-navbar.mjs +9 -9
- package/fesm2022/acorex-components-navbar.mjs.map +1 -1
- package/fesm2022/acorex-components-notification.mjs +16 -23
- package/fesm2022/acorex-components-notification.mjs.map +1 -1
- package/fesm2022/acorex-components-number-box-legacy.mjs +412 -0
- package/fesm2022/acorex-components-number-box-legacy.mjs.map +1 -0
- package/fesm2022/acorex-components-number-box.mjs +98 -331
- package/fesm2022/acorex-components-number-box.mjs.map +1 -1
- package/fesm2022/acorex-components-otp.mjs +10 -10
- package/fesm2022/acorex-components-otp.mjs.map +1 -1
- package/fesm2022/acorex-components-page.mjs +10 -10
- package/fesm2022/acorex-components-page.mjs.map +1 -1
- package/fesm2022/acorex-components-paint.mjs +35 -40
- package/fesm2022/acorex-components-paint.mjs.map +1 -1
- package/fesm2022/acorex-components-password-box.mjs +13 -13
- package/fesm2022/acorex-components-password-box.mjs.map +1 -1
- package/fesm2022/acorex-components-pdf-reader.mjs +8 -8
- package/fesm2022/acorex-components-pdf-reader.mjs.map +1 -1
- package/fesm2022/acorex-components-phone-box.mjs +10 -10
- package/fesm2022/acorex-components-phone-box.mjs.map +1 -1
- package/fesm2022/acorex-components-picker.mjs +17 -17
- package/fesm2022/acorex-components-picker.mjs.map +1 -1
- package/fesm2022/acorex-components-popover.mjs +12 -12
- package/fesm2022/acorex-components-popover.mjs.map +1 -1
- package/fesm2022/acorex-components-popup.mjs +13 -13
- package/fesm2022/acorex-components-popup.mjs.map +1 -1
- package/fesm2022/acorex-components-progress-bar.mjs +11 -9
- package/fesm2022/acorex-components-progress-bar.mjs.map +1 -1
- package/fesm2022/acorex-components-qrcode.mjs +8 -8
- package/fesm2022/acorex-components-qrcode.mjs.map +1 -1
- package/fesm2022/acorex-components-query-builder.mjs +9 -9
- package/fesm2022/acorex-components-query-builder.mjs.map +1 -1
- package/fesm2022/acorex-components-radio.mjs +7 -7
- package/fesm2022/acorex-components-radio.mjs.map +1 -1
- package/fesm2022/acorex-components-rail-navigation.mjs +40 -38
- package/fesm2022/acorex-components-rail-navigation.mjs.map +1 -1
- package/fesm2022/acorex-components-range-slider.mjs +11 -11
- package/fesm2022/acorex-components-range-slider.mjs.map +1 -1
- package/fesm2022/acorex-components-rate-picker.mjs +20 -35
- package/fesm2022/acorex-components-rate-picker.mjs.map +1 -1
- package/fesm2022/acorex-components-rest-api-generator.mjs +23 -23
- package/fesm2022/acorex-components-rest-api-generator.mjs.map +1 -1
- package/fesm2022/acorex-components-result.mjs +8 -8
- package/fesm2022/acorex-components-result.mjs.map +1 -1
- package/fesm2022/acorex-components-routing-progress.mjs +8 -8
- package/fesm2022/acorex-components-routing-progress.mjs.map +1 -1
- package/fesm2022/acorex-components-rrule.mjs +111 -16
- package/fesm2022/acorex-components-rrule.mjs.map +1 -1
- package/fesm2022/acorex-components-scheduler-picker.mjs +2339 -0
- package/fesm2022/acorex-components-scheduler-picker.mjs.map +1 -0
- package/fesm2022/acorex-components-scheduler.mjs +52 -52
- package/fesm2022/acorex-components-scheduler.mjs.map +1 -1
- package/fesm2022/acorex-components-scss.mjs +4 -4
- package/fesm2022/acorex-components-scss.mjs.map +1 -1
- package/fesm2022/acorex-components-search-box.mjs +23 -12
- package/fesm2022/acorex-components-search-box.mjs.map +1 -1
- package/fesm2022/acorex-components-select-box.mjs +36 -17
- package/fesm2022/acorex-components-select-box.mjs.map +1 -1
- package/fesm2022/acorex-components-selection-list-2.mjs +10 -10
- package/fesm2022/acorex-components-selection-list-2.mjs.map +1 -1
- package/fesm2022/acorex-components-selection-list.mjs +10 -10
- package/fesm2022/acorex-components-selection-list.mjs.map +1 -1
- package/fesm2022/acorex-components-side-menu.mjs +31 -38
- package/fesm2022/acorex-components-side-menu.mjs.map +1 -1
- package/fesm2022/acorex-components-skeleton.mjs +8 -8
- package/fesm2022/acorex-components-skeleton.mjs.map +1 -1
- package/fesm2022/acorex-components-slider.mjs +11 -11
- package/fesm2022/acorex-components-slider.mjs.map +1 -1
- package/fesm2022/acorex-components-sliding-item.mjs +17 -17
- package/fesm2022/acorex-components-sliding-item.mjs.map +1 -1
- package/fesm2022/acorex-components-step-wizard.mjs +16 -16
- package/fesm2022/acorex-components-step-wizard.mjs.map +1 -1
- package/fesm2022/acorex-components-switch.mjs +14 -14
- package/fesm2022/acorex-components-switch.mjs.map +1 -1
- package/fesm2022/acorex-components-tabs.mjs +20 -16
- package/fesm2022/acorex-components-tabs.mjs.map +1 -1
- package/fesm2022/acorex-components-tag-box.mjs +51 -21
- package/fesm2022/acorex-components-tag-box.mjs.map +1 -1
- package/fesm2022/acorex-components-tag.mjs +47 -11
- package/fesm2022/acorex-components-tag.mjs.map +1 -1
- package/fesm2022/acorex-components-text-area.mjs +9 -9
- package/fesm2022/acorex-components-text-area.mjs.map +1 -1
- package/fesm2022/acorex-components-text-box.mjs +13 -13
- package/fesm2022/acorex-components-text-box.mjs.map +1 -1
- package/fesm2022/acorex-components-time-duration.mjs +54 -14
- package/fesm2022/acorex-components-time-duration.mjs.map +1 -1
- package/fesm2022/acorex-components-time-line.mjs +14 -29
- package/fesm2022/acorex-components-time-line.mjs.map +1 -1
- package/fesm2022/acorex-components-toast.mjs +14 -14
- package/fesm2022/acorex-components-toast.mjs.map +1 -1
- package/fesm2022/acorex-components-toolbar.mjs +9 -9
- package/fesm2022/acorex-components-toolbar.mjs.map +1 -1
- package/fesm2022/acorex-components-tooltip.mjs +12 -12
- package/fesm2022/acorex-components-tooltip.mjs.map +1 -1
- package/fesm2022/acorex-components-tree-view.mjs +16 -45
- package/fesm2022/acorex-components-tree-view.mjs.map +1 -1
- package/fesm2022/acorex-components-tree2.mjs +689 -0
- package/fesm2022/acorex-components-tree2.mjs.map +1 -0
- package/fesm2022/acorex-components-uploader.mjs +28 -641
- package/fesm2022/acorex-components-uploader.mjs.map +1 -1
- package/fesm2022/acorex-components-video-player.mjs +8 -8
- package/fesm2022/acorex-components-video-player.mjs.map +1 -1
- package/fesm2022/acorex-components-wysiwyg.mjs +213 -462
- package/fesm2022/acorex-components-wysiwyg.mjs.map +1 -1
- package/fesm2022/acorex-components.mjs.map +1 -1
- package/form/index.d.ts +3 -3
- package/grid-layout-builder/index.d.ts +1 -2
- package/image-editor/index.d.ts +8 -5
- package/loading/index.d.ts +1 -1
- package/media-viewer/index.d.ts +2 -3
- package/notification/index.d.ts +0 -2
- package/number-box/README.md +2 -2
- package/number-box/index.d.ts +31 -171
- package/number-box-legacy/README.md +3 -0
- package/number-box-legacy/index.d.ts +191 -0
- package/package.json +53 -26
- package/paint/index.d.ts +1 -6
- package/phone-box/index.d.ts +4 -4
- package/rate-picker/index.d.ts +5 -15
- package/rrule/index.d.ts +96 -1
- package/scheduler-picker/README.md +15 -0
- package/scheduler-picker/index.d.ts +1360 -0
- package/search-box/index.d.ts +6 -1
- package/select-box/index.d.ts +15 -10
- package/side-menu/index.d.ts +3 -2
- package/tag/index.d.ts +8 -2
- package/tag-box/index.d.ts +12 -3
- package/time-duration/index.d.ts +19 -3
- package/tree2/README.md +3 -0
- package/tree2/index.d.ts +337 -0
- package/uploader/index.d.ts +4 -331
- package/wysiwyg/index.d.ts +57 -159
- package/drawer-2/README.md +0 -3
- package/drawer-2/index.d.ts +0 -62
- package/fesm2022/acorex-components-drawer-2.mjs +0 -134
- package/fesm2022/acorex-components-drawer-2.mjs.map +0 -1
- package/fesm2022/acorex-components-modal-acorex-components-modal-h5Y-qcbh.mjs.map +0 -1
- package/fesm2022/acorex-components-modal-modal-content.component-B6tyMLdU.mjs +0 -235
- package/fesm2022/acorex-components-modal-modal-content.component-B6tyMLdU.mjs.map +0 -1
- package/fesm2022/acorex-components-number-box-2.mjs +0 -183
- package/fesm2022/acorex-components-number-box-2.mjs.map +0 -1
- package/number-box-2/README.md +0 -3
- package/number-box-2/index.d.ts +0 -41
|
@@ -2,15 +2,473 @@ import { MXValueComponent, AXValuableComponent, AXComponent } from '@acorex/cdk/
|
|
|
2
2
|
import { AXPlatform } from '@acorex/core/platform';
|
|
3
3
|
import { isPlatformBrowser, CommonModule } from '@angular/common';
|
|
4
4
|
import * as i0 from '@angular/core';
|
|
5
|
-
import { input, output, viewChild,
|
|
5
|
+
import { InjectionToken, inject, Injectable, input, output, viewChild, PLATFORM_ID, DestroyRef, signal, computed, afterNextRender, effect, forwardRef, Component, NgModule } from '@angular/core';
|
|
6
6
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
7
7
|
|
|
8
|
+
class PrettierFormatterPlugin {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.id = 'prettier';
|
|
11
|
+
this.name = 'Prettier';
|
|
12
|
+
this.version = '1.0.0';
|
|
13
|
+
this.languages = ['javascript', 'js', 'typescript', 'ts', 'json', 'html', 'css', 'markdown'];
|
|
14
|
+
}
|
|
15
|
+
async format(text, language) {
|
|
16
|
+
try {
|
|
17
|
+
const prettier = await import('prettier/standalone');
|
|
18
|
+
let parser = null;
|
|
19
|
+
const plugins = [];
|
|
20
|
+
switch (language) {
|
|
21
|
+
case 'javascript':
|
|
22
|
+
case 'js': {
|
|
23
|
+
const [babel, estree] = await Promise.all([
|
|
24
|
+
import('prettier/plugins/babel'),
|
|
25
|
+
import('prettier/plugins/estree'),
|
|
26
|
+
]);
|
|
27
|
+
plugins.push(babel, estree);
|
|
28
|
+
parser = 'babel';
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
case 'typescript':
|
|
32
|
+
case 'ts': {
|
|
33
|
+
const [typescript, estree] = await Promise.all([
|
|
34
|
+
import('prettier/plugins/typescript'),
|
|
35
|
+
import('prettier/plugins/estree'),
|
|
36
|
+
]);
|
|
37
|
+
plugins.push(typescript, estree);
|
|
38
|
+
parser = 'typescript';
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
case 'json': {
|
|
42
|
+
const [babel, estree] = await Promise.all([
|
|
43
|
+
import('prettier/plugins/babel'),
|
|
44
|
+
import('prettier/plugins/estree'),
|
|
45
|
+
]);
|
|
46
|
+
plugins.push(babel, estree);
|
|
47
|
+
parser = 'json';
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
case 'html': {
|
|
51
|
+
const html = await import('prettier/plugins/html');
|
|
52
|
+
plugins.push(html);
|
|
53
|
+
parser = 'html';
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
case 'css': {
|
|
57
|
+
const postcss = await import('prettier/plugins/postcss');
|
|
58
|
+
plugins.push(postcss);
|
|
59
|
+
parser = 'css';
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
case 'markdown': {
|
|
63
|
+
const markdown = await import('prettier/plugins/markdown');
|
|
64
|
+
plugins.push(markdown);
|
|
65
|
+
parser = 'markdown';
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
default:
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
if (!parser)
|
|
72
|
+
return null;
|
|
73
|
+
const formatted = await prettier.format(text, {
|
|
74
|
+
parser,
|
|
75
|
+
plugins,
|
|
76
|
+
});
|
|
77
|
+
return formatted;
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
class CSSLanguagePlugin {
|
|
86
|
+
constructor() {
|
|
87
|
+
this.id = 'css';
|
|
88
|
+
this.name = 'CSS';
|
|
89
|
+
this.version = '1.0.0';
|
|
90
|
+
this.languages = ['css'];
|
|
91
|
+
}
|
|
92
|
+
async getExtension() {
|
|
93
|
+
const { css } = await import('@codemirror/lang-css');
|
|
94
|
+
return css();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
class HTMLLanguagePlugin {
|
|
99
|
+
constructor() {
|
|
100
|
+
this.id = 'html';
|
|
101
|
+
this.name = 'HTML';
|
|
102
|
+
this.version = '1.0.0';
|
|
103
|
+
this.languages = ['html'];
|
|
104
|
+
}
|
|
105
|
+
async getExtension() {
|
|
106
|
+
const { html } = await import('@codemirror/lang-html');
|
|
107
|
+
return html();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
class JavaScriptLanguagePlugin {
|
|
112
|
+
constructor() {
|
|
113
|
+
this.id = 'javascript';
|
|
114
|
+
this.name = 'JavaScript';
|
|
115
|
+
this.version = '1.0.0';
|
|
116
|
+
this.languages = ['javascript', 'js'];
|
|
117
|
+
}
|
|
118
|
+
async getExtension() {
|
|
119
|
+
const { javascript } = await import('@codemirror/lang-javascript');
|
|
120
|
+
return javascript();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
class JSONLanguagePlugin {
|
|
125
|
+
constructor() {
|
|
126
|
+
this.id = 'json';
|
|
127
|
+
this.name = 'JSON';
|
|
128
|
+
this.version = '1.0.0';
|
|
129
|
+
this.languages = ['json'];
|
|
130
|
+
}
|
|
131
|
+
async getExtension() {
|
|
132
|
+
const { json } = await import('@codemirror/lang-json');
|
|
133
|
+
return json();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
class MarkdownLanguagePlugin {
|
|
138
|
+
constructor() {
|
|
139
|
+
this.id = 'markdown';
|
|
140
|
+
this.name = 'Markdown';
|
|
141
|
+
this.version = '1.0.0';
|
|
142
|
+
this.languages = ['markdown'];
|
|
143
|
+
}
|
|
144
|
+
async getExtension() {
|
|
145
|
+
const { markdown } = await import('@codemirror/lang-markdown');
|
|
146
|
+
return markdown();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
class SassLanguagePlugin {
|
|
151
|
+
constructor() {
|
|
152
|
+
this.id = 'sass';
|
|
153
|
+
this.name = 'Sass/SCSS';
|
|
154
|
+
this.version = '1.0.0';
|
|
155
|
+
this.languages = ['sass', 'scss'];
|
|
156
|
+
}
|
|
157
|
+
async getExtension() {
|
|
158
|
+
const { sass } = await import('@codemirror/lang-sass');
|
|
159
|
+
return sass();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
class SQLLanguagePlugin {
|
|
164
|
+
constructor() {
|
|
165
|
+
this.id = 'sql';
|
|
166
|
+
this.name = 'SQL';
|
|
167
|
+
this.version = '1.0.0';
|
|
168
|
+
this.languages = ['sql'];
|
|
169
|
+
}
|
|
170
|
+
async getExtension() {
|
|
171
|
+
const { sql } = await import('@codemirror/lang-sql');
|
|
172
|
+
return sql();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
class TypeScriptLanguagePlugin {
|
|
177
|
+
constructor() {
|
|
178
|
+
this.id = 'typescript';
|
|
179
|
+
this.name = 'TypeScript';
|
|
180
|
+
this.version = '1.0.0';
|
|
181
|
+
this.languages = ['typescript', 'ts'];
|
|
182
|
+
}
|
|
183
|
+
async getExtension() {
|
|
184
|
+
const { javascript } = await import('@codemirror/lang-javascript');
|
|
185
|
+
return javascript({ typescript: true });
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
class XMLLanguagePlugin {
|
|
190
|
+
constructor() {
|
|
191
|
+
this.id = 'xml';
|
|
192
|
+
this.name = 'XML';
|
|
193
|
+
this.version = '1.0.0';
|
|
194
|
+
this.languages = ['xml'];
|
|
195
|
+
}
|
|
196
|
+
async getExtension() {
|
|
197
|
+
const { xml } = await import('@codemirror/lang-xml');
|
|
198
|
+
return xml();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
class GitHubDarkThemePlugin {
|
|
203
|
+
constructor() {
|
|
204
|
+
this.id = 'github-dark';
|
|
205
|
+
this.name = 'GitHub Dark';
|
|
206
|
+
this.version = '1.0.0';
|
|
207
|
+
this.dark = true;
|
|
208
|
+
}
|
|
209
|
+
async getExtension() {
|
|
210
|
+
const [{ githubDark }, { EditorView }] = await Promise.all([
|
|
211
|
+
import('@uiw/codemirror-theme-github'),
|
|
212
|
+
import('@codemirror/view'),
|
|
213
|
+
]);
|
|
214
|
+
return [
|
|
215
|
+
githubDark,
|
|
216
|
+
EditorView.theme({
|
|
217
|
+
'&': { backgroundColor: 'transparent !important' },
|
|
218
|
+
'.cm-gutters': { backgroundColor: 'transparent !important' },
|
|
219
|
+
}, { dark: true }),
|
|
220
|
+
];
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
class GitHubLightThemePlugin {
|
|
225
|
+
constructor() {
|
|
226
|
+
this.id = 'github-light';
|
|
227
|
+
this.name = 'GitHub Light';
|
|
228
|
+
this.version = '1.0.0';
|
|
229
|
+
this.dark = false;
|
|
230
|
+
}
|
|
231
|
+
async getExtension() {
|
|
232
|
+
const [{ githubLight }, { EditorView }] = await Promise.all([
|
|
233
|
+
import('@uiw/codemirror-theme-github'),
|
|
234
|
+
import('@codemirror/view'),
|
|
235
|
+
]);
|
|
236
|
+
return [
|
|
237
|
+
githubLight,
|
|
238
|
+
EditorView.theme({
|
|
239
|
+
'&': { backgroundColor: 'transparent !important' },
|
|
240
|
+
'.cm-gutters': { backgroundColor: 'transparent !important' },
|
|
241
|
+
}, { dark: false }),
|
|
242
|
+
];
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
class LightThemePlugin {
|
|
247
|
+
constructor() {
|
|
248
|
+
this.id = 'light';
|
|
249
|
+
this.name = 'Light';
|
|
250
|
+
this.version = '1.0.0';
|
|
251
|
+
this.dark = false;
|
|
252
|
+
}
|
|
253
|
+
async getExtension() {
|
|
254
|
+
const { EditorView } = await import('@codemirror/view');
|
|
255
|
+
return EditorView.theme({
|
|
256
|
+
'&': { backgroundColor: 'transparent !important' },
|
|
257
|
+
'.cm-gutters': {},
|
|
258
|
+
}, { dark: false });
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
class OneDarkThemePlugin {
|
|
263
|
+
constructor() {
|
|
264
|
+
this.id = 'one-dark';
|
|
265
|
+
this.name = 'One Dark';
|
|
266
|
+
this.version = '1.0.0';
|
|
267
|
+
this.dark = true;
|
|
268
|
+
}
|
|
269
|
+
async getExtension() {
|
|
270
|
+
const { EditorView } = await import('@codemirror/view');
|
|
271
|
+
try {
|
|
272
|
+
const { oneDark } = await import('@codemirror/theme-one-dark');
|
|
273
|
+
return [
|
|
274
|
+
oneDark,
|
|
275
|
+
EditorView.theme({
|
|
276
|
+
'&': { backgroundColor: 'transparent !important' },
|
|
277
|
+
'.cm-gutters': {},
|
|
278
|
+
}, { dark: true }),
|
|
279
|
+
];
|
|
280
|
+
}
|
|
281
|
+
catch {
|
|
282
|
+
return EditorView.theme({
|
|
283
|
+
'&': { backgroundColor: 'transparent !important' },
|
|
284
|
+
'.cm-gutters': {},
|
|
285
|
+
}, { dark: true });
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Default plugin configuration with all built-in plugins
|
|
292
|
+
*/
|
|
293
|
+
function provideDefaultCodeEditorPlugins() {
|
|
294
|
+
return {
|
|
295
|
+
languages: [
|
|
296
|
+
new JavaScriptLanguagePlugin(),
|
|
297
|
+
new TypeScriptLanguagePlugin(),
|
|
298
|
+
new JSONLanguagePlugin(),
|
|
299
|
+
new HTMLLanguagePlugin(),
|
|
300
|
+
new CSSLanguagePlugin(),
|
|
301
|
+
new SassLanguagePlugin(),
|
|
302
|
+
new SQLLanguagePlugin(),
|
|
303
|
+
new XMLLanguagePlugin(),
|
|
304
|
+
new MarkdownLanguagePlugin(),
|
|
305
|
+
],
|
|
306
|
+
themes: [
|
|
307
|
+
new OneDarkThemePlugin(),
|
|
308
|
+
new LightThemePlugin(),
|
|
309
|
+
new GitHubLightThemePlugin(),
|
|
310
|
+
new GitHubDarkThemePlugin(),
|
|
311
|
+
],
|
|
312
|
+
formatters: [new PrettierFormatterPlugin()],
|
|
313
|
+
extensions: [],
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Injection token for providing code editor plugin configuration
|
|
319
|
+
*/
|
|
320
|
+
const AX_CODE_EDITOR_PLUGIN_CONFIG = new InjectionToken('AX_CODE_EDITOR_PLUGIN_CONFIG', {
|
|
321
|
+
providedIn: 'root',
|
|
322
|
+
factory: () => provideDefaultCodeEditorPlugins(),
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Registry service for managing code editor plugins
|
|
327
|
+
*/
|
|
328
|
+
class AXCodeEditorPluginRegistry {
|
|
329
|
+
constructor() {
|
|
330
|
+
this.config = inject(AX_CODE_EDITOR_PLUGIN_CONFIG, { optional: true });
|
|
331
|
+
this.languagePlugins = new Map();
|
|
332
|
+
this.themePlugins = new Map();
|
|
333
|
+
this.formatterPlugins = new Map();
|
|
334
|
+
this.extensionPlugins = new Map();
|
|
335
|
+
this.initializePlugins();
|
|
336
|
+
}
|
|
337
|
+
initializePlugins() {
|
|
338
|
+
if (!this.config)
|
|
339
|
+
return;
|
|
340
|
+
// Register language plugins
|
|
341
|
+
this.config.languages?.forEach((plugin) => {
|
|
342
|
+
plugin.languages.forEach((lang) => {
|
|
343
|
+
this.languagePlugins.set(lang, plugin);
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
// Register theme plugins
|
|
347
|
+
this.config.themes?.forEach((plugin) => {
|
|
348
|
+
this.themePlugins.set(plugin.id, plugin);
|
|
349
|
+
});
|
|
350
|
+
// Register formatter plugins
|
|
351
|
+
this.config.formatters?.forEach((plugin) => {
|
|
352
|
+
plugin.languages.forEach((lang) => {
|
|
353
|
+
this.formatterPlugins.set(lang, plugin);
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
// Register extension plugins
|
|
357
|
+
this.config.extensions?.forEach((plugin) => {
|
|
358
|
+
this.extensionPlugins.set(plugin.id, plugin);
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Get language extension for the specified language
|
|
363
|
+
*/
|
|
364
|
+
async getLanguageExtension(language) {
|
|
365
|
+
const plugin = this.languagePlugins.get(language);
|
|
366
|
+
if (!plugin) {
|
|
367
|
+
console.warn(`No language plugin found for: ${language}`);
|
|
368
|
+
return [];
|
|
369
|
+
}
|
|
370
|
+
return plugin.getExtension();
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Get theme extension by theme ID
|
|
374
|
+
*/
|
|
375
|
+
async getThemeExtension(themeId) {
|
|
376
|
+
const plugin = this.themePlugins.get(themeId);
|
|
377
|
+
if (!plugin) {
|
|
378
|
+
console.warn(`No theme plugin found for: ${themeId}`);
|
|
379
|
+
return [];
|
|
380
|
+
}
|
|
381
|
+
return plugin.getExtension();
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Format text using the appropriate formatter for the language
|
|
385
|
+
*/
|
|
386
|
+
async format(text, language) {
|
|
387
|
+
const plugin = this.formatterPlugins.get(language);
|
|
388
|
+
if (!plugin) {
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
return plugin.format(text, language);
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Get all registered extension plugins
|
|
395
|
+
*/
|
|
396
|
+
async getExtensionPlugins() {
|
|
397
|
+
const extensions = await Promise.all(Array.from(this.extensionPlugins.values()).map((plugin) => plugin.getExtension()));
|
|
398
|
+
return extensions;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Check if a language is supported
|
|
402
|
+
*/
|
|
403
|
+
hasLanguage(language) {
|
|
404
|
+
return this.languagePlugins.has(language);
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Check if a theme is available
|
|
408
|
+
*/
|
|
409
|
+
hasTheme(themeId) {
|
|
410
|
+
return this.themePlugins.has(themeId);
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Check if a formatter is available for a language
|
|
414
|
+
*/
|
|
415
|
+
hasFormatter(language) {
|
|
416
|
+
return this.formatterPlugins.has(language);
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Get all available language identifiers
|
|
420
|
+
*/
|
|
421
|
+
getAvailableLanguages() {
|
|
422
|
+
return Array.from(this.languagePlugins.keys());
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Get all available theme identifiers
|
|
426
|
+
*/
|
|
427
|
+
getAvailableThemes() {
|
|
428
|
+
return Array.from(this.themePlugins.keys());
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Register a language plugin at runtime
|
|
432
|
+
*/
|
|
433
|
+
registerLanguagePlugin(plugin) {
|
|
434
|
+
plugin.languages.forEach((lang) => {
|
|
435
|
+
this.languagePlugins.set(lang, plugin);
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Register a theme plugin at runtime
|
|
440
|
+
*/
|
|
441
|
+
registerThemePlugin(plugin) {
|
|
442
|
+
this.themePlugins.set(plugin.id, plugin);
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Register a formatter plugin at runtime
|
|
446
|
+
*/
|
|
447
|
+
registerFormatterPlugin(plugin) {
|
|
448
|
+
plugin.languages.forEach((lang) => {
|
|
449
|
+
this.formatterPlugins.set(lang, plugin);
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Register an extension plugin at runtime
|
|
454
|
+
*/
|
|
455
|
+
registerExtensionPlugin(plugin) {
|
|
456
|
+
this.extensionPlugins.set(plugin.id, plugin);
|
|
457
|
+
}
|
|
458
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXCodeEditorPluginRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
459
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXCodeEditorPluginRegistry, providedIn: 'root' }); }
|
|
460
|
+
}
|
|
461
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXCodeEditorPluginRegistry, decorators: [{
|
|
462
|
+
type: Injectable,
|
|
463
|
+
args: [{ providedIn: 'root' }]
|
|
464
|
+
}], ctorParameters: () => [] });
|
|
465
|
+
|
|
8
466
|
class AXCodeEditorComponent extends MXValueComponent {
|
|
9
467
|
constructor() {
|
|
10
468
|
super();
|
|
11
469
|
// Inputs (signals)
|
|
12
470
|
// value = input<string>('');
|
|
13
|
-
/** Active language
|
|
471
|
+
/** Active language identifier from default plugins. Default: 'javascript'. */
|
|
14
472
|
this.language = input('javascript', ...(ngDevMode ? [{ debugName: "language" }] : []));
|
|
15
473
|
/** When true, the editor becomes readonly (non-editable). */
|
|
16
474
|
this.readOnly = input(false, ...(ngDevMode ? [{ debugName: "readOnly" }] : []));
|
|
@@ -30,7 +488,8 @@ class AXCodeEditorComponent extends MXValueComponent {
|
|
|
30
488
|
this.minHeight = input(null, ...(ngDevMode ? [{ debugName: "minHeight" }] : []));
|
|
31
489
|
/** Maximum height for the editor. */
|
|
32
490
|
this.maxHeight = input(null, ...(ngDevMode ? [{ debugName: "maxHeight" }] : []));
|
|
33
|
-
|
|
491
|
+
/** Theme identifier. If null, uses platform theme mode (dark/light). */
|
|
492
|
+
this.theme = input(null, ...(ngDevMode ? [{ debugName: "theme" }] : []));
|
|
34
493
|
/** Additional CodeMirror extensions to apply. Reconfigures at runtime. */
|
|
35
494
|
this.extensions = input([], ...(ngDevMode ? [{ debugName: "extensions" }] : []));
|
|
36
495
|
/** ARIA label for accessibility. */
|
|
@@ -56,6 +515,7 @@ class AXCodeEditorComponent extends MXValueComponent {
|
|
|
56
515
|
this.platformId = inject(PLATFORM_ID);
|
|
57
516
|
this.destroyRef = inject(DestroyRef);
|
|
58
517
|
this.platformService = inject(AXPlatform);
|
|
518
|
+
this.pluginRegistry = inject(AXCodeEditorPluginRegistry);
|
|
59
519
|
this.editorViewSig = signal(null, ...(ngDevMode ? [{ debugName: "editorViewSig" }] : []));
|
|
60
520
|
// Compartments to reconfigure editor without recreating it
|
|
61
521
|
this.languageCompartment = null;
|
|
@@ -93,7 +553,7 @@ class AXCodeEditorComponent extends MXValueComponent {
|
|
|
93
553
|
if (!view || !this.languageCompartment)
|
|
94
554
|
return;
|
|
95
555
|
const lang = this.language();
|
|
96
|
-
this.
|
|
556
|
+
this.pluginRegistry.getLanguageExtension(lang).then((ext) => {
|
|
97
557
|
if (!view || !this.languageCompartment)
|
|
98
558
|
return;
|
|
99
559
|
view.dispatch({ effects: this.languageCompartment.reconfigure(ext) });
|
|
@@ -112,12 +572,12 @@ class AXCodeEditorComponent extends MXValueComponent {
|
|
|
112
572
|
});
|
|
113
573
|
effect(() => {
|
|
114
574
|
const view = this.editorViewSig();
|
|
115
|
-
// Establish reactive dependency on platform theme
|
|
116
|
-
|
|
117
|
-
|
|
575
|
+
// Establish reactive dependency on theme and platform theme
|
|
576
|
+
const customTheme = this.theme();
|
|
577
|
+
const platformTheme = this.platformService.themeMode();
|
|
118
578
|
if (!view || !this.themeCompartment)
|
|
119
579
|
return;
|
|
120
|
-
this.resolveThemeExtension().then((themeExt) => {
|
|
580
|
+
this.resolveThemeExtension(customTheme, platformTheme).then((themeExt) => {
|
|
121
581
|
if (!view || !this.themeCompartment)
|
|
122
582
|
return;
|
|
123
583
|
view.dispatch({ effects: this.themeCompartment.reconfigure(themeExt) });
|
|
@@ -189,8 +649,8 @@ class AXCodeEditorComponent extends MXValueComponent {
|
|
|
189
649
|
const lintMod = this.cm.lint;
|
|
190
650
|
if (!viewMod || !stateMod || !languageMod || !autoMod || !commandsMod || !searchMod || !lintMod)
|
|
191
651
|
return;
|
|
192
|
-
const languageExt = await this.
|
|
193
|
-
const themeExt = await this.resolveThemeExtension();
|
|
652
|
+
const languageExt = await this.pluginRegistry.getLanguageExtension(this.language());
|
|
653
|
+
const themeExt = await this.resolveThemeExtension(this.theme(), this.platformService.themeMode());
|
|
194
654
|
const placeholderExt = viewMod.placeholder(this.placeholder() ?? '');
|
|
195
655
|
const editableExt = viewMod.EditorView.editable.of(!this.readOnly());
|
|
196
656
|
const wrappingExt = this.lineWrapping() ? viewMod.EditorView.lineWrapping : [];
|
|
@@ -314,148 +774,14 @@ class AXCodeEditorComponent extends MXValueComponent {
|
|
|
314
774
|
...lintMod.lintKeymap,
|
|
315
775
|
];
|
|
316
776
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
if (
|
|
320
|
-
return
|
|
321
|
-
try {
|
|
322
|
-
const prettier = await import('prettier/standalone');
|
|
323
|
-
let parser = null;
|
|
324
|
-
const plugins = [];
|
|
325
|
-
switch (lang) {
|
|
326
|
-
case 'javascript':
|
|
327
|
-
case 'js': {
|
|
328
|
-
const [babel, estree] = await Promise.all([
|
|
329
|
-
import('prettier/plugins/babel'),
|
|
330
|
-
import('prettier/plugins/estree'),
|
|
331
|
-
]);
|
|
332
|
-
plugins.push(babel, estree);
|
|
333
|
-
parser = 'babel';
|
|
334
|
-
break;
|
|
335
|
-
}
|
|
336
|
-
case 'typescript':
|
|
337
|
-
case 'ts': {
|
|
338
|
-
const [typescript, estree] = await Promise.all([
|
|
339
|
-
import('prettier/plugins/typescript'),
|
|
340
|
-
import('prettier/plugins/estree'),
|
|
341
|
-
]);
|
|
342
|
-
plugins.push(typescript, estree);
|
|
343
|
-
parser = 'typescript';
|
|
344
|
-
break;
|
|
345
|
-
}
|
|
346
|
-
case 'json': {
|
|
347
|
-
const [babel, estree] = await Promise.all([
|
|
348
|
-
import('prettier/plugins/babel'),
|
|
349
|
-
import('prettier/plugins/estree'),
|
|
350
|
-
]);
|
|
351
|
-
plugins.push(babel, estree);
|
|
352
|
-
parser = 'json';
|
|
353
|
-
break;
|
|
354
|
-
}
|
|
355
|
-
case 'html': {
|
|
356
|
-
const html = await import('prettier/plugins/html');
|
|
357
|
-
plugins.push(html);
|
|
358
|
-
parser = 'html';
|
|
359
|
-
break;
|
|
360
|
-
}
|
|
361
|
-
case 'css': {
|
|
362
|
-
const postcss = await import('prettier/plugins/postcss');
|
|
363
|
-
plugins.push(postcss);
|
|
364
|
-
parser = 'css';
|
|
365
|
-
break;
|
|
366
|
-
}
|
|
367
|
-
case 'markdown': {
|
|
368
|
-
const markdown = await import('prettier/plugins/markdown');
|
|
369
|
-
plugins.push(markdown);
|
|
370
|
-
parser = 'markdown';
|
|
371
|
-
break;
|
|
372
|
-
}
|
|
373
|
-
default:
|
|
374
|
-
return null;
|
|
375
|
-
}
|
|
376
|
-
if (!parser)
|
|
377
|
-
return null;
|
|
378
|
-
const formatted = await prettier.format(text, {
|
|
379
|
-
parser,
|
|
380
|
-
plugins,
|
|
381
|
-
});
|
|
382
|
-
return formatted;
|
|
383
|
-
}
|
|
384
|
-
catch {
|
|
385
|
-
return null;
|
|
777
|
+
async resolveThemeExtension(customTheme, platformTheme) {
|
|
778
|
+
// If custom theme is specified, use it
|
|
779
|
+
if (customTheme) {
|
|
780
|
+
return this.pluginRegistry.getThemeExtension(customTheme);
|
|
386
781
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
case 'javascript':
|
|
391
|
-
case 'js': {
|
|
392
|
-
const m = await import('@codemirror/lang-javascript');
|
|
393
|
-
return m.javascript();
|
|
394
|
-
}
|
|
395
|
-
case 'typescript':
|
|
396
|
-
case 'ts': {
|
|
397
|
-
const m = await import('@codemirror/lang-javascript');
|
|
398
|
-
return m.javascript({ typescript: true });
|
|
399
|
-
}
|
|
400
|
-
case 'json': {
|
|
401
|
-
const m = await import('@codemirror/lang-json');
|
|
402
|
-
return m.json();
|
|
403
|
-
}
|
|
404
|
-
case 'html': {
|
|
405
|
-
const m = await import('@codemirror/lang-html');
|
|
406
|
-
return m.html();
|
|
407
|
-
}
|
|
408
|
-
case 'css': {
|
|
409
|
-
const m = await import('@codemirror/lang-css');
|
|
410
|
-
return m.css();
|
|
411
|
-
}
|
|
412
|
-
case 'scss':
|
|
413
|
-
case 'sass': {
|
|
414
|
-
const m = await import('@codemirror/lang-sass');
|
|
415
|
-
return m.sass();
|
|
416
|
-
}
|
|
417
|
-
case 'sql': {
|
|
418
|
-
const m = await import('@codemirror/lang-sql');
|
|
419
|
-
return m.sql();
|
|
420
|
-
}
|
|
421
|
-
case 'xml': {
|
|
422
|
-
const m = await import('@codemirror/lang-xml');
|
|
423
|
-
return m.xml();
|
|
424
|
-
}
|
|
425
|
-
case 'markdown': {
|
|
426
|
-
const m = await import('@codemirror/lang-markdown');
|
|
427
|
-
return m.markdown();
|
|
428
|
-
}
|
|
429
|
-
default:
|
|
430
|
-
return [];
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
async resolveThemeExtension() {
|
|
434
|
-
const { EditorView } = await import('@codemirror/view');
|
|
435
|
-
const darkMode = this.platformService.themeMode() === 'dark';
|
|
436
|
-
// const surfaceVar = 'rgb(var(--ax-sys-color-surface)) !important';
|
|
437
|
-
if (darkMode) {
|
|
438
|
-
try {
|
|
439
|
-
const { oneDark } = await import('@codemirror/theme-one-dark');
|
|
440
|
-
return [
|
|
441
|
-
oneDark,
|
|
442
|
-
EditorView.theme({
|
|
443
|
-
'&': { backgroundColor: 'transparent !important' },
|
|
444
|
-
'.cm-gutters': {},
|
|
445
|
-
}, { dark: true }),
|
|
446
|
-
];
|
|
447
|
-
}
|
|
448
|
-
catch {
|
|
449
|
-
return EditorView.theme({
|
|
450
|
-
'&': { backgroundColor: 'transparent !important' },
|
|
451
|
-
'.cm-gutters': {},
|
|
452
|
-
}, { dark: true });
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
return EditorView.theme({
|
|
456
|
-
'&': { backgroundColor: 'transparent !important' },
|
|
457
|
-
'.cm-gutters': {},
|
|
458
|
-
}, { dark: false });
|
|
782
|
+
// Otherwise, use platform theme (handle 'system' by defaulting to 'github-light')
|
|
783
|
+
const themeId = platformTheme === 'dark' ? 'github-dark' : 'github-light';
|
|
784
|
+
return this.pluginRegistry.getThemeExtension(themeId);
|
|
459
785
|
}
|
|
460
786
|
buildCustomCompletionSources() {
|
|
461
787
|
const provided = this.customCompletions();
|
|
@@ -486,7 +812,7 @@ class AXCodeEditorComponent extends MXValueComponent {
|
|
|
486
812
|
const length = view.state.doc.length;
|
|
487
813
|
view.dispatch({ selection: { anchor: 0, head: length } });
|
|
488
814
|
}
|
|
489
|
-
// Formats the current document
|
|
815
|
+
// Formats the current document using the registered formatter plugin (if available for the active language).
|
|
490
816
|
// Returns the formatted text or null if unchanged/unsupported.
|
|
491
817
|
async format(affect = true) {
|
|
492
818
|
const view = this.editorViewSig();
|
|
@@ -495,7 +821,7 @@ class AXCodeEditorComponent extends MXValueComponent {
|
|
|
495
821
|
const source = view.state.doc.toString();
|
|
496
822
|
if (!source)
|
|
497
823
|
return null;
|
|
498
|
-
const formatted = await this.
|
|
824
|
+
const formatted = await this.pluginRegistry.format(source, this.language());
|
|
499
825
|
if (!formatted || formatted === source)
|
|
500
826
|
return null;
|
|
501
827
|
if (affect) {
|
|
@@ -521,8 +847,8 @@ class AXCodeEditorComponent extends MXValueComponent {
|
|
|
521
847
|
const text = this.value ?? '';
|
|
522
848
|
return text ? text.split(/\r?\n/).length : 1;
|
|
523
849
|
}
|
|
524
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.
|
|
525
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.3.
|
|
850
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXCodeEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
851
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.3.12", type: AXCodeEditorComponent, isStandalone: true, selector: "ax-code-editor", inputs: { language: { classPropertyName: "language", publicName: "language", isSignal: true, isRequired: false, transformFunction: null }, readOnly: { classPropertyName: "readOnly", publicName: "readOnly", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, lineNumbers: { classPropertyName: "lineNumbers", publicName: "lineNumbers", isSignal: true, isRequired: false, transformFunction: null }, lineWrapping: { classPropertyName: "lineWrapping", publicName: "lineWrapping", isSignal: true, isRequired: false, transformFunction: null }, tabSize: { classPropertyName: "tabSize", publicName: "tabSize", isSignal: true, isRequired: false, transformFunction: null }, indentWithTab: { classPropertyName: "indentWithTab", publicName: "indentWithTab", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, minHeight: { classPropertyName: "minHeight", publicName: "minHeight", isSignal: true, isRequired: false, transformFunction: null }, maxHeight: { classPropertyName: "maxHeight", publicName: "maxHeight", isSignal: true, isRequired: false, transformFunction: null }, theme: { classPropertyName: "theme", publicName: "theme", isSignal: true, isRequired: false, transformFunction: null }, extensions: { classPropertyName: "extensions", publicName: "extensions", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, focusOnReady: { classPropertyName: "focusOnReady", publicName: "focusOnReady", isSignal: true, isRequired: false, transformFunction: null }, formatOnSave: { classPropertyName: "formatOnSave", publicName: "formatOnSave", isSignal: true, isRequired: false, transformFunction: null }, customCompletions: { classPropertyName: "customCompletions", publicName: "customCompletions", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { ready: "ready", save: "save" }, host: { listeners: { "keydown.control.s": "onSaveShortcut($event)" }, classAttribute: "ax-code-editor block" }, providers: [
|
|
526
852
|
{ provide: AXValuableComponent, useExisting: AXCodeEditorComponent },
|
|
527
853
|
{
|
|
528
854
|
provide: NG_VALUE_ACCESSOR,
|
|
@@ -543,7 +869,7 @@ class AXCodeEditorComponent extends MXValueComponent {
|
|
|
543
869
|
></div>
|
|
544
870
|
`, isInline: true, styles: [":host{display:block;width:100%;transition:none}.cm-editor{width:100%;max-width:100%;box-sizing:border-box}.cm-editor.cm-focused{outline:none}\n"] }); }
|
|
545
871
|
}
|
|
546
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.
|
|
872
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXCodeEditorComponent, decorators: [{
|
|
547
873
|
type: Component,
|
|
548
874
|
args: [{ selector: 'ax-code-editor', host: {
|
|
549
875
|
'(keydown.control.s)': 'onSaveShortcut($event)',
|
|
@@ -568,14 +894,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImpor
|
|
|
568
894
|
[style.maxHeight]="maxHeight() ?? null"
|
|
569
895
|
></div>
|
|
570
896
|
`, styles: [":host{display:block;width:100%;transition:none}.cm-editor{width:100%;max-width:100%;box-sizing:border-box}.cm-editor.cm-focused{outline:none}\n"] }]
|
|
571
|
-
}], ctorParameters: () => [] });
|
|
897
|
+
}], ctorParameters: () => [], propDecorators: { language: [{ type: i0.Input, args: [{ isSignal: true, alias: "language", required: false }] }], readOnly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readOnly", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], lineNumbers: [{ type: i0.Input, args: [{ isSignal: true, alias: "lineNumbers", required: false }] }], lineWrapping: [{ type: i0.Input, args: [{ isSignal: true, alias: "lineWrapping", required: false }] }], tabSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabSize", required: false }] }], indentWithTab: [{ type: i0.Input, args: [{ isSignal: true, alias: "indentWithTab", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], minHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "minHeight", required: false }] }], maxHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxHeight", required: false }] }], theme: [{ type: i0.Input, args: [{ isSignal: true, alias: "theme", required: false }] }], extensions: [{ type: i0.Input, args: [{ isSignal: true, alias: "extensions", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], focusOnReady: [{ type: i0.Input, args: [{ isSignal: true, alias: "focusOnReady", required: false }] }], formatOnSave: [{ type: i0.Input, args: [{ isSignal: true, alias: "formatOnSave", required: false }] }], customCompletions: [{ type: i0.Input, args: [{ isSignal: true, alias: "customCompletions", required: false }] }], ready: [{ type: i0.Output, args: ["ready"] }], save: [{ type: i0.Output, args: ["save"] }], host: [{ type: i0.ViewChild, args: ['host', { isSignal: true }] }] } });
|
|
572
898
|
|
|
573
899
|
class AXCodeEditorModule {
|
|
574
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.
|
|
575
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.
|
|
576
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.
|
|
900
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXCodeEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
901
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.12", ngImport: i0, type: AXCodeEditorModule, imports: [CommonModule, AXCodeEditorComponent], exports: [AXCodeEditorComponent] }); }
|
|
902
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXCodeEditorModule, imports: [CommonModule] }); }
|
|
577
903
|
}
|
|
578
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.
|
|
904
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXCodeEditorModule, decorators: [{
|
|
579
905
|
type: NgModule,
|
|
580
906
|
args: [{
|
|
581
907
|
imports: [CommonModule, AXCodeEditorComponent],
|
|
@@ -583,9 +909,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImpor
|
|
|
583
909
|
}]
|
|
584
910
|
}] });
|
|
585
911
|
|
|
912
|
+
// Language plugins
|
|
913
|
+
|
|
914
|
+
// Language plugins
|
|
915
|
+
|
|
916
|
+
// Component & Module
|
|
917
|
+
|
|
586
918
|
/**
|
|
587
919
|
* Generated bundle index. Do not edit.
|
|
588
920
|
*/
|
|
589
921
|
|
|
590
|
-
export { AXCodeEditorComponent, AXCodeEditorModule };
|
|
922
|
+
export { AXCodeEditorComponent, AXCodeEditorModule, AXCodeEditorPluginRegistry, AX_CODE_EDITOR_PLUGIN_CONFIG, CSSLanguagePlugin, GitHubDarkThemePlugin, GitHubLightThemePlugin, HTMLLanguagePlugin, JSONLanguagePlugin, JavaScriptLanguagePlugin, LightThemePlugin, MarkdownLanguagePlugin, OneDarkThemePlugin, PrettierFormatterPlugin, SQLLanguagePlugin, SassLanguagePlugin, TypeScriptLanguagePlugin, XMLLanguagePlugin, provideDefaultCodeEditorPlugins };
|
|
591
923
|
//# sourceMappingURL=acorex-components-code-editor.mjs.map
|