@widergy/energy-ui 3.183.0 → 3.184.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [3.184.0](https://github.com/widergy/energy-ui/compare/v3.183.0...v3.184.0) (2026-09-03)
2
+
3
+
4
+ ### Features
5
+
6
+ * [AXCH-2327] add HTML and Markdown content builders to UTRichText ([#858](https://github.com/widergy/energy-ui/issues/858)) ([470cc87](https://github.com/widergy/energy-ui/commit/470cc87c0719f794ef743e1f74d387bb5598b32e))
7
+
1
8
  # [3.183.0](https://github.com/widergy/energy-ui/compare/v3.182.0...v3.183.0) (2026-09-02)
2
9
 
3
10
 
@@ -11,17 +11,12 @@
11
11
  display: flex;
12
12
  flex-direction: column;
13
13
  grid-gap: var(--UT-richText-gap);
14
- // En longhand y no en shorthand: sin los fallbacks, sass-lint lee los dos var()
15
- // como el mismo token y pide colapsarlos en uno solo.
16
14
  padding-bottom: var(--UT-richText-padding-y);
17
15
  padding-left: var(--UT-richText-padding-x);
18
16
  padding-right: var(--UT-richText-padding-x);
19
17
  padding-top: var(--UT-richText-padding-y);
20
18
  }
21
19
 
22
- // El foco engrosa el borde a 2px con un box-shadow interior en vez de subir el
23
- // border-width. El shadow no participa del layout, así que el padding no necesita
24
- // compensar nada y el contenido no se corre al enfocar.
25
20
  .fieldFocused {
26
21
  border-color: var(--actionAccent04);
27
22
  box-shadow: inset 0 0 0 1px var(--actionAccent04);
@@ -30,8 +25,6 @@
30
25
  .fieldError {
31
26
  border-color: var(--actionError04);
32
27
 
33
- // Con error el anillo de foco toma el color de error, para no mezclar dos
34
- // colores en el mismo borde.
35
28
  &.fieldFocused {
36
29
  box-shadow: inset 0 0 0 1px var(--actionError04);
37
30
  }
@@ -48,22 +41,19 @@
48
41
  padding-right: 0;
49
42
  }
50
43
 
51
- // El área de scroll y el wrapper que monta Tiptap se estiran para que el
52
- // contenteditable ocupe todo el espacio disponible, y no solo el alto de su
53
- // contenido. Así el espacio vacío debajo del texto ES área editable: clickear ahí
54
- // enfoca de forma nativa y ProseMirror pone el cursor en la posición más cercana,
55
- // sin ningún handler de JS.
56
44
  .scrollArea {
57
45
  display: flex;
58
46
  flex-direction: column;
59
47
  max-height: var(--UT-richText-content-max-height);
60
48
  min-height: var(--UT-richText-content-min-height);
49
+ overflow-x: hidden;
61
50
  overflow-y: auto;
62
51
  }
63
52
 
64
53
  .editorWrapper {
65
54
  display: flex;
66
55
  flex: 1 1 auto;
56
+ min-width: 0;
67
57
  }
68
58
 
69
59
  .helpText {
@@ -75,6 +65,7 @@
75
65
  flex: 1 1 auto;
76
66
  font-size: var(--UT-richText-body-size);
77
67
  line-height: var(--UT-richText-body-lh);
68
+ min-width: 0;
78
69
  outline: none;
79
70
 
80
71
  p {
@@ -87,9 +78,6 @@
87
78
  padding-left: var(--UT-richText-list-indent);
88
79
  }
89
80
 
90
- // Separación entre bloques hermanos del documento (párrafo ↔ párrafo,
91
- // párrafo ↔ lista). Solo hijos directos: los párrafos dentro de un li no
92
- // llevan margen.
93
81
  > * + * {
94
82
  margin-top: var(--UT-richText-block-gap);
95
83
  }
@@ -107,14 +95,14 @@
107
95
  text-decoration: underline;
108
96
  }
109
97
 
110
- // --- Estilos de tabla ---
111
- // Applies only to tables rendered inside the editor (not in email output, which uses
112
- // inline styles via the `style` attribute set by buildTableNode / EnergyTable*).
113
-
114
- // Wrapper generado por Tiptap cuando resizable:true. Scroll horizontal cuando la
115
- // tabla supera el ancho del contenedor.
116
98
  :global(.tableWrapper) {
117
99
  overflow-x: auto;
100
+ overflow-y: hidden;
101
+ // sass-lint 1.12 es anterior a estas dos propiedades y las lee como mal escritas.
102
+ // sass-lint:disable no-misspelled-properties
103
+ scrollbar-color: var(--light04) transparent;
104
+ scrollbar-width: thin;
105
+ // sass-lint:enable no-misspelled-properties
118
106
 
119
107
  & + * {
120
108
  margin-top: var(--UT-textEditor-block-gap, 8px);
@@ -192,8 +180,6 @@
192
180
  }
193
181
  }
194
182
 
195
- // Column resize handle — spans the full column height by extending beyond the cell
196
- // boundaries with large top/bottom values (td/th don't clip overflow by default).
197
183
  :global(.column-resize-handle) {
198
184
  background-color: var(--actionAccent04);
199
185
  bottom: -9999px;
@@ -207,12 +193,10 @@
207
193
  z-index: 10;
208
194
  }
209
195
 
210
- // Cursor de redimensionado activo.
211
196
  :global(.resize-cursor) {
212
197
  cursor: col-resize;
213
198
  }
214
199
 
215
- // Tiptap selection highlight on cells.
216
200
  .selectedCell {
217
201
  &::after {
218
202
  background: var(--actionAccent01);
@@ -224,9 +208,6 @@
224
208
  }
225
209
  }
226
210
 
227
- // Única clase global necesaria: la genera la extensión Placeholder de Tiptap,
228
- // así que CSS Modules la hashearía y la regla no aplicaría. Va anidada dentro
229
- // de .editorContent, así que no se filtra fuera del editor.
230
211
  :global(.is-editor-empty) {
231
212
  &:first-child {
232
213
  &::before {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.serializeToHTML=exports.buildTableNode=exports.buildSerializationExtensions=exports.buildParagraphNodes=void 0;var _html=require("@tiptap/html"),_isEmpty=_interopRequireDefault(require("lodash/isEmpty")),_constants=require("../constants.js"),_utils=require("../utils.js"),_moduleResolution=require("./moduleResolution.js");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const TABLE_EMAIL_STYLE="border-collapse: collapse; width: 100%; border-spacing: 0;",HEADER_CELL_EMAIL_STYLE="border: 1px solid #CCCCCC; padding: 8px 12px; text-align: left; font-family: inherit; font-weight: 600; background-color: #F5F5F5;",DATA_CELL_EMAIL_STYLE="border: 1px solid #CCCCCC; padding: 8px 12px; text-align: left; font-family: inherit;",buildParagraph=e=>({type:"paragraph",content:e?[{type:"text",text:String(e)}]:[]}),PARAGRAPH_SEPARATOR=/(?:\r?\n){2,}/,LINE_SEPARATOR=/\r?\n/,buildEmptyParagraph=()=>({type:"paragraph"}),buildParagraphContent=e=>e.split(LINE_SEPARATOR).flatMap((e,t)=>[...t>0?[{type:"hardBreak"}]:[],...e?[{type:"text",text:e}]:[]]),buildParagraphNodes=e=>e?e.split(PARAGRAPH_SEPARATOR).map(e=>{const t=buildParagraphContent(e);return(0,_isEmpty.default)(t)?buildEmptyParagraph():{type:"paragraph",content:t}}):[buildEmptyParagraph()];exports.buildParagraphNodes=buildParagraphNodes;const buildTableNode=e=>{let{headers:t,rows:a,cellColwidth:l}=e;return{type:"table",attrs:{style:TABLE_EMAIL_STYLE},content:[{type:"tableRow",content:t.map(e=>({type:"tableHeader",attrs:{colspan:1,colwidth:l?[l]:null,rowspan:1,style:HEADER_CELL_EMAIL_STYLE},content:[buildParagraph(e)]}))},...a.map(e=>({type:"tableRow",content:e.map(e=>({type:"tableCell",attrs:{colspan:1,colwidth:l?[l]:null,rowspan:1,style:DATA_CELL_EMAIL_STYLE},content:[buildParagraph(e)]}))}))]}};exports.buildTableNode=buildTableNode;const buildSerializationExtensions=function(){let{moduleConfig:e,modules:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,_utils.dedupeExtensions)([...(0,_constants.buildBaseExtensions)({}),...(0,_moduleResolution.buildModuleGroups)(t,e).flat().flatMap(e=>e.resolvedExtensions)])};exports.buildSerializationExtensions=buildSerializationExtensions;const serializeToHTML=function(e){let{moduleConfig:t,modules:a}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,_html.generateHTML)(e,buildSerializationExtensions({moduleConfig:t,modules:a}))};exports.serializeToHTML=serializeToHTML;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.serializeToHTML=exports.readTableNode=exports.buildTableNode=exports.buildSerializationExtensions=exports.buildParagraphNodes=exports.buildNodesFromHTML=void 0;var _core=require("@tiptap/core"),_html=require("@tiptap/html"),_isEmpty=_interopRequireDefault(require("lodash/isEmpty")),_constants=require("../constants.js"),_utils=require("../utils.js"),_moduleResolution=require("./moduleResolution.js");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const buildSerializationExtensions=function(){let{moduleConfig:e,modules:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,_utils.dedupeExtensions)([...(0,_constants.buildBaseExtensions)({}),...(0,_moduleResolution.buildModuleGroups)(t,e).flat().flatMap(e=>e.resolvedExtensions)])};exports.buildSerializationExtensions=buildSerializationExtensions;const buildEmptyParagraph=()=>({type:"paragraph"}),buildPlainInlineContent=e=>e?[{type:"text",text:e}]:[],buildInlineNodes=(e,t)=>(e||[]).reduce((e,n)=>{var l;if("text"===n.type||null!==(l=t.nodes[n.type])&&void 0!==l&&l.isInline)return[...e,n];const o=buildInlineNodes(n.content,t);return(0,_isEmpty.default)(o)?e:(0,_isEmpty.default)(e)?o:[...e,{type:"hardBreak"},...o]},[]),buildInlineHTMLContent=(e,t)=>{let{extensions:n,schema:l}=t;if(!e)return[];const{content:o}=(0,_html.generateJSON)("<p>".concat(e,"</p>"),n);return buildInlineNodes(o,l)},buildInlineContentResolver=function(){let{inlineHTML:e,moduleConfig:t,modules:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e)return buildPlainInlineContent;const l=buildSerializationExtensions({moduleConfig:t,modules:n}),o=(0,_core.getSchema)(l);return e=>buildInlineHTMLContent(e,{extensions:l,schema:o})},PARAGRAPH_SEPARATOR=/(?:\r?\n){2,}/,LINE_SEPARATOR=/\r?\n/,buildParagraphContent=(e,t)=>e.split(LINE_SEPARATOR).map(t).reduce((e,t)=>(0,_isEmpty.default)(t)?e:(0,_isEmpty.default)(e)?t:[...e,{type:"hardBreak"},...t],[]),buildParagraphNodes=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return[buildEmptyParagraph()];const n=buildInlineContentResolver(t);return e.split(PARAGRAPH_SEPARATOR).map(e=>{const t=buildParagraphContent(e,n);return(0,_isEmpty.default)(t)?buildEmptyParagraph():{type:"paragraph",content:t}})};exports.buildParagraphNodes=buildParagraphNodes;const buildNodesFromHTML=function(e){let{moduleConfig:t,modules:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return[buildEmptyParagraph()];const{content:l}=(0,_html.generateJSON)(e,buildSerializationExtensions({moduleConfig:t,modules:n}));return(0,_isEmpty.default)(l)?[buildEmptyParagraph()]:l};exports.buildNodesFromHTML=buildNodesFromHTML;const TABLE_HEADER_TYPE="tableHeader",TABLE_EMAIL_STYLE="border-collapse: collapse; width: 100%; border-spacing: 0;",HEADER_CELL_EMAIL_STYLE="border: 1px solid #CCCCCC; padding: 8px 12px; text-align: left; font-family: inherit; font-weight: 600; background-color: #F5F5F5;",DATA_CELL_EMAIL_STYLE="border: 1px solid #CCCCCC; padding: 8px 12px; text-align: left; font-family: inherit;",buildParagraph=(e,t)=>({type:"paragraph",content:e?t(String(e)):[]}),buildTableNode=e=>{let{cellColwidth:t,headers:n,inlineHTML:l,moduleConfig:o,modules:i,rows:r}=e;const a=buildInlineContentResolver({inlineHTML:l,moduleConfig:o,modules:i});return{type:"table",attrs:{style:TABLE_EMAIL_STYLE},content:[{type:"tableRow",content:n.map(e=>({type:"tableHeader",attrs:{colspan:1,colwidth:t?[t]:null,rowspan:1,style:HEADER_CELL_EMAIL_STYLE},content:[buildParagraph(e,a)]}))},...r.map(e=>({type:"tableRow",content:e.map(e=>({type:"tableCell",attrs:{colspan:1,colwidth:t?[t]:null,rowspan:1,style:DATA_CELL_EMAIL_STYLE},content:[buildParagraph(e,a)]}))}))]}};exports.buildTableNode=buildTableNode;const serializeInlineContent=(e,t)=>(e||[]).map(e=>(0,_html.generateHTML)({type:"doc",content:[e]},t).replace(/^<p>|<\/p>$/g,"")).filter(Boolean).join("<br>"),readTableNode=function(e){var t;let{moduleConfig:n,modules:l}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=buildSerializationExtensions({moduleConfig:n,modules:l}),i=e=>serializeInlineContent(e.content,o),r=(null==e?void 0:e.content)||[],a="tableHeader"===(null===(t=r[0])||void 0===t||null===(t=t.content)||void 0===t||null===(t=t[0])||void 0===t?void 0:t.type),[d,s]=a?[r[0],r.slice(1)]:[null,r],u=((null==d?void 0:d.content)||[]).map(e=>{var t;return null===(t=e.attrs)||void 0===t||null===(t=t.colwidth)||void 0===t?void 0:t[0]}),[p]=u;return{cellColwidth:u.every(e=>e===p)&&null!=p?p:void 0,headers:((null==d?void 0:d.content)||[]).map(i),inlineHTML:!0,rows:s.map(e=>(e.content||[]).map(i))}};exports.readTableNode=readTableNode;const serializeToHTML=function(e){let{moduleConfig:t,modules:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,_html.generateHTML)(e,buildSerializationExtensions({moduleConfig:t,modules:n}))};exports.serializeToHTML=serializeToHTML;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.buildNodesFromMarkdown=void 0;var _contentBuilders=require("./contentBuilders.js");const PARAGRAPH_SEPARATOR=/(?:\r?\n){2,}/,LINE_SEPARATOR=/\r?\n/,BULLET_MARKER=/^\s*[-*+]\s+/,ORDERED_MARKER=/^\s*\d+[.)]\s+/,HTML_ESCAPES={"&":"&amp;","<":"&lt;",">":"&gt;"},BACKSLASH_ESCAPES={"*":"&#42;","[":"&#91;","\\":"&#92;","]":"&#93;",_:"&#95;","`":"&#96;"},INLINE_RULES=[{pattern:/\*\*(?=\S)([\s\S]*?\S)\*\*/g,replacement:"<strong>$1</strong>"},{pattern:/(^|\s)__(?=\S)([\s\S]*?\S)__(?=\s|$|[.,;:!?)])/g,replacement:"$1<strong>$2</strong>"},{pattern:/(^|[\s(])\*(?=\S)([^*]*\S)\*(?=\s|$|[.,;:!?)])/g,replacement:"$1<em>$2</em>"},{pattern:/(^|\s)_(?=\S)([^_]*\S)_(?=\s|$|[.,;:!?)])/g,replacement:"$1<em>$2</em>"},{pattern:/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g,replacement:'<a href="$2">$1</a>'}],buildInlineHTML=e=>INLINE_RULES.reduce((e,t)=>{let{pattern:n,replacement:r}=t;return e.replace(n,r)},e.replace(/&(?!#?\w+;)|[<>]/g,e=>HTML_ESCAPES[e]).replace(/\\([*_[\]`\\])/g,(e,t)=>BACKSLASH_ESCAPES[t])),buildLineGroups=e=>e.reduce((e,t)=>{const n=(BULLET_MARKER.test(t)?"ul":ORDERED_MARKER.test(t)&&"ol")||"p",r=e[e.length-1];return(null==r?void 0:r.tag)===n?r.lines.push(t):e.push({lines:[t],tag:n}),e},[]),buildGroupHTML=e=>{var t;let{lines:n,tag:r}=e;if("p"===r){const e=n.map(e=>buildInlineHTML(e.trim())).filter(Boolean).join("<br>");return e?"<p>".concat(e,"</p>"):""}const o="ul"===r?BULLET_MARKER:ORDERED_MARKER,l=n.map(e=>"<li>".concat(buildInlineHTML(e.replace(o,"").trim()),"</li>")),s="ol"===r?Number(null===(t=n[0].match(/\d+/))||void 0===t?void 0:t[0]):null,i=s>1?' start="'.concat(s,'"'):"";return"<".concat(r).concat(i,">").concat(l.join(""),"</").concat(r,">")},buildNodesFromMarkdown=function(e){let{moduleConfig:t,modules:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=(e||"").split(PARAGRAPH_SEPARATOR).flatMap(e=>buildLineGroups(e.split(LINE_SEPARATOR)).map(buildGroupHTML)).filter(Boolean).join("");return(0,_contentBuilders.buildNodesFromHTML)(r,{moduleConfig:t,modules:n})};exports.buildNodesFromMarkdown=buildNodesFromMarkdown;
@@ -11,17 +11,12 @@
11
11
  display: flex;
12
12
  flex-direction: column;
13
13
  grid-gap: var(--UT-richText-gap);
14
- // En longhand y no en shorthand: sin los fallbacks, sass-lint lee los dos var()
15
- // como el mismo token y pide colapsarlos en uno solo.
16
14
  padding-bottom: var(--UT-richText-padding-y);
17
15
  padding-left: var(--UT-richText-padding-x);
18
16
  padding-right: var(--UT-richText-padding-x);
19
17
  padding-top: var(--UT-richText-padding-y);
20
18
  }
21
19
 
22
- // El foco engrosa el borde a 2px con un box-shadow interior en vez de subir el
23
- // border-width. El shadow no participa del layout, así que el padding no necesita
24
- // compensar nada y el contenido no se corre al enfocar.
25
20
  .fieldFocused {
26
21
  border-color: var(--actionAccent04);
27
22
  box-shadow: inset 0 0 0 1px var(--actionAccent04);
@@ -30,8 +25,6 @@
30
25
  .fieldError {
31
26
  border-color: var(--actionError04);
32
27
 
33
- // Con error el anillo de foco toma el color de error, para no mezclar dos
34
- // colores en el mismo borde.
35
28
  &.fieldFocused {
36
29
  box-shadow: inset 0 0 0 1px var(--actionError04);
37
30
  }
@@ -48,22 +41,19 @@
48
41
  padding-right: 0;
49
42
  }
50
43
 
51
- // El área de scroll y el wrapper que monta Tiptap se estiran para que el
52
- // contenteditable ocupe todo el espacio disponible, y no solo el alto de su
53
- // contenido. Así el espacio vacío debajo del texto ES área editable: clickear ahí
54
- // enfoca de forma nativa y ProseMirror pone el cursor en la posición más cercana,
55
- // sin ningún handler de JS.
56
44
  .scrollArea {
57
45
  display: flex;
58
46
  flex-direction: column;
59
47
  max-height: var(--UT-richText-content-max-height);
60
48
  min-height: var(--UT-richText-content-min-height);
49
+ overflow-x: hidden;
61
50
  overflow-y: auto;
62
51
  }
63
52
 
64
53
  .editorWrapper {
65
54
  display: flex;
66
55
  flex: 1 1 auto;
56
+ min-width: 0;
67
57
  }
68
58
 
69
59
  .helpText {
@@ -75,6 +65,7 @@
75
65
  flex: 1 1 auto;
76
66
  font-size: var(--UT-richText-body-size);
77
67
  line-height: var(--UT-richText-body-lh);
68
+ min-width: 0;
78
69
  outline: none;
79
70
 
80
71
  p {
@@ -87,9 +78,6 @@
87
78
  padding-left: var(--UT-richText-list-indent);
88
79
  }
89
80
 
90
- // Separación entre bloques hermanos del documento (párrafo ↔ párrafo,
91
- // párrafo ↔ lista). Solo hijos directos: los párrafos dentro de un li no
92
- // llevan margen.
93
81
  > * + * {
94
82
  margin-top: var(--UT-richText-block-gap);
95
83
  }
@@ -107,14 +95,14 @@
107
95
  text-decoration: underline;
108
96
  }
109
97
 
110
- // --- Estilos de tabla ---
111
- // Applies only to tables rendered inside the editor (not in email output, which uses
112
- // inline styles via the `style` attribute set by buildTableNode / EnergyTable*).
113
-
114
- // Wrapper generado por Tiptap cuando resizable:true. Scroll horizontal cuando la
115
- // tabla supera el ancho del contenedor.
116
98
  :global(.tableWrapper) {
117
99
  overflow-x: auto;
100
+ overflow-y: hidden;
101
+ // sass-lint 1.12 es anterior a estas dos propiedades y las lee como mal escritas.
102
+ // sass-lint:disable no-misspelled-properties
103
+ scrollbar-color: var(--light04) transparent;
104
+ scrollbar-width: thin;
105
+ // sass-lint:enable no-misspelled-properties
118
106
 
119
107
  & + * {
120
108
  margin-top: var(--UT-textEditor-block-gap, 8px);
@@ -192,8 +180,6 @@
192
180
  }
193
181
  }
194
182
 
195
- // Column resize handle — spans the full column height by extending beyond the cell
196
- // boundaries with large top/bottom values (td/th don't clip overflow by default).
197
183
  :global(.column-resize-handle) {
198
184
  background-color: var(--actionAccent04);
199
185
  bottom: -9999px;
@@ -207,12 +193,10 @@
207
193
  z-index: 10;
208
194
  }
209
195
 
210
- // Cursor de redimensionado activo.
211
196
  :global(.resize-cursor) {
212
197
  cursor: col-resize;
213
198
  }
214
199
 
215
- // Tiptap selection highlight on cells.
216
200
  .selectedCell {
217
201
  &::after {
218
202
  background: var(--actionAccent01);
@@ -224,9 +208,6 @@
224
208
  }
225
209
  }
226
210
 
227
- // Única clase global necesaria: la genera la extensión Placeholder de Tiptap,
228
- // así que CSS Modules la hashearía y la regla no aplicaría. Va anidada dentro
229
- // de .editorContent, así que no se filtra fuera del editor.
230
211
  :global(.is-editor-empty) {
231
212
  &:first-child {
232
213
  &::before {
@@ -1 +1 @@
1
- import{generateHTML}from"@tiptap/html";import isEmpty from"lodash/isEmpty";import{buildBaseExtensions}from"../constants.js";import{dedupeExtensions}from"../utils.js";import{buildModuleGroups}from"./moduleResolution.js";const TABLE_EMAIL_STYLE="border-collapse: collapse; width: 100%; border-spacing: 0;",HEADER_CELL_EMAIL_STYLE="border: 1px solid #CCCCCC; padding: 8px 12px; text-align: left; font-family: inherit; font-weight: 600; background-color: #F5F5F5;",DATA_CELL_EMAIL_STYLE="border: 1px solid #CCCCCC; padding: 8px 12px; text-align: left; font-family: inherit;",buildParagraph=t=>({type:"paragraph",content:t?[{type:"text",text:String(t)}]:[]}),PARAGRAPH_SEPARATOR=/(?:\r?\n){2,}/,LINE_SEPARATOR=/\r?\n/,buildEmptyParagraph=()=>({type:"paragraph"}),buildParagraphContent=t=>t.split(LINE_SEPARATOR).flatMap((t,e)=>[...e>0?[{type:"hardBreak"}]:[],...t?[{type:"text",text:t}]:[]]);export const buildParagraphNodes=t=>t?t.split(PARAGRAPH_SEPARATOR).map(t=>{const e=buildParagraphContent(t);return isEmpty(e)?buildEmptyParagraph():{type:"paragraph",content:e}}):[buildEmptyParagraph()];export const buildTableNode=t=>{let{headers:e,rows:o,cellColwidth:a}=t;return{type:"table",attrs:{style:TABLE_EMAIL_STYLE},content:[{type:"tableRow",content:e.map(t=>({type:"tableHeader",attrs:{colspan:1,colwidth:a?[a]:null,rowspan:1,style:HEADER_CELL_EMAIL_STYLE},content:[buildParagraph(t)]}))},...o.map(t=>({type:"tableRow",content:t.map(t=>({type:"tableCell",attrs:{colspan:1,colwidth:a?[a]:null,rowspan:1,style:DATA_CELL_EMAIL_STYLE},content:[buildParagraph(t)]}))}))]}};export const buildSerializationExtensions=function(){let{moduleConfig:t,modules:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return dedupeExtensions([...buildBaseExtensions({}),...buildModuleGroups(e,t).flat().flatMap(t=>t.resolvedExtensions)])};export const serializeToHTML=function(t){let{moduleConfig:e,modules:o}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return generateHTML(t,buildSerializationExtensions({moduleConfig:e,modules:o}))};
1
+ import{getSchema}from"@tiptap/core";import{generateHTML,generateJSON}from"@tiptap/html";import isEmpty from"lodash/isEmpty";import{buildBaseExtensions}from"../constants.js";import{dedupeExtensions}from"../utils.js";import{buildModuleGroups}from"./moduleResolution.js";export const buildSerializationExtensions=function(){let{moduleConfig:e,modules:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return dedupeExtensions([...buildBaseExtensions({}),...buildModuleGroups(t,e).flat().flatMap(e=>e.resolvedExtensions)])};const buildEmptyParagraph=()=>({type:"paragraph"}),buildPlainInlineContent=e=>e?[{type:"text",text:e}]:[],buildInlineNodes=(e,t)=>(e||[]).reduce((e,n)=>{var o;if("text"===n.type||null!==(o=t.nodes[n.type])&&void 0!==o&&o.isInline)return[...e,n];const l=buildInlineNodes(n.content,t);return isEmpty(l)?e:isEmpty(e)?l:[...e,{type:"hardBreak"},...l]},[]),buildInlineHTMLContent=(e,t)=>{let{extensions:n,schema:o}=t;if(!e)return[];const{content:l}=generateJSON("<p>".concat(e,"</p>"),n);return buildInlineNodes(l,o)},buildInlineContentResolver=function(){let{inlineHTML:e,moduleConfig:t,modules:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e)return buildPlainInlineContent;const o=buildSerializationExtensions({moduleConfig:t,modules:n}),l=getSchema(o);return e=>buildInlineHTMLContent(e,{extensions:o,schema:l})},PARAGRAPH_SEPARATOR=/(?:\r?\n){2,}/,LINE_SEPARATOR=/\r?\n/,buildParagraphContent=(e,t)=>e.split(LINE_SEPARATOR).map(t).reduce((e,t)=>isEmpty(t)?e:isEmpty(e)?t:[...e,{type:"hardBreak"},...t],[]);export const buildParagraphNodes=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return[buildEmptyParagraph()];const n=buildInlineContentResolver(t);return e.split(PARAGRAPH_SEPARATOR).map(e=>{const t=buildParagraphContent(e,n);return isEmpty(t)?buildEmptyParagraph():{type:"paragraph",content:t}})};export const buildNodesFromHTML=function(e){let{moduleConfig:t,modules:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return[buildEmptyParagraph()];const{content:o}=generateJSON(e,buildSerializationExtensions({moduleConfig:t,modules:n}));return isEmpty(o)?[buildEmptyParagraph()]:o};const TABLE_HEADER_TYPE="tableHeader",TABLE_EMAIL_STYLE="border-collapse: collapse; width: 100%; border-spacing: 0;",HEADER_CELL_EMAIL_STYLE="border: 1px solid #CCCCCC; padding: 8px 12px; text-align: left; font-family: inherit; font-weight: 600; background-color: #F5F5F5;",DATA_CELL_EMAIL_STYLE="border: 1px solid #CCCCCC; padding: 8px 12px; text-align: left; font-family: inherit;",buildParagraph=(e,t)=>({type:"paragraph",content:e?t(String(e)):[]});export const buildTableNode=e=>{let{cellColwidth:t,headers:n,inlineHTML:o,moduleConfig:l,modules:i,rows:r}=e;const a=buildInlineContentResolver({inlineHTML:o,moduleConfig:l,modules:i});return{type:"table",attrs:{style:TABLE_EMAIL_STYLE},content:[{type:"tableRow",content:n.map(e=>({type:"tableHeader",attrs:{colspan:1,colwidth:t?[t]:null,rowspan:1,style:HEADER_CELL_EMAIL_STYLE},content:[buildParagraph(e,a)]}))},...r.map(e=>({type:"tableRow",content:e.map(e=>({type:"tableCell",attrs:{colspan:1,colwidth:t?[t]:null,rowspan:1,style:DATA_CELL_EMAIL_STYLE},content:[buildParagraph(e,a)]}))}))]}};const serializeInlineContent=(e,t)=>(e||[]).map(e=>generateHTML({type:"doc",content:[e]},t).replace(/^<p>|<\/p>$/g,"")).filter(Boolean).join("<br>");export const readTableNode=function(e){var t;let{moduleConfig:n,modules:o}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const l=buildSerializationExtensions({moduleConfig:n,modules:o}),i=e=>serializeInlineContent(e.content,l),r=(null==e?void 0:e.content)||[],a="tableHeader"===(null===(t=r[0])||void 0===t||null===(t=t.content)||void 0===t||null===(t=t[0])||void 0===t?void 0:t.type),[d,s]=a?[r[0],r.slice(1)]:[null,r],u=((null==d?void 0:d.content)||[]).map(e=>{var t;return null===(t=e.attrs)||void 0===t||null===(t=t.colwidth)||void 0===t?void 0:t[0]}),[p]=u;return{cellColwidth:u.every(e=>e===p)&&null!=p?p:void 0,headers:((null==d?void 0:d.content)||[]).map(i),inlineHTML:!0,rows:s.map(e=>(e.content||[]).map(i))}};export const serializeToHTML=function(e){let{moduleConfig:t,modules:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return generateHTML(e,buildSerializationExtensions({moduleConfig:t,modules:n}))};
@@ -0,0 +1 @@
1
+ import{buildNodesFromHTML}from"./contentBuilders.js";const PARAGRAPH_SEPARATOR=/(?:\r?\n){2,}/,LINE_SEPARATOR=/\r?\n/,BULLET_MARKER=/^\s*[-*+]\s+/,ORDERED_MARKER=/^\s*\d+[.)]\s+/,HTML_ESCAPES={"&":"&amp;","<":"&lt;",">":"&gt;"},BACKSLASH_ESCAPES={"*":"&#42;","[":"&#91;","\\":"&#92;","]":"&#93;",_:"&#95;","`":"&#96;"},INLINE_RULES=[{pattern:/\*\*(?=\S)([\s\S]*?\S)\*\*/g,replacement:"<strong>$1</strong>"},{pattern:/(^|\s)__(?=\S)([\s\S]*?\S)__(?=\s|$|[.,;:!?)])/g,replacement:"$1<strong>$2</strong>"},{pattern:/(^|[\s(])\*(?=\S)([^*]*\S)\*(?=\s|$|[.,;:!?)])/g,replacement:"$1<em>$2</em>"},{pattern:/(^|\s)_(?=\S)([^_]*\S)_(?=\s|$|[.,;:!?)])/g,replacement:"$1<em>$2</em>"},{pattern:/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g,replacement:'<a href="$2">$1</a>'}],buildInlineHTML=e=>INLINE_RULES.reduce((e,t)=>{let{pattern:n,replacement:l}=t;return e.replace(n,l)},e.replace(/&(?!#?\w+;)|[<>]/g,e=>HTML_ESCAPES[e]).replace(/\\([*_[\]`\\])/g,(e,t)=>BACKSLASH_ESCAPES[t])),buildLineGroups=e=>e.reduce((e,t)=>{const n=(BULLET_MARKER.test(t)?"ul":ORDERED_MARKER.test(t)&&"ol")||"p",l=e[e.length-1];return(null==l?void 0:l.tag)===n?l.lines.push(t):e.push({lines:[t],tag:n}),e},[]),buildGroupHTML=e=>{var t;let{lines:n,tag:l}=e;if("p"===l){const e=n.map(e=>buildInlineHTML(e.trim())).filter(Boolean).join("<br>");return e?"<p>".concat(e,"</p>"):""}const r="ul"===l?BULLET_MARKER:ORDERED_MARKER,o=n.map(e=>"<li>".concat(buildInlineHTML(e.replace(r,"").trim()),"</li>")),s="ol"===l?Number(null===(t=n[0].match(/\d+/))||void 0===t?void 0:t[0]):null,a=s>1?' start="'.concat(s,'"'):"";return"<".concat(l).concat(a,">").concat(o.join(""),"</").concat(l,">")};export const buildNodesFromMarkdown=function(e){let{moduleConfig:t,modules:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const l=(e||"").split(PARAGRAPH_SEPARATOR).flatMap(e=>buildLineGroups(e.split(LINE_SEPARATOR)).map(buildGroupHTML)).filter(Boolean).join("");return buildNodesFromHTML(l,{moduleConfig:t,modules:n})};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widergy/energy-ui",
3
- "version": "3.183.0",
3
+ "version": "3.184.0",
4
4
  "description": "Widergy Web Components",
5
5
  "author": "widergy",
6
6
  "license": "MIT",