@descope/web-components-ui 1.0.304 → 1.0.306

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/dist/index.esm.js CHANGED
@@ -5,7 +5,7 @@ import '@vaadin/text-field';
5
5
  import '@vaadin/email-field';
6
6
  import '@vaadin/number-field';
7
7
  import '@vaadin/password-field';
8
- import { Remarkable } from 'remarkable';
8
+ import MarkdownIt from 'markdown-it';
9
9
  import '@vaadin/text-area';
10
10
  import '@vaadin/combo-box';
11
11
  import '@vaadin/grid';
@@ -3331,85 +3331,24 @@ const PasswordClass = compose(
3331
3331
 
3332
3332
  customElements.define(componentName$A, PasswordClass);
3333
3333
 
3334
- const ruleSet = {
3335
- custom: ['image'],
3336
- core: [
3337
- 'block',
3338
- 'inline',
3339
- 'abbr', // Parse abbreviation definitions, i.e. `*[abbr]: description`
3340
- 'abbr2', // Enclose abbreviations in <abbr> tags
3341
- 'references',
3342
- 'footnote_tail',
3343
- 'replacements', // Simple typographical replacements
3344
- 'smartquotes', // Convert straight quotation marks to typographic ones
3345
- ],
3346
- inline: [
3347
- 'text',
3348
- 'newline', // Proceess '\n'
3349
- 'backticks', // Parse backticks
3350
- 'del', // Process ~~deleted text~~
3351
- 'emphasis', // Process *this* and _that_
3352
- 'sub', // Process ~subscript~
3353
- 'sup', // Process ^superscript^
3354
- 'links', // Process [links](<to> "stuff")
3355
- 'escape', // Proceess escaped chars and hardbreaks
3356
- 'ins', // Process ++inserted text++
3357
- 'mark', // Process ==highlighted text==
3358
- 'footnote_inline', // Process inline footnotes (^[...])
3359
- 'footnote_ref', // Process footnote references ([^...])
3360
- 'autolink', // Process autolinks '<protocol:...>'
3361
- 'htmltag', // Process html tags
3362
- 'entity', // Process html entity - &#123;, &#xAF;, &quot;, ...
3363
- ],
3364
- block: [
3365
- 'code', // Code block (4 spaces padded)
3366
- 'fences', // fences (``` lang, ~~~ lang)
3367
- 'blockquote', // Block quotes
3368
- 'list',
3369
- 'heading', // heading (#, ##, ...)
3370
- 'paragraph',
3371
- 'hr', // Horizontal rule
3372
- 'footnote', // Process footnote reference list
3373
- 'lheading', // lheading (---, ===)
3374
- 'htmlblock', // HTML block
3375
- 'table', // GFM table, non-standard
3376
- 'deflist', // Definition lists
3377
- ],
3378
- };
3379
-
3380
3334
  const textRuleSet = {
3381
- core: ['block', 'inline'],
3382
- inline: [
3383
- 'text',
3384
- 'newline', // Proceess '\n'
3385
- 'backticks', // Parse backticks
3386
- 'del', // Process ~~deleted text~~
3387
- 'emphasis', // Process *this* and _that_
3388
- 'sub', // Process ~subscript~
3389
- 'sup', // Process ^superscript^
3390
- 'links', // Process [links](<to> "stuff")
3391
- 'escape', // Proceess escaped chars and hardbreaks
3392
- 'ins', // Process ++inserted text++
3393
- 'footnote_inline', // Process inline footnotes (^[...])
3394
- 'footnote_ref', // Process footnote references ([^...])
3395
- 'autolink', // Process autolinks '<protocol:...>'
3396
- ],
3397
- block: [
3398
- 'code', // Code block (4 spaces padded)
3399
- 'fences', // fences (``` lang, ~~~ lang)
3400
- 'blockquote', // Block quotes
3401
- 'list',
3402
- 'heading', // heading (#, ##, ...)
3403
- 'paragraph',
3404
- 'footnote', // Process footnote reference list
3405
- 'htmlblock', // HTML block
3406
- ],
3335
+ components: {
3336
+ core: {
3337
+ rules: ['block', 'inline'],
3338
+ },
3339
+ block: {
3340
+ rules: ['blockquote', 'code', 'heading', 'list', 'paragraph', 'list'],
3341
+ },
3342
+ inline: {
3343
+ rules: ['backticks', 'strikethrough', 'link', 'emphasis', 'strikethrough', 'newline', 'text'],
3344
+ },
3345
+ },
3407
3346
  };
3408
3347
 
3409
3348
  const componentName$z = getComponentName('enriched-text');
3410
3349
 
3411
3350
  let EnrichedText$2 = class EnrichedText extends createBaseClass({ componentName: componentName$z, baseSelector: ':host > div' }) {
3412
- #origImageRenderer;
3351
+ #origLinkRenderer;
3413
3352
 
3414
3353
  constructor() {
3415
3354
  super();
@@ -3458,7 +3397,7 @@ let EnrichedText$2 = class EnrichedText extends createBaseClass({ componentName:
3458
3397
  }
3459
3398
 
3460
3399
  static get observedAttributes() {
3461
- return ['readonly'];
3400
+ return ['readonly', 'link-target-blank'];
3462
3401
  }
3463
3402
 
3464
3403
  attributeChangedCallback(attrName, oldValue, newValue) {
@@ -3468,21 +3407,24 @@ let EnrichedText$2 = class EnrichedText extends createBaseClass({ componentName:
3468
3407
  if (attrName === 'readonly') {
3469
3408
  this.onReadOnlyChange(newValue === 'true');
3470
3409
  }
3410
+
3411
+ if (attrName === 'link-target-blank') {
3412
+ this.#initProcessor();
3413
+ }
3471
3414
  }
3472
3415
  }
3473
3416
 
3474
- #disableAllRules() {
3475
- if (!this.processor) {
3476
- return;
3417
+ #customizeLinkRenderer() {
3418
+ if (this.linkTargetBlank) {
3419
+ this.processor.renderer.rules.link_open = (tokens, idx, options, env, self) => {
3420
+ // Add a new `target` attribute, or replace the value of the existing one.
3421
+ tokens[idx].attrSet('target', '_blank');
3422
+ // Pass the token to the default renderer.
3423
+ return this.#origLinkRenderer(tokens, idx, options, env, self);
3424
+ };
3425
+ } else {
3426
+ this.processor.renderer.rules.link_open = this.#origLinkRenderer;
3477
3427
  }
3478
-
3479
- ruleSet?.core && this.processor.core.ruler.disable(ruleSet.core);
3480
- ruleSet?.inline && this.processor.inline.ruler.disable(ruleSet.inline);
3481
- ruleSet?.block && this.processor.block.ruler.disable(ruleSet.block);
3482
-
3483
- this.processor.renderer.rules.image = () => {
3484
- return '';
3485
- };
3486
3428
  }
3487
3429
 
3488
3430
  #enableCustomRules() {
@@ -3491,25 +3433,28 @@ let EnrichedText$2 = class EnrichedText extends createBaseClass({ componentName:
3491
3433
  }
3492
3434
 
3493
3435
  const customRuleSet = textRuleSet;
3494
-
3495
- customRuleSet?.core && this.processor?.core.ruler.enable(customRuleSet?.core);
3496
- customRuleSet?.inline && this.processor?.inline.ruler.enable(customRuleSet?.inline);
3497
- customRuleSet?.block && this.processor?.block.ruler.enable(customRuleSet?.block);
3498
-
3499
- if (customRuleSet?.custom?.includes('image')) {
3500
- this.processor.renderer.rules.image = this.#origImageRenderer;
3501
- }
3436
+ this.processor.configure(customRuleSet || {});
3502
3437
  }
3503
3438
 
3504
3439
  #updateProcessorRules() {
3505
- this.#disableAllRules();
3506
3440
  this.#enableCustomRules();
3507
3441
  }
3508
3442
 
3443
+ #storeOrigRenderers() {
3444
+ const defaultLinkRenderer = (tokens, idx, options, _, self) =>
3445
+ self.renderToken(tokens, idx, options);
3446
+ this.#origLinkRenderer = this.processor.renderer.rules.link_open || defaultLinkRenderer;
3447
+ }
3448
+
3509
3449
  #initProcessor() {
3510
- this.processor = new Remarkable();
3511
- this.#origImageRenderer = this.processor.renderer.rules.image;
3450
+ this.processor = new MarkdownIt();
3451
+ this.#storeOrigRenderers();
3512
3452
  this.#updateProcessorRules();
3453
+ this.#customizeLinkRenderer();
3454
+ }
3455
+
3456
+ get linkTargetBlank() {
3457
+ return this.getAttribute('link-target-blank') === 'true';
3513
3458
  }
3514
3459
 
3515
3460
  get contentNode() {
@@ -3524,7 +3469,7 @@ let EnrichedText$2 = class EnrichedText extends createBaseClass({ componentName:
3524
3469
  let html = this.textContent;
3525
3470
 
3526
3471
  try {
3527
- const tokens = this.processor.parse(this.textContent);
3472
+ const tokens = this.processor.parse(this.textContent, { references: undefined });
3528
3473
  html = this.processor.renderer.render(tokens, { breaks: true });
3529
3474
  } catch (e) {
3530
3475
  // eslint-disable-next-line no-console