@sveltia/ui 0.79.3 → 0.80.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.
Files changed (52) hide show
  1. package/dist/components/emoji/position.d.ts +2 -1
  2. package/dist/components/emoji/position.js +11 -3
  3. package/dist/components/text-editor/constants.d.ts +9 -1
  4. package/dist/components/text-editor/constants.js +10 -1
  5. package/dist/components/text-editor/core.d.ts +4 -2
  6. package/dist/components/text-editor/core.js +152 -33
  7. package/dist/components/text-editor/floating-link-editor.svelte +685 -0
  8. package/dist/components/text-editor/floating-link-editor.svelte.d.ts +17 -0
  9. package/dist/components/text-editor/html.d.ts +18 -0
  10. package/dist/components/text-editor/html.js +407 -0
  11. package/dist/components/text-editor/shiki/version.d.ts +1 -1
  12. package/dist/components/text-editor/shiki/version.js +1 -1
  13. package/dist/components/text-editor/store.svelte.js +39 -14
  14. package/dist/components/text-editor/text-editor.svelte +43 -17
  15. package/dist/components/text-editor/text-editor.svelte.d.ts +23 -6
  16. package/dist/components/text-editor/toolbar/code-language-switcher.svelte +42 -23
  17. package/dist/components/text-editor/toolbar/insert-link-button.svelte +14 -71
  18. package/dist/components/text-editor/toolbar/text-editor-toolbar.svelte +12 -5
  19. package/dist/locales/ar.yaml +5 -1
  20. package/dist/locales/bg.yaml +5 -1
  21. package/dist/locales/ca.yaml +5 -1
  22. package/dist/locales/cs.yaml +5 -1
  23. package/dist/locales/da.yaml +5 -1
  24. package/dist/locales/de.yaml +5 -1
  25. package/dist/locales/el.yaml +5 -1
  26. package/dist/locales/en-CA.yaml +5 -1
  27. package/dist/locales/en-GB.yaml +5 -1
  28. package/dist/locales/en-US.yaml +5 -1
  29. package/dist/locales/es-CO.yaml +5 -1
  30. package/dist/locales/fa.yaml +5 -1
  31. package/dist/locales/fi.yaml +5 -1
  32. package/dist/locales/fr.yaml +5 -1
  33. package/dist/locales/he.yaml +5 -1
  34. package/dist/locales/hr.yaml +5 -1
  35. package/dist/locales/it.yaml +5 -1
  36. package/dist/locales/ja.yaml +5 -1
  37. package/dist/locales/ko.yaml +5 -1
  38. package/dist/locales/nl.yaml +5 -1
  39. package/dist/locales/pl.yaml +5 -1
  40. package/dist/locales/pt-BR.yaml +5 -1
  41. package/dist/locales/pt-PT.yaml +5 -1
  42. package/dist/locales/ru.yaml +5 -1
  43. package/dist/locales/sk.yaml +5 -1
  44. package/dist/locales/sv.yaml +5 -1
  45. package/dist/locales/tr.yaml +5 -1
  46. package/dist/locales/uk.yaml +5 -1
  47. package/dist/locales/vi.yaml +5 -1
  48. package/dist/locales/zh-CN.yaml +5 -1
  49. package/dist/locales/zh-TW.yaml +5 -1
  50. package/dist/typedefs.d.ts +19 -6
  51. package/dist/typedefs.js +15 -5
  52. package/package.json +7 -6
@@ -122,12 +122,16 @@ text_editor:
122
122
  link: リンク
123
123
  # Link dialog title
124
124
  insert_link: リンクを挿入
125
- update_link: リンクを更新
125
+ # Floating link editor button aria-labels
126
+ edit_link: リンクを編集
127
+ remove_link: リンクを削除
126
128
  # Link dialog input field labels
127
129
  text: テキスト
128
130
  url: URL
129
131
  # Markdown mode toggle button aria-label
130
132
  edit_in_markdown: マークダウンで編集
133
+ # HTML mode toggle button aria-label
134
+ edit_in_html: HTML で編集
131
135
  # Error message when rich text conversion fails
132
136
  converter_error: リッチテキストモードを有効にできませんでした。プレーンテキストエディターを使用してください。
133
137
  # Language selector aria-label
@@ -122,12 +122,16 @@ text_editor:
122
122
  link: 링크
123
123
  # Link dialog title
124
124
  insert_link: 링크 삽입
125
- update_link: 링크 업데이트
125
+ # Floating link editor button aria-labels
126
+ edit_link: 링크 편집
127
+ remove_link: 링크 제거
126
128
  # Link dialog input field labels
127
129
  text: 텍스트
128
130
  url: URL
129
131
  # Markdown mode toggle button aria-label
130
132
  edit_in_markdown: 마크다운으로 편집
133
+ # HTML mode toggle button aria-label
134
+ edit_in_html: HTML로 편집
131
135
  # Error message when rich text conversion fails
132
136
  converter_error: 리치 텍스트 모드를 사용할 수 없습니다. 일반 텍스트 에디터를 사용하십시오.
133
137
  # Language selector aria-label
@@ -122,12 +122,16 @@ text_editor:
122
122
  link: Link
123
123
  # Link dialog title
124
124
  insert_link: Link invoegen
125
- update_link: Link bijwerken
125
+ # Floating link editor button aria-labels
126
+ edit_link: Link bewerken
127
+ remove_link: Link verwijderen
126
128
  # Link dialog input field labels
127
129
  text: Tekst
128
130
  url: URL
129
131
  # Markdown mode toggle button aria-label
130
132
  edit_in_markdown: Bewerken in Markdown
133
+ # HTML mode toggle button aria-label
134
+ edit_in_html: Bewerken in HTML
131
135
  # Error message when rich text conversion fails
132
136
  converter_error: De rich-text-modus kan niet worden ingeschakeld. Gebruik in plaats daarvan de platteteksteditor.
133
137
  # Language selector aria-label
@@ -122,12 +122,16 @@ text_editor:
122
122
  link: Odnośnik
123
123
  # Link dialog title
124
124
  insert_link: Wstaw odnośnik
125
- update_link: Zaktualizuj odnośnik
125
+ # Floating link editor button aria-labels
126
+ edit_link: Edytuj odnośnik
127
+ remove_link: Usuń odnośnik
126
128
  # Link dialog input field labels
127
129
  text: Tekst
128
130
  url: URL
129
131
  # Markdown mode toggle button aria-label
130
132
  edit_in_markdown: Edytuj w Markdown
133
+ # HTML mode toggle button aria-label
134
+ edit_in_html: Edytuj w HTML
131
135
  # Error message when rich text conversion fails
132
136
  converter_error: Nie można włączyć trybu tekstu sformatowanego. Zamiast tego użyj zwykłego edytora tekstu.
133
137
  # Language selector aria-label
@@ -122,12 +122,16 @@ text_editor:
122
122
  link: Link
123
123
  # Link dialog title
124
124
  insert_link: Inserir link
125
- update_link: Atualizar link
125
+ # Floating link editor button aria-labels
126
+ edit_link: Editar link
127
+ remove_link: Remover link
126
128
  # Link dialog input field labels
127
129
  text: Texto
128
130
  url: URL
129
131
  # Markdown mode toggle button aria-label
130
132
  edit_in_markdown: Editar em Markdown
133
+ # HTML mode toggle button aria-label
134
+ edit_in_html: Editar em HTML
131
135
  # Error message when rich text conversion fails
132
136
  converter_error: Não foi possível ativar o modo de texto formatado. Use o editor de texto simples.
133
137
  # Language selector aria-label
@@ -122,12 +122,16 @@ text_editor:
122
122
  link: Ligação
123
123
  # Link dialog title
124
124
  insert_link: Inserir ligação
125
- update_link: Atualizar ligação
125
+ # Floating link editor button aria-labels
126
+ edit_link: Editar ligação
127
+ remove_link: Remover ligação
126
128
  # Link dialog input field labels
127
129
  text: Texto
128
130
  url: URL
129
131
  # Markdown mode toggle button aria-label
130
132
  edit_in_markdown: Editar em Markdown
133
+ # HTML mode toggle button aria-label
134
+ edit_in_html: Editar em HTML
131
135
  # Error message when rich text conversion fails
132
136
  converter_error: Não foi possível ativar o modo de texto formatado. Utilize o editor de texto simples.
133
137
  # Language selector aria-label
@@ -122,12 +122,16 @@ text_editor:
122
122
  link: Ссылка
123
123
  # Link dialog title
124
124
  insert_link: Вставить ссылку
125
- update_link: Обновить ссылку
125
+ # Floating link editor button aria-labels
126
+ edit_link: Изменить ссылку
127
+ remove_link: Удалить ссылку
126
128
  # Link dialog input field labels
127
129
  text: Текст
128
130
  url: URL
129
131
  # Markdown mode toggle button aria-label
130
132
  edit_in_markdown: Редактировать в Markdown
133
+ # HTML mode toggle button aria-label
134
+ edit_in_html: Редактировать в HTML
131
135
  # Error message when rich text conversion fails
132
136
  converter_error: Не удалось включить режим форматированного текста. Вместо этого используйте редактор обычного текста.
133
137
  # Language selector aria-label
@@ -122,12 +122,16 @@ text_editor:
122
122
  link: Odkaz
123
123
  # Link dialog title
124
124
  insert_link: Vložiť odkaz
125
- update_link: Aktualizovať odkaz
125
+ # Floating link editor button aria-labels
126
+ edit_link: Upraviť odkaz
127
+ remove_link: Odstrániť odkaz
126
128
  # Link dialog input field labels
127
129
  text: Text
128
130
  url: URL
129
131
  # Markdown mode toggle button aria-label
130
132
  edit_in_markdown: Upraviť v Markdowne
133
+ # HTML mode toggle button aria-label
134
+ edit_in_html: Upraviť v HTML
131
135
  # Error message when rich text conversion fails
132
136
  converter_error: Režim formátovaného textu nie je možné zapnúť. Použite namiesto neho editor obyčajného textu.
133
137
  # Language selector aria-label
@@ -122,12 +122,16 @@ text_editor:
122
122
  link: Länk
123
123
  # Link dialog title
124
124
  insert_link: Infoga länk
125
- update_link: Uppdatera länk
125
+ # Floating link editor button aria-labels
126
+ edit_link: Redigera länk
127
+ remove_link: Ta bort länk
126
128
  # Link dialog input field labels
127
129
  text: Text
128
130
  url: URL
129
131
  # Markdown mode toggle button aria-label
130
132
  edit_in_markdown: Redigera som Markdown
133
+ # HTML mode toggle button aria-label
134
+ edit_in_html: Redigera som HTML
131
135
  # Error message when rich text conversion fails
132
136
  converter_error: Det gick inte att aktivera läget för formaterad text. Använd istället redigeraren för vanlig text.
133
137
  # Language selector aria-label
@@ -122,12 +122,16 @@ text_editor:
122
122
  link: Bağlantı
123
123
  # Link dialog title
124
124
  insert_link: Bağlantı Ekle
125
- update_link: Bağlantıyı Güncelle
125
+ # Floating link editor button aria-labels
126
+ edit_link: Bağlantıyı Düzenle
127
+ remove_link: Bağlantıyı Kaldır
126
128
  # Link dialog input field labels
127
129
  text: Metin
128
130
  url: URL
129
131
  # Markdown mode toggle button aria-label
130
132
  edit_in_markdown: Markdown ile Düzenle
133
+ # HTML mode toggle button aria-label
134
+ edit_in_html: HTML ile Düzenle
131
135
  # Error message when rich text conversion fails
132
136
  converter_error: Zengin metin modu etkinleştirilemedi. Lütfen düz metin düzenleyicisini kullanın.
133
137
  # Language selector aria-label
@@ -122,12 +122,16 @@ text_editor:
122
122
  link: Посилання
123
123
  # Link dialog title
124
124
  insert_link: Вставити посилання
125
- update_link: Оновити посилання
125
+ # Floating link editor button aria-labels
126
+ edit_link: Редагувати посилання
127
+ remove_link: Видалити посилання
126
128
  # Link dialog input field labels
127
129
  text: Текст
128
130
  url: URL
129
131
  # Markdown mode toggle button aria-label
130
132
  edit_in_markdown: Редагувати в Markdown
133
+ # HTML mode toggle button aria-label
134
+ edit_in_html: Редагувати в HTML
131
135
  # Error message when rich text conversion fails
132
136
  converter_error: Не вдалося ввімкнути режим форматованого тексту. Натомість скористайтеся редактором звичайного тексту.
133
137
  # Language selector aria-label
@@ -122,12 +122,16 @@ text_editor:
122
122
  link: Liên kết
123
123
  # Link dialog title
124
124
  insert_link: Chèn liên kết
125
- update_link: Cập nhật liên kết
125
+ # Floating link editor button aria-labels
126
+ edit_link: Chỉnh sửa liên kết
127
+ remove_link: Xóa liên kết
126
128
  # Link dialog input field labels
127
129
  text: Văn bản
128
130
  url: URL
129
131
  # Markdown mode toggle button aria-label
130
132
  edit_in_markdown: Chỉnh sửa bằng Markdown
133
+ # HTML mode toggle button aria-label
134
+ edit_in_html: Chỉnh sửa bằng HTML
131
135
  # Error message when rich text conversion fails
132
136
  converter_error: Không thể bật chế độ văn bản đa định dạng. Vui lòng sử dụng trình soạn thảo văn bản thuần.
133
137
  # Language selector aria-label
@@ -122,12 +122,16 @@ text_editor:
122
122
  link: 链接
123
123
  # Link dialog title
124
124
  insert_link: 插入链接
125
- update_link: 更新链接
125
+ # Floating link editor button aria-labels
126
+ edit_link: 编辑链接
127
+ remove_link: 移除链接
126
128
  # Link dialog input field labels
127
129
  text: 文字
128
130
  url: URL
129
131
  # Markdown mode toggle button aria-label
130
132
  edit_in_markdown: 以 Markdown 编辑
133
+ # HTML mode toggle button aria-label
134
+ edit_in_html: 以 HTML 编辑
131
135
  # Error message when rich text conversion fails
132
136
  converter_error: 无法启用富文本模式。请改用纯文本编辑器。
133
137
  # Language selector aria-label
@@ -122,12 +122,16 @@ text_editor:
122
122
  link: 連結
123
123
  # Link dialog title
124
124
  insert_link: 插入連結
125
- update_link: 更新連結
125
+ # Floating link editor button aria-labels
126
+ edit_link: 編輯連結
127
+ remove_link: 移除連結
126
128
  # Link dialog input field labels
127
129
  text: 文字
128
130
  url: URL
129
131
  # Markdown mode toggle button aria-label
130
132
  edit_in_markdown: 以 Markdown 編輯
133
+ # HTML mode toggle button aria-label
134
+ edit_in_html: 以 HTML 編輯
131
135
  # Error message when rich text conversion fails
132
136
  converter_error: 無法啟用格式化文字模式。請改用純文字編輯器。
133
137
  # Language selector aria-label
@@ -728,6 +728,7 @@ export type TextEditorFormatType = "bold" | "italic" | "strikethrough" | "code";
728
728
  export type TextEditorInlineType = TextEditorFormatType | "link";
729
729
  export type TextEditorNodeType = TextEditorBlockType | TextEditorInlineType;
730
730
  export type TextEditorMode = "rich-text" | "plain-text";
731
+ export type TextEditorValueFormat = "markdown" | "html";
731
732
  export type TextEditorComponent = {
732
733
  /**
733
734
  * Component ID.
@@ -799,6 +800,10 @@ export type TextEditorConfig = {
799
800
  * Default language for the code editor.
800
801
  */
801
802
  defaultLanguage?: string | undefined;
803
+ /**
804
+ * Format of the value. Default: `markdown`.
805
+ */
806
+ format?: TextEditorValueFormat | undefined;
802
807
  };
803
808
  export type EmojiEntry = {
804
809
  /**
@@ -1035,8 +1040,8 @@ export type TextEditorStore = {
1035
1040
  */
1036
1041
  controlId: string;
1037
1042
  /**
1038
- * Whether there was an error while converting Markdown to
1039
- * Lexical nodes.
1043
+ * Whether there was an error while converting Markdown or
1044
+ * HTML to Lexical nodes.
1040
1045
  */
1041
1046
  hasConverterError: boolean;
1042
1047
  /**
@@ -1045,7 +1050,8 @@ export type TextEditorStore = {
1045
1050
  showConverterError: boolean;
1046
1051
  /**
1047
1052
  * Whether the user has changed the rich text content, and the editor
1048
- * has yet to convert it to Markdown and update {@link TextEditorStore.inputValue}.
1053
+ * has yet to convert it to Markdown or HTML and update {@link TextEditorStore.inputValue}. It’s
1054
+ * also set while an operation started with {@link TextEditorStore.startOperation} is running.
1049
1055
  */
1050
1056
  pending: boolean;
1051
1057
  /**
@@ -1054,13 +1060,20 @@ export type TextEditorStore = {
1054
1060
  */
1055
1061
  importing: boolean;
1056
1062
  /**
1057
- * Function to trigger the Lexical converter.
1063
+ * Function to trigger the Lexical converter, which
1064
+ * imports the Markdown or HTML {@link TextEditorStore.inputValue} to the editor.
1065
+ */
1066
+ convertToLexical: () => Promise<void>;
1067
+ /**
1068
+ * Function marking an operation the user started, which
1069
+ * only updates the editor after an `await`, as running. It returns a function to call once the
1070
+ * operation is done. The content counts as {@link TextEditorStore.pending} meanwhile.
1058
1071
  */
1059
- convertMarkdown: () => Promise<void>;
1072
+ startOperation: () => () => void;
1060
1073
  /**
1061
1074
  * Function to get the
1062
1075
  * {@link TextEditorStore.inputValue} last imported if the given value, exported by the editor, is
1063
- * only that value written in the editor’s own Markdown style, e.g. `_text_` for `*text*`.
1076
+ * only that value written in the editor’s own Markdown or HTML style, e.g. `_text_` for `*text*`.
1064
1077
  */
1065
1078
  getImportedValue: (value: string) => string | undefined;
1066
1079
  };
package/dist/typedefs.js CHANGED
@@ -307,6 +307,10 @@
307
307
  * @typedef {'rich-text' | 'plain-text'} TextEditorMode
308
308
  */
309
309
 
310
+ /**
311
+ * @typedef {'markdown' | 'html'} TextEditorValueFormat
312
+ */
313
+
310
314
  /**
311
315
  * @typedef {object} TextEditorComponent
312
316
  * @property {string} id Component ID.
@@ -336,6 +340,7 @@
336
340
  * @property {boolean} [useEmojiAutocomplete] Whether to autocomplete emojis when the user types a
337
341
  * shortcode, like `:smi`. Default: `false`.
338
342
  * @property {string} [defaultLanguage] Default language for the code editor.
343
+ * @property {TextEditorValueFormat} [format] Format of the value. Default: `markdown`.
339
344
  */
340
345
 
341
346
  /**
@@ -443,17 +448,22 @@
443
448
  * mode.
444
449
  * @property {string} controlId ID of the editable element currently shown: the Lexical root in the
445
450
  * rich text mode, or the `<textarea>` in the plain text mode.
446
- * @property {boolean} hasConverterError Whether there was an error while converting Markdown to
447
- * Lexical nodes.
451
+ * @property {boolean} hasConverterError Whether there was an error while converting Markdown or
452
+ * HTML to Lexical nodes.
448
453
  * @property {boolean} showConverterError Whether to show a converter error in the UI.
449
454
  * @property {boolean} pending Whether the user has changed the rich text content, and the editor
450
- * has yet to convert it to Markdown and update {@link TextEditorStore.inputValue}.
455
+ * has yet to convert it to Markdown or HTML and update {@link TextEditorStore.inputValue}. It’s
456
+ * also set while an operation started with {@link TextEditorStore.startOperation} is running.
451
457
  * @property {boolean} importing Whether the latest {@link TextEditorStore.inputValue} is still
452
458
  * being imported to the Lexical editor.
453
- * @property {() => Promise<void>} convertMarkdown Function to trigger the Lexical converter.
459
+ * @property {() => Promise<void>} convertToLexical Function to trigger the Lexical converter, which
460
+ * imports the Markdown or HTML {@link TextEditorStore.inputValue} to the editor.
461
+ * @property {() => () => void} startOperation Function marking an operation the user started, which
462
+ * only updates the editor after an `await`, as running. It returns a function to call once the
463
+ * operation is done. The content counts as {@link TextEditorStore.pending} meanwhile.
454
464
  * @property {(value: string) => string | undefined} getImportedValue Function to get the
455
465
  * {@link TextEditorStore.inputValue} last imported if the given value, exported by the editor, is
456
- * only that value written in the editor’s own Markdown style, e.g. `_text_` for `*text*`.
466
+ * only that value written in the editor’s own Markdown or HTML style, e.g. `_text_` for `*text*`.
457
467
  */
458
468
 
459
469
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltia/ui",
3
- "version": "0.79.3",
3
+ "version": "0.80.0",
4
4
  "description": "A collection of Svelte components and utilities for building user interfaces.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -51,6 +51,7 @@
51
51
  "@lexical/dragon": "^0.52.0",
52
52
  "@lexical/extension": "^0.52.0",
53
53
  "@lexical/history": "^0.52.0",
54
+ "@lexical/html": "^0.52.0",
54
55
  "@lexical/link": "^0.52.0",
55
56
  "@lexical/list": "^0.52.0",
56
57
  "@lexical/markdown": "^0.52.0",
@@ -70,7 +71,7 @@
70
71
  "@fontsource/noto-mono": "5.3.0",
71
72
  "@rollup/plugin-yaml": "^5.0.0",
72
73
  "@sveltejs/adapter-auto": "^8.0.0",
73
- "@sveltejs/kit": "^3.0.0",
74
+ "@sveltejs/kit": "^3.0.1",
74
75
  "@sveltejs/package": "^3.0.0",
75
76
  "@sveltejs/vite-plugin-svelte": "^7.3.1",
76
77
  "@vitest/browser-playwright": "^5.0.3",
@@ -85,9 +86,9 @@
85
86
  "eslint-plugin-svelte": "^3.23.0",
86
87
  "globals": "^17.13.0",
87
88
  "happy-dom": "^20.14.5",
88
- "oxlint": "^1.86.0",
89
+ "oxlint": "^1.87.0",
89
90
  "playwright": "^1.63.0",
90
- "postcss": "^8.5.28",
91
+ "postcss": "^8.5.29",
91
92
  "postcss-html": "^2.0.0",
92
93
  "prettier": "^3.9.9",
93
94
  "prettier-plugin-svelte": "^4.1.1",
@@ -97,11 +98,11 @@
97
98
  "stylelint": "^17.16.0",
98
99
  "stylelint-config-recommended-scss": "^17.0.1",
99
100
  "stylelint-scss": "^7.3.0",
100
- "svelte": "^5.57.1",
101
+ "svelte": "^5.57.2",
101
102
  "svelte-check": "^4.7.6",
102
103
  "svelte-preprocess": "^6.0.5",
103
104
  "tslib": "^2.8.1",
104
- "vite": "^8.3.2",
105
+ "vite": "^8.3.3",
105
106
  "vitest": "^5.0.3",
106
107
  "vitest-browser-svelte": "^3.1.0"
107
108
  },