tiptapify 0.0.5 → 0.0.6

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.
@@ -0,0 +1,60 @@
1
+ import * as mdi from "@mdi/js";
2
+ import { Editor } from "@tiptap/vue-3";
3
+ import { computed } from "vue";
4
+
5
+ export function getAlignmentItems(editor: Editor) {
6
+ return {
7
+ alignmentLeft: {
8
+ name: 'alignments.left',
9
+ tooltip: 'alignments.left',
10
+ icon: mdi.mdiFormatAlignLeft,
11
+ enabled: true,
12
+ props: {
13
+ active: false,
14
+ color: computed(() => editor.isActive({ textAlign: 'left' }) ? 'primary' : ''),
15
+ },
16
+ attrs: {
17
+ click: () => editor.chain().focus().toggleTextAlign('left').run()
18
+ }
19
+ },
20
+ alignmentCenter: {
21
+ name: 'alignments.center',
22
+ tooltip: 'alignments.center',
23
+ icon: mdi.mdiFormatAlignCenter,
24
+ enabled: true,
25
+ props: {
26
+ active: false,
27
+ color: computed(() => editor.isActive({ textAlign: 'center' }) ? 'primary' : ''),
28
+ },
29
+ attrs: {
30
+ click: () => editor.chain().focus().toggleTextAlign('center').run()
31
+ }
32
+ },
33
+ alignmentRight: {
34
+ name: 'alignments.right',
35
+ tooltip: 'alignments.right',
36
+ icon: mdi.mdiFormatAlignRight,
37
+ enabled: true,
38
+ props: {
39
+ active: false,
40
+ color: computed(() => editor.isActive({ textAlign: 'right' }) ? 'primary' : ''),
41
+ },
42
+ attrs: {
43
+ click: () => editor.chain().focus().toggleTextAlign('right').run()
44
+ }
45
+ },
46
+ alignmentJustify: {
47
+ name: 'alignments.justify',
48
+ tooltip: 'alignments.justify',
49
+ icon: mdi.mdiFormatAlignJustify,
50
+ enabled: true,
51
+ props: {
52
+ active: false,
53
+ color: computed(() => editor.isActive({ textAlign: 'justify' }) ? 'primary' : ''),
54
+ },
55
+ attrs: {
56
+ click: () => editor.chain().focus().toggleTextAlign('justify').run()
57
+ }
58
+ },
59
+ }
60
+ }
@@ -0,0 +1,73 @@
1
+ import * as mdi from "@mdi/js";
2
+ import { Editor } from "@tiptap/vue-3";
3
+ import { computed } from "vue";
4
+
5
+ export function getFormatItems(editor: Editor) {
6
+ return {
7
+ bold: {
8
+ name: 'bold',
9
+ tooltip: 'format.bold',
10
+ icon: mdi.mdiFormatBold,
11
+ enabled: true,
12
+ props: {
13
+ disabled: computed(() => !editor.can().chain().focus().toggleBold().run()),
14
+ color: computed(() => editor.isActive('bold') ? 'primary' : ''),
15
+ },
16
+ attrs: {
17
+ click: () => editor.chain().focus().toggleBold().run()
18
+ }
19
+ },
20
+ italic: {
21
+ name: 'italic',
22
+ tooltip: 'format.italic',
23
+ icon: mdi.mdiFormatItalic,
24
+ enabled: true,
25
+ props: {
26
+ disabled: computed(() => !editor.can().chain().focus().toggleItalic().run()),
27
+ color: computed(() => editor.isActive('italic') ? 'primary' : ''),
28
+ },
29
+ attrs: {
30
+ click: () => editor.chain().focus().toggleItalic().run()
31
+ }
32
+ },
33
+ strike: {
34
+ name: 'strike',
35
+ tooltip: 'format.strike',
36
+ icon: mdi.mdiFormatStrikethroughVariant,
37
+ enabled: true,
38
+ props: {
39
+ disabled: computed(() => !editor.can().chain().focus().toggleStrike().run()),
40
+ color: computed(() => editor.isActive('strike') ? 'primary' : ''),
41
+ },
42
+ attrs: {
43
+ click: () => editor.chain().focus().toggleStrike().run()
44
+ }
45
+ },
46
+ underline: {
47
+ name: 'underline',
48
+ tooltip: 'format.underline',
49
+ icon: mdi.mdiFormatUnderline,
50
+ enabled: true,
51
+ props: {
52
+ disabled: computed(() => !editor.can().chain().focus().toggleUnderline().run()),
53
+ color: computed(() => editor.isActive('underline') ? 'primary' : ''),
54
+ },
55
+ attrs: {
56
+ click: () => editor.chain().focus().toggleUnderline().run()
57
+ }
58
+ },
59
+ highlight: {
60
+ name: 'highlight',
61
+ tooltip: 'format.highlight',
62
+ icon: mdi.mdiMarker,
63
+ enabled: true,
64
+ props: {
65
+ disabled: computed(() => !editor.can().chain().focus().toggleHighlight().run()),
66
+ color: computed(() => editor.isActive('highlight') ? 'primary' : ''),
67
+ },
68
+ attrs: {
69
+ click: () => editor.chain().focus().toggleHighlight().run()
70
+ }
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,73 @@
1
+ import * as mdi from "@mdi/js";
2
+ import { Editor } from "@tiptap/vue-3";
3
+ import { computed } from "vue";
4
+
5
+ export function getFormatExtraItems(editor: Editor) {
6
+ return {
7
+ sup: {
8
+ name: 'sup',
9
+ tooltip: 'format.sup',
10
+ icon: mdi.mdiFormatSuperscript,
11
+ enabled: true,
12
+ props: {
13
+ disabled: computed(() => !editor.can().chain().focus().toggleSuperscript().run()),
14
+ color: computed(() => editor.isActive('superscript') ? 'primary' : ''),
15
+ },
16
+ attrs: {
17
+ click: () => editor.chain().focus().toggleSuperscript().run()
18
+ }
19
+ },
20
+ sub: {
21
+ name: 'sub',
22
+ tooltip: 'format.sub',
23
+ icon: mdi.mdiFormatSubscript,
24
+ enabled: true,
25
+ props: {
26
+ disabled: computed(() => !editor.can().chain().focus().toggleSubscript().run()),
27
+ color: computed(() => editor.isActive('subscript') ? 'primary' : ''),
28
+ },
29
+ attrs: {
30
+ click: () => editor.chain().focus().toggleSubscript().run()
31
+ }
32
+ },
33
+ code: {
34
+ name: 'code',
35
+ tooltip: 'format.code',
36
+ icon: mdi.mdiXml,
37
+ enabled: true,
38
+ props: {
39
+ disabled: computed(() => !editor.can().chain().focus().toggleCode().run()),
40
+ color: computed(() => editor.isActive('code') ? 'primary' : ''),
41
+ },
42
+ attrs: {
43
+ click: () => editor.chain().focus().toggleCode().run()
44
+ }
45
+ },
46
+ codeBlock: {
47
+ name: 'codeblock',
48
+ tooltip: 'format.codeblock',
49
+ icon: mdi.mdiCodeBlockTags,
50
+ enabled: true,
51
+ props: {
52
+ disabled: computed(() => !editor.can().chain().focus().toggleCodeBlock().run()),
53
+ color: computed(() => editor.isActive('codeBlock') ? 'primary' : ''),
54
+ },
55
+ attrs: {
56
+ click: () => editor.chain().focus().toggleCodeBlock().run()
57
+ }
58
+ },
59
+ blockquote: {
60
+ name: 'blockquote',
61
+ tooltip: 'format.blockquote',
62
+ icon: mdi.mdiCommentQuote,
63
+ enabled: true,
64
+ props: {
65
+ disabled: computed(() => !editor.can().chain().focus().toggleBlockquote().run()),
66
+ color: computed(() => editor.isActive('blockquote') ? 'primary' : ''),
67
+ },
68
+ attrs: {
69
+ click: () => editor.chain().focus().toggleBlockquote().run()
70
+ }
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,70 @@
1
+ import * as mdi from "@mdi/js";
2
+ import { Editor } from "@tiptap/vue-3";
3
+ import { computed } from "vue";
4
+
5
+ export function getListItems(editor: Editor) {
6
+ return {
7
+ listBullet: {
8
+ name: 'lists.bullet',
9
+ tooltip: 'lists.bullet',
10
+ icon: mdi.mdiFormatListBulleted,
11
+ enabled: true,
12
+ props: {
13
+ color: computed(() => editor.isActive('bulletList') ? 'primary' : ''),
14
+ },
15
+ attrs: {
16
+ click: () => editor.chain().focus().toggleBulletList().run()
17
+ }
18
+ },
19
+ listNumbered: {
20
+ name: 'lists.numbered',
21
+ tooltip: 'lists.numbered',
22
+ icon: mdi.mdiFormatListNumbered,
23
+ enabled: true,
24
+ props: {
25
+ color: computed(() => editor.isActive('orderedList') ? 'primary' : ''),
26
+ },
27
+ attrs: {
28
+ click: () => editor.chain().focus().toggleOrderedList().run()
29
+ }
30
+ },
31
+ listTask: {
32
+ name: 'lists.task',
33
+ tooltip: 'lists.task',
34
+ icon: mdi.mdiFormatListChecks,
35
+ enabled: true,
36
+ props: {
37
+ color: computed(() => editor.isActive('taskList') ? 'primary' : ''),
38
+ },
39
+ attrs: {
40
+ click: () => editor.chain().focus().toggleTaskList().run()
41
+ }
42
+ },
43
+ listIndent: {
44
+ name: 'lists.indent',
45
+ tooltip: 'lists.indent',
46
+ icon: mdi.mdiFormatIndentIncrease,
47
+ enabled: true,
48
+ props: {
49
+ disabled: computed(() => !editor.can().sinkListItem('listItem')),
50
+ active: false,
51
+ },
52
+ attrs: {
53
+ click: () => editor.chain().focus().sinkListItem('listItem').run()
54
+ }
55
+ },
56
+ listOutdent: {
57
+ name: 'lists.outdent',
58
+ tooltip: 'lists.outdent',
59
+ icon: mdi.mdiFormatIndentDecrease,
60
+ enabled: true,
61
+ props: {
62
+ disabled: computed(() => !editor.can().liftListItem('listItem')),
63
+ active: false,
64
+ },
65
+ attrs: {
66
+ click: () => editor.chain().focus().liftListItem('listItem').run()
67
+ }
68
+ }
69
+ }
70
+ }
@@ -0,0 +1,25 @@
1
+ import * as mdi from "@mdi/js";
2
+ import { Editor } from "@tiptap/vue-3";
3
+ import { computed } from "vue";
4
+
5
+ export function getMediaItems(editor: Editor, toolbarLinkButton: any) {
6
+ return {
7
+ link: {
8
+ name: 'format.link',
9
+ tooltip: 'format.link',
10
+ icon: computed(() => editor.isActive('link') ? mdi.mdiLinkOff : mdi.mdiLink),
11
+ enabled: true,
12
+ props: {
13
+ color: computed(() => editor.isActive('link') ? 'primary' : ''),
14
+ disabled: computed(() => editor.isActive('code') || editor.isActive('codeBlock')),
15
+ },
16
+ attrs: {
17
+ click: computed(() => {
18
+ return editor.isActive('link')
19
+ ? editor.chain().focus().unsetLink().run
20
+ : toolbarLinkButton?.value?.open
21
+ })
22
+ }
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,50 @@
1
+ import * as mdi from "@mdi/js";
2
+ import { Editor } from "@tiptap/vue-3";
3
+ import { computed } from "vue";
4
+
5
+ export function getMiscItems(editor: Editor) {
6
+ return {
7
+ line: {
8
+ name: 'line',
9
+ tooltip: 'format.line',
10
+ icon: mdi.mdiMinus,
11
+ enabled: true,
12
+ props: {},
13
+ attrs: {
14
+ click: () => editor.chain().focus().setHorizontalRule().run()
15
+ }
16
+ },
17
+ break: {
18
+ name: 'break',
19
+ tooltip: 'format.break',
20
+ icon: mdi.mdiFormatPageBreak,
21
+ enabled: true,
22
+ props: {},
23
+ attrs: {
24
+ click: () => editor.chain().focus().setHardBreak().run()
25
+ }
26
+ },
27
+ source: {
28
+ name: 'source',
29
+ tooltip: 'misc.source',
30
+ icon: mdi.mdiCodeTags,
31
+ enabled: true,
32
+ props: {},
33
+ attrs: {
34
+ click: () => editor.commands.showSource()
35
+ }
36
+ },
37
+ formatClear: {
38
+ name: 'format clear',
39
+ tooltip: 'format.formatClear',
40
+ icon: mdi.mdiFormatClear,
41
+ enabled: true,
42
+ props: {
43
+ disabled: computed(() => !editor.can().chain().focus().unsetAllMarks().run()),
44
+ },
45
+ attrs: {
46
+ click: () => editor.chain().focus().unsetAllMarks().clearNodes().run()
47
+ }
48
+ },
49
+ }
50
+ }
@@ -0,0 +1,146 @@
1
+ import * as mdi from "@mdi/js";
2
+ import { Editor } from "@tiptap/vue-3";
3
+ import { fonts } from "@tiptapify/components/Toolbar/fonts";
4
+ import { computed, ref } from "vue";
5
+
6
+ interface MDIIcons {
7
+ [key: string]: string
8
+ }
9
+ const mdiIcons = mdi as MDIIcons
10
+
11
+ export function getStyleItems(editor: Editor, fontMeasure: string, customHeadingLevels: Array<number> = []) {
12
+ const headingLevels = ref([1, 2, 3, 4, 5, 6])
13
+ if (customHeadingLevels.length) {
14
+ customHeadingLevels.forEach(level => {
15
+ if (level <= 0 || level > 6) {
16
+ throw new Error('customHeadingLevels must be between 1 and 6')
17
+ }
18
+ })
19
+
20
+ headingLevels.value = customHeadingLevels
21
+ }
22
+
23
+ const fontSizes = [6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 32, 48, 64, 96]
24
+
25
+ const lineHeights = [1, 1.5, 2, 3, 4]
26
+
27
+ return {
28
+ heading: {
29
+ name: 'heading',
30
+ tooltip: 'style.heading',
31
+ icon: mdi.mdiFormatHeaderPound,
32
+ modelValue: null,
33
+ enabled: true,
34
+ props: {
35
+ color: computed(() => editor.isActive('heading') || editor.isActive('paragraph') ? 'primary' : ''),
36
+ },
37
+ children: [
38
+ {
39
+ name: `paragraph`,
40
+ tooltip: `style.paragraph`,
41
+ icon: mdiIcons[`mdiFormatParagraph`],
42
+ noI18n: true,
43
+ enabled: true,
44
+ props: {
45
+ color: computed(() => editor.isActive('paragraph') ? 'primary' : ''),
46
+ },
47
+ attrs: {
48
+ click: () => editor.chain().focus().setParagraph().run()
49
+ }
50
+ }
51
+ ].concat(
52
+ headingLevels.value.map(level => {
53
+ return {
54
+ name: `H${level}`,
55
+ tooltip: `style.headings.h${level}`,
56
+ icon: mdiIcons[`mdiFormatHeader${level}`],
57
+ noI18n: true,
58
+ enabled: true,
59
+ props: {
60
+ color: computed(() => editor.isActive('heading', { level: level }) ? 'primary' : ''),
61
+ },
62
+ attrs: {
63
+ click: () => editor.chain().focus().toggleHeading({ level }).run()
64
+ }
65
+ }
66
+ })
67
+ )
68
+ },
69
+ fontFamily: {
70
+ name: 'font-family',
71
+ tooltip: 'style.fontFamily',
72
+ icon: mdi.mdiFormatFont,
73
+ modelValue: null,
74
+ enabled: true,
75
+ attrs: {
76
+ click: () => editor.chain().focus().unsetFontFamily().run()
77
+ },
78
+ children: fonts.map((font) => {
79
+ return {
80
+ name: font.name,
81
+ tooltip: '',
82
+ icon: '',
83
+ enabled: true,
84
+ noI18n: true,
85
+ props: {
86
+ color: computed(() => editor.isActive('textStyle', {fontFamily: font.fontFamily}) ? 'primary' : ''),
87
+ style: `font-family: ${font.fontFamily};`
88
+ },
89
+ attrs: {
90
+ click: () => editor.chain().focus().setFontFamily(font.fontFamily).run()
91
+ }
92
+ }
93
+ })
94
+ },
95
+ fontSize: {
96
+ name: 'font-size',
97
+ tooltip: 'style.fontSize',
98
+ icon: mdi.mdiFormatSize,
99
+ modelValue: computed(() => editor.getAttributes('textStyle').fontSize || null),
100
+ enabled: true,
101
+ attrs: {
102
+ click: () => editor.chain().focus().unsetFontSize().run()
103
+ },
104
+ children: fontSizes.map((fontSize) => {
105
+ return {
106
+ name: `${fontSize}${fontMeasure}`,
107
+ tooltip: '',
108
+ icon: '',
109
+ enabled: true,
110
+ noI18n: true,
111
+ props: {
112
+ color: computed(() => editor.isActive('textStyle', {fontSizes: fontSize}) ? 'primary' : ''),
113
+ },
114
+ attrs: {
115
+ click: () => editor.chain().focus().setFontSize(`${fontSize}${fontMeasure}`).run()
116
+ }
117
+ }
118
+ })
119
+ },
120
+ lineHeight: {
121
+ name: 'line-height',
122
+ tooltip: 'style.lineHeight',
123
+ icon: mdi.mdiFormatLineHeight,
124
+ modelValue: null,
125
+ enabled: true,
126
+ attrs: {
127
+ click: () => editor.chain().focus().unsetLineHeight().run()
128
+ },
129
+ children: lineHeights.map((lineHeight) => {
130
+ return {
131
+ name: lineHeight,
132
+ tooltip: '',
133
+ icon: '',
134
+ enabled: true,
135
+ noI18n: true,
136
+ props: {
137
+ color: computed(() => editor.isActive('textStyle', {lineHeights: lineHeight}) ? 'primary' : ''),
138
+ },
139
+ attrs: {
140
+ click: () => editor.chain().focus().setLineHeight(lineHeight.toString()).run()
141
+ }
142
+ }
143
+ })
144
+ }
145
+ }
146
+ }