frappe-ui 1.1.0 → 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 (103) hide show
  1. package/experimental/Calendar/CalendarEventRow.vue +0 -4
  2. package/experimental/CommandPalette/CommandPaletteItem.vue +9 -1
  3. package/experimental/SpriteIcons/IconPicker.vue +2 -1
  4. package/experimental.ts +0 -21
  5. package/package.json +1 -3
  6. package/src/components/Breadcrumbs/Breadcrumbs.vue +2 -1
  7. package/src/components/DatePicker/DatePicker.md +7 -0
  8. package/src/components/DatePicker/DatePicker.vue +6 -0
  9. package/src/components/DatePicker/DateTimePicker.vue +6 -0
  10. package/src/components/DatePicker/composables.ts +18 -1
  11. package/src/components/DatePicker/utils.ts +53 -0
  12. package/src/components/HoverCard/HoverCard.vue +21 -5
  13. package/src/components/MobileNav/MobileNavItem.vue +3 -22
  14. package/src/components/SettingsDialog/SettingsDialog.api.md +7 -2
  15. package/src/components/SettingsDialog/SettingsDialog.md +2 -1
  16. package/src/components/SettingsDialog/SettingsRow.vue +12 -2
  17. package/src/components/Sidebar/SidebarItem.vue +3 -33
  18. package/src/components/SidebarRail/SidebarRailItem.vue +4 -17
  19. package/src/components/Tooltip/Tooltip.vue +8 -0
  20. package/src/components/shared/deferredTrigger.ts +174 -0
  21. package/src/components/shared/navLink.ts +45 -0
  22. package/src/molecules/editor/extensions/attachment/attachment-engine.ts +1 -1
  23. package/src/molecules/editor/extensions/content-paste/paste-html-utils.ts +16 -6
  24. package/src/molecules/editor/extensions/iframe/IframeNodeView.vue +26 -9
  25. package/src/molecules/editor/extensions/iframe/iframe-allowlist.ts +35 -16
  26. package/src/molecules/editor/extensions/iframe/iframe-embed-utils.ts +1 -1
  27. package/src/molecules/editor/extensions/iframe/iframe-extension.ts +30 -30
  28. package/src/molecules/editor/extensions/link/LinkEditorPopup.vue +1 -1
  29. package/src/molecules/editor/extensions/link/link-paste-plugin.ts +1 -1
  30. package/src/molecules/editor/extensions/shared/media-upload-engine.ts +1 -1
  31. package/src/molecules/list/ListRow.vue +8 -1
  32. package/src/utils/dialog.ts +20 -2
  33. package/src/{molecules/editor/extensions/shared → utils}/url-safety.ts +28 -16
  34. package/tailwind/content.js +0 -1
  35. package/tailwind/plugin.js +22 -0
  36. package/vite/doctypeInterfaceGenerator.js +52 -39
  37. package/vitepress/index.node.ts +0 -2
  38. package/experimental/TextEditor/TextEditor.api.md +0 -161
  39. package/experimental/TextEditor/TextEditor.vue +0 -298
  40. package/experimental/TextEditor/classIcon.ts +0 -21
  41. package/experimental/TextEditor/commands.js +0 -344
  42. package/experimental/TextEditor/components/CodeBlockComponent.vue +0 -103
  43. package/experimental/TextEditor/components/FontColor.vue +0 -153
  44. package/experimental/TextEditor/components/ImageViewerModal.vue +0 -463
  45. package/experimental/TextEditor/components/InsertImage.vue +0 -54
  46. package/experimental/TextEditor/components/InsertLink.vue +0 -13
  47. package/experimental/TextEditor/components/InsertVideo.vue +0 -14
  48. package/experimental/TextEditor/components/LinkPopup.vue +0 -99
  49. package/experimental/TextEditor/components/MediaNodeView.vue +0 -398
  50. package/experimental/TextEditor/components/MentionList.vue +0 -95
  51. package/experimental/TextEditor/components/TextEditorBubbleMenu.vue +0 -78
  52. package/experimental/TextEditor/components/TextEditorFixedMenu.vue +0 -78
  53. package/experimental/TextEditor/components/TextEditorFloatingMenu.vue +0 -61
  54. package/experimental/TextEditor/components/TextEditorMenu.vue +0 -218
  55. package/experimental/TextEditor/components/index.js +0 -0
  56. package/experimental/TextEditor/extensions/code-block.ts +0 -119
  57. package/experimental/TextEditor/extensions/color/color-extension.ts +0 -140
  58. package/experimental/TextEditor/extensions/color/color-styles.css +0 -25
  59. package/experimental/TextEditor/extensions/color/index.ts +0 -2
  60. package/experimental/TextEditor/extensions/content-paste-extension.ts +0 -160
  61. package/experimental/TextEditor/extensions/copy-styles.ts +0 -160
  62. package/experimental/TextEditor/extensions/emoji/EmojiList.vue +0 -55
  63. package/experimental/TextEditor/extensions/emoji/emoji-extension.ts +0 -55
  64. package/experimental/TextEditor/extensions/emoji/emojis.json +0 -7422
  65. package/experimental/TextEditor/extensions/heading/heading.ts +0 -20
  66. package/experimental/TextEditor/extensions/highlight/highlight-extension.ts +0 -241
  67. package/experimental/TextEditor/extensions/highlight/highlight-styles.css +0 -31
  68. package/experimental/TextEditor/extensions/highlight/index.ts +0 -2
  69. package/experimental/TextEditor/extensions/iframe/IframeNodeView.vue +0 -308
  70. package/experimental/TextEditor/extensions/iframe/InsertIframe.vue +0 -209
  71. package/experimental/TextEditor/extensions/iframe/iframe-extension.ts +0 -404
  72. package/experimental/TextEditor/extensions/iframe/index.ts +0 -11
  73. package/experimental/TextEditor/extensions/iframe/utils.ts +0 -283
  74. package/experimental/TextEditor/extensions/image/image-extension.ts +0 -661
  75. package/experimental/TextEditor/extensions/image/index.ts +0 -5
  76. package/experimental/TextEditor/extensions/image-group/ImageGroupNodeView.vue +0 -182
  77. package/experimental/TextEditor/extensions/image-group/ImageGroupUploadDialog.vue +0 -740
  78. package/experimental/TextEditor/extensions/image-group/image-group-extension.ts +0 -187
  79. package/experimental/TextEditor/extensions/image-viewer-extension.ts +0 -162
  80. package/experimental/TextEditor/extensions/link/index.ts +0 -1
  81. package/experimental/TextEditor/extensions/link/link-extension.ts +0 -323
  82. package/experimental/TextEditor/extensions/link/linkPasteHandler.ts +0 -51
  83. package/experimental/TextEditor/extensions/mention/index.ts +0 -1
  84. package/experimental/TextEditor/extensions/mention/mention-extension.ts +0 -204
  85. package/experimental/TextEditor/extensions/mention/style.css +0 -11
  86. package/experimental/TextEditor/extensions/shared/color-utils.ts +0 -236
  87. package/experimental/TextEditor/extensions/slash-commands/SlashCommandsList.vue +0 -59
  88. package/experimental/TextEditor/extensions/slash-commands/slash-commands-extension.ts +0 -184
  89. package/experimental/TextEditor/extensions/suggestion/SuggestionList.vue +0 -130
  90. package/experimental/TextEditor/extensions/suggestion/createSuggestionExtension.ts +0 -151
  91. package/experimental/TextEditor/extensions/suggestion/index.ts +0 -5
  92. package/experimental/TextEditor/extensions/tag/index.ts +0 -1
  93. package/experimental/TextEditor/extensions/tag/tag-extension.ts +0 -170
  94. package/experimental/TextEditor/extensions/toc-node/TocNodeView.vue +0 -439
  95. package/experimental/TextEditor/extensions/toc-node/index.ts +0 -3
  96. package/experimental/TextEditor/extensions/toc-node/toc-node-extension.ts +0 -167
  97. package/experimental/TextEditor/extensions/video-extension.ts +0 -653
  98. package/experimental/TextEditor/hljs-github.css +0 -197
  99. package/experimental/TextEditor/index.ts +0 -21
  100. package/experimental/TextEditor/style.css +0 -190
  101. package/experimental/TextEditor/types.ts +0 -72
  102. package/experimental/TextEditor/utils.js +0 -11
  103. package/src/utils/url-validation.ts +0 -39
@@ -1,160 +0,0 @@
1
- // @ts-nocheck -- frozen v0 code, kept out of type-check (see tsconfig.app.json)
2
- import { Extension, Node } from '@tiptap/core'
3
- import { Plugin, PluginKey } from '@tiptap/pm/state'
4
- import { Slice, Fragment } from '@tiptap/pm/model'
5
- import { DOMParser } from '@tiptap/pm/model'
6
- import { EditorView } from '@tiptap/pm/view'
7
- import { detectMarkdown, markdownToHTML } from '#utils/markdown'
8
- import { processMultipleImages } from './image/image-extension'
9
-
10
- export interface ContentPasteOptions {
11
- enabled: boolean
12
- uploadFunction: Function | null
13
- }
14
-
15
- export const ContentPasteExtension = Extension.create<ContentPasteOptions>({
16
- name: 'contentPaste',
17
-
18
- addOptions() {
19
- return {
20
- enabled: true,
21
- uploadFunction: null,
22
- }
23
- },
24
- addProseMirrorPlugins() {
25
- const extensionThis = this
26
- return [
27
- new Plugin({
28
- key: new PluginKey('contentPaste'),
29
- props: {
30
- transformCopied(slice) {
31
- if (!slice) return slice
32
- const newFragment = updateMediaSrcs(slice.content)
33
- return new Slice(newFragment, slice.openStart, slice.openEnd)
34
- },
35
- handlePaste: (view: EditorView, event: ClipboardEvent) => {
36
- if (!this.options.enabled) return false
37
-
38
- // handle image pasting
39
- const files: File[] | [] = Array.from(
40
- event.clipboardData?.files || [],
41
- )
42
- const images = Array.from(files).filter((file) =>
43
- file.type.startsWith('image/'),
44
- )
45
- if (images.length > 0) {
46
- processMultipleImages(images, view, null, extensionThis.options)
47
- return true
48
- }
49
-
50
- // handle html with media
51
- const htmlData = event.clipboardData?.getData('text/html')
52
- if (htmlData) {
53
- processHTMLImages(htmlData, view, this.options)
54
- return true
55
- }
56
-
57
- // handle markdown pasting
58
- const text = event.clipboardData?.getData('text/plain')
59
- if (!text) return false
60
-
61
- if (!detectMarkdown(text)) return false
62
-
63
- const htmlContent = markdownToHTML(text)
64
- const tempDiv = document.createElement('div')
65
- tempDiv.innerHTML = htmlContent
66
-
67
- const parser = DOMParser.fromSchema(view.state.schema)
68
- const parsedSlice = parser.parseSlice(tempDiv, {
69
- preserveWhitespace: true,
70
- })
71
-
72
- const tr = view.state.tr.replaceSelection(parsedSlice)
73
- view.dispatch(tr)
74
-
75
- return true
76
- },
77
- },
78
- }),
79
- ]
80
- },
81
- })
82
-
83
- async function processHTMLImages(
84
- html: string,
85
- view: EditorView,
86
- extensionOptions: ContentPasteOptions,
87
- ): Promise<undefined> {
88
- const tempDiv = document.createElement('div')
89
- tempDiv.innerHTML = html.replace(/font-size:\s*([\d.]+)pt/gi, (_, pt) => {
90
- const px = Math.round((parseFloat(pt) * 96) / 72)
91
- return `font-size:${px}px`
92
- })
93
- const images = tempDiv.querySelectorAll('img')
94
-
95
- const parser = DOMParser.fromSchema(view.state.schema)
96
- const parsedSlice = parser.parseSlice(tempDiv, {
97
- preserveWhitespace: true,
98
- })
99
- const tr = view.state.tr.replaceSelection(parsedSlice)
100
- view.dispatch(tr)
101
-
102
- const imageInfo: Array<{ src: string; pos: number }> = []
103
- view.state.doc.descendants((node, pos) => {
104
- for (let img of images) {
105
- const src = img.getAttribute('src')
106
- if (node.type.name === 'image' && node.attrs['src'] === src) {
107
- imageInfo.push({ src, pos })
108
- }
109
- }
110
- })
111
-
112
- // Process each image
113
- const imagePromises = Array.from(imageInfo).map(async ({ src, pos }) => {
114
- if (src.startsWith('data:') || src.startsWith('blob:')) {
115
- try {
116
- const response = await fetch(src)
117
- const blob = await response.blob()
118
- const file = new File([blob], 'pasted-data-image.png', {
119
- type: blob.type,
120
- })
121
- processMultipleImages([file], view, pos, extensionOptions)
122
- } catch (error) {
123
- console.error('Failed to process image:', error)
124
- }
125
- }
126
- })
127
-
128
- await Promise.all(imagePromises)
129
- }
130
-
131
- function updateMediaSrcs(fragment: Fragment) {
132
- const children: Node[] = []
133
- fragment.forEach((node) => {
134
- let newNode = node
135
-
136
- // If it's an image node, modify attrs
137
- if (node.type.name === 'image' || node.type.name === 'video') {
138
- const src = node.attrs.src
139
- if (src && src.startsWith('/')) {
140
- newNode = node.type.create(
141
- {
142
- ...node.attrs,
143
- src: `${window.location.origin}${src}`,
144
- },
145
- node.content,
146
- node.marks,
147
- )
148
- }
149
- }
150
-
151
- // Recurse into children
152
- if (node.content && node.content.size > 0) {
153
- newNode = newNode.copy(updateMediaSrcs(node.content))
154
- }
155
-
156
- children.push(newNode)
157
- })
158
-
159
- return Fragment.fromArray(children)
160
- }
@@ -1,160 +0,0 @@
1
- // @ts-nocheck -- frozen v0 code, kept out of type-check (see tsconfig.app.json)
2
- import { Extension } from '@tiptap/core'
3
- import { Plugin } from '@tiptap/pm/state'
4
-
5
- interface StyleClipboardOptions {
6
- enabled: boolean
7
- }
8
-
9
- const COPIED_MARKS = [
10
- 'textStyle',
11
- 'underline',
12
- 'strike',
13
- 'bold',
14
- 'italic',
15
- 'namedHighlight',
16
- 'namedColor',
17
- ]
18
- const PARAGRAPH_ATTRS = ['lineHeight', 'spacingBefore', 'spacingAfter']
19
-
20
- const StyleClipboardExtension = Extension.create<StyleClipboardOptions>({
21
- name: 'styleClipboard',
22
-
23
- addOptions() {
24
- return { enabled: true }
25
- },
26
- addCommands() {
27
- return {
28
- storeStyles:
29
- () =>
30
- ({ editor }) => {
31
- const { state } = editor
32
- const { from, to } = state.selection
33
- if (from === to) return false
34
-
35
- const marks: Record<string, any> = {}
36
- state.doc.nodesBetween(from, to, (node) => {
37
- node.marks.forEach((mark) => (marks[mark.type.name] = mark.attrs))
38
- })
39
-
40
- const storedNodeAttrs = state.doc.resolve(from).parent.attrs
41
- this.storage.styleClipboard = {
42
- marks,
43
- nodeAttrs: storedNodeAttrs,
44
- }
45
- return true
46
- },
47
-
48
- applyStyles:
49
- () =>
50
- ({ editor, tr, dispatch }) => {
51
- const { state } = editor
52
- const { from, to } = state.selection
53
- const stored = this.storage?.styleClipboard
54
- if (!stored) return false
55
-
56
- COPIED_MARKS.forEach((markName) => {
57
- const markType = state.schema.marks[markName]
58
- if (markType) {
59
- tr.removeMark(from, to, markType)
60
- }
61
- })
62
-
63
- const { marks } = stored
64
- for (const [markName, attrs] of Object.entries(marks)) {
65
- const markType = state.schema.marks[markName]
66
- if (markType) {
67
- tr.addMark(from, to, markType.create(attrs))
68
- }
69
- }
70
- dispatch(tr)
71
- this.storage.styleClipboard = null
72
- return true
73
- },
74
-
75
- clearStyles:
76
- () =>
77
- ({ editor, tr, dispatch }) => {
78
- console.log('called!')
79
- const { state } = editor
80
- const { from, to } = state.selection
81
- COPIED_MARKS.forEach((markName) => {
82
- const markType = state.schema.marks[markName]
83
- if (markType) {
84
- tr.removeMark(from, to, markType)
85
- }
86
- })
87
-
88
- const paragraphType = state.schema.nodes.paragraph
89
- if (paragraphType) {
90
- state.doc.nodesBetween(from, to, (node, pos) => {
91
- if (node.type === paragraphType) {
92
- // Reset paragraph attributes to null
93
- const clearedAttrs: Record<string, null> = {}
94
- PARAGRAPH_ATTRS.forEach((attr) => {
95
- clearedAttrs[attr] = null
96
- })
97
-
98
- tr.setNodeMarkup(pos, null, {
99
- ...node.attrs,
100
- ...clearedAttrs,
101
- })
102
- }
103
- })
104
- }
105
- dispatch(tr)
106
- },
107
- }
108
- },
109
- addKeyboardShortcuts() {
110
- return {
111
- Escape: ({ tr, dispatch }) => {
112
- if (this.storage.styleClipboard) {
113
- console.log(this.storage.styleClipboard)
114
- this.storage.styleClipboard = null
115
- this.editor.commands.focus()
116
- return true
117
- }
118
- },
119
- }
120
- },
121
- addStorage() {
122
- return {
123
- styleClipboard: null as {
124
- marks: Record<string, any>
125
- nodeAttrs: Record<string, any>
126
- } | null,
127
- }
128
- },
129
- addProseMirrorPlugins() {
130
- const extension = this
131
-
132
- return [
133
- new Plugin({
134
- view(view) {
135
- const applyIfPainting = () => {
136
- const stored = extension.storage.styleClipboard
137
- if (!stored) return
138
-
139
- const { from, to } = view.state.selection
140
- if (from === to) return
141
-
142
- extension.editor.commands.applyStyles()
143
- }
144
-
145
- const handleMouseUp = () => applyIfPainting()
146
-
147
- view.dom.addEventListener('mouseup', handleMouseUp)
148
-
149
- return {
150
- destroy() {
151
- view.dom.removeEventListener('mouseup', handleMouseUp)
152
- },
153
- }
154
- },
155
- }),
156
- ]
157
- },
158
- })
159
-
160
- export default StyleClipboardExtension
@@ -1,55 +0,0 @@
1
- <template>
2
- <SuggestionList
3
- ref="suggestionList"
4
- :items="items"
5
- :command="(item) => onItemSelect(item as EmojiItem)"
6
- item-class="py-2"
7
- >
8
- <template #default="{ item }">
9
- <span class="mr-2">{{ item.emoji }}</span>
10
- <span>{{ item.name }}</span>
11
- </template>
12
- </SuggestionList>
13
- </template>
14
-
15
- <script setup lang="ts">
16
- import { ref, type PropType } from 'vue'
17
- import SuggestionList from '../suggestion/SuggestionList.vue'
18
- import type { Editor, Range } from '@tiptap/core'
19
- import type { EmojiItem } from './emoji-extension'
20
-
21
- const props = defineProps({
22
- items: {
23
- type: Array as PropType<EmojiItem[]>,
24
- required: true,
25
- },
26
- editor: {
27
- type: Object as PropType<Editor>,
28
- required: true,
29
- },
30
- range: {
31
- type: Object as PropType<Range>,
32
- required: true,
33
- },
34
- command: {
35
- type: Function as PropType<(item: EmojiItem) => void>,
36
- required: true,
37
- },
38
- })
39
-
40
- const suggestionList = ref<InstanceType<typeof SuggestionList> | null>(null)
41
-
42
- const onItemSelect = (item: EmojiItem) => {
43
- if (item) {
44
- props.command(item)
45
- }
46
- }
47
-
48
- const onKeyDown = ({ event }: { event: KeyboardEvent }) => {
49
- return suggestionList.value?.onKeyDown({ event }) ?? false
50
- }
51
-
52
- defineExpose({
53
- onKeyDown,
54
- })
55
- </script>
@@ -1,55 +0,0 @@
1
- import { PluginKey } from '@tiptap/pm/state'
2
- import {
3
- BaseSuggestionItem,
4
- createSuggestionExtension,
5
- } from '../suggestion/createSuggestionExtension'
6
- import EmojiList from './EmojiList.vue'
7
- import _EMOJIS from './emojis.json'
8
-
9
- const EMOJIS = _EMOJIS as EmojiItem[]
10
-
11
- export interface EmojiItem extends BaseSuggestionItem {
12
- name: string
13
- emoji: string
14
- }
15
-
16
- export default createSuggestionExtension<EmojiItem>({
17
- name: 'emoji',
18
- char: ':',
19
- pluginKey: new PluginKey('emojiSuggestion'),
20
- items: ({ query }: { query: string }) => {
21
- return EMOJIS.filter((item) =>
22
- item.name.toLowerCase().includes(query.toLowerCase()),
23
- )
24
- .sort((a, b) => {
25
- const aName = a.name.toLowerCase()
26
- const bName = b.name.toLowerCase()
27
- const queryLower = query.toLowerCase()
28
-
29
- // Exact matches first
30
- if (aName === queryLower && bName !== queryLower) return -1
31
- if (bName === queryLower && aName !== queryLower) return 1
32
-
33
- // Then names starting with the query
34
- if (aName.startsWith(queryLower) && !bName.startsWith(queryLower))
35
- return -1
36
- if (bName.startsWith(queryLower) && !aName.startsWith(queryLower))
37
- return 1
38
-
39
- // Then sort by name length (shorter first)
40
- return aName.length - bName.length
41
- })
42
- .slice(0, 5)
43
- },
44
- command: ({ editor, range, props: item }) => {
45
- if (item && item.emoji) {
46
- editor.chain().focus().deleteRange(range).insertContent(item.emoji).run()
47
- } else {
48
- console.error(
49
- 'Emoji command execution error: emoji property not found on selected item or item is invalid.',
50
- item,
51
- )
52
- }
53
- },
54
- component: EmojiList,
55
- })