@threadlabs/looma 0.17.0 → 0.17.2

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 (229) hide show
  1. package/components/ui-avatar-group/ui-avatar-group.html +8 -5
  2. package/components/ui-avatar-group/ui-avatar-group.js +3 -3
  3. package/components/ui-badge/ui-badge.html +10 -5
  4. package/components/ui-breadcrumb-item/ui-breadcrumb-item.html +2 -1
  5. package/components/ui-button/ui-button.html +33 -26
  6. package/components/ui-button/ui-button.js +2 -2
  7. package/components/ui-callout/ui-callout.html +3 -1
  8. package/components/ui-card/ui-card.html +5 -3
  9. package/components/ui-checkbox/ui-checkbox.html +36 -8
  10. package/components/ui-combobox/ui-combobox.html +72 -45
  11. package/components/ui-combobox/ui-combobox.js +7 -2
  12. package/components/ui-context-menu/ui-context-menu.html +2 -2
  13. package/components/ui-description-item/ui-description-item.html +1 -1
  14. package/components/ui-description-list/ui-description-list.html +2 -0
  15. package/components/ui-dialog/ui-dialog.html +3 -23
  16. package/components/ui-disclosure/ui-disclosure.html +2 -2
  17. package/components/ui-editor-insert-table-grid/ui-editor-insert-table-grid.html +2 -2
  18. package/components/ui-editor-mention-menu/ui-editor-mention-menu.html +3 -3
  19. package/components/ui-editor-slash-menu/ui-editor-slash-menu.html +4 -4
  20. package/components/ui-editor-slash-menu-item/ui-editor-slash-menu-item.html +6 -1
  21. package/components/ui-editor-table-context-menu/ui-editor-table-context-menu.html +2 -2
  22. package/components/ui-editor-table-toolbar/ui-editor-table-toolbar.html +4 -4
  23. package/components/ui-editor-toolbar/ui-editor-toolbar.html +5 -5
  24. package/components/ui-floating-action-button/ui-floating-action-button.html +4 -2
  25. package/components/ui-icon-button/ui-icon-button.html +57 -17
  26. package/components/ui-icon-button/ui-icon-button.js +1 -1
  27. package/components/ui-list/ui-list.html +46 -6
  28. package/components/ui-list-item/ui-list-item.html +1 -1
  29. package/components/ui-menu/ui-menu.html +4 -3
  30. package/components/ui-menu/ui-menu.js +9 -3
  31. package/components/ui-menu-item/ui-menu-item.html +43 -6
  32. package/components/ui-meter/ui-meter.html +4 -1
  33. package/components/ui-nav-item/ui-nav-item.html +0 -1
  34. package/components/ui-page-header/ui-page-header.html +1 -0
  35. package/components/ui-popover/ui-popover.html +1 -1
  36. package/components/ui-radio/ui-radio.html +5 -2
  37. package/components/ui-scroll-area/ui-scroll-area.html +9 -14
  38. package/components/ui-scroll-area/ui-scroll-area.js +32 -0
  39. package/components/ui-search-result-row/ui-search-result-row.html +5 -3
  40. package/components/ui-search-shell/ui-search-shell.html +8 -8
  41. package/components/ui-section/ui-section.html +5 -3
  42. package/components/ui-separator/ui-separator.html +2 -2
  43. package/components/ui-sidebar/ui-sidebar.html +2 -2
  44. package/components/ui-spinner/ui-spinner.html +28 -8
  45. package/components/ui-status-message/ui-status-message.html +1 -1
  46. package/components/ui-switch/ui-switch.html +17 -8
  47. package/components/ui-table/ui-table.html +1 -1
  48. package/components/ui-tabs/ui-tabs.html +21 -12
  49. package/components/ui-toast/ui-toast.html +1 -1
  50. package/components/ui-toast-region/ui-toast-region.html +1 -1
  51. package/components/ui-tooltip/ui-tooltip.html +12 -12
  52. package/components/ui-tooltip/ui-tooltip.js +1 -1
  53. package/components/ui-top-bar/ui-top-bar.html +1 -1
  54. package/components/ui-tree/ui-tree.js +4 -1
  55. package/components/ui-tree-item/ui-tree-item.html +2 -1
  56. package/dist/index.js +15 -14
  57. package/editor/chunks/extensions.js +12 -2
  58. package/editor/extensions/preset.d.ts +6 -1
  59. package/package.json +1 -1
  60. package/styles/ui-avatar-group.css +8 -5
  61. package/styles/ui-badge.css +10 -5
  62. package/styles/ui-breadcrumb-item.css +2 -1
  63. package/styles/ui-button.css +19 -25
  64. package/styles/ui-callout.css +3 -1
  65. package/styles/ui-card.css +4 -2
  66. package/styles/ui-checkbox.css +38 -8
  67. package/styles/ui-combobox.css +27 -8
  68. package/styles/ui-context-menu.css +2 -2
  69. package/styles/ui-description-item.css +1 -1
  70. package/styles/ui-description-list.css +2 -0
  71. package/styles/ui-dialog.css +1 -22
  72. package/styles/ui-disclosure.css +2 -2
  73. package/styles/ui-editor-insert-table-grid.css +2 -2
  74. package/styles/ui-editor-mention-menu.css +3 -3
  75. package/styles/ui-editor-slash-menu-item.css +6 -1
  76. package/styles/ui-editor-slash-menu.css +4 -4
  77. package/styles/ui-editor-table-context-menu.css +2 -2
  78. package/styles/ui-editor-table-toolbar.css +4 -4
  79. package/styles/ui-editor-toolbar.css +5 -5
  80. package/styles/ui-floating-action-button.css +3 -1
  81. package/styles/ui-icon-button.css +53 -18
  82. package/styles/ui-list-item.css +1 -1
  83. package/styles/ui-list.css +41 -6
  84. package/styles/ui-menu-item.css +43 -5
  85. package/styles/ui-menu.css +3 -3
  86. package/styles/ui-meter.css +4 -1
  87. package/styles/ui-nav-item.css +0 -1
  88. package/styles/ui-page-header.css +1 -0
  89. package/styles/ui-popover.css +1 -1
  90. package/styles/ui-radio.css +5 -2
  91. package/styles/ui-scroll-area.css +10 -16
  92. package/styles/ui-search-result-row.css +3 -2
  93. package/styles/ui-search-shell.css +7 -7
  94. package/styles/ui-section.css +5 -3
  95. package/styles/ui-separator.css +2 -2
  96. package/styles/ui-sidebar.css +2 -2
  97. package/styles/ui-spinner.css +27 -6
  98. package/styles/ui-status-message.css +1 -1
  99. package/styles/ui-switch.css +17 -8
  100. package/styles/ui-table.css +1 -1
  101. package/styles/ui-tabs.css +60 -51
  102. package/styles/ui-toast-region.css +1 -1
  103. package/styles/ui-toast.css +1 -1
  104. package/styles/ui-tooltip.css +12 -12
  105. package/styles/ui-top-bar.css +1 -1
  106. package/styles/ui-tree-item.css +2 -1
  107. package/theme-dark.css +4 -4
  108. package/theme-light.css +3 -3
  109. package/tokens.css +9 -6
  110. package/vanilla/UiButton.d.ts +1 -0
  111. package/vanilla/UiButton.js +17 -19
  112. package/vanilla/UiCombobox.js +162 -159
  113. package/vanilla/UiDialog.js +2 -2
  114. package/vanilla/UiIconButton.d.ts +1 -0
  115. package/vanilla/UiIconButton.js +1 -4
  116. package/vanilla/UiList.d.ts +3 -1
  117. package/vanilla/UiList.js +36 -19
  118. package/vanilla/UiMenu.d.ts +1 -0
  119. package/vanilla/UiMenu.js +1 -1
  120. package/vanilla/UiMenuItem.js +10 -13
  121. package/vanilla/UiScrollArea.js +11 -6
  122. package/vanilla/UiSearchShell.js +2 -2
  123. package/vanilla/UiSpinner.js +2 -4
  124. package/vue/UiAvatarGroup.vue +8 -5
  125. package/vue/UiBadge.vue +10 -5
  126. package/vue/UiBreadcrumbItem.vue +2 -1
  127. package/vue/UiButton.d.ts +2 -0
  128. package/vue/UiButton.vue +31 -28
  129. package/vue/UiCallout.vue +3 -2
  130. package/vue/UiCard.vue +4 -2
  131. package/vue/UiCheckbox.vue +36 -8
  132. package/vue/UiCombobox.d.ts +1 -1
  133. package/vue/UiCombobox.vue +55 -35
  134. package/vue/UiContextMenu.vue +2 -2
  135. package/vue/UiDescriptionItem.vue +1 -1
  136. package/vue/UiDescriptionList.vue +2 -0
  137. package/vue/UiDialog.d.ts +3 -3
  138. package/vue/UiDialog.vue +3 -27
  139. package/vue/UiDisclosure.vue +2 -2
  140. package/vue/UiEditorInsertTableGrid.vue +2 -2
  141. package/vue/UiEditorMentionMenu.d.ts +1 -1
  142. package/vue/UiEditorMentionMenu.vue +4 -3
  143. package/vue/UiEditorSlashMenu.vue +6 -4
  144. package/vue/UiEditorSlashMenuItem.vue +6 -1
  145. package/vue/UiEditorTableContextMenu.vue +2 -2
  146. package/vue/UiEditorTableToolbar.vue +4 -4
  147. package/vue/UiEditorToolbar.vue +5 -5
  148. package/vue/UiFloatingActionButton.vue +3 -1
  149. package/vue/UiIconButton.d.ts +2 -0
  150. package/vue/UiIconButton.vue +61 -19
  151. package/vue/UiList.d.ts +7 -1
  152. package/vue/UiList.vue +57 -6
  153. package/vue/UiListItem.vue +1 -1
  154. package/vue/UiMenu.d.ts +2 -0
  155. package/vue/UiMenu.vue +6 -3
  156. package/vue/UiMenuItem.d.ts +3 -3
  157. package/vue/UiMenuItem.vue +47 -7
  158. package/vue/UiMeter.vue +4 -1
  159. package/vue/UiNavItem.vue +0 -1
  160. package/vue/UiPageHeader.vue +1 -0
  161. package/vue/UiPopover.vue +1 -1
  162. package/vue/UiRadio.vue +5 -2
  163. package/vue/UiScrollArea.vue +24 -18
  164. package/vue/UiSearchResultRow.vue +3 -2
  165. package/vue/UiSearchShell.vue +8 -8
  166. package/vue/UiSection.vue +5 -3
  167. package/vue/UiSeparator.vue +2 -2
  168. package/vue/UiSidebar.vue +2 -2
  169. package/vue/UiSpinner.vue +28 -7
  170. package/vue/UiStatusMessage.vue +1 -1
  171. package/vue/UiSwitch.vue +20 -9
  172. package/vue/UiTable.vue +1 -1
  173. package/vue/UiTabs.vue +25 -12
  174. package/vue/UiToast.vue +1 -1
  175. package/vue/UiToastRegion.vue +1 -1
  176. package/vue/UiTooltip.vue +12 -12
  177. package/vue/UiTopBar.vue +1 -1
  178. package/vue/UiTreeItem.vue +2 -1
  179. package/vue/chunks/UiAvatarGroup.js +1 -1
  180. package/vue/chunks/UiBadge.js +1 -1
  181. package/vue/chunks/UiBreadcrumbItem.js +1 -1
  182. package/vue/chunks/UiButton.js +28 -23
  183. package/vue/chunks/UiCallout.js +1 -1
  184. package/vue/chunks/UiCard.js +1 -1
  185. package/vue/chunks/UiCheckbox.js +1 -1
  186. package/vue/chunks/UiCombobox.js +80 -77
  187. package/vue/chunks/UiContextMenu.js +1 -1
  188. package/vue/chunks/UiDescriptionItem.js +1 -1
  189. package/vue/chunks/UiDescriptionList.js +1 -1
  190. package/vue/chunks/UiDialog.js +7 -4
  191. package/vue/chunks/UiDisclosure.js +1 -1
  192. package/vue/chunks/UiEditorInsertTableGrid.js +1 -1
  193. package/vue/chunks/UiEditorMentionMenu.js +1 -1
  194. package/vue/chunks/UiEditorSlashMenu.js +1 -1
  195. package/vue/chunks/UiEditorSlashMenuItem.js +1 -1
  196. package/vue/chunks/UiEditorTableContextMenu.js +1 -1
  197. package/vue/chunks/UiEditorTableToolbar.js +1 -1
  198. package/vue/chunks/UiEditorToolbar.js +1 -1
  199. package/vue/chunks/UiFloatingActionButton.js +1 -1
  200. package/vue/chunks/UiIconButton.js +13 -8
  201. package/vue/chunks/UiList.js +17 -5
  202. package/vue/chunks/UiListItem.js +1 -1
  203. package/vue/chunks/UiMenu.js +10 -2
  204. package/vue/chunks/UiMenuItem.js +1 -4
  205. package/vue/chunks/UiMeter.js +1 -1
  206. package/vue/chunks/UiNavItem.js +1 -1
  207. package/vue/chunks/UiPageHeader.js +1 -1
  208. package/vue/chunks/UiPopover.js +1 -1
  209. package/vue/chunks/UiRadio.js +1 -1
  210. package/vue/chunks/UiScrollArea.js +22 -3
  211. package/vue/chunks/UiSearchResultRow.js +1 -1
  212. package/vue/chunks/UiSearchShell.js +2 -2
  213. package/vue/chunks/UiSection.js +1 -1
  214. package/vue/chunks/UiSeparator.js +1 -1
  215. package/vue/chunks/UiSidebar.js +1 -1
  216. package/vue/chunks/UiSpinner.js +7 -5
  217. package/vue/chunks/UiStatusMessage.js +1 -1
  218. package/vue/chunks/UiSwitch.js +1 -1
  219. package/vue/chunks/UiTable.js +1 -1
  220. package/vue/chunks/UiTabs.js +1 -1
  221. package/vue/chunks/UiToast.js +1 -1
  222. package/vue/chunks/UiToastRegion.js +1 -1
  223. package/vue/chunks/UiTooltip.js +1 -1
  224. package/vue/chunks/UiTopBar.js +1 -1
  225. package/vue/chunks/UiTreeItem.js +1 -1
  226. package/vue/components.css +1231 -1032
  227. package/vue/editor/code-block-view.d.ts +29 -0
  228. package/vue/editor/index.js +70 -4
  229. package/vue/index.js +1 -1
@@ -0,0 +1,29 @@
1
+ import type { LoomaCodeLanguages } from "@threadlabs/looma/editor";
2
+ /** Per-block language control; the document stores only the code and explicit language. */
3
+ export declare function createCodeBlockView(languages: LoomaCodeLanguages, isEditable: () => boolean): import("vue").DefineComponent<{
4
+ decorations: readonly import("@tiptap/core").DecorationWithType[];
5
+ selected: boolean;
6
+ updateAttributes: (attributes: Record<string, any>) => void;
7
+ deleteNode: () => void;
8
+ node: Parameters<import("@tiptap/pm/view").NodeViewConstructor>[0];
9
+ view: Parameters<import("@tiptap/pm/view").NodeViewConstructor>[1];
10
+ getPos: () => number;
11
+ innerDecorations: Parameters<import("@tiptap/pm/view").NodeViewConstructor>[4];
12
+ editor: import("@tiptap/core").Editor;
13
+ extension: import("@tiptap/core").Node;
14
+ HTMLAttributes: Record<string, any>;
15
+ }, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
16
+ [key: string]: any;
17
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
18
+ decorations: readonly import("@tiptap/core").DecorationWithType[];
19
+ selected: boolean;
20
+ updateAttributes: (attributes: Record<string, any>) => void;
21
+ deleteNode: () => void;
22
+ node: Parameters<import("@tiptap/pm/view").NodeViewConstructor>[0];
23
+ view: Parameters<import("@tiptap/pm/view").NodeViewConstructor>[1];
24
+ getPos: () => number;
25
+ innerDecorations: Parameters<import("@tiptap/pm/view").NodeViewConstructor>[4];
26
+ editor: import("@tiptap/core").Editor;
27
+ extension: import("@tiptap/core").Node;
28
+ HTMLAttributes: Record<string, any>;
29
+ }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -1,10 +1,12 @@
1
- import { defineComponent, h, nextTick, onBeforeUnmount, onMounted, reactive, ref, useId, watch } from "vue";
1
+ import { computed, defineComponent, h, nextTick, onBeforeUnmount, onMounted, reactive, ref, useId, watch } from "vue";
2
2
  import { DEFAULT_MENTION_RESULT_LIMIT, LOOMA_CHIP_COLORS, LOOMA_ICONS, createLoomaMentionExtension, createLoomaSlashCommandExtension, getActiveTableUiState, getDefaultEditorExtensions, getVisualViewportRect, handleTableAction, handleTableOverlayAction, measureTableOverlayGeometry, normalizeActiveTableColumnWidths, normalizeLoomaChipColor, resolveTableCellAt, shouldShowTextFormattingToolbar } from "@threadlabs/looma/editor";
3
- import { EditorInsertTableGrid, EditorMentionMenu, EditorSlashMenu, EditorTableContextMenu, EditorTableOverlay, EditorTableToolbar, EditorToolbar, IconButton, Menu, MenuItem, Popover, Tooltip } from "@threadlabs/looma/vue";
4
- import { BubbleMenu, EditorContent, useEditor } from "@tiptap/vue-3";
3
+ import { Combobox, EditorInsertTableGrid, EditorMentionMenu, EditorSlashMenu, EditorTableContextMenu, EditorTableOverlay, EditorTableToolbar, EditorToolbar, IconButton, Menu, MenuItem, Popover, Tooltip } from "@threadlabs/looma/vue";
4
+ import { BubbleMenu, EditorContent, NodeViewContent, NodeViewWrapper, VueNodeViewRenderer, nodeViewProps, useEditor } from "@tiptap/vue-3";
5
5
  import { Plugin, PluginKey, TextSelection } from "@tiptap/pm/state";
6
6
  import { Extension } from "@tiptap/core";
7
7
  import { Decoration, DecorationSet } from "@tiptap/pm/view";
8
+ import { closeHistory } from "@tiptap/pm/history";
9
+ import { createLowlight } from "lowlight";
8
10
  export * from "@threadlabs/looma/editor";
9
11
  //#region src/vue/editor/primitives.ts
10
12
  /** Each Vue editor component's element tag, for tooling that enumerates them. */
@@ -178,6 +180,69 @@ function imageUploadContent(image) {
178
180
  };
179
181
  }
180
182
  //#endregion
183
+ //#region src/vue/editor/code-block-view.ts
184
+ /** Per-block language control; the document stores only the code and explicit language. */
185
+ function createCodeBlockView(languages, isEditable) {
186
+ const lowlight = createLowlight(languages);
187
+ const names = Object.keys(languages).sort();
188
+ return defineComponent({
189
+ name: "LoomaCodeBlockView",
190
+ props: nodeViewProps,
191
+ setup(props) {
192
+ const selected = computed(() => {
193
+ const language = props.node.attrs.language;
194
+ return typeof language === "string" && language ? language : "auto";
195
+ });
196
+ const detected = computed(() => {
197
+ if (!props.node.textContent.trim()) return null;
198
+ const language = lowlight.highlightAuto(props.node.textContent).data?.language;
199
+ return typeof language === "string" ? language : null;
200
+ });
201
+ const options = computed(() => [
202
+ {
203
+ id: "auto",
204
+ value: "auto",
205
+ label: detected.value ? `Auto (${detected.value.toUpperCase()})` : "Auto"
206
+ },
207
+ ...selected.value !== "auto" && !Object.hasOwn(languages, selected.value) ? [{
208
+ id: selected.value,
209
+ value: selected.value,
210
+ label: `${selected.value.toUpperCase()} (unavailable)`
211
+ }] : [],
212
+ ...names.map((name) => ({
213
+ id: name,
214
+ value: name,
215
+ label: name.toUpperCase()
216
+ }))
217
+ ]);
218
+ const choose = (detail) => {
219
+ if (detail.kind !== "selection" || !detail.value) return;
220
+ const language = detail.value === "auto" ? null : detail.value;
221
+ if (language !== null && !Object.hasOwn(languages, language)) return;
222
+ props.editor.view.dispatch(closeHistory(props.editor.state.tr));
223
+ props.updateAttributes({ language });
224
+ props.editor.view.dispatch(closeHistory(props.editor.state.tr));
225
+ };
226
+ const showControl = () => names.length > 0 && isEditable() && props.editor.isEditable;
227
+ return () => h(NodeViewWrapper, {
228
+ as: "pre",
229
+ class: showControl() ? "looma-editor__code-block--has-language" : void 0
230
+ }, () => [showControl() ? h("div", {
231
+ class: "looma-editor__code-language",
232
+ contenteditable: "false"
233
+ }, [h(Combobox, {
234
+ label: "Code language",
235
+ labelVisibility: "sr-only",
236
+ size: "sm",
237
+ disclosure: true,
238
+ filter: "label",
239
+ value: selected.value,
240
+ onValueChange: choose
241
+ }, () => options.value.map((option) => h("option", { value: option.value }, option.label)))]) : null, h(NodeViewContent, { as: "code" })]);
242
+ }
243
+ });
244
+ }
245
+ //#endregion
181
246
  //#region src/vue/editor/LoomaEditor.ts
182
247
  var EMPTY_DOCUMENT = {
183
248
  type: "doc",
@@ -518,7 +583,8 @@ var LoomaEditor = defineComponent({
518
583
  placeholder: props.placeholder,
519
584
  mention: mentionExtension ?? false,
520
585
  disableHighlight: props.disableHighlight,
521
- codeLanguages: props.codeLanguages
586
+ codeLanguages: props.codeLanguages,
587
+ codeBlockNodeView: VueNodeViewRenderer(createCodeBlockView(props.codeLanguages, () => props.editable))
522
588
  }),
523
589
  imageDelivery.extension,
524
590
  slashExtension,
package/vue/index.js CHANGED
@@ -19,6 +19,7 @@ import { t as UiContextMenu_default } from "./chunks/UiContextMenu.js";
19
19
  import { t as UiCover_default } from "./chunks/UiCover.js";
20
20
  import { t as UiDescriptionItem_default } from "./chunks/UiDescriptionItem.js";
21
21
  import { t as UiDescriptionList_default } from "./chunks/UiDescriptionList.js";
22
+ import { t as UiScrollArea_default } from "./chunks/UiScrollArea.js";
22
23
  import { t as UiDialog_default } from "./chunks/UiDialog.js";
23
24
  import { t as UiDisclosure_default } from "./chunks/UiDisclosure.js";
24
25
  import { t as UiEditable_default } from "./chunks/UiEditable.js";
@@ -51,7 +52,6 @@ import { t as UiPopover_default } from "./chunks/UiPopover.js";
51
52
  import { t as UiRadio_default } from "./chunks/UiRadio.js";
52
53
  import { t as UiRadioGroup_default } from "./chunks/UiRadioGroup.js";
53
54
  import { t as UiReel_default } from "./chunks/UiReel.js";
54
- import { t as UiScrollArea_default } from "./chunks/UiScrollArea.js";
55
55
  import { t as UiSearchResultRow_default } from "./chunks/UiSearchResultRow.js";
56
56
  import { t as UiSearchShell_default } from "./chunks/UiSearchShell.js";
57
57
  import { t as UiSection_default } from "./chunks/UiSection.js";