@sveltia/ui 0.15.6 → 0.15.8

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.
@@ -11,6 +11,7 @@ import {
11
11
  INSERT_UNORDERED_LIST_COMMAND,
12
12
  ListItemNode,
13
13
  ListNode,
14
+ $handleListInsertParagraph as handleListInsertParagraph,
14
15
  insertList,
15
16
  $isListItemNode as isListItemNode,
16
17
  $isListNode as isListNode,
@@ -32,6 +33,9 @@ import { $getNearestNodeOfType as getNearestNodeOfType } from '@lexical/utils';
32
33
  import {
33
34
  COMMAND_PRIORITY_NORMAL,
34
35
  ElementNode,
36
+ INDENT_CONTENT_COMMAND,
37
+ INSERT_PARAGRAPH_COMMAND,
38
+ OUTDENT_CONTENT_COMMAND,
35
39
  createEditor,
36
40
  $getSelection as getSelection,
37
41
  $isRangeSelection as isRangeSelection,
@@ -64,6 +68,11 @@ const editorConfig = {
64
68
  */
65
69
  italic: 'italic',
66
70
  },
71
+ list: {
72
+ nested: {
73
+ listitem: 'nested',
74
+ },
75
+ },
67
76
  },
68
77
  };
69
78
 
@@ -176,6 +185,13 @@ export const initEditor = () => {
176
185
  COMMAND_PRIORITY_NORMAL,
177
186
  );
178
187
 
188
+ // https://github.com/facebook/lexical/blob/main/packages/lexical-react/src/shared/useList.ts
189
+ editor.registerCommand(
190
+ INSERT_PARAGRAPH_COMMAND,
191
+ () => handleListInsertParagraph(),
192
+ COMMAND_PRIORITY_NORMAL,
193
+ );
194
+
179
195
  editor.registerUpdateListener(({ editorState }) => {
180
196
  if (editor?.isComposing()) {
181
197
  return;
@@ -186,6 +202,39 @@ export const initEditor = () => {
186
202
  });
187
203
  });
188
204
 
205
+ // `editor.registerCommand(KEY_TAB_COMMAND, listener, priority)` doesn’t work for some reason, so
206
+ // use another method
207
+ editor.registerRootListener((root) => {
208
+ if (root) {
209
+ root.addEventListener('keydown', (event) => {
210
+ editor.update(() => {
211
+ if (event.key === 'Tab') {
212
+ const selection = getSelection();
213
+
214
+ if (!isRangeSelection(selection)) {
215
+ return;
216
+ }
217
+
218
+ const anchor = selection.anchor.getNode();
219
+
220
+ const parent =
221
+ anchor instanceof ElementNode ? anchor : getNearestNodeOfType(anchor, ElementNode);
222
+
223
+ if (isListItemNode(parent) && parent.canIndent()) {
224
+ if (!event.shiftKey) {
225
+ event.preventDefault();
226
+ editor.dispatchCommand(INDENT_CONTENT_COMMAND, undefined);
227
+ } else if (parent.getIndent() > 0) {
228
+ event.preventDefault();
229
+ editor.dispatchCommand(OUTDENT_CONTENT_COMMAND, undefined);
230
+ }
231
+ }
232
+ }
233
+ });
234
+ });
235
+ }
236
+ });
237
+
189
238
  return editor;
190
239
  };
191
240
 
@@ -133,6 +133,9 @@
133
133
  .lexical-root :global(strong.italic) {
134
134
  font-style: italic;
135
135
  }
136
+ .lexical-root :global(li.nested) {
137
+ list-style-type: none;
138
+ }
136
139
  .lexical-root :global([data-lexical-text="true"]) {
137
140
  cursor: text;
138
141
  }</style>
@@ -95,11 +95,11 @@
95
95
  * Update {@link inputValue} based on {@link value}.
96
96
  */
97
97
  const setInputValue = () => {
98
- const newValue = value ?? '';
98
+ const newValue = value;
99
99
 
100
100
  // Avoid a cycle dependency & infinite loop
101
101
  if (inputValue !== newValue) {
102
- inputValue = newValue;
102
+ inputValue = newValue ?? '';
103
103
 
104
104
  if ($useRichText) {
105
105
  convertMarkdown();
@@ -66,6 +66,11 @@
66
66
  setBlocksType(getSelection(), () => createQuoteNode());
67
67
  });
68
68
  }
69
+
70
+ // Move focus back to the editor
71
+ window.setTimeout(() => {
72
+ $editor.focus();
73
+ }, 500);
69
74
  };
70
75
  </script>
71
76
 
@@ -99,13 +99,17 @@ class Group {
99
99
  * Activate the members.
100
100
  */
101
101
  activate() {
102
- const { parent, allMembers, selected: defaultSelected } = this;
102
+ const { parent, role, allMembers, selected: defaultSelected } = this;
103
+ const multi = this.multi || role === 'menu' || role === 'menubar';
103
104
 
104
105
  allMembers.forEach((element, index) => {
105
106
  // Select the first one if no member has the `selected` attribute
106
- const isSelected = defaultSelected
107
- ? element === defaultSelected
108
- : this.selectFirst && index === 0;
107
+ // eslint-disable-next-line no-nested-ternary
108
+ const isSelected = multi
109
+ ? element.getAttribute(this.childSelectedAttr) === 'true'
110
+ : defaultSelected
111
+ ? element === defaultSelected
112
+ : this.selectFirst && index === 0;
109
113
 
110
114
  const controlTarget = /** @type {HTMLElement | null} */ (
111
115
  document.querySelector(`#${element.getAttribute('aria-controls')}`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltia/ui",
3
- "version": "0.15.6",
3
+ "version": "0.15.8",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -23,18 +23,18 @@
23
23
  "test:unit": "vitest"
24
24
  },
25
25
  "dependencies": {
26
- "@lexical/code": "^0.15.0",
27
- "@lexical/history": "^0.15.0",
28
- "@lexical/link": "^0.15.0",
29
- "@lexical/list": "^0.15.0",
30
- "@lexical/markdown": "^0.15.0",
31
- "@lexical/rich-text": "^0.15.0",
32
- "@lexical/selection": "^0.15.0",
33
- "@lexical/table": "^0.15.0",
34
- "@lexical/utils": "^0.15.0",
35
- "@sveltia/utils": "^0.3.0",
36
- "lexical": "^0.15.0",
37
- "svelte": "^4.2.17"
26
+ "@lexical/code": "^0.16.0",
27
+ "@lexical/history": "^0.16.0",
28
+ "@lexical/link": "^0.16.0",
29
+ "@lexical/list": "^0.16.0",
30
+ "@lexical/markdown": "^0.16.0",
31
+ "@lexical/rich-text": "^0.16.0",
32
+ "@lexical/selection": "^0.16.0",
33
+ "@lexical/table": "^0.16.0",
34
+ "@lexical/utils": "^0.16.0",
35
+ "@sveltia/utils": "^0.4.0",
36
+ "lexical": "^0.16.0",
37
+ "svelte": "^4.2.18"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@playwright/test": "^1.44.1",
@@ -42,27 +42,27 @@
42
42
  "@sveltejs/kit": "^2.5.10",
43
43
  "@sveltejs/package": "^2.3.1",
44
44
  "@sveltejs/vite-plugin-svelte": "^3.1.1",
45
- "cspell": "^8.8.3",
45
+ "cspell": "^8.8.4",
46
46
  "eslint": "^8.57.0",
47
47
  "eslint-config-airbnb-base": "^15.0.0",
48
48
  "eslint-config-prettier": "^9.1.0",
49
49
  "eslint-plugin-import": "^2.29.1",
50
- "eslint-plugin-jsdoc": "^48.2.7",
51
- "eslint-plugin-svelte": "^2.39.0",
50
+ "eslint-plugin-jsdoc": "^48.2.9",
51
+ "eslint-plugin-svelte": "^2.39.2",
52
52
  "npm-run-all": "^4.1.5",
53
53
  "postcss": "^8.4.38",
54
54
  "postcss-html": "^1.7.0",
55
- "prettier": "^3.3.0",
56
- "prettier-plugin-svelte": "^3.2.3",
55
+ "prettier": "^3.3.1",
56
+ "prettier-plugin-svelte": "^3.2.4",
57
57
  "sass": "^1.77.4",
58
58
  "stylelint": "^16.6.1",
59
59
  "stylelint-config-recommended-scss": "^14.0.0",
60
- "stylelint-scss": "^6.3.0",
60
+ "stylelint-scss": "^6.3.1",
61
61
  "svelte-check": "^3.8.0",
62
62
  "svelte-i18n": "^4.0.0",
63
63
  "svelte-preprocess": "^5.1.4",
64
- "tslib": "^2.6.2",
65
- "vite": "^5.2.12",
64
+ "tslib": "^2.6.3",
65
+ "vite": "^5.2.13",
66
66
  "vitest": "^1.6.0"
67
67
  },
68
68
  "exports": {