frappe-ui 0.0.87 → 0.0.89
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 +5 -1
- package/src/components/TextEditor/FontColor.vue +108 -0
- package/src/components/TextEditor/Menu.vue +3 -1
- package/src/components/TextEditor/TextEditor.vue +13 -0
- package/src/components/TextEditor/TextEditorFixedMenu.vue +1 -0
- package/src/components/TextEditor/commands.js +8 -0
- package/src/components/Tooltip.vue +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "frappe-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.89",
|
|
4
4
|
"description": "A set of components and utilities for rapid UI development",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
"@popperjs/core": "^2.11.2",
|
|
24
24
|
"@tailwindcss/forms": "^0.5.3",
|
|
25
25
|
"@tailwindcss/typography": "^0.5.0",
|
|
26
|
+
"@tiptap/extension-color": "^2.0.0-beta.202",
|
|
27
|
+
"@tiptap/extension-highlight": "^2.0.0-beta.202",
|
|
26
28
|
"@tiptap/extension-image": "^2.0.0-beta.30",
|
|
27
29
|
"@tiptap/extension-link": "^2.0.0-beta.43",
|
|
28
30
|
"@tiptap/extension-mention": "^2.0.0-beta.102",
|
|
@@ -32,6 +34,8 @@
|
|
|
32
34
|
"@tiptap/extension-table-header": "^2.0.0-beta.25",
|
|
33
35
|
"@tiptap/extension-table-row": "^2.0.0-beta.22",
|
|
34
36
|
"@tiptap/extension-text-align": "^2.0.0-beta.31",
|
|
37
|
+
"@tiptap/extension-text-style": "^2.0.0-beta.202",
|
|
38
|
+
"@tiptap/extension-typography": "^2.0.0-beta.202",
|
|
35
39
|
"@tiptap/starter-kit": "^2.0.0-beta.191",
|
|
36
40
|
"@tiptap/suggestion": "^2.0.0-beta.195",
|
|
37
41
|
"@tiptap/vue-3": "^2.0.0-beta.96",
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Popover transition="default">
|
|
3
|
+
<template #target="{ togglePopover, isOpen }">
|
|
4
|
+
<slot
|
|
5
|
+
v-bind="{ onClick: () => togglePopover(), isActive: isOpen }"
|
|
6
|
+
></slot>
|
|
7
|
+
</template>
|
|
8
|
+
<template #body-main>
|
|
9
|
+
<div class="p-2">
|
|
10
|
+
<div class="text-sm text-gray-700">Text Color</div>
|
|
11
|
+
<div class="mt-1 grid grid-cols-8 gap-1">
|
|
12
|
+
<Tooltip
|
|
13
|
+
class="flex"
|
|
14
|
+
v-for="color in foregroundColors"
|
|
15
|
+
:key="color.name"
|
|
16
|
+
:text="color.name"
|
|
17
|
+
>
|
|
18
|
+
<button
|
|
19
|
+
:aria-label="color.name"
|
|
20
|
+
class="flex h-5 w-5 items-center justify-center rounded border text-base"
|
|
21
|
+
:style="{
|
|
22
|
+
color: color.hex,
|
|
23
|
+
}"
|
|
24
|
+
@click="setForegroundColor(color)"
|
|
25
|
+
>
|
|
26
|
+
A
|
|
27
|
+
</button>
|
|
28
|
+
</Tooltip>
|
|
29
|
+
</div>
|
|
30
|
+
<div class="mt-2 text-sm text-gray-700">Background Color</div>
|
|
31
|
+
<div class="mt-1 grid grid-cols-8 gap-1">
|
|
32
|
+
<Tooltip
|
|
33
|
+
class="flex"
|
|
34
|
+
v-for="color in backgroundColors"
|
|
35
|
+
:key="color.name"
|
|
36
|
+
:text="color.name"
|
|
37
|
+
>
|
|
38
|
+
<button
|
|
39
|
+
:aria-label="color.name"
|
|
40
|
+
class="flex h-5 w-5 items-center justify-center rounded border text-base text-gray-900"
|
|
41
|
+
:class="!color.hex ? 'border-gray-200' : 'border-transparent'"
|
|
42
|
+
:style="{
|
|
43
|
+
backgroundColor: color.hex,
|
|
44
|
+
}"
|
|
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 '../Popover.vue'
|
|
57
|
+
import Tooltip from '../Tooltip.vue'
|
|
58
|
+
|
|
59
|
+
export default {
|
|
60
|
+
name: 'FontColor',
|
|
61
|
+
props: ['editor'],
|
|
62
|
+
components: { Popover, Tooltip },
|
|
63
|
+
methods: {
|
|
64
|
+
setBackgroundColor(color) {
|
|
65
|
+
if (color.name != 'Default') {
|
|
66
|
+
this.editor.chain().focus().toggleHighlight({ color: color.hex }).run()
|
|
67
|
+
} else {
|
|
68
|
+
this.editor.chain().focus().unsetHighlight().run()
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
setForegroundColor(color) {
|
|
72
|
+
if (color.name != 'Default') {
|
|
73
|
+
this.editor.chain().focus().setColor(color.hex).run()
|
|
74
|
+
} else {
|
|
75
|
+
this.editor.chain().focus().unsetColor().run()
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
computed: {
|
|
80
|
+
foregroundColors() {
|
|
81
|
+
// tailwind css colors, scale 600
|
|
82
|
+
return [
|
|
83
|
+
{ name: 'Default', hex: '#1F272E' },
|
|
84
|
+
{ name: 'Yellow', hex: '#ca8a04' },
|
|
85
|
+
{ name: 'Orange', hex: '#ea580c' },
|
|
86
|
+
{ name: 'Red', hex: '#dc2626' },
|
|
87
|
+
{ name: 'Green', hex: '#16a34a' },
|
|
88
|
+
{ name: 'Blue', hex: '#1579D0' },
|
|
89
|
+
{ name: 'Purple', hex: '#9333ea' },
|
|
90
|
+
{ name: 'Pink', hex: '#db2777' },
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
backgroundColors() {
|
|
94
|
+
// tailwind css colors, scale 100
|
|
95
|
+
return [
|
|
96
|
+
{ name: 'Default', hex: null },
|
|
97
|
+
{ name: 'Yellow', hex: '#fef9c3' },
|
|
98
|
+
{ name: 'Orange', hex: '#ffedd5' },
|
|
99
|
+
{ name: 'Red', hex: '#fee2e2' },
|
|
100
|
+
{ name: 'Green', hex: '#dcfce7' },
|
|
101
|
+
{ name: 'Blue', hex: '#D3E9FC' },
|
|
102
|
+
{ name: 'Purple', hex: '#f3e8ff' },
|
|
103
|
+
{ name: 'Pink', hex: '#fce7f3' },
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
}
|
|
108
|
+
</script>
|
|
@@ -55,7 +55,9 @@
|
|
|
55
55
|
<button
|
|
56
56
|
class="flex rounded p-1 text-gray-800 transition-colors"
|
|
57
57
|
:class="
|
|
58
|
-
button.isActive(editor)
|
|
58
|
+
button.isActive(editor) || componentSlotProps?.isActive
|
|
59
|
+
? 'bg-gray-100'
|
|
60
|
+
: 'hover:bg-gray-100'
|
|
59
61
|
"
|
|
60
62
|
@click="
|
|
61
63
|
componentSlotProps?.onClick
|
|
@@ -28,6 +28,10 @@ import TableRow from '@tiptap/extension-table-row'
|
|
|
28
28
|
import Image from './image-extension'
|
|
29
29
|
import Video from './video-extension'
|
|
30
30
|
import Link from '@tiptap/extension-link'
|
|
31
|
+
import Typography from '@tiptap/extension-typography'
|
|
32
|
+
import TextStyle from '@tiptap/extension-text-style'
|
|
33
|
+
import Highlight from '@tiptap/extension-highlight'
|
|
34
|
+
import { Color } from '@tiptap/extension-color'
|
|
31
35
|
import configureMention from './mention'
|
|
32
36
|
import TextEditorFixedMenu from './TextEditorFixedMenu.vue'
|
|
33
37
|
import TextEditorBubbleMenu from './TextEditorBubbleMenu.vue'
|
|
@@ -134,9 +138,13 @@ export default {
|
|
|
134
138
|
TableRow,
|
|
135
139
|
TableHeader,
|
|
136
140
|
TableCell,
|
|
141
|
+
Typography,
|
|
137
142
|
TextAlign.configure({
|
|
138
143
|
types: ['heading', 'paragraph'],
|
|
139
144
|
}),
|
|
145
|
+
TextStyle,
|
|
146
|
+
Color,
|
|
147
|
+
Highlight.configure({ multicolor: true }),
|
|
140
148
|
Image,
|
|
141
149
|
Video,
|
|
142
150
|
Link.configure({
|
|
@@ -259,4 +267,9 @@ img.ProseMirror-selectednode {
|
|
|
259
267
|
cursor: ew-resize;
|
|
260
268
|
cursor: col-resize;
|
|
261
269
|
}
|
|
270
|
+
|
|
271
|
+
.ProseMirror mark {
|
|
272
|
+
border-radius: 3px;
|
|
273
|
+
padding: 0 2px;
|
|
274
|
+
}
|
|
262
275
|
</style>
|
|
@@ -12,6 +12,7 @@ import Underline from './icons/underline.vue'
|
|
|
12
12
|
import AlignCenter from './icons/align-center.vue'
|
|
13
13
|
import AlignLeft from './icons/align-left.vue'
|
|
14
14
|
import AlignRight from './icons/align-right.vue'
|
|
15
|
+
import FontColor from './icons/font-color.vue'
|
|
15
16
|
import ListOrdered from './icons/list-ordered.vue'
|
|
16
17
|
import ListUnordered from './icons/list-unordered.vue'
|
|
17
18
|
import DoubleQuotes from './icons/double-quotes-r.vue'
|
|
@@ -127,6 +128,13 @@ export default {
|
|
|
127
128
|
action: (editor) => editor.chain().focus().setTextAlign('right').run(),
|
|
128
129
|
isActive: (editor) => editor.isActive({ textAlign: 'right' }),
|
|
129
130
|
},
|
|
131
|
+
FontColor: {
|
|
132
|
+
label: 'Font Color',
|
|
133
|
+
icon: FontColor,
|
|
134
|
+
isActive: (editor) =>
|
|
135
|
+
editor.isActive('textStyle') || editor.isActive('highlight'),
|
|
136
|
+
component: defineAsyncComponent(() => import('./FontColor.vue')),
|
|
137
|
+
},
|
|
130
138
|
Blockquote: {
|
|
131
139
|
label: 'Blockquote',
|
|
132
140
|
icon: DoubleQuotes,
|