@sveltia/ui 0.78.3 → 0.78.4
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CodeExtension,
|
|
2
3
|
CodeHighlightNode,
|
|
3
4
|
CodeNode,
|
|
4
5
|
$createCodeNode as createCodeNode,
|
|
@@ -6,7 +7,7 @@ import {
|
|
|
6
7
|
$isCodeNode as isCodeNode,
|
|
7
8
|
} from '@lexical/code-core';
|
|
8
9
|
import { registerDragonSupport } from '@lexical/dragon';
|
|
9
|
-
import { HorizontalRuleNode } from '@lexical/extension';
|
|
10
|
+
import { buildEditorFromExtensions, HorizontalRuleNode } from '@lexical/extension';
|
|
10
11
|
import { createEmptyHistoryState, registerHistory } from '@lexical/history';
|
|
11
12
|
import {
|
|
12
13
|
$isLinkNode as isLinkNode,
|
|
@@ -41,6 +42,7 @@ import {
|
|
|
41
42
|
COMMAND_PRIORITY_LOW,
|
|
42
43
|
COMMAND_PRIORITY_NORMAL,
|
|
43
44
|
createEditor,
|
|
45
|
+
defineExtension,
|
|
44
46
|
DELETE_CHARACTER_COMMAND,
|
|
45
47
|
$createParagraphNode as createParagraphNode,
|
|
46
48
|
$createTextNode as createTextNode,
|
|
@@ -87,7 +89,7 @@ import { HR } from './transformers/hr.js';
|
|
|
87
89
|
import { TABLE } from './transformers/table.js';
|
|
88
90
|
|
|
89
91
|
/**
|
|
90
|
-
* @import {
|
|
92
|
+
* @import { LexicalEditor } from 'lexical';
|
|
91
93
|
* @import { Transformer } from '@lexical/markdown';
|
|
92
94
|
* @import {
|
|
93
95
|
* TextEditorBlockType,
|
|
@@ -540,9 +542,14 @@ export const initEditor = ({
|
|
|
540
542
|
isCodeEditor = false,
|
|
541
543
|
defaultLanguage = 'plain',
|
|
542
544
|
}) => {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
+
const hasCodeBlock = enabledButtons.includes('code-block') || isCodeEditor;
|
|
546
|
+
|
|
547
|
+
const editorExtension = defineExtension({
|
|
548
|
+
name: '@sveltia/ui/editor',
|
|
545
549
|
namespace: 'editor',
|
|
550
|
+
// `CodeNode` expects the editor to be built with `CodeExtension`, which also registers the
|
|
551
|
+
// `CodeNode` and `CodeHighlightNode` nodes
|
|
552
|
+
dependencies: hasCodeBlock ? [CodeExtension] : [],
|
|
546
553
|
nodes: [
|
|
547
554
|
...components.map(({ node }) => node),
|
|
548
555
|
...new Set(
|
|
@@ -557,7 +564,15 @@ export const initEditor = ({
|
|
|
557
564
|
[HorizontalRuleNode, TableNode, TableCellNode, TableRowNode]),
|
|
558
565
|
],
|
|
559
566
|
theme: EDITOR_THEME,
|
|
560
|
-
|
|
567
|
+
/**
|
|
568
|
+
* Log an error like `createEditor` does by default, instead of throwing it.
|
|
569
|
+
* @param {Error} error Error.
|
|
570
|
+
*/
|
|
571
|
+
onError: (error) => {
|
|
572
|
+
// eslint-disable-next-line no-console
|
|
573
|
+
console.error(error);
|
|
574
|
+
},
|
|
575
|
+
});
|
|
561
576
|
|
|
562
577
|
/** @type {Transformer[]} */
|
|
563
578
|
const enabledTransformers = [
|
|
@@ -573,7 +588,7 @@ export const initEditor = ({
|
|
|
573
588
|
[HR, TABLE]),
|
|
574
589
|
];
|
|
575
590
|
|
|
576
|
-
const editor =
|
|
591
|
+
const editor = buildEditorFromExtensions(editorExtension);
|
|
577
592
|
/** @type {Array<() => void>} */
|
|
578
593
|
const unregisters = [];
|
|
579
594
|
|
|
@@ -661,7 +676,7 @@ export const initEditor = ({
|
|
|
661
676
|
addUnregister(registerMarkdownShortcuts(editor, enabledTransformers));
|
|
662
677
|
}
|
|
663
678
|
|
|
664
|
-
if (
|
|
679
|
+
if (hasCodeBlock) {
|
|
665
680
|
addUnregister(
|
|
666
681
|
registerCodeHighlighting(editor, {
|
|
667
682
|
...shikiTokenizer,
|
|
@@ -876,6 +891,7 @@ export const initEditor = ({
|
|
|
876
891
|
*/
|
|
877
892
|
dispose: () => {
|
|
878
893
|
unregisters.forEach((unregister) => unregister());
|
|
894
|
+
editor.dispose();
|
|
879
895
|
},
|
|
880
896
|
};
|
|
881
897
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltia/ui",
|
|
3
|
-
"version": "0.78.
|
|
3
|
+
"version": "0.78.4",
|
|
4
4
|
"description": "A collection of Svelte components and utilities for building user interfaces.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -43,22 +43,22 @@
|
|
|
43
43
|
"!dist/test-utils"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@lexical/code-core": "^0.
|
|
47
|
-
"@lexical/dragon": "^0.
|
|
48
|
-
"@lexical/extension": "^0.
|
|
49
|
-
"@lexical/history": "^0.
|
|
50
|
-
"@lexical/link": "^0.
|
|
51
|
-
"@lexical/list": "^0.
|
|
52
|
-
"@lexical/markdown": "^0.
|
|
53
|
-
"@lexical/rich-text": "^0.
|
|
54
|
-
"@lexical/selection": "^0.
|
|
55
|
-
"@lexical/table": "^0.
|
|
56
|
-
"@lexical/utils": "^0.
|
|
46
|
+
"@lexical/code-core": "^0.52.0",
|
|
47
|
+
"@lexical/dragon": "^0.52.0",
|
|
48
|
+
"@lexical/extension": "^0.52.0",
|
|
49
|
+
"@lexical/history": "^0.52.0",
|
|
50
|
+
"@lexical/link": "^0.52.0",
|
|
51
|
+
"@lexical/list": "^0.52.0",
|
|
52
|
+
"@lexical/markdown": "^0.52.0",
|
|
53
|
+
"@lexical/rich-text": "^0.52.0",
|
|
54
|
+
"@lexical/selection": "^0.52.0",
|
|
55
|
+
"@lexical/table": "^0.52.0",
|
|
56
|
+
"@lexical/utils": "^0.52.0",
|
|
57
57
|
"@shikijs/langs": "4.4.3",
|
|
58
58
|
"@shikijs/themes": "4.4.3",
|
|
59
59
|
"@sveltia/i18n": "^1.4.0",
|
|
60
60
|
"@sveltia/utils": "^0.12.2",
|
|
61
|
-
"lexical": "^0.
|
|
61
|
+
"lexical": "^0.52.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@fontsource-variable/material-symbols-outlined": "5.3.8",
|
|
@@ -71,17 +71,17 @@
|
|
|
71
71
|
"@sveltejs/vite-plugin-svelte": "^7.3.1",
|
|
72
72
|
"@vitest/browser-playwright": "^5.0.2",
|
|
73
73
|
"@vitest/coverage-v8": "^5.0.2",
|
|
74
|
-
"cspell": "^10.3.
|
|
74
|
+
"cspell": "^10.3.5",
|
|
75
75
|
"eslint": "^9.39.5",
|
|
76
76
|
"eslint-config-airbnb-extended": "^3.2.0",
|
|
77
77
|
"eslint-config-prettier": "^10.1.8",
|
|
78
78
|
"eslint-plugin-import": "^2.32.0",
|
|
79
|
-
"eslint-plugin-jsdoc": "^
|
|
80
|
-
"eslint-plugin-package-json": "^1.10.
|
|
79
|
+
"eslint-plugin-jsdoc": "^65.0.0",
|
|
80
|
+
"eslint-plugin-package-json": "^1.10.1",
|
|
81
81
|
"eslint-plugin-svelte": "^3.23.0",
|
|
82
82
|
"globals": "^17.12.0",
|
|
83
83
|
"happy-dom": "^20.14.5",
|
|
84
|
-
"oxlint": "^1.
|
|
84
|
+
"oxlint": "^1.86.0",
|
|
85
85
|
"playwright": "^1.63.0",
|
|
86
86
|
"postcss": "^8.5.28",
|
|
87
87
|
"postcss-html": "^2.0.0",
|