@acorex/components 21.0.0-next.5 → 21.0.0-next.51
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/button-group/index.d.ts +6 -4
- package/calendar/index.d.ts +4 -0
- package/chips/index.d.ts +3 -8
- package/code-editor/README.md +291 -1
- package/code-editor/index.d.ts +262 -20
- package/collapse/index.d.ts +4 -6
- 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 +97 -261
- 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 +25 -21
- package/fesm2022/acorex-components-button-group.mjs.map +1 -1
- package/fesm2022/acorex-components-button.mjs +68 -28
- package/fesm2022/acorex-components-button.mjs.map +1 -1
- package/fesm2022/acorex-components-calendar.mjs +39 -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 +532 -200
- package/fesm2022/acorex-components-code-editor.mjs.map +1 -1
- package/fesm2022/acorex-components-collapse.mjs +22 -34
- 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 +63 -47
- package/fesm2022/acorex-components-data-pager.mjs.map +1 -1
- package/fesm2022/acorex-components-data-table.mjs +509 -551
- 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 +10 -10
- 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 +20 -18
- 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 +34 -34
- 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 +62 -37
- 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 +206 -156
- 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 +29 -11
- 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 +23 -14
- 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 +290 -31
- package/fesm2022/acorex-components-map.mjs.map +1 -1
- package/fesm2022/acorex-components-media-viewer.mjs +95 -99
- 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-BnUdtPke.mjs} +24 -24
- package/fesm2022/acorex-components-modal-acorex-components-modal-BnUdtPke.mjs.map +1 -0
- package/fesm2022/acorex-components-modal-modal-content.component-Cgq-wx_m.mjs +214 -0
- package/fesm2022/acorex-components-modal-modal-content.component-Cgq-wx_m.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 +113 -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 +14 -14
- package/fesm2022/acorex-components-password-box.mjs.map +1 -1
- package/fesm2022/acorex-components-pdf-reader.mjs +9 -9
- package/fesm2022/acorex-components-pdf-reader.mjs.map +1 -1
- package/fesm2022/acorex-components-phone-box.mjs +47 -10
- package/fesm2022/acorex-components-phone-box.mjs.map +1 -1
- package/fesm2022/acorex-components-picker.mjs +19 -19
- 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 +10 -10
- 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 +9 -9
- 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 +12 -12
- 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 +13 -13
- 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 +28 -20
- 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 +15 -20
- package/fesm2022/acorex-components-tooltip.mjs.map +1 -1
- package/fesm2022/acorex-components-tree-view-legacy.mjs +511 -0
- package/fesm2022/acorex-components-tree-view-legacy.mjs.map +1 -0
- package/fesm2022/acorex-components-tree-view.mjs +2223 -437
- package/fesm2022/acorex-components-tree-view.mjs.map +1 -1
- 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 +229 -473
- package/fesm2022/acorex-components-wysiwyg.mjs.map +1 -1
- package/fesm2022/acorex-components.mjs.map +1 -1
- package/file-explorer/index.d.ts +6 -6
- package/form/index.d.ts +3 -3
- package/grid-layout-builder/index.d.ts +1 -2
- package/image-editor/index.d.ts +11 -13
- package/kbd/index.d.ts +13 -7
- package/loading/index.d.ts +1 -1
- package/map/index.d.ts +28 -1
- package/media-viewer/index.d.ts +7 -3
- package/notification/index.d.ts +0 -2
- package/number-box/README.md +2 -2
- package/number-box/index.d.ts +32 -171
- package/number-box-legacy/README.md +3 -0
- package/number-box-legacy/index.d.ts +191 -0
- package/package.json +42 -14
- package/paint/index.d.ts +1 -6
- package/phone-box/index.d.ts +5 -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/slider/index.d.ts +2 -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/tooltip/index.d.ts +0 -1
- package/tree-view/index.d.ts +941 -168
- package/tree-view-legacy/README.md +3 -0
- package/tree-view-legacy/index.d.ts +184 -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,18 +2,476 @@ 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.15", ngImport: i0, type: AXCodeEditorPluginRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
459
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AXCodeEditorPluginRegistry, providedIn: 'root' }); }
|
|
460
|
+
}
|
|
461
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", 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
|
-
this.
|
|
474
|
+
this.editorReadonly = input(false, ...(ngDevMode ? [{ debugName: "editorReadonly", alias: 'readonly' }] : [{ alias: 'readonly' }]));
|
|
17
475
|
/** Placeholder text shown when the document is empty. */
|
|
18
476
|
this.placeholder = input('', ...(ngDevMode ? [{ debugName: "placeholder" }] : []));
|
|
19
477
|
/** Toggle rendering of line numbers in the gutter. */
|
|
@@ -24,13 +482,8 @@ class AXCodeEditorComponent extends MXValueComponent {
|
|
|
24
482
|
this.tabSize = input(2, ...(ngDevMode ? [{ debugName: "tabSize" }] : []));
|
|
25
483
|
/** When true, the Tab key indents instead of moving focus. */
|
|
26
484
|
this.indentWithTab = input(true, ...(ngDevMode ? [{ debugName: "indentWithTab" }] : []));
|
|
27
|
-
/**
|
|
28
|
-
this.
|
|
29
|
-
/** Minimum height for the editor. */
|
|
30
|
-
this.minHeight = input(null, ...(ngDevMode ? [{ debugName: "minHeight" }] : []));
|
|
31
|
-
/** Maximum height for the editor. */
|
|
32
|
-
this.maxHeight = input(null, ...(ngDevMode ? [{ debugName: "maxHeight" }] : []));
|
|
33
|
-
// Theme follows platform theme mode; no input
|
|
485
|
+
/** Theme identifier. If null, uses platform theme mode (dark/light). */
|
|
486
|
+
this.theme = input(null, ...(ngDevMode ? [{ debugName: "theme" }] : []));
|
|
34
487
|
/** Additional CodeMirror extensions to apply. Reconfigures at runtime. */
|
|
35
488
|
this.extensions = input([], ...(ngDevMode ? [{ debugName: "extensions" }] : []));
|
|
36
489
|
/** ARIA label for accessibility. */
|
|
@@ -56,10 +509,11 @@ class AXCodeEditorComponent extends MXValueComponent {
|
|
|
56
509
|
this.platformId = inject(PLATFORM_ID);
|
|
57
510
|
this.destroyRef = inject(DestroyRef);
|
|
58
511
|
this.platformService = inject(AXPlatform);
|
|
512
|
+
this.pluginRegistry = inject(AXCodeEditorPluginRegistry);
|
|
59
513
|
this.editorViewSig = signal(null, ...(ngDevMode ? [{ debugName: "editorViewSig" }] : []));
|
|
60
514
|
// Compartments to reconfigure editor without recreating it
|
|
61
515
|
this.languageCompartment = null;
|
|
62
|
-
this.
|
|
516
|
+
this.readonlyCompartment = null;
|
|
63
517
|
this.themeCompartment = null;
|
|
64
518
|
this.placeholderCompartment = null;
|
|
65
519
|
this.wrappingCompartment = null;
|
|
@@ -93,7 +547,7 @@ class AXCodeEditorComponent extends MXValueComponent {
|
|
|
93
547
|
if (!view || !this.languageCompartment)
|
|
94
548
|
return;
|
|
95
549
|
const lang = this.language();
|
|
96
|
-
this.
|
|
550
|
+
this.pluginRegistry.getLanguageExtension(lang).then((ext) => {
|
|
97
551
|
if (!view || !this.languageCompartment)
|
|
98
552
|
return;
|
|
99
553
|
view.dispatch({ effects: this.languageCompartment.reconfigure(ext) });
|
|
@@ -101,23 +555,23 @@ class AXCodeEditorComponent extends MXValueComponent {
|
|
|
101
555
|
});
|
|
102
556
|
effect(() => {
|
|
103
557
|
const view = this.editorViewSig();
|
|
104
|
-
if (!view || !this.
|
|
558
|
+
if (!view || !this.readonlyCompartment)
|
|
105
559
|
return;
|
|
106
|
-
const editable = !this.
|
|
560
|
+
const editable = !this.editorReadonly();
|
|
107
561
|
import('@codemirror/view').then(({ EditorView }) => {
|
|
108
|
-
if (!view || !this.
|
|
562
|
+
if (!view || !this.readonlyCompartment)
|
|
109
563
|
return;
|
|
110
|
-
view.dispatch({ effects: this.
|
|
564
|
+
view.dispatch({ effects: this.readonlyCompartment.reconfigure(EditorView.editable.of(editable)) });
|
|
111
565
|
});
|
|
112
566
|
});
|
|
113
567
|
effect(() => {
|
|
114
568
|
const view = this.editorViewSig();
|
|
115
|
-
// Establish reactive dependency on platform theme
|
|
116
|
-
|
|
117
|
-
|
|
569
|
+
// Establish reactive dependency on theme and platform theme
|
|
570
|
+
const customTheme = this.theme();
|
|
571
|
+
const platformTheme = this.platformService.themeMode();
|
|
118
572
|
if (!view || !this.themeCompartment)
|
|
119
573
|
return;
|
|
120
|
-
this.resolveThemeExtension().then((themeExt) => {
|
|
574
|
+
this.resolveThemeExtension(customTheme, platformTheme).then((themeExt) => {
|
|
121
575
|
if (!view || !this.themeCompartment)
|
|
122
576
|
return;
|
|
123
577
|
view.dispatch({ effects: this.themeCompartment.reconfigure(themeExt) });
|
|
@@ -189,10 +643,10 @@ class AXCodeEditorComponent extends MXValueComponent {
|
|
|
189
643
|
const lintMod = this.cm.lint;
|
|
190
644
|
if (!viewMod || !stateMod || !languageMod || !autoMod || !commandsMod || !searchMod || !lintMod)
|
|
191
645
|
return;
|
|
192
|
-
const languageExt = await this.
|
|
193
|
-
const themeExt = await this.resolveThemeExtension();
|
|
646
|
+
const languageExt = await this.pluginRegistry.getLanguageExtension(this.language());
|
|
647
|
+
const themeExt = await this.resolveThemeExtension(this.theme(), this.platformService.themeMode());
|
|
194
648
|
const placeholderExt = viewMod.placeholder(this.placeholder() ?? '');
|
|
195
|
-
const editableExt = viewMod.EditorView.editable.of(!this.
|
|
649
|
+
const editableExt = viewMod.EditorView.editable.of(!this.editorReadonly());
|
|
196
650
|
const wrappingExt = this.lineWrapping() ? viewMod.EditorView.lineWrapping : [];
|
|
197
651
|
const tabSizeExt = stateMod.EditorState.tabSize.of(this.tabSize() ?? 2);
|
|
198
652
|
const lineNumbersExt = this.lineNumbers() ? viewMod.lineNumbers() : [];
|
|
@@ -216,7 +670,7 @@ class AXCodeEditorComponent extends MXValueComponent {
|
|
|
216
670
|
viewMod.keymap.of(keymaps),
|
|
217
671
|
autoCompleteExt,
|
|
218
672
|
this.languageCompartment.of(languageExt),
|
|
219
|
-
this.
|
|
673
|
+
this.readonlyCompartment.of(editableExt),
|
|
220
674
|
this.themeCompartment.of(themeExt),
|
|
221
675
|
this.placeholderCompartment.of(placeholderExt),
|
|
222
676
|
this.wrappingCompartment.of(wrappingExt),
|
|
@@ -291,7 +745,7 @@ class AXCodeEditorComponent extends MXValueComponent {
|
|
|
291
745
|
if (!stateMod)
|
|
292
746
|
return;
|
|
293
747
|
this.languageCompartment = new stateMod.Compartment();
|
|
294
|
-
this.
|
|
748
|
+
this.readonlyCompartment = new stateMod.Compartment();
|
|
295
749
|
this.themeCompartment = new stateMod.Compartment();
|
|
296
750
|
this.placeholderCompartment = new stateMod.Compartment();
|
|
297
751
|
this.wrappingCompartment = new stateMod.Compartment();
|
|
@@ -314,148 +768,14 @@ class AXCodeEditorComponent extends MXValueComponent {
|
|
|
314
768
|
...lintMod.lintKeymap,
|
|
315
769
|
];
|
|
316
770
|
}
|
|
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;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
async resolveLanguageExtension(lang) {
|
|
389
|
-
switch (lang) {
|
|
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 [];
|
|
771
|
+
async resolveThemeExtension(customTheme, platformTheme) {
|
|
772
|
+
// If custom theme is specified, use it
|
|
773
|
+
if (customTheme) {
|
|
774
|
+
return this.pluginRegistry.getThemeExtension(customTheme);
|
|
431
775
|
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
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 });
|
|
776
|
+
// Otherwise, use platform theme (handle 'system' by defaulting to 'github-light')
|
|
777
|
+
const themeId = platformTheme === 'dark' ? 'github-dark' : 'github-light';
|
|
778
|
+
return this.pluginRegistry.getThemeExtension(themeId);
|
|
459
779
|
}
|
|
460
780
|
buildCustomCompletionSources() {
|
|
461
781
|
const provided = this.customCompletions();
|
|
@@ -486,7 +806,7 @@ class AXCodeEditorComponent extends MXValueComponent {
|
|
|
486
806
|
const length = view.state.doc.length;
|
|
487
807
|
view.dispatch({ selection: { anchor: 0, head: length } });
|
|
488
808
|
}
|
|
489
|
-
// Formats the current document
|
|
809
|
+
// Formats the current document using the registered formatter plugin (if available for the active language).
|
|
490
810
|
// Returns the formatted text or null if unchanged/unsupported.
|
|
491
811
|
async format(affect = true) {
|
|
492
812
|
const view = this.editorViewSig();
|
|
@@ -495,7 +815,7 @@ class AXCodeEditorComponent extends MXValueComponent {
|
|
|
495
815
|
const source = view.state.doc.toString();
|
|
496
816
|
if (!source)
|
|
497
817
|
return null;
|
|
498
|
-
const formatted = await this.
|
|
818
|
+
const formatted = await this.pluginRegistry.format(source, this.language());
|
|
499
819
|
if (!formatted || formatted === source)
|
|
500
820
|
return null;
|
|
501
821
|
if (affect) {
|
|
@@ -521,8 +841,8 @@ class AXCodeEditorComponent extends MXValueComponent {
|
|
|
521
841
|
const text = this.value ?? '';
|
|
522
842
|
return text ? text.split(/\r?\n/).length : 1;
|
|
523
843
|
}
|
|
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.
|
|
844
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AXCodeEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
845
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.3.15", type: AXCodeEditorComponent, isStandalone: true, selector: "ax-code-editor", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: false, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: false, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: false, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: false, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: false, isRequired: false, transformFunction: null }, language: { classPropertyName: "language", publicName: "language", isSignal: true, isRequired: false, transformFunction: null }, editorReadonly: { classPropertyName: "editorReadonly", 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 }, 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: { onValueChanged: "onValueChanged", valueChange: "valueChange", stateChange: "stateChange", readonlyChange: "readonlyChange", disabledChange: "disabledChange", ready: "ready", save: "save" }, host: { listeners: { "keydown.control.s": "onSaveShortcut($event)" }, classAttribute: "ax-code-editor block" }, providers: [
|
|
526
846
|
{ provide: AXValuableComponent, useExisting: AXCodeEditorComponent },
|
|
527
847
|
{
|
|
528
848
|
provide: NG_VALUE_ACCESSOR,
|
|
@@ -531,24 +851,27 @@ class AXCodeEditorComponent extends MXValueComponent {
|
|
|
531
851
|
},
|
|
532
852
|
{ provide: AXComponent, useExisting: AXCodeEditorComponent },
|
|
533
853
|
], viewQueries: [{ propertyName: "host", first: true, predicate: ["host"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: `
|
|
534
|
-
<div
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
854
|
+
<div class="ax-editor-container">
|
|
855
|
+
<div class="ax-code-editor-container">
|
|
856
|
+
<div
|
|
857
|
+
#host
|
|
858
|
+
class="cm-editor"
|
|
859
|
+
[attr.aria-label]="ariaLabel() ?? null"
|
|
860
|
+
[attr.aria-readonly]="editorReadonly() ? 'true' : 'false'"
|
|
861
|
+
[attr.data-placeholder]="placeholder() ?? null"
|
|
862
|
+
></div>
|
|
863
|
+
</div>
|
|
864
|
+
<ng-content select="ax-validation-rule"> </ng-content>
|
|
865
|
+
</div>
|
|
866
|
+
<div class="ax-error-container"></div>
|
|
867
|
+
`, isInline: true, styles: [":host{display:block;width:100%;height:100%}:host .ax-editor-container{padding:.1rem}:host.ax-disable{opacity:.5;cursor:not-allowed}:host>.ax-editor-container{display:block;height:100%!important;--ax-comp-editor-space-start-size: 0;--ax-comp-editor-space-end-size: 0;overflow:visible;position:relative}:host .ax-code-editor-container{display:flex;flex-direction:column;height:100%}:host .cm-editor{width:100%;max-width:100%;overflow:auto}:host .cm-editor.cm-focused{outline:none}:host .ax-error-message{padding-inline:.5rem}\n"] }); }
|
|
545
868
|
}
|
|
546
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.
|
|
869
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AXCodeEditorComponent, decorators: [{
|
|
547
870
|
type: Component,
|
|
548
871
|
args: [{ selector: 'ax-code-editor', host: {
|
|
549
872
|
'(keydown.control.s)': 'onSaveShortcut($event)',
|
|
550
873
|
class: 'ax-code-editor block',
|
|
551
|
-
}, providers: [
|
|
874
|
+
}, inputs: ['disabled', 'value', 'state', 'name', 'id'], outputs: ['onValueChanged', 'valueChange', 'stateChange', 'readonlyChange', 'disabledChange'], providers: [
|
|
552
875
|
{ provide: AXValuableComponent, useExisting: AXCodeEditorComponent },
|
|
553
876
|
{
|
|
554
877
|
provide: NG_VALUE_ACCESSOR,
|
|
@@ -557,25 +880,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImpor
|
|
|
557
880
|
},
|
|
558
881
|
{ provide: AXComponent, useExisting: AXCodeEditorComponent },
|
|
559
882
|
], template: `
|
|
560
|
-
<div
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
883
|
+
<div class="ax-editor-container">
|
|
884
|
+
<div class="ax-code-editor-container">
|
|
885
|
+
<div
|
|
886
|
+
#host
|
|
887
|
+
class="cm-editor"
|
|
888
|
+
[attr.aria-label]="ariaLabel() ?? null"
|
|
889
|
+
[attr.aria-readonly]="editorReadonly() ? 'true' : 'false'"
|
|
890
|
+
[attr.data-placeholder]="placeholder() ?? null"
|
|
891
|
+
></div>
|
|
892
|
+
</div>
|
|
893
|
+
<ng-content select="ax-validation-rule"> </ng-content>
|
|
894
|
+
</div>
|
|
895
|
+
<div class="ax-error-container"></div>
|
|
896
|
+
`, styles: [":host{display:block;width:100%;height:100%}:host .ax-editor-container{padding:.1rem}:host.ax-disable{opacity:.5;cursor:not-allowed}:host>.ax-editor-container{display:block;height:100%!important;--ax-comp-editor-space-start-size: 0;--ax-comp-editor-space-end-size: 0;overflow:visible;position:relative}:host .ax-code-editor-container{display:flex;flex-direction:column;height:100%}:host .cm-editor{width:100%;max-width:100%;overflow:auto}:host .cm-editor.cm-focused{outline:none}:host .ax-error-message{padding-inline:.5rem}\n"] }]
|
|
897
|
+
}], ctorParameters: () => [], propDecorators: { language: [{ type: i0.Input, args: [{ isSignal: true, alias: "language", required: false }] }], editorReadonly: [{ 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 }] }], 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.15", ngImport: i0, type: AXCodeEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
901
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.15", ngImport: i0, type: AXCodeEditorModule, imports: [CommonModule, AXCodeEditorComponent], exports: [AXCodeEditorComponent] }); }
|
|
902
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.15", 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.15", 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
|