ngx-axis-appforge 0.0.52 → 0.0.54
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/axis-components/rich-text-editor/index.d.ts +1 -0
- package/fesm2022/ngx-axis-appforge-axis-components-editor.mjs +4 -4
- package/fesm2022/ngx-axis-appforge-axis-components-editor.mjs.map +1 -1
- package/fesm2022/ngx-axis-appforge-axis-components-rich-text-editor.mjs +3 -1
- package/fesm2022/ngx-axis-appforge-axis-components-rich-text-editor.mjs.map +1 -1
- package/fesm2022/ngx-axis-appforge-core.mjs +49 -36
- package/fesm2022/ngx-axis-appforge-core.mjs.map +1 -1
- package/package.json +124 -124
|
@@ -14,6 +14,7 @@ declare class RichTextEditor extends ValueAccess<RichTextEditorOptions> {
|
|
|
14
14
|
options: RichTextEditorOptions;
|
|
15
15
|
private readonly fileBaseUrl;
|
|
16
16
|
private readonly http;
|
|
17
|
+
private platformLocation;
|
|
17
18
|
editor: EditorComponent;
|
|
18
19
|
editorConfig: _angular_core.Signal<any>;
|
|
19
20
|
filePickerCallback(callback: (value: string, meta?: Record<string, any>) => void, value: string, meta: Record<string, any>): void;
|
|
@@ -10,7 +10,7 @@ import { of } from 'rxjs';
|
|
|
10
10
|
import * as i3 from 'ng-zorro-antd/icon';
|
|
11
11
|
import { NzIconModule } from 'ng-zorro-antd/icon';
|
|
12
12
|
import * as i4 from 'ng-zorro-antd/tooltip';
|
|
13
|
-
import {
|
|
13
|
+
import { NzTooltipModule, NzTooltipDirective } from 'ng-zorro-antd/tooltip';
|
|
14
14
|
import * as i5 from 'ng-zorro-antd/button';
|
|
15
15
|
import { NzButtonModule } from 'ng-zorro-antd/button';
|
|
16
16
|
import * as i6 from 'ng-zorro-antd/core/transition-patch';
|
|
@@ -40,7 +40,7 @@ class Editor extends ValueAccess {
|
|
|
40
40
|
editor;
|
|
41
41
|
mouseenter() {
|
|
42
42
|
if (this.config().language == "javascript") {
|
|
43
|
-
const lsd = monaco
|
|
43
|
+
const lsd = monaco?.languages.typescript.javascriptDefaults;
|
|
44
44
|
lsd.setExtraLibs(this.options.typescriptExtLibs());
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -72,11 +72,11 @@ class Editor extends ValueAccess {
|
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: Editor, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
75
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.4", type: Editor, isStandalone: true, selector: "axis-editor", host: { listeners: { "mouseenter": "mouseenter()", "keydown": "keydown($event)" } }, viewQueries: [{ propertyName: "tooltip", first: true, predicate: NzTooltipDirective, descendants: true }, { propertyName: "editor", first: true, predicate: NzCodeEditorComponent, descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"container\" [class.full-screen]=\"fullScreen()\">\n <div class=\"toolBar\">\n <a nz-button nzType=\"link\" nzSize=\"small\" (click)=\"toggleFullScreen()\">\n <nz-icon [class.active]=\"fullScreen()\" nz-tooltip nzTooltipTitle=\"\u5207\u6362\u5168\u5C4F\"\n [nzType]=\"fullScreen() ? 'fullscreen-exit' : 'fullscreen'\" />\n </a>\n </div>\n <nz-code-editor [(ngModel)]=\"value\" (ngModelChange)=\"onChange?.($event)\"\n [nzEditorOption]=\"config()\"></nz-code-editor>\n</div>", styles: [":host{display:block;width:100%;height:100%}.container{display:flex;flex-direction:column;height:100%;width:100%;background-color:#fff;position:relative}nz-code-editor{height:100%;width:100%;flex:1}.full-screen{position:fixed;z-index:999;height:100vh;inset:0}.toolBar{display:flex;justify-content:end;position:absolute;top:20px;right:50px;border-radius:16px;z-index:1000}.toolBar:hover{background-color:#fff;box-shadow:2px 2px 5px #00000026;transition:all .2s ease-in-out}\n"], dependencies: [{ kind: "ngmodule", type: NzCodeEditorModule }, { kind: "component", type: i1.NzCodeEditorComponent, selector: "nz-code-editor", inputs: ["nzEditorMode", "nzOriginalText", "nzLoading", "nzFullControl", "nzToolkit", "nzEditorOption"], outputs: ["nzEditorInitialized"], exportAs: ["nzCodeEditor"] }, { kind: "ngmodule", type: NzFormModule }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i3.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { kind: "ngmodule", type:
|
|
75
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.4", type: Editor, isStandalone: true, selector: "axis-editor", host: { listeners: { "mouseenter": "mouseenter()", "keydown": "keydown($event)" } }, viewQueries: [{ propertyName: "tooltip", first: true, predicate: NzTooltipDirective, descendants: true }, { propertyName: "editor", first: true, predicate: NzCodeEditorComponent, descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"container\" [class.full-screen]=\"fullScreen()\">\n <div class=\"toolBar\">\n <a nz-button nzType=\"link\" nzSize=\"small\" (click)=\"toggleFullScreen()\">\n <nz-icon [class.active]=\"fullScreen()\" nz-tooltip nzTooltipTitle=\"\u5207\u6362\u5168\u5C4F\"\n [nzType]=\"fullScreen() ? 'fullscreen-exit' : 'fullscreen'\" />\n </a>\n </div>\n <nz-code-editor [(ngModel)]=\"value\" (ngModelChange)=\"onChange?.($event)\"\n [nzEditorOption]=\"config()\"></nz-code-editor>\n</div>", styles: [":host{display:block;width:100%;height:100%}.container{display:flex;flex-direction:column;height:100%;width:100%;background-color:#fff;position:relative}nz-code-editor{height:100%;width:100%;flex:1}.full-screen{position:fixed;z-index:999;height:100vh;inset:0}.toolBar{display:flex;justify-content:end;position:absolute;top:20px;right:50px;border-radius:16px;z-index:1000}.toolBar:hover{background-color:#fff;box-shadow:2px 2px 5px #00000026;transition:all .2s ease-in-out}\n"], dependencies: [{ kind: "ngmodule", type: NzCodeEditorModule }, { kind: "component", type: i1.NzCodeEditorComponent, selector: "nz-code-editor", inputs: ["nzEditorMode", "nzOriginalText", "nzLoading", "nzFullControl", "nzToolkit", "nzEditorOption"], outputs: ["nzEditorInitialized"], exportAs: ["nzCodeEditor"] }, { kind: "ngmodule", type: NzFormModule }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i3.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { kind: "ngmodule", type: NzTooltipModule }, { kind: "directive", type: i4.NzTooltipDirective, selector: "[nz-tooltip]", inputs: ["nzTooltipTitle", "nzTooltipTitleContext", "nz-tooltip", "nzTooltipTrigger", "nzTooltipPlacement", "nzTooltipOrigin", "nzTooltipVisible", "nzTooltipMouseEnterDelay", "nzTooltipMouseLeaveDelay", "nzTooltipOverlayClassName", "nzTooltipOverlayStyle", "nzTooltipArrowPointAtCenter", "cdkConnectedOverlayPush", "nzTooltipColor"], outputs: ["nzTooltipVisibleChange"], exportAs: ["nzTooltip"] }, { kind: "ngmodule", type: NzButtonModule }, { kind: "component", type: i5.NzButtonComponent, selector: "button[nz-button], a[nz-button]", inputs: ["nzBlock", "nzGhost", "nzSearch", "nzLoading", "nzDanger", "disabled", "tabIndex", "nzType", "nzShape", "nzSize"], exportAs: ["nzButton"] }, { kind: "directive", type: i6.ɵNzTransitionPatchDirective, selector: "[nz-button], [nz-icon], nz-icon, [nz-menu-item], [nz-submenu], nz-select-top-control, nz-select-placeholder, nz-input-group", inputs: ["hidden"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
76
76
|
}
|
|
77
77
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: Editor, decorators: [{
|
|
78
78
|
type: Component,
|
|
79
|
-
args: [{ selector: 'axis-editor', imports: [NzCodeEditorModule, NzFormModule, FormsModule, NzIconModule,
|
|
79
|
+
args: [{ selector: 'axis-editor', imports: [NzCodeEditorModule, NzFormModule, FormsModule, NzIconModule, NzTooltipModule, NzButtonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"container\" [class.full-screen]=\"fullScreen()\">\n <div class=\"toolBar\">\n <a nz-button nzType=\"link\" nzSize=\"small\" (click)=\"toggleFullScreen()\">\n <nz-icon [class.active]=\"fullScreen()\" nz-tooltip nzTooltipTitle=\"\u5207\u6362\u5168\u5C4F\"\n [nzType]=\"fullScreen() ? 'fullscreen-exit' : 'fullscreen'\" />\n </a>\n </div>\n <nz-code-editor [(ngModel)]=\"value\" (ngModelChange)=\"onChange?.($event)\"\n [nzEditorOption]=\"config()\"></nz-code-editor>\n</div>", styles: [":host{display:block;width:100%;height:100%}.container{display:flex;flex-direction:column;height:100%;width:100%;background-color:#fff;position:relative}nz-code-editor{height:100%;width:100%;flex:1}.full-screen{position:fixed;z-index:999;height:100vh;inset:0}.toolBar{display:flex;justify-content:end;position:absolute;top:20px;right:50px;border-radius:16px;z-index:1000}.toolBar:hover{background-color:#fff;box-shadow:2px 2px 5px #00000026;transition:all .2s ease-in-out}\n"] }]
|
|
80
80
|
}], propDecorators: { tooltip: [{
|
|
81
81
|
type: ViewChild,
|
|
82
82
|
args: [NzTooltipDirective, { static: false }]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngx-axis-appforge-axis-components-editor.mjs","sources":["../../../axis-components/editor/editor.options.ts","../../../axis-components/editor/editor.ts","../../../axis-components/editor/editor.html","../../../axis-components/editor/ngx-axis-appforge-axis-components-editor.ts"],"sourcesContent":["import { signal } from \"@angular/core\";\nimport { ValueAccessOptions } from \"ngx-axis-appforge/core\";\n\nexport class EditorOptions extends ValueAccessOptions {\n\n readonly mode = signal<\"json\" | \"javascript\" | \"plain_text\" | \"sql\" | \"html\">(\"plain_text\");\n readonly otherOptions = signal<any>({});\n readonly typescriptExtLibs = signal<{ content: string; filePath?: string; }[]>([]);\n\n}","import { ChangeDetectionStrategy, Component, computed, DOCUMENT, HostListener, inject, Renderer2, signal, ViewChild } from '@angular/core';\nimport { EditorOptions } from './editor.options';\nimport { NzCodeEditorComponent, NzCodeEditorModule } from 'ng-zorro-antd/code-editor';\nimport { NzFormModule } from 'ng-zorro-antd/form';\nimport { FormsModule } from '@angular/forms';\nimport { ValueAccess, EventHandlerOptions } from 'ngx-axis-appforge/core';\nimport type { languages } from 'monaco-editor';\nimport { NzSafeAny } from 'ng-zorro-antd/core/types';\nimport { Observable, of } from 'rxjs';\nimport { NzIconModule } from 'ng-zorro-antd/icon';\nimport { NzTooltipDirective,
|
|
1
|
+
{"version":3,"file":"ngx-axis-appforge-axis-components-editor.mjs","sources":["../../../axis-components/editor/editor.options.ts","../../../axis-components/editor/editor.ts","../../../axis-components/editor/editor.html","../../../axis-components/editor/ngx-axis-appforge-axis-components-editor.ts"],"sourcesContent":["import { signal } from \"@angular/core\";\nimport { ValueAccessOptions } from \"ngx-axis-appforge/core\";\n\nexport class EditorOptions extends ValueAccessOptions {\n\n readonly mode = signal<\"json\" | \"javascript\" | \"plain_text\" | \"sql\" | \"html\">(\"plain_text\");\n readonly otherOptions = signal<any>({});\n readonly typescriptExtLibs = signal<{ content: string; filePath?: string; }[]>([]);\n\n}","import { ChangeDetectionStrategy, Component, computed, DOCUMENT, HostListener, inject, Renderer2, signal, ViewChild } from '@angular/core';\nimport { EditorOptions } from './editor.options';\nimport { NzCodeEditorComponent, NzCodeEditorModule } from 'ng-zorro-antd/code-editor';\nimport { NzFormModule } from 'ng-zorro-antd/form';\nimport { FormsModule } from '@angular/forms';\nimport { ValueAccess, EventHandlerOptions } from 'ngx-axis-appforge/core';\nimport type { languages } from 'monaco-editor';\nimport { NzSafeAny } from 'ng-zorro-antd/core/types';\nimport { Observable, of } from 'rxjs';\nimport { NzIconModule } from 'ng-zorro-antd/icon';\nimport { NzTooltipDirective, NzTooltipModule } from 'ng-zorro-antd/tooltip';\nimport { NzButtonModule } from 'ng-zorro-antd/button';\ndeclare const monaco: NzSafeAny;\n\n@Component({\n selector: 'axis-editor',\n imports: [NzCodeEditorModule, NzFormModule, FormsModule, NzIconModule, NzTooltipModule, NzButtonModule],\n templateUrl: './editor.html',\n styleUrl: './editor.css',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class Editor extends ValueAccess<EditorOptions> {\n\n override options: EditorOptions = new EditorOptions();\n\n override writeValue(value: any): void {\n super.writeValue(value ?? \"\");\n }\n\n config = computed(() => ({\n language: this.options.mode(),\n readOnly: this.options.readonly() || this.options.disabled(),\n domReadOnly: this.options.readonly() || this.options.disabled(),\n fixedOverflowWidgets: true,\n ...this.options.otherOptions(),\n }));\n\n readonly fullScreen = signal(false);\n private document: Document = inject(DOCUMENT);\n private renderer: Renderer2 = inject(Renderer2);\n @ViewChild(NzTooltipDirective, { static: false })\n tooltip?: NzTooltipDirective;\n\n\n @ViewChild(NzCodeEditorComponent, { static: true })\n editor!: NzCodeEditorComponent;\n\n @HostListener(\"mouseenter\")\n mouseenter() {\n if (this.config().language == \"javascript\") {\n const lsd: languages.typescript.LanguageServiceDefaults = monaco?.languages.typescript.javascriptDefaults;\n lsd.setExtraLibs(this.options.typescriptExtLibs());\n }\n }\n\n @HostListener(\"keydown\", ['$event'])\n keydown(e: KeyboardEvent) {\n if (e.key == \"Escape\" && this.fullScreen()) {\n this.toggleFullScreen();\n e.stopPropagation();\n e.preventDefault();\n }\n }\n\n override onEvents(e: EventHandlerOptions<any>): Observable<boolean> | undefined {\n const obs = super.onEvents?.(e);\n if (obs) {\n return obs;\n }\n switch (e.name) {\n case \"layout\":\n this.editor?.layout();\n return of(true);\n }\n return undefined;\n }\n\n toggleFullScreen(): void {\n this.fullScreen.set(!this.fullScreen());\n this.renderer.setStyle(this.document.body, 'overflow-y', this.fullScreen() ? 'hidden' : null);\n this.tooltip?.hide();\n setTimeout(() => {\n this.editor?.layout();\n });\n }\n}\n","<div class=\"container\" [class.full-screen]=\"fullScreen()\">\n <div class=\"toolBar\">\n <a nz-button nzType=\"link\" nzSize=\"small\" (click)=\"toggleFullScreen()\">\n <nz-icon [class.active]=\"fullScreen()\" nz-tooltip nzTooltipTitle=\"切换全屏\"\n [nzType]=\"fullScreen() ? 'fullscreen-exit' : 'fullscreen'\" />\n </a>\n </div>\n <nz-code-editor [(ngModel)]=\"value\" (ngModelChange)=\"onChange?.($event)\"\n [nzEditorOption]=\"config()\"></nz-code-editor>\n</div>","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './editor';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAGM,MAAO,aAAc,SAAQ,kBAAkB,CAAA;AAExC,IAAA,IAAI,GAAG,MAAM,CAAwD,YAAY,gDAAC;AAClF,IAAA,YAAY,GAAG,MAAM,CAAM,EAAE,wDAAC;AAC9B,IAAA,iBAAiB,GAAG,MAAM,CAA4C,EAAE,6DAAC;AAErF;;ACYK,MAAO,MAAO,SAAQ,WAA0B,CAAA;AAE3C,IAAA,OAAO,GAAkB,IAAI,aAAa,EAAE;AAE5C,IAAA,UAAU,CAAC,KAAU,EAAA;AAC5B,QAAA,KAAK,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE,CAAC;IAC/B;AAEA,IAAA,MAAM,GAAG,QAAQ,CAAC,OAAO;AACvB,QAAA,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,IA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,IAAA,EAAA,EAAA,CAAA,2BAAA,EAAA,QAAA,EAAA,6HAAA,EAAA,MAAA,EAAA,CAAA,QAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FAK3F,MAAM,EAAA,UAAA,EAAA,CAAA;kBAPlB,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,aAAa,WACd,CAAC,kBAAkB,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,CAAC,EAAA,eAAA,EAGtF,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,+hBAAA,EAAA,MAAA,EAAA,CAAA,2dAAA,CAAA,EAAA;8BAsB/C,OAAO,EAAA,CAAA;sBADN,SAAS;AAAC,gBAAA,IAAA,EAAA,CAAA,kBAAkB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;gBAKhD,MAAM,EAAA,CAAA;sBADL,SAAS;AAAC,gBAAA,IAAA,EAAA,CAAA,qBAAqB,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;gBAIlD,UAAU,EAAA,CAAA;sBADT,YAAY;uBAAC,YAAY;gBAS1B,OAAO,EAAA,CAAA;sBADN,YAAY;uBAAC,SAAS,EAAE,CAAC,QAAQ,CAAC;;;AEvDrC;;AAEG;;;;"}
|
|
@@ -7,6 +7,7 @@ import * as i2 from '@tinymce/tinymce-angular';
|
|
|
7
7
|
import { EditorModule, EditorComponent, TINYMCE_SCRIPT_SRC } from '@tinymce/tinymce-angular';
|
|
8
8
|
import { BehaviorSubject } from 'rxjs';
|
|
9
9
|
import { HttpClient, HttpResponse, HttpEventType } from '@angular/common/http';
|
|
10
|
+
import { PlatformLocation } from '@angular/common';
|
|
10
11
|
|
|
11
12
|
class RichTextEditorOptions extends ValueAccessOptions {
|
|
12
13
|
fileUploadUrl = signal("", ...(ngDevMode ? [{ debugName: "fileUploadUrl" }] : []));
|
|
@@ -19,6 +20,7 @@ class RichTextEditor extends ValueAccess {
|
|
|
19
20
|
options = new RichTextEditorOptions();
|
|
20
21
|
fileBaseUrl = inject(AXIS_FILE_BASE_URL_TOKEN, { optional: true }) ?? "";
|
|
21
22
|
http = inject(HttpClient);
|
|
23
|
+
platformLocation = inject(PlatformLocation);
|
|
22
24
|
editor;
|
|
23
25
|
editorConfig = computed(() => {
|
|
24
26
|
return Object.assign({}, this.defaultEditorConfig, this.options.tinymceOptions());
|
|
@@ -92,7 +94,7 @@ class RichTextEditor extends ValueAccess {
|
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
defaultEditorConfig = {
|
|
95
|
-
base_url:
|
|
97
|
+
base_url: `${this.platformLocation.getBaseHrefFromDOM()}tinymce`,
|
|
96
98
|
suffix: '.min',
|
|
97
99
|
language: 'zh_CN',
|
|
98
100
|
skin: (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'oxide-dark' : 'oxide'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngx-axis-appforge-axis-components-rich-text-editor.mjs","sources":["../../../axis-components/rich-text-editor/rich-text-editor.options.ts","../../../axis-components/rich-text-editor/rich-text-editor.ts","../../../axis-components/rich-text-editor/rich-text-editor.html","../../../axis-components/rich-text-editor/ngx-axis-appforge-axis-components-rich-text-editor.ts"],"sourcesContent":["import { signal } from \"@angular/core\";\nimport { ValueAccessOptions } from \"ngx-axis-appforge/core\";\n\nexport class RichTextEditorOptions extends ValueAccessOptions {\n\n readonly fileUploadUrl = signal(\"\");\n readonly fileUploadFormName = signal(\"file\");\n readonly fileUploadResponseFn = signal(\"\");\n readonly tinymceOptions = signal<any>(undefined);\n}","import { ChangeDetectionStrategy, Component, computed, inject, ViewChild } from '@angular/core';\nimport { RichTextEditorOptions } from './rich-text-editor.options';\nimport { AXIS_FILE_BASE_URL_TOKEN, ValueAccess } from 'ngx-axis-appforge/core';\nimport { FormsModule } from '@angular/forms';\nimport { EditorComponent, EditorModule, TINYMCE_SCRIPT_SRC } from '@tinymce/tinymce-angular';\nimport { RawEditorOptions } from 'tinymce';\nimport { BehaviorSubject } from 'rxjs';\nimport { HttpClient, HttpEventType, HttpResponse } from '@angular/common/http';\n\n@Component({\n selector: 'axis-rich-text-editor',\n imports: [FormsModule, EditorModule],\n templateUrl: './rich-text-editor.html',\n styleUrl: './rich-text-editor.css',\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [\n { provide: TINYMCE_SCRIPT_SRC, useValue: 'tinymce/tinymce.min.js' }\n ]\n})\nexport class RichTextEditor extends ValueAccess<RichTextEditorOptions> {\n\n override options: RichTextEditorOptions = new RichTextEditorOptions();\n private readonly fileBaseUrl = inject(AXIS_FILE_BASE_URL_TOKEN, { optional: true }) ?? \"\";\n private readonly http = inject(HttpClient);\n\n @ViewChild(EditorComponent, { static: true })\n editor!: EditorComponent;\n\n editorConfig = computed(() => {\n return Object.assign({}, this.defaultEditorConfig, this.options.tinymceOptions());\n })\n\n filePickerCallback(callback: (value: string, meta?: Record<string, any>) => void, value: string, meta: Record<string, any>) {\n const input = document.createElement('input');\n input.setAttribute('type', 'file');\n let accept;\n switch (meta['filetype']) {\n case \"image\":\n accept = \"image/*\";\n break;\n case \"media\":\n accept = \"video/*,audio/*\";\n break;\n default:\n accept = \"*/*\";\n }\n input.setAttribute('accept', accept);\n input.onchange = (e) => {\n const file = (e?.target as HTMLInputElement | undefined)?.files?.[0];\n if (file) {\n const reader = new FileReader();\n reader.onload = () => {\n if (reader.result) {\n const id = 'blobid' + (new Date()).getTime();\n const blobCache = this.editor.editor.editorUpload.blobCache;\n const base64 = reader.result?.toString()?.split(',')[1];\n const blobInfo = blobCache.create(id, file, base64);\n blobCache.add(blobInfo);\n callback(blobInfo.blobUri(), { title: file.name });\n }\n }\n reader.readAsDataURL(file);\n }\n };\n\n input.click();\n }\n\n uploadHandler(blobInfo: any, progress: any): Promise<string> {\n return new Promise((resolve, reject) => {\n const formData = new FormData();\n formData.append(this.options.fileUploadFormName(), blobInfo.blob(), blobInfo.filename());\n this.http.post(this.options.fileUploadUrl(), formData, { reportProgress: true, observe: 'events' }).subscribe(event => {\n if (event instanceof HttpResponse) {\n if (this.options.fileUploadResponseFn()) {\n const res = this.runFn(this.options.fileUploadResponseFn(), { apiResponse: event.body });\n const { success, errmsg, url } = res;\n if (success) {\n resolve(this.getUrl(url));\n } else {\n reject(errmsg || \"上传失败\");\n }\n }\n } else if (event.type == HttpEventType.UploadProgress) {\n progress(Math.floor(event.loaded / event.total! * 100));\n }\n });\n });\n }\n\n getUrl(url: string): string {\n if (url.startsWith(\"http\")) {\n return url;\n } else if (this.fileBaseUrl instanceof BehaviorSubject) {\n return this.fileBaseUrl.value + url;\n } else {\n return this.fileBaseUrl + url;\n }\n }\n\n\n defaultEditorConfig: RawEditorOptions = {\n base_url: \"/tinymce\",\n suffix: '.min',\n language: 'zh_CN',\n skin: (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'oxide-dark' : 'oxide'),\n content_css: (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'default'),\n promotion: false,\n onboarding: false,\n branding: false,\n plugins: 'preview importcss searchreplace autolink directionality code visualblocks visualchars fullscreen image link media codesample table charmap pagebreak nonbreaking anchor insertdatetime advlist lists wordcount help charmap quickbars emoticons accordion',\n menubar: 'file edit view insert format tools table help',\n toolbar: \"undo redo | blocks fontfamily fontsize | bold italic underline strikethrough | align numlist bullist | link image | table media | lineheight outdent indent| forecolor backcolor removeformat | charmap emoticons | accordion accordionremove | code fullscreen preview | print | pagebreak anchor codesample | ltr rtl\",\n hidden_input: false,\n file_picker_callback: this.filePickerCallback.bind(this),\n images_upload_handler: this.uploadHandler.bind(this),\n convert_urls: false,\n image_advtab: true,\n importcss_append: true,\n image_caption: true,\n images_reuse_filename: true,\n quickbars_selection_toolbar: 'bold italic | quicklink h2 h3 blockquote quickimage quicktable',\n noneditable_class: 'mceNonEditable',\n toolbar_mode: 'sliding',\n contextmenu: 'link image table',\n }\n}\n","<editor style=\"height: 100%;\" [init]=\"editorConfig()\" licenseKey=\"gpl\" [(ngModel)]=\"value\" (ngModelChange)=\"onChange?.($event)\"></editor>","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './rich-text-editor';\n"],"names":[],"mappings":";;;;;;;;;;AAGM,MAAO,qBAAsB,SAAQ,kBAAkB,CAAA;AAEhD,IAAA,aAAa,GAAG,MAAM,CAAC,EAAE,yDAAC;AAC1B,IAAA,kBAAkB,GAAG,MAAM,CAAC,MAAM,8DAAC;AACnC,IAAA,oBAAoB,GAAG,MAAM,CAAC,EAAE,gEAAC;AACjC,IAAA,cAAc,GAAG,MAAM,CAAM,SAAS,0DAAC;AACnD;;ACUK,MAAO,cAAe,SAAQ,WAAkC,CAAA;AAE3D,IAAA,OAAO,GAA0B,IAAI,qBAAqB,EAAE;AACpD,IAAA,WAAW,GAAG,MAAM,CAAC,wBAAwB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE;AACxE,IAAA,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC;AAG1C,IAAA,MAAM;AAEN,IAAA,YAAY,GAAG,QAAQ,CAAC,MAAK;AAC3B,QAAA,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;AACnF,IAAA,CAAC,wDAAC;AAEF,IAAA,kBAAkB,CAAC,QAA6D,EAAE,KAAa,EAAE,IAAyB,EAAA;QACxH,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC;AAC7C,QAAA,KAAK,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC;AAClC,QAAA,IAAI,MAAM;AACV,QAAA,QAAQ,IAAI,CAAC,UAAU,CAAC;AACtB,YAAA,KAAK,OAAO;gBACV,MAAM,GAAG,SAAS;gBAClB;AACF,YAAA,KAAK,OAAO;gBACV,MAAM,GAAG,iBAAiB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AClE,qBAAA,EAAA,QAAA,EAAA,qJAAA,EAAA,MAAA,EAAA,CAAA,mCAAA,CAAA,EAAA;8BASD,MAAM,EAAA,CAAA;sBADL,SAAS;AAAC,gBAAA,IAAA,EAAA,CAAA,eAAe,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;;;AEzB9C;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngx-axis-appforge-axis-components-rich-text-editor.mjs","sources":["../../../axis-components/rich-text-editor/rich-text-editor.options.ts","../../../axis-components/rich-text-editor/rich-text-editor.ts","../../../axis-components/rich-text-editor/rich-text-editor.html","../../../axis-components/rich-text-editor/ngx-axis-appforge-axis-components-rich-text-editor.ts"],"sourcesContent":["import { signal } from \"@angular/core\";\nimport { ValueAccessOptions } from \"ngx-axis-appforge/core\";\n\nexport class RichTextEditorOptions extends ValueAccessOptions {\n\n readonly fileUploadUrl = signal(\"\");\n readonly fileUploadFormName = signal(\"file\");\n readonly fileUploadResponseFn = signal(\"\");\n readonly tinymceOptions = signal<any>(undefined);\n}","import { ChangeDetectionStrategy, Component, computed, inject, ViewChild } from '@angular/core';\nimport { RichTextEditorOptions } from './rich-text-editor.options';\nimport { AXIS_FILE_BASE_URL_TOKEN, ValueAccess } from 'ngx-axis-appforge/core';\nimport { FormsModule } from '@angular/forms';\nimport { EditorComponent, EditorModule, TINYMCE_SCRIPT_SRC } from '@tinymce/tinymce-angular';\nimport { RawEditorOptions } from 'tinymce';\nimport { BehaviorSubject } from 'rxjs';\nimport { HttpClient, HttpEventType, HttpResponse } from '@angular/common/http';\nimport { PlatformLocation } from '@angular/common';\n\n@Component({\n selector: 'axis-rich-text-editor',\n imports: [FormsModule, EditorModule],\n templateUrl: './rich-text-editor.html',\n styleUrl: './rich-text-editor.css',\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [\n { provide: TINYMCE_SCRIPT_SRC, useValue: 'tinymce/tinymce.min.js' }\n ]\n})\nexport class RichTextEditor extends ValueAccess<RichTextEditorOptions> {\n\n override options: RichTextEditorOptions = new RichTextEditorOptions();\n private readonly fileBaseUrl = inject(AXIS_FILE_BASE_URL_TOKEN, { optional: true }) ?? \"\";\n private readonly http = inject(HttpClient);\n private platformLocation = inject(PlatformLocation);\n @ViewChild(EditorComponent, { static: true })\n editor!: EditorComponent;\n\n editorConfig = computed(() => {\n return Object.assign({}, this.defaultEditorConfig, this.options.tinymceOptions());\n })\n\n filePickerCallback(callback: (value: string, meta?: Record<string, any>) => void, value: string, meta: Record<string, any>) {\n const input = document.createElement('input');\n input.setAttribute('type', 'file');\n let accept;\n switch (meta['filetype']) {\n case \"image\":\n accept = \"image/*\";\n break;\n case \"media\":\n accept = \"video/*,audio/*\";\n break;\n default:\n accept = \"*/*\";\n }\n input.setAttribute('accept', accept);\n input.onchange = (e) => {\n const file = (e?.target as HTMLInputElement | undefined)?.files?.[0];\n if (file) {\n const reader = new FileReader();\n reader.onload = () => {\n if (reader.result) {\n const id = 'blobid' + (new Date()).getTime();\n const blobCache = this.editor.editor.editorUpload.blobCache;\n const base64 = reader.result?.toString()?.split(',')[1];\n const blobInfo = blobCache.create(id, file, base64);\n blobCache.add(blobInfo);\n callback(blobInfo.blobUri(), { title: file.name });\n }\n }\n reader.readAsDataURL(file);\n }\n };\n\n input.click();\n }\n\n uploadHandler(blobInfo: any, progress: any): Promise<string> {\n return new Promise((resolve, reject) => {\n const formData = new FormData();\n formData.append(this.options.fileUploadFormName(), blobInfo.blob(), blobInfo.filename());\n this.http.post(this.options.fileUploadUrl(), formData, { reportProgress: true, observe: 'events' }).subscribe(event => {\n if (event instanceof HttpResponse) {\n if (this.options.fileUploadResponseFn()) {\n const res = this.runFn(this.options.fileUploadResponseFn(), { apiResponse: event.body });\n const { success, errmsg, url } = res;\n if (success) {\n resolve(this.getUrl(url));\n } else {\n reject(errmsg || \"上传失败\");\n }\n }\n } else if (event.type == HttpEventType.UploadProgress) {\n progress(Math.floor(event.loaded / event.total! * 100));\n }\n });\n });\n }\n\n getUrl(url: string): string {\n if (url.startsWith(\"http\")) {\n return url;\n } else if (this.fileBaseUrl instanceof BehaviorSubject) {\n return this.fileBaseUrl.value + url;\n } else {\n return this.fileBaseUrl + url;\n }\n }\n\n\n defaultEditorConfig: RawEditorOptions = {\n base_url: `${this.platformLocation.getBaseHrefFromDOM()}tinymce`,\n suffix: '.min',\n language: 'zh_CN',\n skin: (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'oxide-dark' : 'oxide'),\n content_css: (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'default'),\n promotion: false,\n onboarding: false,\n branding: false,\n plugins: 'preview importcss searchreplace autolink directionality code visualblocks visualchars fullscreen image link media codesample table charmap pagebreak nonbreaking anchor insertdatetime advlist lists wordcount help charmap quickbars emoticons accordion',\n menubar: 'file edit view insert format tools table help',\n toolbar: \"undo redo | blocks fontfamily fontsize | bold italic underline strikethrough | align numlist bullist | link image | table media | lineheight outdent indent| forecolor backcolor removeformat | charmap emoticons | accordion accordionremove | code fullscreen preview | print | pagebreak anchor codesample | ltr rtl\",\n hidden_input: false,\n file_picker_callback: this.filePickerCallback.bind(this),\n images_upload_handler: this.uploadHandler.bind(this),\n convert_urls: false,\n image_advtab: true,\n importcss_append: true,\n image_caption: true,\n images_reuse_filename: true,\n quickbars_selection_toolbar: 'bold italic | quicklink h2 h3 blockquote quickimage quicktable',\n noneditable_class: 'mceNonEditable',\n toolbar_mode: 'sliding',\n contextmenu: 'link image table',\n }\n}\n","<editor style=\"height: 100%;\" [init]=\"editorConfig()\" licenseKey=\"gpl\" [(ngModel)]=\"value\" (ngModelChange)=\"onChange?.($event)\"></editor>","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './rich-text-editor';\n"],"names":[],"mappings":";;;;;;;;;;;AAGM,MAAO,qBAAsB,SAAQ,kBAAkB,CAAA;AAEhD,IAAA,aAAa,GAAG,MAAM,CAAC,EAAE,yDAAC;AAC1B,IAAA,kBAAkB,GAAG,MAAM,CAAC,MAAM,8DAAC;AAC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