@descope/web-components-ui 1.0.304 → 1.0.306

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
 
3
3
  var merge = require('lodash.merge');
4
4
  var Color = require('color');
5
- var remarkable = require('remarkable');
5
+ var MarkdownIt = require('markdown-it');
6
6
 
7
7
  const DESCOPE_PREFIX = 'descope';
8
8
  const CSS_SELECTOR_SPECIFIER_MULTIPLY = 3;
@@ -4565,85 +4565,24 @@ var text$3 = /*#__PURE__*/Object.freeze({
4565
4565
  vars: vars$r
4566
4566
  });
4567
4567
 
4568
- const ruleSet = {
4569
- custom: ['image'],
4570
- core: [
4571
- 'block',
4572
- 'inline',
4573
- 'abbr', // Parse abbreviation definitions, i.e. `*[abbr]: description`
4574
- 'abbr2', // Enclose abbreviations in <abbr> tags
4575
- 'references',
4576
- 'footnote_tail',
4577
- 'replacements', // Simple typographical replacements
4578
- 'smartquotes', // Convert straight quotation marks to typographic ones
4579
- ],
4580
- inline: [
4581
- 'text',
4582
- 'newline', // Proceess '\n'
4583
- 'backticks', // Parse backticks
4584
- 'del', // Process ~~deleted text~~
4585
- 'emphasis', // Process *this* and _that_
4586
- 'sub', // Process ~subscript~
4587
- 'sup', // Process ^superscript^
4588
- 'links', // Process [links](<to> "stuff")
4589
- 'escape', // Proceess escaped chars and hardbreaks
4590
- 'ins', // Process ++inserted text++
4591
- 'mark', // Process ==highlighted text==
4592
- 'footnote_inline', // Process inline footnotes (^[...])
4593
- 'footnote_ref', // Process footnote references ([^...])
4594
- 'autolink', // Process autolinks '<protocol:...>'
4595
- 'htmltag', // Process html tags
4596
- 'entity', // Process html entity - &#123;, &#xAF;, &quot;, ...
4597
- ],
4598
- block: [
4599
- 'code', // Code block (4 spaces padded)
4600
- 'fences', // fences (``` lang, ~~~ lang)
4601
- 'blockquote', // Block quotes
4602
- 'list',
4603
- 'heading', // heading (#, ##, ...)
4604
- 'paragraph',
4605
- 'hr', // Horizontal rule
4606
- 'footnote', // Process footnote reference list
4607
- 'lheading', // lheading (---, ===)
4608
- 'htmlblock', // HTML block
4609
- 'table', // GFM table, non-standard
4610
- 'deflist', // Definition lists
4611
- ],
4612
- };
4613
-
4614
4568
  const textRuleSet = {
4615
- core: ['block', 'inline'],
4616
- inline: [
4617
- 'text',
4618
- 'newline', // Proceess '\n'
4619
- 'backticks', // Parse backticks
4620
- 'del', // Process ~~deleted text~~
4621
- 'emphasis', // Process *this* and _that_
4622
- 'sub', // Process ~subscript~
4623
- 'sup', // Process ^superscript^
4624
- 'links', // Process [links](<to> "stuff")
4625
- 'escape', // Proceess escaped chars and hardbreaks
4626
- 'ins', // Process ++inserted text++
4627
- 'footnote_inline', // Process inline footnotes (^[...])
4628
- 'footnote_ref', // Process footnote references ([^...])
4629
- 'autolink', // Process autolinks '<protocol:...>'
4630
- ],
4631
- block: [
4632
- 'code', // Code block (4 spaces padded)
4633
- 'fences', // fences (``` lang, ~~~ lang)
4634
- 'blockquote', // Block quotes
4635
- 'list',
4636
- 'heading', // heading (#, ##, ...)
4637
- 'paragraph',
4638
- 'footnote', // Process footnote reference list
4639
- 'htmlblock', // HTML block
4640
- ],
4569
+ components: {
4570
+ core: {
4571
+ rules: ['block', 'inline'],
4572
+ },
4573
+ block: {
4574
+ rules: ['blockquote', 'code', 'heading', 'list', 'paragraph', 'list'],
4575
+ },
4576
+ inline: {
4577
+ rules: ['backticks', 'strikethrough', 'link', 'emphasis', 'strikethrough', 'newline', 'text'],
4578
+ },
4579
+ },
4641
4580
  };
4642
4581
 
4643
4582
  const componentName$z = getComponentName('enriched-text');
4644
4583
 
4645
4584
  let EnrichedText$2 = class EnrichedText extends createBaseClass({ componentName: componentName$z, baseSelector: ':host > div' }) {
4646
- #origImageRenderer;
4585
+ #origLinkRenderer;
4647
4586
 
4648
4587
  constructor() {
4649
4588
  super();
@@ -4692,7 +4631,7 @@ let EnrichedText$2 = class EnrichedText extends createBaseClass({ componentName:
4692
4631
  }
4693
4632
 
4694
4633
  static get observedAttributes() {
4695
- return ['readonly'];
4634
+ return ['readonly', 'link-target-blank'];
4696
4635
  }
4697
4636
 
4698
4637
  attributeChangedCallback(attrName, oldValue, newValue) {
@@ -4702,21 +4641,24 @@ let EnrichedText$2 = class EnrichedText extends createBaseClass({ componentName:
4702
4641
  if (attrName === 'readonly') {
4703
4642
  this.onReadOnlyChange(newValue === 'true');
4704
4643
  }
4644
+
4645
+ if (attrName === 'link-target-blank') {
4646
+ this.#initProcessor();
4647
+ }
4705
4648
  }
4706
4649
  }
4707
4650
 
4708
- #disableAllRules() {
4709
- if (!this.processor) {
4710
- return;
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;
4711
4661
  }
4712
-
4713
- ruleSet?.core && this.processor.core.ruler.disable(ruleSet.core);
4714
- ruleSet?.inline && this.processor.inline.ruler.disable(ruleSet.inline);
4715
- ruleSet?.block && this.processor.block.ruler.disable(ruleSet.block);
4716
-
4717
- this.processor.renderer.rules.image = () => {
4718
- return '';
4719
- };
4720
4662
  }
4721
4663
 
4722
4664
  #enableCustomRules() {
@@ -4725,25 +4667,28 @@ let EnrichedText$2 = class EnrichedText extends createBaseClass({ componentName:
4725
4667
  }
4726
4668
 
4727
4669
  const customRuleSet = textRuleSet;
4728
-
4729
- customRuleSet?.core && this.processor?.core.ruler.enable(customRuleSet?.core);
4730
- customRuleSet?.inline && this.processor?.inline.ruler.enable(customRuleSet?.inline);
4731
- customRuleSet?.block && this.processor?.block.ruler.enable(customRuleSet?.block);
4732
-
4733
- if (customRuleSet?.custom?.includes('image')) {
4734
- this.processor.renderer.rules.image = this.#origImageRenderer;
4735
- }
4670
+ this.processor.configure(customRuleSet || {});
4736
4671
  }
4737
4672
 
4738
4673
  #updateProcessorRules() {
4739
- this.#disableAllRules();
4740
4674
  this.#enableCustomRules();
4741
4675
  }
4742
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
+
4743
4683
  #initProcessor() {
4744
- this.processor = new remarkable.Remarkable();
4745
- this.#origImageRenderer = this.processor.renderer.rules.image;
4684
+ this.processor = new MarkdownIt();
4685
+ this.#storeOrigRenderers();
4746
4686
  this.#updateProcessorRules();
4687
+ this.#customizeLinkRenderer();
4688
+ }
4689
+
4690
+ get linkTargetBlank() {
4691
+ return this.getAttribute('link-target-blank') === 'true';
4747
4692
  }
4748
4693
 
4749
4694
  get contentNode() {
@@ -4758,7 +4703,7 @@ let EnrichedText$2 = class EnrichedText extends createBaseClass({ componentName:
4758
4703
  let html = this.textContent;
4759
4704
 
4760
4705
  try {
4761
- const tokens = this.processor.parse(this.textContent);
4706
+ const tokens = this.processor.parse(this.textContent, { references: undefined });
4762
4707
  html = this.processor.renderer.render(tokens, { breaks: true });
4763
4708
  } catch (e) {
4764
4709
  // eslint-disable-next-line no-console