@descope/web-components-ui 1.0.305 → 1.0.306

Sign up to get free protection for your applications and to get access to all the features.
@@ -4582,7 +4582,7 @@ const textRuleSet = {
4582
4582
  const componentName$z = getComponentName('enriched-text');
4583
4583
 
4584
4584
  let EnrichedText$2 = class EnrichedText extends createBaseClass({ componentName: componentName$z, baseSelector: ':host > div' }) {
4585
- #origImageRenderer;
4585
+ #origLinkRenderer;
4586
4586
 
4587
4587
  constructor() {
4588
4588
  super();
@@ -4631,7 +4631,7 @@ let EnrichedText$2 = class EnrichedText extends createBaseClass({ componentName:
4631
4631
  }
4632
4632
 
4633
4633
  static get observedAttributes() {
4634
- return ['readonly'];
4634
+ return ['readonly', 'link-target-blank'];
4635
4635
  }
4636
4636
 
4637
4637
  attributeChangedCallback(attrName, oldValue, newValue) {
@@ -4641,6 +4641,23 @@ let EnrichedText$2 = class EnrichedText extends createBaseClass({ componentName:
4641
4641
  if (attrName === 'readonly') {
4642
4642
  this.onReadOnlyChange(newValue === 'true');
4643
4643
  }
4644
+
4645
+ if (attrName === 'link-target-blank') {
4646
+ this.#initProcessor();
4647
+ }
4648
+ }
4649
+ }
4650
+
4651
+ #customizeLinkRenderer() {
4652
+ if (this.linkTargetBlank) {
4653
+ this.processor.renderer.rules.link_open = (tokens, idx, options, env, self) => {
4654
+ // Add a new `target` attribute, or replace the value of the existing one.
4655
+ tokens[idx].attrSet('target', '_blank');
4656
+ // Pass the token to the default renderer.
4657
+ return this.#origLinkRenderer(tokens, idx, options, env, self);
4658
+ };
4659
+ } else {
4660
+ this.processor.renderer.rules.link_open = this.#origLinkRenderer;
4644
4661
  }
4645
4662
  }
4646
4663
 
@@ -4651,19 +4668,27 @@ let EnrichedText$2 = class EnrichedText extends createBaseClass({ componentName:
4651
4668
 
4652
4669
  const customRuleSet = textRuleSet;
4653
4670
  this.processor.configure(customRuleSet || {});
4654
-
4655
- if (customRuleSet?.custom?.includes('image')) {
4656
- this.processor.renderer.rules.image = this.#origImageRenderer;
4657
- }
4658
4671
  }
4659
4672
 
4660
4673
  #updateProcessorRules() {
4661
4674
  this.#enableCustomRules();
4662
4675
  }
4663
4676
 
4677
+ #storeOrigRenderers() {
4678
+ const defaultLinkRenderer = (tokens, idx, options, _, self) =>
4679
+ self.renderToken(tokens, idx, options);
4680
+ this.#origLinkRenderer = this.processor.renderer.rules.link_open || defaultLinkRenderer;
4681
+ }
4682
+
4664
4683
  #initProcessor() {
4665
4684
  this.processor = new MarkdownIt();
4685
+ this.#storeOrigRenderers();
4666
4686
  this.#updateProcessorRules();
4687
+ this.#customizeLinkRenderer();
4688
+ }
4689
+
4690
+ get linkTargetBlank() {
4691
+ return this.getAttribute('link-target-blank') === 'true';
4667
4692
  }
4668
4693
 
4669
4694
  get contentNode() {