frappe-ui 1.0.2 → 1.2.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 (194) hide show
  1. package/experimental/Calendar/CalendarEventRow.vue +0 -4
  2. package/experimental/Calendar/calendarUtils.ts +33 -21
  3. package/experimental/CommandPalette/CommandPaletteItem.vue +9 -1
  4. package/experimental/MultiEmailInput/MultiEmailInput.vue +64 -12
  5. package/experimental/MultiEmailInput/types.ts +12 -3
  6. package/experimental/SpriteIcons/IconPicker.vue +2 -1
  7. package/experimental/Stepper/StepIndicator.vue +129 -0
  8. package/experimental/Stepper/Stepper.api.md +117 -0
  9. package/experimental/Stepper/Stepper.md +95 -0
  10. package/experimental/Stepper/Stepper.vue +82 -0
  11. package/experimental/Stepper/StepperHorizontal.vue +93 -0
  12. package/experimental/Stepper/StepperVertical.vue +291 -0
  13. package/experimental/Stepper/index.ts +11 -0
  14. package/experimental/Stepper/resolve.ts +87 -0
  15. package/experimental/Stepper/types.ts +89 -0
  16. package/experimental.ts +2 -21
  17. package/package.json +1 -3
  18. package/src/charts/CalendarHeatmapChart.vue +353 -0
  19. package/src/charts/DonutChart.vue +34 -58
  20. package/src/charts/HeatmapChart.vue +26 -64
  21. package/src/charts/NumberCard.vue +62 -7
  22. package/src/charts/PercentageBarChart.vue +243 -0
  23. package/src/charts/SankeyChart.vue +14 -11
  24. package/src/charts/ScatterChart.vue +24 -20
  25. package/src/charts/axisChartCommon.ts +182 -18
  26. package/src/charts/axisFormat.ts +8 -3
  27. package/src/charts/calendarHeatmapOptions.ts +604 -0
  28. package/src/charts/colorMath.ts +26 -0
  29. package/src/charts/components/ChartContainer.vue +63 -53
  30. package/src/charts/components/ChartLegend.vue +216 -24
  31. package/src/charts/components/ChartScale.vue +85 -0
  32. package/src/charts/core/dataLabelFit.ts +45 -6
  33. package/src/charts/core/useAxisChart.ts +36 -19
  34. package/src/charts/core/useChart.ts +6 -1
  35. package/src/charts/core/usePlotKeyboard.ts +13 -2
  36. package/src/charts/docs/BarChart.md +11 -3
  37. package/src/charts/docs/CalendarHeatmapChart.api.md +165 -0
  38. package/src/charts/docs/CalendarHeatmapChart.md +33 -0
  39. package/src/charts/docs/ChartContainer.api.md +6 -0
  40. package/src/charts/docs/ChartLegend.api.md +1 -1
  41. package/src/charts/docs/ChartLegend.md +25 -3
  42. package/src/charts/docs/DonutChart.api.md +12 -0
  43. package/src/charts/docs/DonutChart.md +17 -0
  44. package/src/charts/docs/HeatmapChart.api.md +1 -1
  45. package/src/charts/docs/LineChart.md +5 -3
  46. package/src/charts/docs/NumberCard.api.md +6 -0
  47. package/src/charts/docs/NumberCard.md +6 -0
  48. package/src/charts/docs/Overview.md +13 -6
  49. package/src/charts/docs/PercentageBarChart.api.md +148 -0
  50. package/src/charts/docs/PercentageBarChart.md +42 -0
  51. package/src/charts/docs/ScatterChart.md +2 -3
  52. package/src/charts/donutChartOptions.ts +22 -130
  53. package/src/charts/format.ts +4 -1
  54. package/src/charts/heatmapOptions.ts +17 -12
  55. package/src/charts/hiddenSeries.ts +8 -3
  56. package/src/charts/index.ts +12 -0
  57. package/src/charts/legendOverflow.ts +40 -0
  58. package/src/charts/numberCardFormat.ts +19 -13
  59. package/src/charts/referenceLines.ts +2 -1
  60. package/src/charts/scatterOptions.ts +16 -3
  61. package/src/charts/seriesData.ts +8 -3
  62. package/src/charts/slices.ts +228 -0
  63. package/src/charts/tokens.ts +99 -0
  64. package/src/charts/types.ts +318 -9
  65. package/src/components/Avatar/Avatar.md +27 -2
  66. package/src/components/Avatar/Avatar.vue +29 -12
  67. package/src/components/Breadcrumbs/Breadcrumbs.vue +2 -1
  68. package/src/components/Combobox/Combobox.vue +9 -2
  69. package/src/components/Combobox/ComboboxResults.vue +6 -1
  70. package/src/components/Combobox/utils.ts +2 -1
  71. package/src/components/DatePicker/DatePicker.md +7 -0
  72. package/src/components/DatePicker/DatePicker.vue +6 -0
  73. package/src/components/DatePicker/DateTimePicker.vue +6 -0
  74. package/src/components/DatePicker/composables.ts +18 -1
  75. package/src/components/DatePicker/utils.ts +53 -0
  76. package/src/components/Dialog/Dialog.md +3 -1
  77. package/src/components/Duration/Duration.api.md +16 -3
  78. package/src/components/Duration/Duration.md +21 -0
  79. package/src/components/Duration/Duration.vue +29 -8
  80. package/src/components/Duration/duration.ts +105 -44
  81. package/src/components/Duration/index.ts +1 -0
  82. package/src/components/Duration/types.ts +30 -1
  83. package/src/components/HoverCard/HoverCard.vue +21 -5
  84. package/src/components/Menu/utils.ts +3 -2
  85. package/src/components/MobileNav/MobileNavItem.vue +3 -22
  86. package/src/components/MultiSelect/MultiSelect.api.md +5 -0
  87. package/src/components/MultiSelect/MultiSelect.vue +34 -0
  88. package/src/components/MultiSelect/MultiSelectResults.vue +3 -4
  89. package/src/components/MultiSelect/types.ts +6 -0
  90. package/src/components/Select/Select.vue +4 -4
  91. package/src/components/Select/utils.ts +1 -0
  92. package/src/components/SettingsDialog/SettingsDialog.api.md +7 -2
  93. package/src/components/SettingsDialog/SettingsDialog.md +2 -1
  94. package/src/components/SettingsDialog/SettingsRow.vue +12 -2
  95. package/src/components/Sidebar/SidebarItem.vue +3 -33
  96. package/src/components/SidebarRail/SidebarRailItem.vue +4 -17
  97. package/src/components/Switch/Switch.vue +3 -3
  98. package/src/components/Tooltip/Tooltip.vue +8 -0
  99. package/src/components/shared/deferredTrigger.ts +174 -0
  100. package/src/components/shared/navLink.ts +45 -0
  101. package/src/components/shared/selection/utils.ts +8 -1
  102. package/src/data-fetching/useCall/useCall.ts +25 -26
  103. package/src/data-fetching/useFrappeFetch.ts +48 -2
  104. package/src/data-fetching/useList/useList.ts +11 -3
  105. package/src/data-fetching/utils.ts +15 -1
  106. package/src/molecules/editor/components/MediaNodeView.vue +10 -1
  107. package/src/molecules/editor/components/MediaResizeGuide.vue +71 -0
  108. package/src/molecules/editor/components/media-node-view-utils.ts +7 -0
  109. package/src/molecules/editor/composables/useNodeViewResize.ts +142 -10
  110. package/src/molecules/editor/extensions/attachment/attachment-engine.ts +1 -1
  111. package/src/molecules/editor/extensions/content-paste/paste-html-utils.ts +16 -6
  112. package/src/molecules/editor/extensions/iframe/IframeNodeView.vue +29 -10
  113. package/src/molecules/editor/extensions/iframe/iframe-allowlist.ts +35 -16
  114. package/src/molecules/editor/extensions/iframe/iframe-embed-utils.ts +1 -1
  115. package/src/molecules/editor/extensions/iframe/iframe-extension.ts +30 -30
  116. package/src/molecules/editor/extensions/link/LinkEditorPopup.vue +1 -1
  117. package/src/molecules/editor/extensions/link/link-paste-plugin.ts +1 -1
  118. package/src/molecules/editor/extensions/shared/media-upload-engine.ts +1 -1
  119. package/src/molecules/editor/useEditor.ts +12 -6
  120. package/src/molecules/list/ListRow.vue +8 -1
  121. package/src/utils/dialog.ts +57 -16
  122. package/src/{molecules/editor/extensions/shared → utils}/url-safety.ts +28 -16
  123. package/tailwind/content.js +1 -1
  124. package/tailwind/plugin.js +22 -0
  125. package/vite/README.md +5 -3
  126. package/vite/codeLanguages.js +41 -17
  127. package/vite/doctypeInterfaceGenerator.js +52 -39
  128. package/vitepress/index.node.ts +0 -2
  129. package/experimental/TextEditor/TextEditor.api.md +0 -161
  130. package/experimental/TextEditor/TextEditor.vue +0 -298
  131. package/experimental/TextEditor/classIcon.ts +0 -21
  132. package/experimental/TextEditor/commands.js +0 -344
  133. package/experimental/TextEditor/components/CodeBlockComponent.vue +0 -103
  134. package/experimental/TextEditor/components/FontColor.vue +0 -153
  135. package/experimental/TextEditor/components/ImageViewerModal.vue +0 -463
  136. package/experimental/TextEditor/components/InsertImage.vue +0 -54
  137. package/experimental/TextEditor/components/InsertLink.vue +0 -13
  138. package/experimental/TextEditor/components/InsertVideo.vue +0 -14
  139. package/experimental/TextEditor/components/LinkPopup.vue +0 -99
  140. package/experimental/TextEditor/components/MediaNodeView.vue +0 -398
  141. package/experimental/TextEditor/components/MentionList.vue +0 -95
  142. package/experimental/TextEditor/components/TextEditorBubbleMenu.vue +0 -78
  143. package/experimental/TextEditor/components/TextEditorFixedMenu.vue +0 -78
  144. package/experimental/TextEditor/components/TextEditorFloatingMenu.vue +0 -61
  145. package/experimental/TextEditor/components/TextEditorMenu.vue +0 -218
  146. package/experimental/TextEditor/components/index.js +0 -0
  147. package/experimental/TextEditor/extensions/code-block.ts +0 -119
  148. package/experimental/TextEditor/extensions/color/color-extension.ts +0 -140
  149. package/experimental/TextEditor/extensions/color/color-styles.css +0 -25
  150. package/experimental/TextEditor/extensions/color/index.ts +0 -2
  151. package/experimental/TextEditor/extensions/content-paste-extension.ts +0 -160
  152. package/experimental/TextEditor/extensions/copy-styles.ts +0 -160
  153. package/experimental/TextEditor/extensions/emoji/EmojiList.vue +0 -55
  154. package/experimental/TextEditor/extensions/emoji/emoji-extension.ts +0 -55
  155. package/experimental/TextEditor/extensions/emoji/emojis.json +0 -7422
  156. package/experimental/TextEditor/extensions/heading/heading.ts +0 -20
  157. package/experimental/TextEditor/extensions/highlight/highlight-extension.ts +0 -241
  158. package/experimental/TextEditor/extensions/highlight/highlight-styles.css +0 -31
  159. package/experimental/TextEditor/extensions/highlight/index.ts +0 -2
  160. package/experimental/TextEditor/extensions/iframe/IframeNodeView.vue +0 -308
  161. package/experimental/TextEditor/extensions/iframe/InsertIframe.vue +0 -209
  162. package/experimental/TextEditor/extensions/iframe/iframe-extension.ts +0 -404
  163. package/experimental/TextEditor/extensions/iframe/index.ts +0 -11
  164. package/experimental/TextEditor/extensions/iframe/utils.ts +0 -283
  165. package/experimental/TextEditor/extensions/image/image-extension.ts +0 -661
  166. package/experimental/TextEditor/extensions/image/index.ts +0 -5
  167. package/experimental/TextEditor/extensions/image-group/ImageGroupNodeView.vue +0 -182
  168. package/experimental/TextEditor/extensions/image-group/ImageGroupUploadDialog.vue +0 -740
  169. package/experimental/TextEditor/extensions/image-group/image-group-extension.ts +0 -187
  170. package/experimental/TextEditor/extensions/image-viewer-extension.ts +0 -162
  171. package/experimental/TextEditor/extensions/link/index.ts +0 -1
  172. package/experimental/TextEditor/extensions/link/link-extension.ts +0 -323
  173. package/experimental/TextEditor/extensions/link/linkPasteHandler.ts +0 -51
  174. package/experimental/TextEditor/extensions/mention/index.ts +0 -1
  175. package/experimental/TextEditor/extensions/mention/mention-extension.ts +0 -204
  176. package/experimental/TextEditor/extensions/mention/style.css +0 -11
  177. package/experimental/TextEditor/extensions/shared/color-utils.ts +0 -236
  178. package/experimental/TextEditor/extensions/slash-commands/SlashCommandsList.vue +0 -59
  179. package/experimental/TextEditor/extensions/slash-commands/slash-commands-extension.ts +0 -184
  180. package/experimental/TextEditor/extensions/suggestion/SuggestionList.vue +0 -130
  181. package/experimental/TextEditor/extensions/suggestion/createSuggestionExtension.ts +0 -151
  182. package/experimental/TextEditor/extensions/suggestion/index.ts +0 -5
  183. package/experimental/TextEditor/extensions/tag/index.ts +0 -1
  184. package/experimental/TextEditor/extensions/tag/tag-extension.ts +0 -170
  185. package/experimental/TextEditor/extensions/toc-node/TocNodeView.vue +0 -439
  186. package/experimental/TextEditor/extensions/toc-node/index.ts +0 -3
  187. package/experimental/TextEditor/extensions/toc-node/toc-node-extension.ts +0 -167
  188. package/experimental/TextEditor/extensions/video-extension.ts +0 -653
  189. package/experimental/TextEditor/hljs-github.css +0 -197
  190. package/experimental/TextEditor/index.ts +0 -21
  191. package/experimental/TextEditor/style.css +0 -190
  192. package/experimental/TextEditor/types.ts +0 -72
  193. package/experimental/TextEditor/utils.js +0 -11
  194. package/src/utils/url-validation.ts +0 -39
@@ -1,21 +0,0 @@
1
- import { h, type FunctionalComponent } from 'vue'
2
-
3
- /**
4
- * Wrap a `lucide-<name>` class icon in the component shape this family expects.
5
- *
6
- * The v0 toolbars and slash-command lists store an icon COMPONENT on each
7
- * command object and render it with `<component :is>`. frappe-ui draws icons
8
- * from class names instead: the Tailwind plugin generates a `lucide-<name>`
9
- * class for every lucide icon and paints it as a CSS mask in `currentColor`.
10
- * This adapter keeps those call sites unchanged while removing the last
11
- * `~icons/lucide/*` imports, which needed the `lucideIcons` Vite plugin.
12
- *
13
- * Every caller passes the class name as a literal, which is what Tailwind's
14
- * scanner needs in order to emit the class. `experimental/TextEditor` is in
15
- * the `content` globs exported from `frappe-ui/tailwind`.
16
- */
17
- export function classIcon(name: string): FunctionalComponent {
18
- // Vue merges a `class` passed at the call site onto this span, so
19
- // `<component :is="icon" class="h-4 w-4" />` still works.
20
- return () => h('span', { class: name })
21
- }
@@ -1,344 +0,0 @@
1
- import { defineAsyncComponent } from 'vue'
2
- import { classIcon } from './classIcon'
3
- const H1 = classIcon('lucide-heading-1')
4
- const H2 = classIcon('lucide-heading-2')
5
- const H3 = classIcon('lucide-heading-3')
6
- const H4 = classIcon('lucide-heading-4')
7
- const H5 = classIcon('lucide-heading-5')
8
- const H6 = classIcon('lucide-heading-6')
9
- const Text = classIcon('lucide-type')
10
- const Underline = classIcon('lucide-underline')
11
- const Italic = classIcon('lucide-italic')
12
- const Bold = classIcon('lucide-bold')
13
- const Strikethrough = classIcon('lucide-strikethrough')
14
- const AlignLeft = classIcon('lucide-text-align-start')
15
- const AlignRight = classIcon('lucide-text-align-end')
16
- const AlignCenter = classIcon('lucide-text-align-center')
17
- const FontColor = classIcon('lucide-paint-bucket')
18
- const ListUnordered = classIcon('lucide-list')
19
- const ListOrdered = classIcon('lucide-list-ordered')
20
- const ListTask = classIcon('lucide-list-check')
21
- const IndentList = classIcon('lucide-list-indent-increase')
22
- const DedentList = classIcon('lucide-list-indent-decrease')
23
- const DoubleQuotes = classIcon('lucide-quote')
24
- const CodeView = classIcon('lucide-code')
25
- const Link = classIcon('lucide-link-2')
26
- const Image = classIcon('lucide-image-plus')
27
- const GalleryVertical = classIcon('lucide-gallery-vertical')
28
- const Video = classIcon('lucide-video')
29
- const Undo = classIcon('lucide-undo-2')
30
- const Redo = classIcon('lucide-redo-2')
31
- const Separator = classIcon('lucide-separator-horizontal')
32
- const Table = classIcon('lucide-table-properties')
33
- const TableOfContentsIcon = classIcon('lucide-square-menu')
34
- export default {
35
- Paragraph: {
36
- label: 'Paragraph',
37
- icon: Text,
38
- action: (editor) => editor.chain().focus().setParagraph().run(),
39
- shortcut: 'Meta-Alt-0',
40
- isActive: (editor) => editor.isActive('paragraph'),
41
- },
42
- 'Heading 1': {
43
- label: 'Heading 1',
44
- text: 'H1',
45
- icon: H1,
46
- action: (editor) =>
47
- editor.chain().focus().toggleHeading({ level: 1 }).run(),
48
- shortcut: 'Meta-Alt-1',
49
- isActive: (editor) => editor.isActive('heading', { level: 1 }),
50
- },
51
- 'Heading 2': {
52
- label: 'Heading 2',
53
- text: 'H2',
54
- icon: H2,
55
- action: (editor) =>
56
- editor.chain().focus().toggleHeading({ level: 2 }).run(),
57
- shortcut: 'Meta-Alt-2',
58
- isActive: (editor) => editor.isActive('heading', { level: 2 }),
59
- },
60
- 'Heading 3': {
61
- label: 'Heading 3',
62
- text: 'H3',
63
- icon: H3,
64
- action: (editor) =>
65
- editor.chain().focus().toggleHeading({ level: 3 }).run(),
66
- shortcut: 'Meta-Alt-3',
67
- isActive: (editor) => editor.isActive('heading', { level: 3 }),
68
- },
69
- 'Heading 4': {
70
- label: 'Heading 4',
71
- text: 'H4',
72
- icon: H4,
73
- action: (editor) =>
74
- editor.chain().focus().toggleHeading({ level: 4 }).run(),
75
- shortcut: 'Meta-Alt-4',
76
- isActive: (editor) => editor.isActive('heading', { level: 4 }),
77
- },
78
- 'Heading 5': {
79
- label: 'Heading 5',
80
- text: 'H5',
81
- icon: H5,
82
- action: (editor) =>
83
- editor.chain().focus().toggleHeading({ level: 5 }).run(),
84
- shortcut: 'Meta-Alt-5',
85
- isActive: (editor) => editor.isActive('heading', { level: 5 }),
86
- },
87
- 'Heading 6': {
88
- label: 'Heading 6',
89
- text: 'H6',
90
- icon: H6,
91
- action: (editor) =>
92
- editor.chain().focus().toggleHeading({ level: 6 }).run(),
93
- shortcut: 'Meta-Alt-6',
94
- isActive: (editor) => editor.isActive('heading', { level: 6 }),
95
- },
96
- Bold: {
97
- label: 'Bold',
98
- icon: Bold,
99
- action: (editor) => editor.chain().focus().toggleBold().run(),
100
- shortcut: 'Meta-B',
101
- isActive: (editor) => editor.isActive('bold'),
102
- },
103
- Italic: {
104
- label: 'Italic',
105
- icon: Italic,
106
- action: (editor) => editor.chain().focus().toggleItalic().run(),
107
- shortcut: 'Meta-I',
108
- isActive: (editor) => editor.isActive('italic'),
109
- },
110
- Underline: {
111
- label: 'Underline',
112
- icon: Underline,
113
- action: (editor) => editor.chain().focus().toggleUnderline().run(),
114
- shortcut: 'Meta-U',
115
- isActive: (editor) => editor.isActive('underline'),
116
- },
117
- Strikethrough: {
118
- label: 'Strikethrough',
119
- icon: Strikethrough,
120
- action: (editor) => editor.chain().focus().toggleStrike().run(),
121
- shortcut: 'Meta-Shift-S',
122
- isActive: (editor) => editor.isActive('strike'),
123
- },
124
- 'Bullet List': {
125
- label: 'Bullet List',
126
- icon: ListUnordered,
127
- action: (editor) => editor.chain().focus().toggleBulletList().run(),
128
- shortcut: 'Meta-Shift-8',
129
- isActive: (editor) => editor.isActive('bulletList'),
130
- },
131
- 'Numbered List': {
132
- label: 'Numbered List',
133
- icon: ListOrdered,
134
- action: (editor) => editor.chain().focus().toggleOrderedList().run(),
135
- shortcut: 'Meta-Shift-7',
136
- isActive: (editor) => editor.isActive('orderedList'),
137
- },
138
- 'Task List': {
139
- label: 'Task List',
140
- icon: ListTask,
141
- action: (editor) => editor.chain().focus().toggleTaskList().run(),
142
- shortcut: 'Meta-Shift-9',
143
- isActive: (editor) => editor.isActive('taskList'),
144
- },
145
- IndentList: {
146
- label: 'Indent List',
147
- action: (editor) => editor.chain().focus().sinkListItem('listItem').run(),
148
- icon: IndentList,
149
- condition: (editor) => editor.can().sinkListItem('listItem'),
150
- },
151
- DedentList: {
152
- label: 'Dedent List',
153
- action: (editor) => editor.chain().focus().liftListItem('listItem').run(),
154
- icon: DedentList,
155
- condition: (editor) => editor.can().liftListItem('listItem'),
156
- },
157
- 'Align Center': {
158
- label: 'Align Center',
159
- icon: AlignCenter,
160
- action: (editor) => editor.chain().focus().setTextAlign('center').run(),
161
- shortcut: 'Meta-Shift-E',
162
- isActive: (editor) => editor.isActive({ textAlign: 'center' }),
163
- },
164
- 'Align Left': {
165
- label: 'Align Left',
166
- icon: AlignLeft,
167
- action: (editor) => editor.chain().focus().setTextAlign('left').run(),
168
- shortcut: 'Meta-Shift-L',
169
- isActive: (editor) => editor.isActive({ textAlign: 'left' }),
170
- },
171
- 'Align Right': {
172
- label: 'Align Right',
173
- icon: AlignRight,
174
- action: (editor) => editor.chain().focus().setTextAlign('right').run(),
175
- shortcut: 'Meta-Shift-R',
176
- isActive: (editor) => editor.isActive({ textAlign: 'right' }),
177
- },
178
- FontColor: {
179
- label: 'Font Color',
180
- icon: FontColor,
181
- isActive: (editor) =>
182
- editor.getAttributes('textStyle')?.color || editor.isActive('highlight'),
183
- component: defineAsyncComponent(() => import('./components/FontColor.vue')),
184
- },
185
- Blockquote: {
186
- label: 'Blockquote',
187
- icon: DoubleQuotes,
188
- action: (editor) => editor.chain().focus().toggleBlockquote().run(),
189
- shortcut: 'Meta-Shift-B',
190
- isActive: (editor) => editor.isActive('blockquote'),
191
- },
192
- Code: {
193
- label: 'Code',
194
- icon: CodeView,
195
- action: (editor) => editor.chain().focus().toggleCodeBlock().run(),
196
- shortcut: 'Meta-Alt-C',
197
- isActive: (editor) => editor.isActive('codeBlock'),
198
- },
199
- 'Horizontal Rule': {
200
- label: 'Horizontal Rule',
201
- icon: Separator,
202
- action: (editor) => editor.chain().focus().setHorizontalRule().run(),
203
- isActive: (editor) => false,
204
- },
205
- Link: {
206
- label: 'Link',
207
- icon: Link,
208
- isActive: (editor) => editor.isActive('link'),
209
- component: defineAsyncComponent(
210
- () => import('./components/InsertLink.vue'),
211
- ),
212
- },
213
- Image: {
214
- label: 'Image',
215
- icon: Image,
216
- isActive: (editor) => false,
217
- component: defineAsyncComponent(
218
- () => import('./components/InsertImage.vue'),
219
- ),
220
- },
221
- Video: {
222
- label: 'Video',
223
- icon: Video,
224
- isActive: (editor) => false,
225
- component: defineAsyncComponent(
226
- () => import('./components/InsertVideo.vue'),
227
- ),
228
- },
229
- Iframe: {
230
- label: 'Embed',
231
- icon: GalleryVertical,
232
- isActive: (editor) => editor.isActive('iframe'),
233
- component: defineAsyncComponent(
234
- () => import('./extensions/iframe/InsertIframe.vue'),
235
- ),
236
- },
237
- Undo: {
238
- label: 'Undo',
239
- icon: Undo,
240
- action: (editor) => editor.chain().focus().undo().run(),
241
- shortcut: 'Meta-Z',
242
- isDisabled: (editor) => !editor.can().chain().focus().undo().run(),
243
- },
244
- Redo: {
245
- label: 'Redo',
246
- icon: Redo,
247
- action: (editor) => editor.chain().focus().redo().run(),
248
- shortcut: 'Meta-Shift-Z',
249
- isDisabled: (editor) => !editor.can().chain().focus().redo().run(),
250
- },
251
- InsertTable: {
252
- label: 'Insert Table',
253
- icon: Table,
254
- action: (editor) =>
255
- editor
256
- .chain()
257
- .focus()
258
- .insertTable({ rows: 3, cols: 3, withHeaderRow: true })
259
- .run(),
260
- isActive: (editor) => editor.can().deleteTable(),
261
- },
262
- AddColumnBefore: {
263
- label: 'Add Column Before',
264
- action: (editor) => editor.chain().focus().addColumnBefore().run(),
265
- isActive: (editor) => false,
266
- condition: (editor) => editor.can().addColumnBefore(),
267
- },
268
- AddColumnAfter: {
269
- label: 'Add Column After',
270
- action: (editor) => editor.chain().focus().addColumnAfter().run(),
271
- isActive: (editor) => false,
272
- condition: (editor) => editor.can().addColumnAfter(),
273
- },
274
- DeleteColumn: {
275
- label: 'Delete Column',
276
- action: (editor) => editor.chain().focus().deleteColumn().run(),
277
- isActive: (editor) => false,
278
- condition: (editor) => editor.can().deleteColumn(),
279
- },
280
- AddRowBefore: {
281
- label: 'Add Row Before',
282
- action: (editor) => editor.chain().focus().addRowBefore().run(),
283
- isActive: (editor) => false,
284
- condition: (editor) => editor.can().addRowBefore(),
285
- },
286
- AddRowAfter: {
287
- label: 'Add Row After',
288
- action: (editor) => editor.chain().focus().addRowAfter().run(),
289
- isActive: (editor) => false,
290
- condition: (editor) => editor.can().addRowAfter(),
291
- },
292
- DeleteRow: {
293
- label: 'Delete Row',
294
- action: (editor) => editor.chain().focus().deleteRow().run(),
295
- isActive: (editor) => false,
296
- condition: (editor) => editor.can().deleteRow(),
297
- },
298
- DeleteTable: {
299
- label: 'Delete Table',
300
- action: (editor) => editor.chain().focus().deleteTable().run(),
301
- isActive: (editor) => false,
302
- condition: (editor) => editor.can().deleteTable(),
303
- },
304
- MergeCells: {
305
- label: 'Merge Cells',
306
- action: (editor) => editor.chain().focus().mergeCells().run(),
307
- isActive: (editor) => false,
308
- condition: (editor) => editor.can().mergeCells(),
309
- },
310
- SplitCell: {
311
- label: 'Split Cell',
312
- action: (editor) => editor.chain().focus().splitCell().run(),
313
- isActive: (editor) => false,
314
- condition: (editor) => editor.can().splitCell(),
315
- },
316
- ToggleHeaderColumn: {
317
- label: 'Toggle Header Column',
318
- action: (editor) => editor.chain().focus().toggleHeaderColumn().run(),
319
- isActive: (editor) => false,
320
- condition: (editor) => editor.can().toggleHeaderColumn(),
321
- },
322
- ToggleHeaderRow: {
323
- label: 'Toggle Header Row',
324
- action: (editor) => editor.chain().focus().toggleHeaderRow().run(),
325
- isActive: (editor) => false,
326
- condition: (editor) => editor.can().toggleHeaderRow(),
327
- },
328
- ToggleHeaderCell: {
329
- label: 'Toggle Header Cell',
330
- action: (editor) => editor.chain().focus().toggleHeaderCell().run(),
331
- isActive: (editor) => false,
332
- condition: (editor) => editor.can().toggleHeaderCell(),
333
- },
334
- TableOfContents: {
335
- label: 'Table of Contents',
336
- icon: TableOfContentsIcon,
337
- action: (editor) =>
338
- editor.chain().focus().insertTableOfContentsNode().run(),
339
- isActive: (editor) => editor.isActive('tocNode'),
340
- },
341
- Separator: {
342
- type: 'separator',
343
- },
344
- }
@@ -1,103 +0,0 @@
1
- <template>
2
- <node-view-wrapper>
3
- <div class="code-block-container">
4
- <pre class="hljs-pre"><code><node-view-content /></code></pre>
5
- <select
6
- v-if="isEditable"
7
- class="language-selector form-select py-0"
8
- contenteditable="false"
9
- v-model="selectedLanguage"
10
- >
11
- <option :value="null">auto</option>
12
- <option disabled>—</option>
13
- <option
14
- v-for="(language, index) in languages"
15
- :value="language.value"
16
- :key="language.value"
17
- >
18
- {{ language.label }}
19
- </option>
20
- </select>
21
- <span v-else class="language-label">{{
22
- selectedLanguage || 'auto'
23
- }}</span>
24
- </div>
25
- </node-view-wrapper>
26
- </template>
27
-
28
- <script>
29
- import { NodeViewContent, nodeViewProps, NodeViewWrapper } from '@tiptap/vue-3'
30
-
31
- export default {
32
- components: {
33
- NodeViewWrapper,
34
- NodeViewContent,
35
- },
36
- props: nodeViewProps,
37
- data() {
38
- return {
39
- isEditable: this.editor.isEditable,
40
- }
41
- },
42
- mounted() {
43
- this.editor.on('update', () => {
44
- this.isEditable = this.editor.isEditable
45
- })
46
- },
47
- computed: {
48
- selectedLanguage: {
49
- get() {
50
- return this.node.attrs.language
51
- },
52
- set(language) {
53
- this.updateAttributes({ language })
54
- },
55
- },
56
- languages() {
57
- let supportedLanguages = this.extension.options.lowlight.listLanguages()
58
- return supportedLanguages
59
- .map((language) => {
60
- return {
61
- label: language,
62
- value: language,
63
- }
64
- })
65
- .concat([{ label: 'html', value: 'xml' }])
66
- .sort((a, b) => a.label.localeCompare(b.label))
67
- },
68
- },
69
- }
70
- </script>
71
-
72
- <style>
73
- @import '../hljs-github.css';
74
-
75
- /* CodeBlock styles */
76
- .code-block {
77
- position: relative;
78
- }
79
-
80
- .code-block-container {
81
- position: relative;
82
- }
83
-
84
- .language-selector {
85
- position: absolute;
86
- top: 0.25rem;
87
- right: 0.25rem;
88
- padding-top: 0;
89
- padding-bottom: 0;
90
- }
91
-
92
- .language-label {
93
- position: absolute;
94
- top: 0.5rem;
95
- right: 0.75rem;
96
- font-size: 12px;
97
- color: var(--ink-gray-4);
98
- pointer-events: none;
99
- user-select: none;
100
- }
101
-
102
- /* ── pre shell (editor-specific overrides) ──────────────────── */
103
- </style>
@@ -1,153 +0,0 @@
1
- <template>
2
- <!--
3
- Controlled rather than trigger-driven: the menu passes `onClick` down to the
4
- button it renders, and reka's PopoverTrigger merges its own handler onto the
5
- same element, so both fire on one click. Opening stays ours — `update:open`
6
- is only honoured on the way down, which keeps Escape and outside-click
7
- working.
8
- -->
9
- <Popover :open="isOpen" @update:open="(value) => !value && (isOpen = false)">
10
- <template #trigger>
11
- <slot v-bind="{ onClick: () => (isOpen = !isOpen), isActive: isOpen }" />
12
- </template>
13
- <template #default>
14
- <div class="p-2">
15
- <div class="text-sm text-ink-gray-7">Text Color</div>
16
- <div class="mt-1 grid grid-cols-6 gap-1">
17
- <Tooltip
18
- class="flex"
19
- v-for="color in foregroundColors"
20
- :key="color.name"
21
- :text="color.name"
22
- >
23
- <button
24
- :aria-label="color.name"
25
- class="flex h-5 w-5 items-center justify-center rounded-4 border text-base"
26
- :class="color.class"
27
- @click="setForegroundColor(color)"
28
- >
29
- A
30
- </button>
31
- </Tooltip>
32
- </div>
33
- <div class="mt-2 text-sm text-ink-gray-7">Background Color</div>
34
- <div class="mt-1 grid grid-cols-6 gap-1">
35
- <Tooltip
36
- class="flex"
37
- v-for="color in backgroundColors"
38
- :key="color.name"
39
- :text="color.name"
40
- >
41
- <button
42
- :aria-label="color.name"
43
- class="flex h-5 w-5 items-center justify-center rounded-4 border text-base text-ink-gray-9"
44
- :class="color.class"
45
- @click="setBackgroundColor(color)"
46
- >
47
- A
48
- </button>
49
- </Tooltip>
50
- </div>
51
- </div>
52
- </template>
53
- </Popover>
54
- </template>
55
- <script>
56
- import Popover from '#components/Popover/Popover.vue'
57
- import { Tooltip } from '#components/Tooltip'
58
-
59
- export default {
60
- name: 'FontColor',
61
- props: ['editor'],
62
- components: { Popover, Tooltip },
63
- data() {
64
- return { isOpen: false }
65
- },
66
- methods: {
67
- setBackgroundColor(color) {
68
- if (color.name != 'Default') {
69
- this.editor
70
- .chain()
71
- .focus()
72
- .toggleHighlightByName(color.name.toLowerCase())
73
- .run()
74
- } else {
75
- this.editor.chain().focus().unsetHighlight().run()
76
- }
77
- },
78
- setForegroundColor(color) {
79
- if (color.name != 'Default') {
80
- this.editor
81
- .chain()
82
- .focus()
83
- .setColorByName(color.name.toLowerCase())
84
- .run()
85
- } else {
86
- this.editor.chain().focus().unsetColor().run()
87
- }
88
- },
89
- },
90
- computed: {
91
- foregroundColors() {
92
- return [
93
- { name: 'Default', class: 'text-ink-gray-9' },
94
- { name: 'Red', class: 'text-red-600 dark:text-dark-red-400' },
95
- { name: 'Orange', class: 'text-orange-600 dark:text-dark-orange-400' },
96
- { name: 'Yellow', class: 'text-yellow-600 dark:text-dark-yellow-400' },
97
- { name: 'Green', class: 'text-green-600 dark:text-dark-green-400' },
98
- { name: 'Teal', class: 'text-teal-600 dark:text-dark-teal-400' },
99
- { name: 'Cyan', class: 'text-cyan-600 dark:text-dark-cyan-400' },
100
- { name: 'Blue', class: 'text-blue-600 dark:text-dark-blue-400' },
101
- { name: 'Purple', class: 'text-purple-600 dark:text-dark-purple-400' },
102
- { name: 'Pink', class: 'text-pink-600 dark:text-dark-pink-400' },
103
- { name: 'Gray', class: 'text-gray-600 dark:text-dark-gray-400' },
104
- ]
105
- },
106
- backgroundColors() {
107
- return [
108
- { name: 'Default', class: 'border-outline-elevation-2' },
109
- {
110
- name: 'Red',
111
- class: 'bg-red-100 dark:bg-dark-red-800 border-transparent',
112
- },
113
- {
114
- name: 'Orange',
115
- class: 'bg-orange-100 dark:bg-dark-orange-800 border-transparent',
116
- },
117
- {
118
- name: 'Yellow',
119
- class: 'bg-yellow-100 dark:bg-dark-yellow-800 border-transparent',
120
- },
121
- {
122
- name: 'Green',
123
- class: 'bg-green-100 dark:bg-dark-green-800 border-transparent',
124
- },
125
- {
126
- name: 'Teal',
127
- class: 'bg-teal-100 dark:bg-dark-teal-800 border-transparent',
128
- },
129
- {
130
- name: 'Cyan',
131
- class: 'bg-cyan-100 dark:bg-dark-cyan-800 border-transparent',
132
- },
133
- {
134
- name: 'Blue',
135
- class: 'bg-blue-100 dark:bg-dark-blue-800 border-transparent',
136
- },
137
- {
138
- name: 'Purple',
139
- class: 'bg-purple-100 dark:bg-dark-purple-800 border-transparent',
140
- },
141
- {
142
- name: 'Pink',
143
- class: 'bg-pink-100 dark:bg-dark-pink-800 border-transparent',
144
- },
145
- {
146
- name: 'Gray',
147
- class: 'bg-gray-100 dark:bg-dark-gray-800 border-transparent',
148
- },
149
- ]
150
- },
151
- },
152
- }
153
- </script>