@entake/particle 19.1.2 → 19.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.
@@ -32,6 +32,7 @@ export declare class RichTextComponent implements ControlValueAccessor, AfterVie
32
32
  private _value;
33
33
  private _editable;
34
34
  protected readonly window: Window & typeof globalThis;
35
+ private CustomLink;
35
36
  editor: Editor;
36
37
  get value(): any;
37
38
  set value(value: string);
@@ -3825,16 +3825,35 @@ class RichTextComponent {
3825
3825
  _value = null;
3826
3826
  _editable = true;
3827
3827
  window = window;
3828
+ CustomLink = Link.extend({
3829
+ renderHTML({ HTMLAttributes }) {
3830
+ const href = HTMLAttributes.href;
3831
+ if (href) {
3832
+ try {
3833
+ const linkUrl = new URL(href, window.location.origin);
3834
+ const currentHost = window.location.hostname;
3835
+ if (linkUrl.hostname !== currentHost) {
3836
+ HTMLAttributes.target = '_blank';
3837
+ HTMLAttributes.rel = 'noopener noreferrer nofollow';
3838
+ }
3839
+ else {
3840
+ HTMLAttributes.target = '_self';
3841
+ HTMLAttributes.rel = undefined;
3842
+ }
3843
+ }
3844
+ catch (e) {
3845
+ console.warn('Invalid URL: ' + href);
3846
+ console.warn(e);
3847
+ }
3848
+ }
3849
+ return ['a', HTMLAttributes, 0];
3850
+ }
3851
+ });
3828
3852
  editor = new Editor({
3829
3853
  extensions: [
3830
3854
  StarterKit,
3831
- Link.configure({
3832
- openOnClick: false,
3833
- HTMLAttributes: {
3834
- class: 'rich-text-link',
3835
- target: '_blank',
3836
- ref: 'noopener'
3837
- },
3855
+ this.CustomLink.configure({
3856
+ openOnClick: false
3838
3857
  }),
3839
3858
  TextAlign.configure({
3840
3859
  types: ['heading', 'paragraph'],
@@ -5699,19 +5718,16 @@ class DropdownComponent {
5699
5718
  * @private
5700
5719
  */
5701
5720
  positionDropdownList() {
5702
- let { left, right, top, bottom } = this.dropdown.nativeElement.getBoundingClientRect();
5703
- if (right - left < this.dropdownBoxMinWidth()) {
5704
- left = left - (this.dropdownBoxMinWidth() - (right - left));
5705
- }
5721
+ const { left, right, top, bottom } = this.dropdown.nativeElement.getBoundingClientRect();
5706
5722
  const { offsetHeight } = this.dropdownList.nativeElement;
5707
- const datePickerBottomLeftAnchor = bottom;
5708
- const availableBottomSpace = window.innerHeight - datePickerBottomLeftAnchor;
5723
+ const bottomLeftAnchor = bottom;
5724
+ const availableBottomSpace = window.innerHeight - bottomLeftAnchor;
5709
5725
  const availableTopSpace = top;
5710
5726
  const offsetListHeight = offsetHeight + DropdownComponent.DROPDOWN_LIST_OFFSET;
5711
5727
  let transformOrigin, positionTop;
5712
5728
  if (availableBottomSpace > offsetListHeight) {
5713
5729
  transformOrigin = 'top left';
5714
- positionTop = `${datePickerBottomLeftAnchor + DropdownComponent.DROPDOWN_LIST_OFFSET}px`;
5730
+ positionTop = `${bottomLeftAnchor + DropdownComponent.DROPDOWN_LIST_OFFSET}px`;
5715
5731
  }
5716
5732
  else if (availableTopSpace > offsetListHeight) {
5717
5733
  transformOrigin = 'bottom left';
@@ -5728,8 +5744,16 @@ class DropdownComponent {
5728
5744
  transformOrigin = 'top left';
5729
5745
  }
5730
5746
  this.renderer.setStyle(this.dropdownList.nativeElement, 'transform-origin', transformOrigin);
5731
- this.renderer.setStyle(this.dropdownList.nativeElement, 'left', `${left}px`);
5732
5747
  this.renderer.setStyle(this.dropdownList.nativeElement, 'top', positionTop);
5748
+ const buttonWidth = right - left;
5749
+ const width = buttonWidth < this.dropdownBoxMinWidth() ? this.dropdownBoxMinWidth() : buttonWidth;
5750
+ if (left + width > window.innerWidth) {
5751
+ const newLeft = left - (this.dropdownBoxMinWidth() - buttonWidth);
5752
+ this.renderer.setStyle(this.dropdownList.nativeElement, 'left', `${newLeft}px`);
5753
+ }
5754
+ else {
5755
+ this.renderer.setStyle(this.dropdownList.nativeElement, 'left', `${left}px`);
5756
+ }
5733
5757
  }
5734
5758
  /**
5735
5759
  * Match the dropdown list width to the dropdown's width