@sd-angular/core 1.2.85 → 1.2.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/sd-angular-core-comment.umd.js +1 -1
- package/bundles/sd-angular-core-comment.umd.js.map +1 -1
- package/bundles/sd-angular-core-comment.umd.min.js +1 -1
- package/bundles/sd-angular-core-comment.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-editor.umd.js +199 -46
- package/bundles/sd-angular-core-editor.umd.js.map +1 -1
- package/bundles/sd-angular-core-editor.umd.min.js +2 -2
- package/bundles/sd-angular-core-editor.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-input-number.umd.js +3 -3
- package/bundles/sd-angular-core-input-number.umd.js.map +1 -1
- package/bundles/sd-angular-core-input-number.umd.min.js +1 -1
- package/bundles/sd-angular-core-input-number.umd.min.js.map +1 -1
- package/comment/sd-angular-core-comment.metadata.json +1 -1
- package/comment/src/lib/comment.model.d.ts +1 -1
- package/editor/sd-angular-core-editor.metadata.json +1 -1
- package/editor/src/lib/editor.component.d.ts +12 -5
- package/editor/src/lib/editor.model.d.ts +16 -0
- package/editor/src/public-api.d.ts +1 -0
- package/esm2015/comment/src/lib/comment.component.js +2 -2
- package/esm2015/comment/src/lib/comment.model.js +1 -1
- package/esm2015/editor/src/lib/editor.component.js +180 -44
- package/esm2015/editor/src/lib/editor.model.js +3 -0
- package/esm2015/editor/src/public-api.js +2 -1
- package/esm2015/input-number/src/lib/input-number.component.js +4 -4
- package/fesm2015/sd-angular-core-comment.js +1 -1
- package/fesm2015/sd-angular-core-comment.js.map +1 -1
- package/fesm2015/sd-angular-core-editor.js +181 -44
- package/fesm2015/sd-angular-core-editor.js.map +1 -1
- package/fesm2015/sd-angular-core-input-number.js +3 -3
- package/fesm2015/sd-angular-core-input-number.js.map +1 -1
- package/package.json +1 -1
- package/{sd-angular-core-1.2.85.tgz → sd-angular-core-1.2.88.tgz} +0 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('ngx-quill'), require('@angular/forms'), require('uuid'), require('rxjs'), require('@sd-angular/core/api'), require('quill-mention'), require('@sd-angular/core/common'), require('@angular/common'), require('@sd-angular/core/translate'), require('@sd-angular/core/button'), require('@sd-angular/core/textarea')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@sd-angular/core/editor', ['exports', '@angular/core', 'ngx-quill', '@angular/forms', 'uuid', 'rxjs', '@sd-angular/core/api', 'quill-mention', '@sd-angular/core/common', '@angular/common', '@sd-angular/core/translate', '@sd-angular/core/button', '@sd-angular/core/textarea'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global['sd-angular'] = global['sd-angular'] || {}, global['sd-angular'].core = global['sd-angular'].core || {}, global['sd-angular'].core.editor = {}), global.ng.core, global['ngx-quill'], global.ng.forms, global.uuid, global.rxjs, global['sd-angular'].core.api, null, global['sd-angular'].core.common, global.ng.common, global['sd-angular'].core.translate, global['sd-angular'].core.button, global['sd-angular'].core.textarea));
|
|
5
|
-
}(this, (function (exports, core, ngxQuill, forms, uuid, rxjs, api, quillMention, common, common$1, translate, button, textarea) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('ngx-quill'), require('@angular/forms'), require('uuid'), require('rxjs'), require('@sd-angular/core/api'), require('quill-mention'), require('@sd-angular/core/common'), require('@sd-angular/core/loading'), require('@angular/common'), require('@sd-angular/core/translate'), require('@sd-angular/core/button'), require('@sd-angular/core/textarea')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@sd-angular/core/editor', ['exports', '@angular/core', 'ngx-quill', '@angular/forms', 'uuid', 'rxjs', '@sd-angular/core/api', 'quill-mention', '@sd-angular/core/common', '@sd-angular/core/loading', '@angular/common', '@sd-angular/core/translate', '@sd-angular/core/button', '@sd-angular/core/textarea'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global['sd-angular'] = global['sd-angular'] || {}, global['sd-angular'].core = global['sd-angular'].core || {}, global['sd-angular'].core.editor = {}), global.ng.core, global['ngx-quill'], global.ng.forms, global.uuid, global.rxjs, global['sd-angular'].core.api, null, global['sd-angular'].core.common, global['sd-angular'].core.loading, global.ng.common, global['sd-angular'].core.translate, global['sd-angular'].core.button, global['sd-angular'].core.textarea));
|
|
5
|
+
}(this, (function (exports, core, ngxQuill, forms, uuid, rxjs, api, quillMention, common, loading, common$1, translate, button, textarea) { 'use strict';
|
|
6
|
+
|
|
7
|
+
var EDITOR_CONFIG = new core.InjectionToken('editor.configuration');
|
|
6
8
|
|
|
7
9
|
/*! *****************************************************************************
|
|
8
10
|
Copyright (c) Microsoft Corporation.
|
|
@@ -427,13 +429,15 @@
|
|
|
427
429
|
}
|
|
428
430
|
};
|
|
429
431
|
|
|
430
|
-
var _name, _subscription, _model, _form, _updateValidator,
|
|
432
|
+
var _name, _subscription, _model, _form, _updateValidator, _initUploadImage;
|
|
431
433
|
var SdEditor = /** @class */ (function () {
|
|
432
|
-
function SdEditor(ngZone, ref, sdApiService) {
|
|
434
|
+
function SdEditor(ngZone, ref, sdApiService, loadingService, configuration) {
|
|
433
435
|
var _this = this;
|
|
434
436
|
this.ngZone = ngZone;
|
|
435
437
|
this.ref = ref;
|
|
436
438
|
this.sdApiService = sdApiService;
|
|
439
|
+
this.loadingService = loadingService;
|
|
440
|
+
this.configuration = configuration;
|
|
437
441
|
_name.set(this, "N" + uuid.v4());
|
|
438
442
|
this.id = "I" + uuid.v4();
|
|
439
443
|
_subscription.set(this, new rxjs.Subscription());
|
|
@@ -510,8 +514,9 @@
|
|
|
510
514
|
}
|
|
511
515
|
}
|
|
512
516
|
};
|
|
513
|
-
this.
|
|
517
|
+
this.customButtonFileSVG = '<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/><path d="M20.41,8.41l-4.83-4.83C15.21,3.21,14.7,3,14.17,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V9.83 C21,9.3,20.79,8.79,20.41,8.41z M7,7h7v2H7V7z M17,17H7v-2h10V17z M17,13H7v-2h10V13z"/></g></svg>';
|
|
514
518
|
this.sdChange = new core.EventEmitter();
|
|
519
|
+
this.timerLoadQuillToolbar = null;
|
|
515
520
|
_updateValidator.set(this, function () {
|
|
516
521
|
_this.formControl.clearValidators();
|
|
517
522
|
_this.formControl.clearAsyncValidators();
|
|
@@ -549,6 +554,35 @@
|
|
|
549
554
|
// // }
|
|
550
555
|
// // this.formControl.setValue(html);
|
|
551
556
|
// });
|
|
557
|
+
var self = _this;
|
|
558
|
+
__classPrivateFieldGet(_this, _initUploadImage).call(_this, quill);
|
|
559
|
+
// this.ngZone.runOutsideAngular(() => {
|
|
560
|
+
// quill.getModule('toolbar').addHandler('image', function () {
|
|
561
|
+
// let fileInput = this.container.querySelector('input.ql-image[type=file]');
|
|
562
|
+
// if (fileInput == null) {
|
|
563
|
+
// fileInput = document.createElement('input');
|
|
564
|
+
// fileInput.setAttribute('type', Constants.FILE);
|
|
565
|
+
// fileInput.setAttribute('accept', 'image/png, image/gif, image/jpeg, image/bmp, image/x-icon');
|
|
566
|
+
// fileInput.classList.add('ql-image');
|
|
567
|
+
// fileInput.addEventListener('change', () => {
|
|
568
|
+
// const files = fileInput.files;
|
|
569
|
+
// const range = this.quill.getSelection(true);
|
|
570
|
+
// if (!files || !files.length) {
|
|
571
|
+
// return;
|
|
572
|
+
// }
|
|
573
|
+
// const formData = new FormData();
|
|
574
|
+
// formData.append(Constants.FILE, files[0]);
|
|
575
|
+
// this.quill.enable(false);
|
|
576
|
+
// self.#uploadImage(formData, quill, range, fileInput);
|
|
577
|
+
// });
|
|
578
|
+
// this.container.appendChild(fileInput);
|
|
579
|
+
// }
|
|
580
|
+
// fileInput.click();
|
|
581
|
+
// });
|
|
582
|
+
// });
|
|
583
|
+
_this.ref.markForCheck();
|
|
584
|
+
};
|
|
585
|
+
_initUploadImage.set(this, function (quill) {
|
|
552
586
|
var self = _this;
|
|
553
587
|
_this.ngZone.runOutsideAngular(function () {
|
|
554
588
|
quill.getModule('toolbar').addHandler('image', function () {
|
|
@@ -560,6 +594,7 @@
|
|
|
560
594
|
fileInput.setAttribute('accept', 'image/png, image/gif, image/jpeg, image/bmp, image/x-icon');
|
|
561
595
|
fileInput.classList.add('ql-image');
|
|
562
596
|
fileInput.addEventListener('change', function () {
|
|
597
|
+
var _a;
|
|
563
598
|
var files = fileInput.files;
|
|
564
599
|
var range = _this.quill.getSelection(true);
|
|
565
600
|
if (!files || !files.length) {
|
|
@@ -568,23 +603,27 @@
|
|
|
568
603
|
var formData = new FormData();
|
|
569
604
|
formData.append(Constants.FILE, files[0]);
|
|
570
605
|
_this.quill.enable(false);
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
606
|
+
// self.#uploadImage(formData, quill, range, fileInput);
|
|
607
|
+
(_a = self.configuration) === null || _a === void 0 ? void 0 : _a.uploadImage(formData, self.args).then(function (url) {
|
|
608
|
+
self.ngZone.runOutsideAngular(function () {
|
|
609
|
+
quill.enable(true);
|
|
610
|
+
// quill.editor.insertEmbed(range.index, 'image', resp?.data?.imageUrl || resp?.data?.publish_url || resp?.url || '');
|
|
611
|
+
quill.getModule('clipboard').dangerouslyPasteHTML(range.index, '<a target="_blank" href="' + (url || '')
|
|
612
|
+
+ '"><img src="' + (url || '') + '" alt="c-image-editor-quill"></a>', 'user');
|
|
613
|
+
// quill.insertText();
|
|
614
|
+
var content = quill.getContents();
|
|
615
|
+
quill.setContents(content);
|
|
616
|
+
quill.setSelection(range.index + 1, 'user');
|
|
617
|
+
fileInput.value = '';
|
|
618
|
+
});
|
|
619
|
+
});
|
|
580
620
|
});
|
|
581
621
|
this.container.appendChild(fileInput);
|
|
582
622
|
}
|
|
583
623
|
fileInput.click();
|
|
584
624
|
});
|
|
585
625
|
});
|
|
586
|
-
|
|
587
|
-
};
|
|
626
|
+
});
|
|
588
627
|
this.onModelChange = function (val) {
|
|
589
628
|
_this.formControl.setValue(val);
|
|
590
629
|
_this.modelHTML = val;
|
|
@@ -594,27 +633,6 @@
|
|
|
594
633
|
_this.showHtmlEditor = !_this.showHtmlEditor;
|
|
595
634
|
_this.ref.markForCheck();
|
|
596
635
|
};
|
|
597
|
-
_uploadImage.set(this, function (formData, quill, range, fileInput) {
|
|
598
|
-
if (!_this.urlUploadImage) {
|
|
599
|
-
_this.urlUploadImage = '/partner/v2/merchandise/file/uploaduserfile';
|
|
600
|
-
}
|
|
601
|
-
// this.domain = 'https://api-commerce-qc.vinid.dev';
|
|
602
|
-
_this.sdApiService.post(_this.urlUploadImage, formData).then(function (resp) {
|
|
603
|
-
_this.ngZone.runOutsideAngular(function () {
|
|
604
|
-
var _a, _b, _c, _d;
|
|
605
|
-
quill.enable(true);
|
|
606
|
-
// quill.editor.insertEmbed(range.index, 'image', resp?.data?.imageUrl || resp?.data?.publish_url || resp?.url || '');
|
|
607
|
-
quill.getModule('clipboard').dangerouslyPasteHTML(range.index, '<a target="_blank" href="' + (((_a = resp === null || resp === void 0 ? void 0 : resp.data) === null || _a === void 0 ? void 0 : _a.imageUrl) || ((_b = resp === null || resp === void 0 ? void 0 : resp.data) === null || _b === void 0 ? void 0 : _b.publish_url) || (resp === null || resp === void 0 ? void 0 : resp.url) || '')
|
|
608
|
-
+ '"><img src="' + (((_c = resp === null || resp === void 0 ? void 0 : resp.data) === null || _c === void 0 ? void 0 : _c.imageUrl) || ((_d = resp === null || resp === void 0 ? void 0 : resp.data) === null || _d === void 0 ? void 0 : _d.publish_url) || (resp === null || resp === void 0 ? void 0 : resp.url) || '') + '" alt="c-image-editor-quill"></a>', 'user');
|
|
609
|
-
// quill.insertText();
|
|
610
|
-
var content = quill.getContents();
|
|
611
|
-
quill.setContents(content);
|
|
612
|
-
quill.setSelection(range.index + 1, 'user');
|
|
613
|
-
fileInput.value = '';
|
|
614
|
-
});
|
|
615
|
-
});
|
|
616
|
-
_this.ref.markForCheck();
|
|
617
|
-
});
|
|
618
636
|
}
|
|
619
637
|
Object.defineProperty(SdEditor.prototype, "model", {
|
|
620
638
|
set: function (val) {
|
|
@@ -680,14 +698,92 @@
|
|
|
680
698
|
configurable: true
|
|
681
699
|
});
|
|
682
700
|
SdEditor.prototype.ngOnInit = function () {
|
|
683
|
-
var
|
|
701
|
+
var e_1, _c;
|
|
702
|
+
var _this = this;
|
|
703
|
+
var _a, _b;
|
|
684
704
|
(_a = __classPrivateFieldGet(this, _form)) === null || _a === void 0 ? void 0 : _a.addControl(__classPrivateFieldGet(this, _name), this.formControl);
|
|
685
705
|
if (this.toolbar) {
|
|
686
706
|
this.quillConfig.toolbar.container = this.toolbar;
|
|
687
|
-
console.log('toolbar', this.quillConfig);
|
|
688
707
|
}
|
|
708
|
+
var _loop_1 = function (action) {
|
|
709
|
+
if (this_1.quillConfig.toolbar.container.toString().includes(action.key)) {
|
|
710
|
+
var qlKey_1 = "button.ql-" + action.key;
|
|
711
|
+
var interval_1 = setInterval(function () {
|
|
712
|
+
if (document.querySelector(qlKey_1)) {
|
|
713
|
+
clearInterval(interval_1);
|
|
714
|
+
document.querySelector(qlKey_1).innerHTML = _this.customButtonFileSVG;
|
|
715
|
+
var customButton = document.querySelector(qlKey_1);
|
|
716
|
+
if (customButton.getAttribute('listener') !== '1') {
|
|
717
|
+
customButton.setAttribute('listener', '1');
|
|
718
|
+
customButton.addEventListener('click', function (e) {
|
|
719
|
+
var cursorPosition = localStorage.getItem('quillRange');
|
|
720
|
+
action.click(e, {
|
|
721
|
+
cursorPosition: JSON.parse(cursorPosition),
|
|
722
|
+
args: _this.args
|
|
723
|
+
});
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
}, 1000);
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
var this_1 = this;
|
|
731
|
+
try {
|
|
732
|
+
for (var _d = __values((((_b = this.configuration) === null || _b === void 0 ? void 0 : _b.actions) || [])), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
733
|
+
var action = _e.value;
|
|
734
|
+
_loop_1(action);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
738
|
+
finally {
|
|
739
|
+
try {
|
|
740
|
+
if (_e && !_e.done && (_c = _d.return)) _c.call(_d);
|
|
741
|
+
}
|
|
742
|
+
finally { if (e_1) throw e_1.error; }
|
|
743
|
+
}
|
|
744
|
+
// if (this.quillConfig.toolbar.container.toString().includes('customFile')) {
|
|
745
|
+
// this.timerLoadQuillToolbar = setInterval(() => {
|
|
746
|
+
// if (document.querySelector('button.ql-customFile')) {
|
|
747
|
+
// clearInterval(this.timerLoadQuillToolbar);
|
|
748
|
+
// document.querySelector('button.ql-customFile').innerHTML = this.customButtonFileSVG;
|
|
749
|
+
// const customButton = document.querySelector('button.ql-customFile');
|
|
750
|
+
// if (customButton.getAttribute('listener') !== '1') {
|
|
751
|
+
// customButton.setAttribute('listener', '1');
|
|
752
|
+
// customButton.addEventListener('click', this.customFileHandler);
|
|
753
|
+
// }
|
|
754
|
+
// }
|
|
755
|
+
// }, 1000);
|
|
756
|
+
// }
|
|
689
757
|
this.ref.markForCheck();
|
|
690
758
|
};
|
|
759
|
+
// customFileHandler = (e) => {
|
|
760
|
+
// const customButton = e.currentTarget;
|
|
761
|
+
// const quillToolbar = customButton.closest('.ql-formats').closest('.ql-toolbar');
|
|
762
|
+
// const quillBox = quillToolbar.closest('.ql-formats')
|
|
763
|
+
// let fileInput: HTMLInputElement = quillToolbar.querySelector('input.ql-customFile[type=file]');
|
|
764
|
+
// if (fileInput == null) {
|
|
765
|
+
// fileInput = document.createElement('input');
|
|
766
|
+
// fileInput.setAttribute('type', Constants.FILE);
|
|
767
|
+
// fileInput.setAttribute('accept', '*');
|
|
768
|
+
// fileInput.classList.add('ql-customFile');
|
|
769
|
+
// fileInput.addEventListener('change', () => {
|
|
770
|
+
// const files = fileInput.files;
|
|
771
|
+
// if (!files || !files.length) {
|
|
772
|
+
// return;
|
|
773
|
+
// }
|
|
774
|
+
// const formData = new FormData();
|
|
775
|
+
// formData.append(Constants.FILE, files[0]);
|
|
776
|
+
// let range = localStorage.getItem('quillRange');
|
|
777
|
+
// if (range) {
|
|
778
|
+
// range = JSON.parse(range);
|
|
779
|
+
// }
|
|
780
|
+
// this.quillEvent.enable(false);
|
|
781
|
+
// this.#uploadFile(formData, this.quillEvent, range, fileInput, quillToolbar.closest('quill-editor').id);
|
|
782
|
+
// });
|
|
783
|
+
// quillToolbar.appendChild(fileInput);
|
|
784
|
+
// }
|
|
785
|
+
// fileInput.click();
|
|
786
|
+
// }
|
|
691
787
|
SdEditor.prototype.ngAfterViewInit = function () {
|
|
692
788
|
var _this = this;
|
|
693
789
|
__classPrivateFieldGet(this, _subscription).add(this.formControl.valueChanges.subscribe(function (val) {
|
|
@@ -700,21 +796,77 @@
|
|
|
700
796
|
(_a = __classPrivateFieldGet(this, _form)) === null || _a === void 0 ? void 0 : _a.removeControl(__classPrivateFieldGet(this, _name));
|
|
701
797
|
__classPrivateFieldGet(this, _subscription).unsubscribe();
|
|
702
798
|
};
|
|
799
|
+
// #uploadImage = (formData, quill, range, fileInput) => {
|
|
800
|
+
// if (!this.urlUploadImage) {
|
|
801
|
+
// this.urlUploadImage = '/partner/v2/merchandise/file/uploaduserfile';
|
|
802
|
+
// }
|
|
803
|
+
// // this.domain = 'https://api-commerce-qc.vinid.dev';
|
|
804
|
+
// this.sdApiService.post(this.urlUploadImage, formData).then((resp: any) => {
|
|
805
|
+
// this.ngZone.runOutsideAngular(() => {
|
|
806
|
+
// quill.enable(true);
|
|
807
|
+
// // quill.editor.insertEmbed(range.index, 'image', resp?.data?.imageUrl || resp?.data?.publish_url || resp?.url || '');
|
|
808
|
+
// quill.getModule('clipboard').dangerouslyPasteHTML(range.index, '<a target="_blank" href="' + (resp?.data?.imageUrl || resp?.data?.publish_url || resp?.url || '')
|
|
809
|
+
// + '"><img src="' + (resp?.data?.imageUrl || resp?.data?.publish_url || resp?.url || '') + '" alt="c-image-editor-quill"></a>', 'user');
|
|
810
|
+
// // quill.insertText();
|
|
811
|
+
// const content = quill.getContents();
|
|
812
|
+
// quill.setContents(content);
|
|
813
|
+
// quill.setSelection(range.index + 1, 'user');
|
|
814
|
+
// fileInput.value = '';
|
|
815
|
+
// });
|
|
816
|
+
// });
|
|
817
|
+
// this.ref.markForCheck();
|
|
818
|
+
// }
|
|
819
|
+
// #uploadFile = (formData, quill, range, fileInput, loadingID) => {
|
|
820
|
+
// if (!this.urlUploadFile) {
|
|
821
|
+
// this.urlUploadFile = '/partner/v2/merchandise/file/uploaduserfile';
|
|
822
|
+
// }
|
|
823
|
+
// // this.domain = 'https://api-commerce-qc.vinid.dev';
|
|
824
|
+
// this.loadingService.start('#box-' + loadingID);
|
|
825
|
+
// this.sdApiService.post(this.urlUploadFile, formData).then((resp: any) => {
|
|
826
|
+
// this.ngZone.runOutsideAngular(() => {
|
|
827
|
+
// quill.enable(true);
|
|
828
|
+
// // quill.editor.insertEmbed(range.index, 'image', resp?.data?.imageUrl || resp?.data?.publish_url || resp?.url || '');
|
|
829
|
+
// quill.getModule('clipboard').dangerouslyPasteHTML(range.index, '<a target="_blank" href="' + (resp?.data?.imageUrl || resp?.data?.publish_url || resp?.url || '')
|
|
830
|
+
// + '">' + (resp?.data?.imageUrl || resp?.data?.publish_url || resp?.url || '') + '</a>', 'user');
|
|
831
|
+
// // quill.insertText();
|
|
832
|
+
// const content = quill.getContents();
|
|
833
|
+
// quill.setContents(content);
|
|
834
|
+
// quill.setSelection(range.index + 1, 'user');
|
|
835
|
+
// fileInput.value = '';
|
|
836
|
+
// });
|
|
837
|
+
// this.loadingService.stop('#box-' + loadingID);
|
|
838
|
+
// }).catch((er) => {
|
|
839
|
+
// this.loadingService.stop('#box-' + loadingID);
|
|
840
|
+
// });
|
|
841
|
+
// this.ref.markForCheck();
|
|
842
|
+
// }
|
|
843
|
+
SdEditor.prototype.onSelectionChanged = function (e) {
|
|
844
|
+
// localStorage.setItem('quillRange', e.range ? JSON.stringify(e.range) : (e.oldRange ? JSON.stringify(e.oldRange) : null));
|
|
845
|
+
localStorage.setItem('quillRange', e.editor.getSelection() ? JSON.stringify(e.editor.getSelection()) : null);
|
|
846
|
+
};
|
|
847
|
+
SdEditor.prototype.onContentChanged = function (e) {
|
|
848
|
+
localStorage.setItem('quillRange', JSON.stringify({
|
|
849
|
+
index: (e.editor.getLength() ? e.editor.getLength() - 1 : 0),
|
|
850
|
+
length: 0
|
|
851
|
+
}));
|
|
852
|
+
};
|
|
703
853
|
return SdEditor;
|
|
704
854
|
}());
|
|
705
|
-
_name = new WeakMap(), _subscription = new WeakMap(), _model = new WeakMap(), _form = new WeakMap(), _updateValidator = new WeakMap(),
|
|
855
|
+
_name = new WeakMap(), _subscription = new WeakMap(), _model = new WeakMap(), _form = new WeakMap(), _updateValidator = new WeakMap(), _initUploadImage = new WeakMap();
|
|
706
856
|
SdEditor.decorators = [
|
|
707
857
|
{ type: core.Component, args: [{
|
|
708
858
|
selector: 'sd-editor',
|
|
709
|
-
template: "<label *ngIf=\"label && !sdLabelDef?.templateRef\" class=\"d-block T14M\">{{label}} <span class=\"text-danger mb-2\"
|
|
859
|
+
template: "<div id=\"box-{{id}}\">\r\n <label *ngIf=\"label && !sdLabelDef?.templateRef\" class=\"d-block T14M\">{{label}} <span class=\"text-danger mb-2\"\r\n *ngIf=\"required\">*</span></label>\r\n <ng-container *ngIf=\"sdLabelDef?.templateRef\" matSuffix>\r\n <ng-container *ngTemplateOutlet=\"sdLabelDef.templateRef\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!formControl.disabled && !showHtmlEditor\">\r\n <quill-editor #editor [styles]=\"styles\" (onEditorCreated)=\"editorInit($event)\" [ngModel]=\"formControl.value\"\r\n (onSelectionChanged)=\"onSelectionChanged($event)\"\r\n (onContentChanged)=\"onContentChanged($event)\"\r\n (ngModelChange)=\"onModelChange($event)\" [id]=\"id\" [modules]=\"quillConfig\" [placeholder]=\"placeholder\"\r\n [maxLength]=\"maxlength\">\r\n </quill-editor>\r\n <span class=\"d-block text-danger mt-5\" *ngIf=\"formControl.errors?.required\">\r\n {{'This field is required' | sdTranslate}}\r\n </span>\r\n <span class=\"d-block text-danger mt-5\" *ngIf=\"formControl.errors?.minlength\">\r\n {{'Max length' | sdTranslate}} <strong>{{minlength}}</strong>\r\n </span>\r\n <span class=\"d-block text-danger mt-5\" *ngIf=\"formControl.errors?.maxlength\">\r\n {{'Max length' | sdTranslate}} <strong>{{maxlength}}</strong>\r\n </span>\r\n </ng-container>\r\n <ng-container *ngIf=\"formControl.disabled\">\r\n <div [innerHtml]=\"formControl.value\"></div>\r\n </ng-container>\r\n <ng-container *ngIf=\"enableHTMLButton\">\r\n <sd-textarea [(model)]=\"modelHTML\" *ngIf=\"showHtmlEditor\" rows=\"20\"\r\n (modelChange)=\"onModelChange($event)\"></sd-textarea>\r\n <sd-button\r\n title=\"{{showHtmlEditor?'\u1EA8n':'Hi\u1EC7n'}} m\u00E3 HTML\"\r\n class=\"mr-8\"\r\n fontSet=\"material-icons-outlined\"\r\n (action)=\"onClickShowHtmlEditor()\"\r\n type=\"light\"\r\n ></sd-button>\r\n </ng-container>\r\n</div>\r\n",
|
|
710
860
|
changeDetection: core.ChangeDetectionStrategy.OnPush,
|
|
711
|
-
styles: ["::ng-deep img[alt=c-image-editor-quill]{max-width:80%}"]
|
|
861
|
+
styles: ["::ng-deep img[alt=c-image-editor-quill]{max-width:80%}::ng-deep .ql-toolbar input.ql-customFile[type=file]{display:none}"]
|
|
712
862
|
},] }
|
|
713
863
|
];
|
|
714
864
|
SdEditor.ctorParameters = function () { return [
|
|
715
865
|
{ type: core.NgZone },
|
|
716
866
|
{ type: core.ChangeDetectorRef },
|
|
717
|
-
{ type: api.SdApiService }
|
|
867
|
+
{ type: api.SdApiService },
|
|
868
|
+
{ type: loading.SdLoadingService },
|
|
869
|
+
{ type: undefined, decorators: [{ type: core.Inject, args: [EDITOR_CONFIG,] }, { type: core.Optional }] }
|
|
718
870
|
]; };
|
|
719
871
|
SdEditor.propDecorators = {
|
|
720
872
|
editor: [{ type: core.ViewChild, args: ['editor',] }],
|
|
@@ -727,8 +879,8 @@
|
|
|
727
879
|
modelChange: [{ type: core.Output }],
|
|
728
880
|
placeholder: [{ type: core.Input }],
|
|
729
881
|
styles: [{ type: core.Input }],
|
|
882
|
+
args: [{ type: core.Input }],
|
|
730
883
|
domain: [{ type: core.Input }],
|
|
731
|
-
urlUploadImage: [{ type: core.Input }],
|
|
732
884
|
form: [{ type: core.Input }],
|
|
733
885
|
toolbar: [{ type: core.Input }],
|
|
734
886
|
enableHTMLButton: [{ type: core.Input }],
|
|
@@ -770,6 +922,7 @@
|
|
|
770
922
|
*/
|
|
771
923
|
|
|
772
924
|
exports.Constants = Constants;
|
|
925
|
+
exports.EDITOR_CONFIG = EDITOR_CONFIG;
|
|
773
926
|
exports.PROMOTION_FORM = PROMOTION_FORM;
|
|
774
927
|
exports.PROMOTION_PERMISSIONS = PROMOTION_PERMISSIONS;
|
|
775
928
|
exports.SdEditor = SdEditor;
|