5htp-core 0.6.0-82 → 0.6.0-83
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 +1 -1
- package/server/utils/rte.ts +44 -16
- package/types/icons.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "5htp-core",
|
|
3
3
|
"description": "Convenient TypeScript framework designed for Performance and Productivity.",
|
|
4
|
-
"version": "0.6.0-
|
|
4
|
+
"version": "0.6.0-83",
|
|
5
5
|
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
6
|
"repository": "git://github.com/gaetanlegac/5htp-core.git",
|
|
7
7
|
"license": "MIT",
|
package/server/utils/rte.ts
CHANGED
|
@@ -346,24 +346,52 @@ export class RteUtils {
|
|
|
346
346
|
return html;
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
-
private jsonToText(
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
349
|
+
private jsonToText(root: LexicalNode): string {
|
|
350
|
+
let result = '';
|
|
351
|
+
|
|
352
|
+
function traverse(node: LexicalNode) {
|
|
353
|
+
switch (node.type) {
|
|
354
|
+
case 'text':
|
|
355
|
+
// Leaf text node
|
|
356
|
+
result += node.text ?? '';
|
|
357
|
+
break;
|
|
358
|
+
case 'linebreak':
|
|
359
|
+
// Explicit line break node
|
|
360
|
+
result += '\n';
|
|
361
|
+
break;
|
|
362
|
+
default:
|
|
363
|
+
// Container or block node: dive into children if any
|
|
364
|
+
if (node.children) {
|
|
365
|
+
node.children.forEach(traverse);
|
|
366
|
+
}
|
|
367
|
+
// After finishing a block-level node, append newline
|
|
368
|
+
if (isBlockNode(node.type)) {
|
|
369
|
+
result += '\n';
|
|
370
|
+
}
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
356
373
|
}
|
|
357
|
-
|
|
358
|
-
//
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
374
|
+
|
|
375
|
+
// Heuristic: treat these as blocks
|
|
376
|
+
function isBlockNode(type: string): boolean {
|
|
377
|
+
return [
|
|
378
|
+
'root',
|
|
379
|
+
'paragraph',
|
|
380
|
+
'heading',
|
|
381
|
+
'listitem',
|
|
382
|
+
'unorderedlist',
|
|
383
|
+
'orderedlist',
|
|
384
|
+
'quote',
|
|
385
|
+
'codeblock',
|
|
386
|
+
'table',
|
|
387
|
+
].includes(type);
|
|
363
388
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
389
|
+
|
|
390
|
+
traverse(root);
|
|
391
|
+
|
|
392
|
+
// Trim trailing whitespace/newlines
|
|
393
|
+
return result.replace(/\s+$/, '');
|
|
394
|
+
}
|
|
367
395
|
|
|
368
396
|
public async htmlToJson(htmlString: string): Promise<LexicalState> {
|
|
369
397
|
|
package/types/icons.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type TIcones = "times"|"solid/spinner-third"|"long-arrow-right"|"sack-dollar"|"bell"|"bullseye"|"project-diagram"|"user-friends"|"eye"|"lock"|"comments"|"phone"|"chalkboard-teacher"|"rocket"|"chart-bar"|"user-circle"|"crosshairs"|"
|
|
1
|
+
export type TIcones = "times"|"solid/spinner-third"|"long-arrow-right"|"sack-dollar"|"bell"|"bullseye"|"project-diagram"|"user-friends"|"eye"|"lock"|"comments"|"phone"|"chalkboard-teacher"|"rocket"|"chart-bar"|"user-circle"|"crosshairs"|"user-shield"|"shield-alt"|"chart-line"|"money-bill-wave"|"star"|"link"|"file-alt"|"long-arrow-left"|"arrow-right"|"plus-circle"|"comments-alt"|"key"|"user"|"at"|"user-plus"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"magnet"|"paper-plane"|"plus"|"binoculars"|"brands/linkedin"|"clock"|"cog"|"trash"|"ellipsis-h"|"times-circle"|"search"|"lightbulb"|"calendar-alt"|"angle-up"|"angle-down"|"solid/crown"|"brands/discord"|"pen"|"file"|"envelope"|"coins"|"download"|"check"|"meh-rolling-eyes"|"arrow-left"|"info-circle"|"check-circle"|"exclamation-circle"|"bars"|"solid/star"|"solid/star-half-alt"|"regular/star"|"chevron-left"|"power-off"|"plane-departure"|"brands/whatsapp"|"wind"|"play"|"minus-circle"|"broom"|"exclamation-triangle"|"external-link"|"solid/check-circle"|"solid/exclamation-triangle"|"solid/times-circle"|"question-circle"|"minus"|"comment-alt"|"map-marker-alt"|"arrow-to-bottom"|"solid/magic"|"users"|"industry"|"map-marker"|"calendar"|"briefcase"|"fire"|"globe"|"magic"|"bug"|"building"|"graduation-cap"|"coin"|"unlink"|"bold"|"italic"|"underline"|"strikethrough"|"subscript"|"superscript"|"code"|"font"|"empty-set"|"horizontal-rule"|"page-break"|"image"|"table"|"poll"|"columns"|"sticky-note"|"caret-right"|"align-left"|"align-center"|"align-right"|"align-justify"|"indent"|"outdent"|"list-ul"|"check-square"|"h1"|"h2"|"h3"|"h4"|"list-ol"|"paragraph"|"quote-left"
|