@lucca-front/ng 21.1.2 → 21.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/lucca-front-ng-callout.mjs +2 -2
- package/fesm2022/lucca-front-ng-callout.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-core-select.mjs +5 -2
- package/fesm2022/lucca-front-ng-core-select.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-date2.mjs +2 -2
- package/fesm2022/lucca-front-ng-date2.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-dialog.mjs +1 -1
- package/fesm2022/lucca-front-ng-dialog.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-form-field.mjs +4 -4
- package/fesm2022/lucca-front-ng-form-field.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-forms-phone-number-input.mjs +2 -2
- package/fesm2022/lucca-front-ng-forms-phone-number-input.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-forms-rich-text-input.mjs +163 -64
- package/fesm2022/lucca-front-ng-forms-rich-text-input.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-forms.mjs +14 -14
- package/fesm2022/lucca-front-ng-forms.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-highlight-data.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-multi-select.mjs +20 -10
- package/fesm2022/lucca-front-ng-multi-select.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-resource-card.mjs +2 -2
- package/fesm2022/lucca-front-ng-resource-card.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-simple-select.mjs +5 -4
- package/fesm2022/lucca-front-ng-simple-select.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-skeleton.mjs +4 -4
- package/fesm2022/lucca-front-ng-skeleton.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-toast.mjs +2 -2
- package/fesm2022/lucca-front-ng-toast.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-tooltip.mjs +129 -162
- package/fesm2022/lucca-front-ng-tooltip.mjs.map +1 -1
- package/package.json +14 -14
- package/schematics/lib/component-mapper.js +1 -1
- package/schematics/lib/css-mapper.js +1 -1
- package/schematics/lu-button/index.js +1 -1
- package/schematics/lu-container/index.js +1 -1
- package/schematics/lu-icon/index.js +1 -1
- package/schematics/lu-loading/index.js +1 -1
- package/schematics/lu-select/index.js +1 -1
- package/schematics/lu-text-input/index.js +1 -1
- package/schematics/new-icons/index.js +1 -1
- package/src/components/cdk/_global.scss +8 -8
- package/types/lucca-front-ng-forms-rich-text-input.d.ts +69 -14
- package/types/lucca-front-ng-tooltip.d.ts +9 -17
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, inject, input, booleanAttribute, viewChild, ElementRef, contentChildren, signal, computed,
|
|
2
|
+
import { InjectionToken, inject, input, booleanAttribute, viewChild, ElementRef, contentChildren, signal, computed, effect, forwardRef, ChangeDetectionStrategy, ViewEncapsulation, Component, DestroyRef, ViewContainerRef, TemplateRef, viewChildren } from '@angular/core';
|
|
3
3
|
import { ButtonComponent } from '@lucca-front/ng/button';
|
|
4
4
|
import { intlInputOptions } from '@lucca-front/ng/core';
|
|
5
5
|
import { IconComponent } from '@lucca-front/ng/icon';
|
|
@@ -80,7 +80,7 @@ class RichTextInputComponent {
|
|
|
80
80
|
this.#isTouched = signal(false, ...(ngDevMode ? [{ debugName: "#isTouched" }] : []));
|
|
81
81
|
this.#focusedPlugin = 0;
|
|
82
82
|
this.#isRootElementInitialized = false;
|
|
83
|
-
|
|
83
|
+
effect(() => {
|
|
84
84
|
if (this.#formField?.presentation() && this.contentPresentation()) {
|
|
85
85
|
this.#editor?.setRootElement(this.contentPresentation()?.nativeElement ?? null);
|
|
86
86
|
this.#editor?.setEditable(false);
|
|
@@ -690,83 +690,169 @@ function registerLinkSelectionChange(editor, onselectionchange) {
|
|
|
690
690
|
}, COMMAND_PRIORITY_NORMAL);
|
|
691
691
|
}
|
|
692
692
|
|
|
693
|
-
class
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
693
|
+
class PopoverLinkNode extends LinkNode {
|
|
694
|
+
#viewContainerRef;
|
|
695
|
+
#templateRef;
|
|
696
|
+
#view;
|
|
697
|
+
setViewContainerRef(vcr) {
|
|
698
|
+
const self = this.getWritable();
|
|
699
|
+
self.#viewContainerRef = vcr;
|
|
700
|
+
return self;
|
|
701
|
+
}
|
|
702
|
+
getViewContainerRef() {
|
|
703
|
+
return this.#viewContainerRef;
|
|
704
|
+
}
|
|
705
|
+
setTemplateRef(vcr) {
|
|
706
|
+
const self = this.getWritable();
|
|
707
|
+
self.#templateRef = vcr;
|
|
708
|
+
return self;
|
|
698
709
|
}
|
|
699
|
-
|
|
700
|
-
|
|
710
|
+
getTemplateRef() {
|
|
711
|
+
return this.#templateRef;
|
|
701
712
|
}
|
|
702
713
|
static getType() {
|
|
703
|
-
return '
|
|
714
|
+
return 'popoverlink';
|
|
704
715
|
}
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
716
|
+
constructor(url, attributes, key) {
|
|
717
|
+
super(url, attributes, key);
|
|
718
|
+
this.#viewContainerRef = attributes?.viewContainerRef;
|
|
719
|
+
this.#templateRef = attributes?.templateRef;
|
|
720
|
+
}
|
|
721
|
+
createDOM(config) {
|
|
722
|
+
if (this.#viewContainerRef && this.#templateRef) {
|
|
723
|
+
const context = {
|
|
709
724
|
href: this.sanitizeUrl(this.__url),
|
|
710
725
|
title: this.__title,
|
|
711
726
|
target: this.__target,
|
|
712
|
-
|
|
727
|
+
key: this.__key,
|
|
728
|
+
};
|
|
729
|
+
if (this.#view) {
|
|
730
|
+
this.#view.context = context;
|
|
731
|
+
this.#view.markForCheck();
|
|
732
|
+
}
|
|
733
|
+
else {
|
|
734
|
+
// Create the view
|
|
735
|
+
this.#view = this.#viewContainerRef.createEmbeddedView(this.#templateRef, context);
|
|
736
|
+
}
|
|
713
737
|
// Return the template DOM element
|
|
714
|
-
return view.rootNodes[0];
|
|
738
|
+
return this.#view.rootNodes[0];
|
|
715
739
|
}
|
|
716
|
-
|
|
740
|
+
return super.createDOM(config);
|
|
741
|
+
}
|
|
742
|
+
updateDOM(prevNode) {
|
|
743
|
+
return (prevNode.getURL() !== this.getURL() ||
|
|
744
|
+
prevNode.getTarget() !== this.getTarget() ||
|
|
745
|
+
prevNode.getRel() !== this.getRel() ||
|
|
746
|
+
prevNode.getTitle() !== this.getTitle() ||
|
|
747
|
+
this.#templateRef !== prevNode.#templateRef ||
|
|
748
|
+
this.#viewContainerRef !== prevNode.#viewContainerRef);
|
|
717
749
|
}
|
|
718
750
|
exportDOM(editor) {
|
|
719
751
|
return {
|
|
720
752
|
element: super.createDOM(editor._config),
|
|
721
753
|
};
|
|
722
754
|
}
|
|
755
|
+
remove(preserveEmptyParent) {
|
|
756
|
+
super.remove(preserveEmptyParent);
|
|
757
|
+
this.#view?.destroy();
|
|
758
|
+
}
|
|
759
|
+
static importJSON(serializedNode) {
|
|
760
|
+
return $createPopoverLinkNode().updateFromJSON(serializedNode);
|
|
761
|
+
}
|
|
723
762
|
static clone(node) {
|
|
724
|
-
return new
|
|
763
|
+
return new PopoverLinkNode(node.__url, { target: node.__target, rel: node.__rel, title: node.__title, templateRef: node.#templateRef, viewContainerRef: node.#viewContainerRef }, node.__key);
|
|
725
764
|
}
|
|
726
765
|
}
|
|
766
|
+
function $createPopoverLinkNode(url, attributes, key) {
|
|
767
|
+
return new PopoverLinkNode(url, attributes, key);
|
|
768
|
+
}
|
|
769
|
+
function $isPopoverLinkNode$1(node) {
|
|
770
|
+
return node instanceof PopoverLinkNode;
|
|
771
|
+
}
|
|
727
772
|
|
|
728
|
-
class
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
773
|
+
class PopoverAutoLinkNode extends AutoLinkNode {
|
|
774
|
+
#viewContainerRef;
|
|
775
|
+
#templateRef;
|
|
776
|
+
#view;
|
|
777
|
+
setViewContainerRef(vcr) {
|
|
778
|
+
const self = this.getWritable();
|
|
779
|
+
self.#viewContainerRef = vcr;
|
|
780
|
+
return self;
|
|
733
781
|
}
|
|
734
|
-
|
|
735
|
-
|
|
782
|
+
getViewContainerRef() {
|
|
783
|
+
return this.#viewContainerRef;
|
|
784
|
+
}
|
|
785
|
+
setTemplateRef(vcr) {
|
|
786
|
+
const self = this.getWritable();
|
|
787
|
+
self.#templateRef = vcr;
|
|
788
|
+
return self;
|
|
789
|
+
}
|
|
790
|
+
getTemplateRef() {
|
|
791
|
+
return this.#templateRef;
|
|
736
792
|
}
|
|
737
793
|
static getType() {
|
|
738
|
-
return '
|
|
794
|
+
return 'popoverautolink';
|
|
739
795
|
}
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
796
|
+
constructor(url, attributes, key) {
|
|
797
|
+
super(url, attributes, key);
|
|
798
|
+
this.#viewContainerRef = attributes?.viewContainerRef;
|
|
799
|
+
this.#templateRef = attributes?.templateRef;
|
|
800
|
+
}
|
|
801
|
+
createDOM(config) {
|
|
802
|
+
if (this.#viewContainerRef && this.#templateRef) {
|
|
803
|
+
const context = {
|
|
744
804
|
href: this.sanitizeUrl(this.__url),
|
|
745
805
|
title: this.__title,
|
|
746
806
|
target: this.__target,
|
|
747
|
-
|
|
807
|
+
key: this.__key,
|
|
808
|
+
};
|
|
809
|
+
if (this.#view) {
|
|
810
|
+
this.#view.context = context;
|
|
811
|
+
this.#view.markForCheck();
|
|
812
|
+
}
|
|
813
|
+
else {
|
|
814
|
+
// Create the view
|
|
815
|
+
this.#view = this.#viewContainerRef.createEmbeddedView(this.#templateRef, context);
|
|
816
|
+
}
|
|
748
817
|
// Return the template DOM element
|
|
749
|
-
return view.rootNodes[0];
|
|
818
|
+
return this.#view.rootNodes[0];
|
|
750
819
|
}
|
|
751
|
-
|
|
820
|
+
return super.createDOM(config);
|
|
821
|
+
}
|
|
822
|
+
updateDOM(prevNode) {
|
|
823
|
+
return (prevNode.getURL() !== this.getURL() ||
|
|
824
|
+
prevNode.getTarget() !== this.getTarget() ||
|
|
825
|
+
prevNode.getRel() !== this.getRel() ||
|
|
826
|
+
prevNode.getTitle() !== this.getTitle() ||
|
|
827
|
+
this.#templateRef !== prevNode.#templateRef ||
|
|
828
|
+
this.#viewContainerRef !== prevNode.#viewContainerRef);
|
|
752
829
|
}
|
|
753
830
|
exportDOM(editor) {
|
|
754
831
|
return {
|
|
755
832
|
element: super.createDOM(editor._config),
|
|
756
833
|
};
|
|
757
834
|
}
|
|
835
|
+
remove(preserveEmptyParent) {
|
|
836
|
+
super.remove(preserveEmptyParent);
|
|
837
|
+
this.#view?.destroy();
|
|
838
|
+
}
|
|
839
|
+
static importJSON(serializedNode) {
|
|
840
|
+
return $createPopoverAutoLinkNode().updateFromJSON(serializedNode);
|
|
841
|
+
}
|
|
758
842
|
static clone(node) {
|
|
759
|
-
return
|
|
843
|
+
return $createPopoverAutoLinkNode(node.__url, { target: node.__target, rel: node.__rel, title: node.__title, templateRef: node.#templateRef, viewContainerRef: node.#viewContainerRef }, node.__key);
|
|
760
844
|
}
|
|
761
845
|
}
|
|
846
|
+
function $createPopoverAutoLinkNode(url, attributes, key) {
|
|
847
|
+
return new PopoverAutoLinkNode(url, attributes, key);
|
|
848
|
+
}
|
|
849
|
+
function $isPopoverLinkNode(node) {
|
|
850
|
+
return node instanceof PopoverAutoLinkNode;
|
|
851
|
+
}
|
|
762
852
|
|
|
763
|
-
const URL_REGEX = /https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_
|
|
853
|
+
const URL_REGEX = /https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_+.~#?!&/=;,[\]]*)/;
|
|
764
854
|
const EMAIL_REGEX = /(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
|
|
765
855
|
class LinkComponent {
|
|
766
|
-
#luDialogService;
|
|
767
|
-
#viewContainerRef;
|
|
768
|
-
#editor;
|
|
769
|
-
#registeredCommands;
|
|
770
856
|
constructor() {
|
|
771
857
|
this.#luDialogService = inject(LuDialogService);
|
|
772
858
|
this.#viewContainerRef = inject(ViewContainerRef);
|
|
@@ -777,18 +863,17 @@ class LinkComponent {
|
|
|
777
863
|
this.isDisabled = signal(false, ...(ngDevMode ? [{ debugName: "isDisabled" }] : []));
|
|
778
864
|
this.intl = input(...intlInputOptions(LU_RICH_TEXT_INPUT_TRANSLATIONS), ...(ngDevMode ? [{ debugName: "intl" }] : []));
|
|
779
865
|
this.#registeredCommands = () => { };
|
|
780
|
-
PopoverLinkNode.setViewContainerRef(this.#viewContainerRef);
|
|
781
|
-
PopoverAutoLinkNode.setViewContainerRef(this.#viewContainerRef);
|
|
782
|
-
}
|
|
783
|
-
ngAfterViewInit() {
|
|
784
|
-
PopoverLinkNode.setTemplateRef(this.linkNodeTemplate());
|
|
785
|
-
PopoverAutoLinkNode.setTemplateRef(this.linkNodeTemplate());
|
|
786
866
|
}
|
|
867
|
+
#luDialogService;
|
|
868
|
+
#viewContainerRef;
|
|
869
|
+
#editor;
|
|
870
|
+
#registeredCommands;
|
|
787
871
|
setEditorInstance(editor) {
|
|
788
872
|
this.#editor = editor;
|
|
789
873
|
this.#registeredCommands = mergeRegister(registerLink(editor), registerLinkSelectionChange(editor, (isLink) => this.active.set(isLink)), registerAutoLink(editor, {
|
|
790
874
|
matchers: [createLinkMatcherWithRegExp(URL_REGEX, (text) => (text.startsWith('http') ? text : `https://${text}`)), createLinkMatcherWithRegExp(EMAIL_REGEX, (text) => `mailto:${text}`)],
|
|
791
875
|
changeHandlers: [],
|
|
876
|
+
excludeParents: [],
|
|
792
877
|
}));
|
|
793
878
|
}
|
|
794
879
|
getLexicalNodes() {
|
|
@@ -797,19 +882,23 @@ class LinkComponent {
|
|
|
797
882
|
PopoverAutoLinkNode,
|
|
798
883
|
{
|
|
799
884
|
replace: LinkNode,
|
|
800
|
-
with: (node) =>
|
|
885
|
+
with: (node) => $createPopoverLinkNode(node.getURL(), {
|
|
801
886
|
rel: node.getRel(),
|
|
802
887
|
target: node.getTarget(),
|
|
803
888
|
title: node.getTitle(),
|
|
889
|
+
viewContainerRef: this.#viewContainerRef,
|
|
890
|
+
templateRef: this.linkNodeTemplate(),
|
|
804
891
|
}),
|
|
805
892
|
withKlass: PopoverLinkNode,
|
|
806
893
|
},
|
|
807
894
|
{
|
|
808
895
|
replace: AutoLinkNode,
|
|
809
|
-
with: (node) =>
|
|
896
|
+
with: (node) => $createPopoverAutoLinkNode(node.getURL(), {
|
|
810
897
|
rel: node.getRel(),
|
|
811
898
|
target: node.getTarget(),
|
|
812
899
|
title: node.getTitle(),
|
|
900
|
+
viewContainerRef: this.#viewContainerRef,
|
|
901
|
+
templateRef: this.linkNodeTemplate(),
|
|
813
902
|
}),
|
|
814
903
|
withKlass: PopoverAutoLinkNode,
|
|
815
904
|
},
|
|
@@ -840,8 +929,8 @@ class LinkComponent {
|
|
|
840
929
|
if (href && !href.startsWith('http')) {
|
|
841
930
|
newHref = `https://${href}`;
|
|
842
931
|
}
|
|
843
|
-
this.#editor
|
|
844
|
-
this.#editor
|
|
932
|
+
this.#editor?.dispatchCommand(FORMAT_LINK, newHref);
|
|
933
|
+
this.#editor?.dispatchCommand(SELECTION_CHANGE_COMMAND, undefined);
|
|
845
934
|
});
|
|
846
935
|
});
|
|
847
936
|
}
|
|
@@ -875,7 +964,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
875
964
|
useExisting: forwardRef(() => LinkComponent),
|
|
876
965
|
},
|
|
877
966
|
], template: "<button\n\t#element\n\tluButton=\"ghost\"\n\ttype=\"button\"\n\tsize=\"S\"\n\t(click)=\"dispatchCommand()\"\n\t[luTooltip]=\"intl().linksLabel\"\n\t[attr.aria-pressed]=\"active()\"\n\tluTooltipOnlyForDisplay\n\t[attr.tabindex]=\"tabindex()\"\n\t[disabled]=\"isDisabled()\"\n\tclass=\"richTextField-toolbar-button\"\n>\n\t<lu-icon icon=\"formatLink\" [alt]=\"intl().linksLabel\" />\n</button>\n\n<ng-template #linkNodeTemplate let-href=\"href\" let-title=\"title\" let-target=\"target\">\n\t<a [href]=\"href\" [title]=\"title\" [target]=\"target\" [luPopover2]=\"popover\" #trigger=\"luPopover2\"></a>\n\t<ng-template #popover>\n\t\t<div class=\"popover-contentOptional linkPopover\">\n\t\t\t<a [href]=\"href\" luLink external class=\"pr-u-ellipsis\">{{ href }}</a>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tluButton=\"ghost\"\n\t\t\t\tsize=\"XS\"\n\t\t\t\t(click)=\"trigger.close(); dispatchCommand()\"\n\t\t\t\t[luTooltip]=\"intl().linksLabel\"\n\t\t\t\tluTooltipOnlyForDisplay\n\t\t\t>\n\t\t\t\t<lu-icon icon=\"officePen\" [alt]=\"intl().linksLabel\" />\n\t\t\t</button>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tluButton=\"ghost\"\n\t\t\t\tsize=\"XS\"\n\t\t\t\t(click)=\"trigger.close(); deleteLink()\"\n\t\t\t\t[luTooltip]=\"intl().linksDelete\"\n\t\t\t\tluTooltipOnlyForDisplay\n\t\t\t>\n\t\t\t\t<lu-icon icon=\"trashDelete\" [alt]=\"intl().linksDelete\" />\n\t\t\t</button>\n\t\t</div>\n\t</ng-template>\n</ng-template>\n", styles: [".linkPopover{display:flex;justify-items:center;gap:var(--pr-t-spacings-50);max-width:20rem}\n"] }]
|
|
878
|
-
}],
|
|
967
|
+
}], propDecorators: { linkNodeTemplate: [{ type: i0.ViewChild, args: ['linkNodeTemplate', { ...{ read: TemplateRef }, isSignal: true }] }], element: [{ type: i0.ViewChild, args: ['element', { ...{ read: (ElementRef) }, isSignal: true }] }], intl: [{ type: i0.Input, args: [{ isSignal: true, alias: "intl", required: false }] }] } });
|
|
879
968
|
|
|
880
969
|
const FORMAT_LIST = createCommand('FORMAT_LIST');
|
|
881
970
|
function registerListsGlobal(editor) {
|
|
@@ -1008,15 +1097,21 @@ class TagNode extends DecoratorNode {
|
|
|
1008
1097
|
#disabled;
|
|
1009
1098
|
// Store the component reference on the node instance
|
|
1010
1099
|
#componentRef;
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1100
|
+
#viewContainerRef;
|
|
1101
|
+
setViewContainerRef(vcr) {
|
|
1102
|
+
const self = this.getWritable();
|
|
1103
|
+
self.#viewContainerRef = vcr;
|
|
1104
|
+
return self;
|
|
1105
|
+
}
|
|
1106
|
+
getViewContainerRef() {
|
|
1107
|
+
return this.#viewContainerRef;
|
|
1014
1108
|
}
|
|
1015
|
-
constructor(tagKey = '', tagDescription, disabled = false, key) {
|
|
1109
|
+
constructor(tagKey = '', viewContainerRef, tagDescription, disabled = false, key) {
|
|
1016
1110
|
super(key);
|
|
1017
1111
|
this.#tagKey = tagKey;
|
|
1018
1112
|
this.#tagDescription = tagDescription;
|
|
1019
1113
|
this.#disabled = disabled;
|
|
1114
|
+
this.#viewContainerRef = viewContainerRef;
|
|
1020
1115
|
}
|
|
1021
1116
|
isDisabled() {
|
|
1022
1117
|
return this.#disabled;
|
|
@@ -1046,7 +1141,7 @@ class TagNode extends DecoratorNode {
|
|
|
1046
1141
|
return 'tag';
|
|
1047
1142
|
}
|
|
1048
1143
|
static clone(node) {
|
|
1049
|
-
return new TagNode(node.#tagKey, node.#tagDescription, node.#disabled, node.__key);
|
|
1144
|
+
return new TagNode(node.#tagKey, node.#viewContainerRef, node.#tagDescription, node.#disabled, node.__key);
|
|
1050
1145
|
}
|
|
1051
1146
|
/**
|
|
1052
1147
|
* This method must be implemented but has no purpose outside of react
|
|
@@ -1055,15 +1150,17 @@ class TagNode extends DecoratorNode {
|
|
|
1055
1150
|
return this.getTextContent();
|
|
1056
1151
|
}
|
|
1057
1152
|
createDOM(_config, editor) {
|
|
1058
|
-
if (
|
|
1153
|
+
if (this.#viewContainerRef) {
|
|
1059
1154
|
if (!editor.isEditable()) {
|
|
1060
1155
|
this.#componentRef?.destroy();
|
|
1061
1156
|
const span = document.createElement('span');
|
|
1062
1157
|
span.textContent = this.#tagDescription ?? this.#tagKey;
|
|
1063
1158
|
return span;
|
|
1064
1159
|
}
|
|
1065
|
-
|
|
1066
|
-
|
|
1160
|
+
if (!this.#componentRef) {
|
|
1161
|
+
// Create the component
|
|
1162
|
+
this.#componentRef = this.#viewContainerRef.createComponent(ChipComponent);
|
|
1163
|
+
}
|
|
1067
1164
|
// Set inputs on the component instance
|
|
1068
1165
|
this.#componentRef.setInput('unkillable', false);
|
|
1069
1166
|
this.#componentRef.setInput('palette', 'product');
|
|
@@ -1083,10 +1180,12 @@ class TagNode extends DecoratorNode {
|
|
|
1083
1180
|
// Return the component's DOM element
|
|
1084
1181
|
return componentElement;
|
|
1085
1182
|
}
|
|
1086
|
-
|
|
1183
|
+
const element = document.createElement('span');
|
|
1184
|
+
element.textContent = this.getTextContent();
|
|
1185
|
+
return element;
|
|
1087
1186
|
}
|
|
1088
1187
|
updateDOM(prevNode, _dom, _config) {
|
|
1089
|
-
return this.#tagDescription !== prevNode.#tagDescription || this.#tagKey !== prevNode.#tagKey || this.#disabled !== prevNode.#disabled;
|
|
1188
|
+
return this.#tagDescription !== prevNode.#tagDescription || this.#tagKey !== prevNode.#tagKey || this.#disabled !== prevNode.#disabled || this.#viewContainerRef !== prevNode.#viewContainerRef;
|
|
1090
1189
|
}
|
|
1091
1190
|
remove(preserveEmptyParent) {
|
|
1092
1191
|
super.remove(preserveEmptyParent);
|
|
@@ -1154,8 +1253,8 @@ function domConversionFunction(domNode) {
|
|
|
1154
1253
|
priority: COMMAND_PRIORITY_NORMAL,
|
|
1155
1254
|
};
|
|
1156
1255
|
}
|
|
1157
|
-
function $createTagNode(key = '', description) {
|
|
1158
|
-
return new TagNode(key, description);
|
|
1256
|
+
function $createTagNode(key = '', viewContainerRef, description) {
|
|
1257
|
+
return new TagNode(key, viewContainerRef, description);
|
|
1159
1258
|
}
|
|
1160
1259
|
function $isTagNode(node) {
|
|
1161
1260
|
return node instanceof TagNode;
|
|
@@ -1176,7 +1275,6 @@ class RichTextPluginTagComponent {
|
|
|
1176
1275
|
this.editor = null;
|
|
1177
1276
|
this.#tagNodeKeys = signal(new Set(), ...(ngDevMode ? [{ debugName: "#tagNodeKeys" }] : []));
|
|
1178
1277
|
this.#registeredCommands = () => { };
|
|
1179
|
-
TagNode.setViewContainerRef(this.#viewContainerRef);
|
|
1180
1278
|
// Listen for new partial tag nodes and update their descriptions
|
|
1181
1279
|
effect(() => {
|
|
1182
1280
|
const tags = this.tags();
|
|
@@ -1191,6 +1289,7 @@ class RichTextPluginTagComponent {
|
|
|
1191
1289
|
}
|
|
1192
1290
|
const tag = tags.find((t) => t.key === tagNode.getTagKey());
|
|
1193
1291
|
if (tag) {
|
|
1292
|
+
tagNode.setViewContainerRef(this.#viewContainerRef);
|
|
1194
1293
|
tagNode.setTagDescription(tag.description ?? '').setDisabled(isDisabled);
|
|
1195
1294
|
}
|
|
1196
1295
|
else {
|
|
@@ -1229,7 +1328,7 @@ class RichTextPluginTagComponent {
|
|
|
1229
1328
|
if (!selection) {
|
|
1230
1329
|
selection = $getRoot().selectEnd();
|
|
1231
1330
|
}
|
|
1232
|
-
const node = $createTagNode(tag.key, tag.description);
|
|
1331
|
+
const node = $createTagNode(tag.key, this.#viewContainerRef, tag.description);
|
|
1233
1332
|
selection.insertNodes([node]);
|
|
1234
1333
|
});
|
|
1235
1334
|
}
|