@sveltia/ui 0.31.12 → 0.32.1
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/components/text-editor/core.js +5 -9
- package/dist/components/text-editor/lexical-root.svelte +12 -0
- package/dist/components/text-editor/markdown.d.ts +0 -1
- package/dist/components/text-editor/markdown.js +0 -14
- package/dist/components/text-editor/transformers/hr.d.ts +8 -0
- package/dist/components/text-editor/transformers/hr.js +34 -0
- package/package.json +24 -22
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
registerCodeHighlighting,
|
|
9
9
|
} from '@lexical/code';
|
|
10
10
|
import { registerDragonSupport } from '@lexical/dragon';
|
|
11
|
+
import { HorizontalRuleNode } from '@lexical/extension';
|
|
11
12
|
import { createEmptyHistoryState, registerHistory } from '@lexical/history';
|
|
12
13
|
import {
|
|
13
14
|
LinkNode,
|
|
@@ -53,11 +54,8 @@ import {
|
|
|
53
54
|
} from 'lexical';
|
|
54
55
|
import prismComponents from 'prismjs/components';
|
|
55
56
|
import { BLOCK_BUTTON_TYPES, TEXT_FORMAT_BUTTON_TYPES } from './constants.js';
|
|
56
|
-
import {
|
|
57
|
-
|
|
58
|
-
increaseListIndentation,
|
|
59
|
-
splitMultilineFormatting,
|
|
60
|
-
} from './markdown.js';
|
|
57
|
+
import { increaseListIndentation, splitMultilineFormatting } from './markdown.js';
|
|
58
|
+
import { HR } from './transformers/hr.js';
|
|
61
59
|
import { TABLE } from './transformers/table.js';
|
|
62
60
|
|
|
63
61
|
/**
|
|
@@ -70,7 +68,7 @@ import { TABLE } from './transformers/table.js';
|
|
|
70
68
|
* } from '../../typedefs';
|
|
71
69
|
*/
|
|
72
70
|
|
|
73
|
-
const allTransformers = [...TRANSFORMERS, TABLE];
|
|
71
|
+
const allTransformers = [...TRANSFORMERS, HR, TABLE];
|
|
74
72
|
const prismBaseURL = `https://unpkg.com/prismjs@1.30.0`;
|
|
75
73
|
|
|
76
74
|
/**
|
|
@@ -87,6 +85,7 @@ const editorConfig = {
|
|
|
87
85
|
ListItemNode,
|
|
88
86
|
CodeNode,
|
|
89
87
|
CodeHighlightNode,
|
|
88
|
+
HorizontalRuleNode,
|
|
90
89
|
TableNode,
|
|
91
90
|
TableCellNode,
|
|
92
91
|
TableRowNode,
|
|
@@ -417,9 +416,6 @@ export const convertMarkdownToLexical = async (editor, value) => {
|
|
|
417
416
|
// Split multiline formatting into separate lines to prevent Markdown parsing issues
|
|
418
417
|
value = splitMultilineFormatting(value);
|
|
419
418
|
|
|
420
|
-
// Fix unclosed formatting markers (work around Lexical bug)
|
|
421
|
-
value = fixMarkdownFormatting(value);
|
|
422
|
-
|
|
423
419
|
// Increase list indentation levels to prevent Markdown parsing issues
|
|
424
420
|
value = increaseListIndentation(value);
|
|
425
421
|
|
|
@@ -204,6 +204,18 @@
|
|
|
204
204
|
white-space: normal;
|
|
205
205
|
word-break: normal;
|
|
206
206
|
}
|
|
207
|
+
.lexical-root :global(hr) {
|
|
208
|
+
margin: var(--sui-paragraph-margin) 0;
|
|
209
|
+
border: none;
|
|
210
|
+
padding: 0;
|
|
211
|
+
}
|
|
212
|
+
.lexical-root :global(hr::after) {
|
|
213
|
+
display: block;
|
|
214
|
+
height: 2px;
|
|
215
|
+
background-color: var(--sui-control-border-color);
|
|
216
|
+
line-height: 2px;
|
|
217
|
+
content: "";
|
|
218
|
+
}
|
|
207
219
|
|
|
208
220
|
:root[data-theme=light] .lexical-root :global(.token:is(.comment, .prolog, .doctype, .cdata)) {
|
|
209
221
|
color: slategray;
|
|
@@ -11,20 +11,6 @@ export const splitMultilineFormatting = (value) =>
|
|
|
11
11
|
.replace(/(\s+)~~([^~\n]+?)\n([^~\n]+?)~~(\s+)/gm, '$1~~$2~~\n~~$3~~$4')
|
|
12
12
|
.replace(/(\s+)`([^`\n]+?)\n([^`\n]+?)`(\s+)/gm, '$1`$2`\n`$3`$4');
|
|
13
13
|
|
|
14
|
-
/**
|
|
15
|
-
* Fix malformed Markdown formatting markers.
|
|
16
|
-
* Converts unclosed formatting markers like `**foo **bar` to `**foo** bar`.
|
|
17
|
-
* This works around a Lexical bug with certain formatting patterns.
|
|
18
|
-
* @param {string} value Markdown string to fix.
|
|
19
|
-
* @returns {string} Fixed Markdown string.
|
|
20
|
-
* @see https://github.com/sveltia/sveltia-cms/issues/599
|
|
21
|
-
*/
|
|
22
|
-
export const fixMarkdownFormatting = (value) =>
|
|
23
|
-
value
|
|
24
|
-
.replace(/\*\*(\S+?) \*\*/gm, '**$1** ')
|
|
25
|
-
.replace(/_(\S+?) _/gm, '_$1_ ')
|
|
26
|
-
.replace(/~~(\S+?) ~~/gm, '~~$1~~ ');
|
|
27
|
-
|
|
28
14
|
/**
|
|
29
15
|
* Increase list indentation levels to prevent Markdown parsing issues.
|
|
30
16
|
* Slate uses 2 spaces per indentation level, whereas Lexical uses 4 spaces.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Adopted from https://github.com/facebook/lexical/blob/main/packages/lexical-playground/src/plugins/MarkdownTransformers/index.ts
|
|
2
|
+
|
|
3
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
$createHorizontalRuleNode,
|
|
7
|
+
$isHorizontalRuleNode,
|
|
8
|
+
HorizontalRuleNode,
|
|
9
|
+
} from '@lexical/extension';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @import { ElementTransformer } from '@lexical/markdown';
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @type {ElementTransformer}
|
|
17
|
+
*/
|
|
18
|
+
export const HR = {
|
|
19
|
+
dependencies: [HorizontalRuleNode],
|
|
20
|
+
export: (node) => ($isHorizontalRuleNode(node) ? '***' : null),
|
|
21
|
+
regExp: /^(---|\*\*\*|___)\s?$/,
|
|
22
|
+
replace: (parentNode, _1, _2, isImport) => {
|
|
23
|
+
const line = $createHorizontalRuleNode();
|
|
24
|
+
|
|
25
|
+
if (isImport || parentNode.getNextSibling() !== null) {
|
|
26
|
+
parentNode.replace(line);
|
|
27
|
+
} else {
|
|
28
|
+
parentNode.insertBefore(line);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
line.selectNext();
|
|
32
|
+
},
|
|
33
|
+
type: 'element',
|
|
34
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltia/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -8,18 +8,19 @@
|
|
|
8
8
|
"url": "github:sveltia/sveltia-ui"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@lexical/code": "^0.
|
|
12
|
-
"@lexical/dragon": "^0.
|
|
13
|
-
"@lexical/
|
|
14
|
-
"@lexical/
|
|
15
|
-
"@lexical/
|
|
16
|
-
"@lexical/
|
|
17
|
-
"@lexical/
|
|
18
|
-
"@lexical/
|
|
19
|
-
"@lexical/
|
|
20
|
-
"@lexical/
|
|
11
|
+
"@lexical/code": "^0.40.0",
|
|
12
|
+
"@lexical/dragon": "^0.40.0",
|
|
13
|
+
"@lexical/extension": "^0.40.0",
|
|
14
|
+
"@lexical/history": "^0.40.0",
|
|
15
|
+
"@lexical/link": "^0.40.0",
|
|
16
|
+
"@lexical/list": "^0.40.0",
|
|
17
|
+
"@lexical/markdown": "^0.40.0",
|
|
18
|
+
"@lexical/rich-text": "^0.40.0",
|
|
19
|
+
"@lexical/selection": "^0.40.0",
|
|
20
|
+
"@lexical/table": "^0.40.0",
|
|
21
|
+
"@lexical/utils": "^0.40.0",
|
|
21
22
|
"@sveltia/utils": "^0.8.6",
|
|
22
|
-
"lexical": "^0.
|
|
23
|
+
"lexical": "^0.40.0",
|
|
23
24
|
"prismjs": "^1.30.0",
|
|
24
25
|
"svelte-i18n": "^4.0.1"
|
|
25
26
|
},
|
|
@@ -28,31 +29,32 @@
|
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@sveltejs/adapter-auto": "^7.0.0",
|
|
31
|
-
"@sveltejs/kit": "^2.50.
|
|
32
|
+
"@sveltejs/kit": "^2.50.2",
|
|
32
33
|
"@sveltejs/package": "^2.5.7",
|
|
33
34
|
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
|
34
|
-
"
|
|
35
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
36
|
+
"cspell": "^9.6.4",
|
|
35
37
|
"eslint": "^8.57.1",
|
|
36
38
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
37
39
|
"eslint-config-prettier": "^10.1.8",
|
|
38
40
|
"eslint-plugin-import": "^2.32.0",
|
|
39
|
-
"eslint-plugin-jsdoc": "^62.
|
|
41
|
+
"eslint-plugin-jsdoc": "^62.5.1",
|
|
40
42
|
"eslint-plugin-svelte": "^2.46.1",
|
|
41
|
-
"oxlint": "^1.
|
|
43
|
+
"oxlint": "^1.43.0",
|
|
42
44
|
"postcss": "^8.5.6",
|
|
43
45
|
"postcss-html": "^1.8.1",
|
|
44
|
-
"prettier": "^3.8.
|
|
46
|
+
"prettier": "^3.8.1",
|
|
45
47
|
"prettier-plugin-svelte": "^3.4.1",
|
|
46
|
-
"sass": "^1.97.
|
|
47
|
-
"stylelint": "^17.
|
|
48
|
+
"sass": "^1.97.3",
|
|
49
|
+
"stylelint": "^17.1.1",
|
|
48
50
|
"stylelint-config-recommended-scss": "^17.0.0",
|
|
49
51
|
"stylelint-scss": "^7.0.0",
|
|
50
|
-
"svelte": "^5.
|
|
51
|
-
"svelte-check": "^4.3.
|
|
52
|
+
"svelte": "^5.49.2",
|
|
53
|
+
"svelte-check": "^4.3.6",
|
|
52
54
|
"svelte-preprocess": "^6.0.3",
|
|
53
55
|
"tslib": "^2.8.1",
|
|
54
56
|
"vite": "^7.3.1",
|
|
55
|
-
"vitest": "^4.0.
|
|
57
|
+
"vitest": "^4.0.18"
|
|
56
58
|
},
|
|
57
59
|
"exports": {
|
|
58
60
|
".": {
|