@descope-ui/descope-enriched-text 3.11.1 → 3.11.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope-ui/descope-enriched-text",
3
- "version": "3.11.1",
3
+ "version": "3.11.2",
4
4
  "files": [
5
5
  "src",
6
6
  "stories"
@@ -18,14 +18,14 @@
18
18
  },
19
19
  "devDependencies": {
20
20
  "@playwright/test": "1.58.2",
21
- "e2e-utils": "3.11.1"
21
+ "e2e-utils": "3.11.2"
22
22
  },
23
23
  "dependencies": {
24
24
  "markdown-it": "14.1.1",
25
- "@descope-ui/common": "3.11.1",
26
- "@descope-ui/theme-globals": "3.11.1",
27
- "@descope-ui/descope-link": "3.11.1",
28
- "@descope-ui/descope-text": "3.11.1"
25
+ "@descope-ui/common": "3.11.2",
26
+ "@descope-ui/descope-text": "3.11.2",
27
+ "@descope-ui/descope-link": "3.11.2",
28
+ "@descope-ui/theme-globals": "3.11.2"
29
29
  },
30
30
  "publishConfig": {
31
31
  "link-workspace-packages": false
@@ -1,16 +1,26 @@
1
- /* eslint-disable no-param-reassign */
2
-
3
1
  import MarkdownIt from 'markdown-it';
4
- import { createStyleMixin, draggableMixin, componentNameValidationMixin } from '@descope-ui/common/components-mixins';
2
+ import {
3
+ createStyleMixin,
4
+ draggableMixin,
5
+ componentNameValidationMixin,
6
+ stretchMixin,
7
+ } from '@descope-ui/common/components-mixins';
5
8
  import { compose } from '@descope-ui/common/utils';
6
9
  import { disableRules } from './consts';
7
10
  import { createBaseClass } from '@descope-ui/common/base-classes';
8
11
  import { decodeHTML } from './helpers';
9
- import { getComponentName, injectStyle, observeChildren } from '@descope-ui/common/components-helpers';
12
+ import {
13
+ getComponentName,
14
+ injectStyle,
15
+ observeChildren,
16
+ } from '@descope-ui/common/components-helpers';
10
17
 
11
18
  export const componentName = getComponentName('enriched-text');
12
19
 
13
- class EnrichedText extends createBaseClass({ componentName, baseSelector: ':host > div' }) {
20
+ class EnrichedText extends createBaseClass({
21
+ componentName,
22
+ baseSelector: ':host > div',
23
+ }) {
14
24
  #origLinkRenderer;
15
25
 
16
26
  #origEmRenderer;
@@ -57,7 +67,7 @@ class EnrichedText extends createBaseClass({ componentName, baseSelector: ':host
57
67
  color: currentColor;
58
68
  }
59
69
  `,
60
- this
70
+ this,
61
71
  );
62
72
 
63
73
  this.#initProcessor();
@@ -92,11 +102,23 @@ class EnrichedText extends createBaseClass({ componentName, baseSelector: ':host
92
102
 
93
103
  // We're overriding the rule for em with single underscore to perform as underline. (_underline_)
94
104
  customUnderlineRenderer() {
95
- this.processor.renderer.rules.em_open = (tokens, idx, options, env, self) => {
105
+ this.processor.renderer.rules.em_open = (
106
+ tokens,
107
+ idx,
108
+ options,
109
+ env,
110
+ self,
111
+ ) => {
96
112
  if (tokens[idx].markup === '_') tokens[idx].tag = 'u';
97
113
  return this.#origEmRenderer(tokens, idx, options, env, self);
98
114
  };
99
- this.processor.renderer.rules.em_close = (tokens, idx, options, env, self) => {
115
+ this.processor.renderer.rules.em_close = (
116
+ tokens,
117
+ idx,
118
+ options,
119
+ env,
120
+ self,
121
+ ) => {
100
122
  if (tokens[idx].markup === '_') tokens[idx].tag = 'u';
101
123
  return this.#origEmRenderer(tokens, idx, options, env, self);
102
124
  };
@@ -104,7 +126,13 @@ class EnrichedText extends createBaseClass({ componentName, baseSelector: ':host
104
126
 
105
127
  #customizeLinkRenderer() {
106
128
  if (this.linkTargetBlank) {
107
- this.processor.renderer.rules.link_open = (tokens, idx, options, env, self) => {
129
+ this.processor.renderer.rules.link_open = (
130
+ tokens,
131
+ idx,
132
+ options,
133
+ env,
134
+ self,
135
+ ) => {
108
136
  // Add a new `target` attribute, or replace the value of the existing one.
109
137
  tokens[idx].attrSet('target', '_blank');
110
138
  // Pass the token to the default renderer.
@@ -129,11 +157,13 @@ class EnrichedText extends createBaseClass({ componentName, baseSelector: ':host
129
157
  #storeOrigRenderers() {
130
158
  const defaultLinkRenderer = (tokens, idx, options, _, self) =>
131
159
  self.renderToken(tokens, idx, options);
132
- this.#origLinkRenderer = this.processor.renderer.rules.link_open || defaultLinkRenderer;
160
+ this.#origLinkRenderer =
161
+ this.processor.renderer.rules.link_open || defaultLinkRenderer;
133
162
 
134
163
  const defaultStrongRenderer = (tokens, idx, options, _, self) =>
135
164
  self.renderToken(tokens, idx, options);
136
- this.#origEmRenderer = this.processor.renderer.rules.em_open || defaultStrongRenderer;
165
+ this.#origEmRenderer =
166
+ this.processor.renderer.rules.em_open || defaultStrongRenderer;
137
167
  }
138
168
 
139
169
  #initProcessor() {
@@ -167,9 +197,11 @@ class EnrichedText extends createBaseClass({ componentName, baseSelector: ':host
167
197
 
168
198
  try {
169
199
  const tokens = this.processor.parse(html, { references: undefined });
170
- html = this.processor.renderer.render(tokens, { html: true, breaks: true });
171
- } catch (e) {
172
- // eslint-disable-next-line no-console
200
+ html = this.processor.renderer.render(tokens, {
201
+ html: true,
202
+ breaks: true,
203
+ });
204
+ } catch {
173
205
  console.warn('Not parsing invalid markdown token');
174
206
  }
175
207
 
@@ -190,7 +222,11 @@ export const EnrichedTextClass = compose(
190
222
  createStyleMixin({
191
223
  mappings: {
192
224
  hostWidth: { selector: () => ':host', property: 'width' },
193
- hostDisplay: { selector: () => ':host', property: 'display', fallback: 'inline-block' },
225
+ hostDisplay: {
226
+ selector: () => ':host',
227
+ property: 'display',
228
+ fallback: 'inline-block',
229
+ },
194
230
  hostDirection: { selector: () => ':host', property: 'direction' },
195
231
  fontSize: {},
196
232
  fontFamily: {},
@@ -204,13 +240,17 @@ export const EnrichedTextClass = compose(
204
240
  textAlign: {},
205
241
  linkColor: { selector: 'a', property: 'color' },
206
242
  linkTextDecoration: { selector: 'a', property: 'text-decoration' },
207
- linkHoverTextDecoration: { selector: 'a:hover', property: 'text-decoration' },
243
+ linkHoverTextDecoration: {
244
+ selector: 'a:hover',
245
+ property: 'text-decoration',
246
+ },
208
247
  minHeight: {},
209
248
  minWidth: {},
210
249
  },
211
250
  }),
212
251
  createStyleMixin({ componentNameOverride: getComponentName('link') }),
213
252
  createStyleMixin({ componentNameOverride: getComponentName('text') }),
253
+ stretchMixin({ triggers: [{ attr: 'full-width', value: 'true' }] }),
214
254
  draggableMixin,
215
- componentNameValidationMixin
255
+ componentNameValidationMixin,
216
256
  )(EnrichedText);