frappe-ui 0.0.20 → 0.0.21

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frappe-ui",
3
- "version": "0.0.20",
3
+ "version": "0.0.21",
4
4
  "description": "A set of components and utilities for rapid UI development",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -22,6 +22,7 @@
22
22
  "@tailwindcss/forms": "^0.4.0",
23
23
  "@tailwindcss/typography": "^0.5.0",
24
24
  "@tiptap/extension-image": "^2.0.0-beta.27",
25
+ "@tiptap/extension-link": "^2.0.0-beta.37",
25
26
  "@tiptap/extension-placeholder": "^2.0.0-beta.48",
26
27
  "@tiptap/starter-kit": "^2.0.0-beta.183",
27
28
  "@tiptap/vue-3": "^2.0.0-beta.90",
@@ -10,7 +10,7 @@
10
10
  v-else
11
11
  class="flex p-1 text-gray-800 transition-colors rounded"
12
12
  :class="button.isActive(editor) ? 'bg-gray-100' : 'hover:bg-gray-100'"
13
- @click="() => button.action(editor)"
13
+ @click="onClick(button)"
14
14
  :title="button.label"
15
15
  >
16
16
  <FeatherIcon v-if="button.icon" :name="button.icon" class="w-4" />
@@ -20,6 +20,15 @@
20
20
  </button>
21
21
  </template>
22
22
  </div>
23
+
24
+ <Dialog :options="{ title: 'Set Link' }" v-model="setLinkDialog.show">
25
+ <template #body-content>
26
+ <Input type="text" label="URL" v-model="setLinkDialog.url" />
27
+ </template>
28
+ <template #actions>
29
+ <Button appearance="primary" @click="setLink"> Save </Button>
30
+ </template>
31
+ </Dialog>
23
32
  </div>
24
33
  </template>
25
34
  <script>
@@ -28,5 +37,40 @@ export default {
28
37
  name: 'TipTapMenu',
29
38
  props: ['editor', 'buttons'],
30
39
  components: { FeatherIcon },
40
+ data() {
41
+ return {
42
+ setLinkDialog: { url: '', show: false },
43
+ }
44
+ },
45
+ methods: {
46
+ onClick(button) {
47
+ if (button.label === 'Link') {
48
+ this.setLinkDialog.show = true
49
+ let existingURL = this.editor.getAttributes('link').href
50
+ if (existingURL) {
51
+ this.setLinkDialog.url = existingURL
52
+ }
53
+ } else {
54
+ button.action(this.editor)
55
+ }
56
+ },
57
+ setLink() {
58
+ // empty
59
+ if (this.setLinkDialog.url === '') {
60
+ this.editor.chain().focus().extendMarkRange('link').unsetLink().run()
61
+ } else {
62
+ // update link
63
+ this.editor
64
+ .chain()
65
+ .focus()
66
+ .extendMarkRange('link')
67
+ .setLink({ href: this.setLinkDialog.url })
68
+ .run()
69
+ }
70
+
71
+ this.setLinkDialog.show = false
72
+ this.setLinkDialog.url = ''
73
+ },
74
+ },
31
75
  }
32
76
  </script>
@@ -49,6 +49,7 @@ import { Editor, EditorContent, BubbleMenu, FloatingMenu } from '@tiptap/vue-3'
49
49
  import StarterKit from '@tiptap/starter-kit'
50
50
  import Placeholder from '@tiptap/extension-placeholder'
51
51
  import Image from '@tiptap/extension-image'
52
+ import Link from '@tiptap/extension-link'
52
53
  import Menu from './Menu.vue'
53
54
  import commands from './commands'
54
55
 
@@ -101,6 +102,7 @@ export default {
101
102
  extensions: [
102
103
  StarterKit,
103
104
  Image,
105
+ Link,
104
106
  Placeholder.configure({
105
107
  placeholder: this.placeholder || 'Write something...',
106
108
  }),
@@ -156,6 +158,7 @@ export default {
156
158
  'Separator',
157
159
  'Bold',
158
160
  'Italic',
161
+ 'Link',
159
162
  'Separator',
160
163
  'Bullet List',
161
164
  'Numbered List',
@@ -61,6 +61,11 @@ export default {
61
61
  action: (editor) => editor.chain().focus().setHorizontalRule().run(),
62
62
  isActive: (editor) => false,
63
63
  },
64
+ Link: {
65
+ label: 'Link',
66
+ icon: 'link',
67
+ isActive: (editor) => editor.isActive('link'),
68
+ },
64
69
  Undo: {
65
70
  label: 'Undo',
66
71
  icon: 'corner-up-left',