@descope/web-components-ui 1.0.372 → 1.0.373
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/index.cjs.js +17 -1
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.esm.js +17 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/umd/DescopeDev.js +1 -1
- package/dist/umd/descope-enriched-text-index-js.js +1 -1
- package/package.json +1 -1
- package/src/components/descope-enriched-text/EnrichedTextClass.js +9 -1
- package/src/theme/components/enrichedText.js +8 -0
@@ -1 +1 @@
|
|
1
|
-
"use strict";(self.webpackChunk_descope_web_components_ui=self.webpackChunk_descope_web_components_ui||[]).push([[5158],{20409:(e,t,r)=>{r.r(t),r.d(t,{EnrichedTextClass:()=>d});var n=r(84569),o=r(94978),s=r(2061),i=r(54567);const l=["blockquote","list","image","table","code","hr","backticks","fence","reference","heading","lheading","html_block"];var a=r(33346);const c=(0,i.iY)("enriched-text");class h extends((0,a.s)({componentName:c,baseSelector:":host > div"})){#e;#t;constructor(){super(),this.attachShadow({mode:"open"}).innerHTML='\n <style>\n :host {\n
|
1
|
+
"use strict";(self.webpackChunk_descope_web_components_ui=self.webpackChunk_descope_web_components_ui||[]).push([[5158],{20409:(e,t,r)=>{r.r(t),r.d(t,{EnrichedTextClass:()=>d});var n=r(84569),o=r(94978),s=r(2061),i=r(54567);const l=["blockquote","list","image","table","code","hr","backticks","fence","reference","heading","lheading","html_block"];var a=r(33346);const c=(0,i.iY)("enriched-text");class h extends((0,a.s)({componentName:c,baseSelector:":host > div"})){#e;#t;constructor(){super(),this.attachShadow({mode:"open"}).innerHTML='\n <style>\n :host {\n line-height: 1em;\n word-break: break-word;\n }\n :host > slot {\n width: 100%;\n display: inline-block;\n }\n *, *:last-child {\n margin: 0;\n }\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n p {\n margin-bottom: 1em;\n }\n a {\n cursor: pointer;\n }\n blockquote {\n padding: 0 2em;\n }\n u {\n text-decoration: underline\n }\n s {\n color: currentColor;\n }\n </style>\n <slot part="text-wrapper" style="display:none"></slot>\n <div class="content"></div>\n ',this.textSlot=this.shadowRoot.querySelector("slot"),this.#r(),(0,i.P$)(this,this.#n.bind(this))}static get observedAttributes(){return["readonly","link-target-blank"]}attributeChangedCallback(e,t,r){super.attributeChangedCallback?.(e,t,r),r!==t&&("readonly"===e&&this.onReadOnlyChange("true"===r),"link-target-blank"===e&&this.#r())}customUnderlineRenderer(){this.processor.renderer.rules.em_open=(e,t,r,n,o)=>("_"===e[t].markup&&(e[t].tag="u"),this.#t(e,t,r,n,o)),this.processor.renderer.rules.em_close=(e,t,r,n,o)=>("_"===e[t].markup&&(e[t].tag="u"),this.#t(e,t,r,n,o))}#o(){this.linkTargetBlank?this.processor.renderer.rules.link_open=(e,t,r,n,o)=>(e[t].attrSet("target","_blank"),this.#e(e,t,r,n,o)):this.processor.renderer.rules.link_open=this.#e}#s(){this.processor&&this.processor.disable(l)}#i(){this.#s()}#l(){this.#e=this.processor.renderer.rules.link_open||((e,t,r,n,o)=>o.renderToken(e,t,r)),this.#t=this.processor.renderer.rules.em_open||((e,t,r,n,o)=>o.renderToken(e,t,r))}#r(){this.processor=new n.Z("commonmark",{html:!0}),this.#l(),this.#i(),this.#o(),this.customUnderlineRenderer()}get linkTargetBlank(){return"true"===this.getAttribute("link-target-blank")}get contentNode(){return this.shadowRoot.querySelector(".content")}#n(){if(!this.processor)return;let e=(e=>{const t=document.createElement("textarea");return t.innerHTML=e,t.value})(this.innerHTML);if(e){this.removeAttribute("empty");try{const t=this.processor.parse(e,{references:void 0});e=this.processor.renderer.render(t,{html:!0,breaks:!0})}catch(e){console.warn("Not parsing invalid markdown token")}this.contentNode.innerHTML=e}else this.setAttribute("empty","true")}onReadOnlyChange(e){e?this.contentNode.setAttribute("inert",e):this.contentNode.removeAttribute("inert")}}const d=(0,s.qC)((0,o.yk)({mappings:{hostWidth:{selector:()=>":host",property:"width"},hostDisplay:{selector:()=>":host",property:"display",fallback:"inline-block"},hostDirection:{selector:()=>":host",property:"direction"},fontSize:{},fontFamily:{},fontWeight:{},fontWeightBold:[{selector:()=>":host strong",property:"font-weight"},{selector:()=>":host b",property:"font-weight"}],textColor:{property:"color"},textLineHeight:{property:"line-height"},textAlign:{},linkColor:{selector:"a",property:"color"},linkTextDecoration:{selector:"a",property:"text-decoration"},linkHoverTextDecoration:{selector:"a:hover",property:"text-decoration"},minHeight:{},minWidth:{}}}),(0,o.yk)({componentNameOverride:(0,i.iY)("link")}),(0,o.yk)({componentNameOverride:(0,i.iY)("text")}),o.e4,o.Ae)(h);customElements.define(c,d)}}]);
|
package/package.json
CHANGED
@@ -21,7 +21,6 @@ class EnrichedText extends createBaseClass({ componentName, baseSelector: ':host
|
|
21
21
|
this.attachShadow({ mode: 'open' }).innerHTML = `
|
22
22
|
<style>
|
23
23
|
:host {
|
24
|
-
display: inline-block;
|
25
24
|
line-height: 1em;
|
26
25
|
word-break: break-word;
|
27
26
|
}
|
@@ -152,6 +151,14 @@ class EnrichedText extends createBaseClass({ componentName, baseSelector: ':host
|
|
152
151
|
|
153
152
|
let html = decodeHTML(this.innerHTML);
|
154
153
|
|
154
|
+
if (!html) {
|
155
|
+
this.setAttribute('empty', 'true');
|
156
|
+
|
157
|
+
return;
|
158
|
+
}
|
159
|
+
|
160
|
+
this.removeAttribute('empty');
|
161
|
+
|
155
162
|
try {
|
156
163
|
const tokens = this.processor.parse(html, { references: undefined });
|
157
164
|
html = this.processor.renderer.render(tokens, { html: true, breaks: true });
|
@@ -176,6 +183,7 @@ export const EnrichedTextClass = compose(
|
|
176
183
|
createStyleMixin({
|
177
184
|
mappings: {
|
178
185
|
hostWidth: { selector: () => ':host', property: 'width' },
|
186
|
+
hostDisplay: { selector: () => ':host', property: 'display', fallback: 'inline-block' },
|
179
187
|
hostDirection: { selector: () => ':host', property: 'direction' },
|
180
188
|
fontSize: {},
|
181
189
|
fontFamily: {},
|
@@ -26,6 +26,14 @@ const enrichedText = {
|
|
26
26
|
[vars.fontWeightBold]: '900',
|
27
27
|
[vars.minWidth]: '0.25em',
|
28
28
|
[vars.minHeight]: '1.35em',
|
29
|
+
|
30
|
+
[vars.hostDisplay]: 'inline-block',
|
31
|
+
|
32
|
+
_empty: {
|
33
|
+
_hideWhenEmpty: {
|
34
|
+
[vars.hostDisplay]: 'none',
|
35
|
+
},
|
36
|
+
},
|
29
37
|
};
|
30
38
|
|
31
39
|
export default enrichedText;
|