sprintify-ui 0.10.80 → 0.10.82
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/dist/{BaseCkeditor-B4PbYw6a.js → BaseCkeditor-Laq0HbvP.js} +49 -32
- package/dist/sprintify-ui.es.js +31388 -14290
- package/dist/style.css +2 -2
- package/dist/types/components/BaseCkeditor.vue.d.ts +2 -6
- package/dist/types/components/BaseGantt.vue.d.ts +12 -12
- package/dist/types/components/BaseRichText.vue.d.ts +8 -2
- package/dist/types/components/BaseTipTap.vue.d.ts +14 -0
- package/package.json +8 -4
- package/src/assets/base-rich-text.css +32 -1
- package/src/components/BaseCkeditor.vue +22 -8
- package/src/components/BaseRichText.stories.js +9 -0
- package/src/components/BaseRichText.vue +21 -6
- package/src/components/BaseTipTap.vue +259 -0
|
@@ -4,11 +4,9 @@ type __VLS_Props = {
|
|
|
4
4
|
modelValue: string | null | undefined;
|
|
5
5
|
editor?: 'classic' | 'inline' | 'balloon';
|
|
6
6
|
size?: Size;
|
|
7
|
-
toolbar?: ToolbarOption[];
|
|
7
|
+
toolbar?: ToolbarOption[] | string[];
|
|
8
8
|
placeholder?: string;
|
|
9
9
|
disabled?: boolean;
|
|
10
|
-
required?: boolean;
|
|
11
|
-
name?: string;
|
|
12
10
|
};
|
|
13
11
|
declare const _default: import("vue").DefineComponent<__VLS_Props, {
|
|
14
12
|
getEditorData(): string;
|
|
@@ -26,11 +24,9 @@ declare const _default: import("vue").DefineComponent<__VLS_Props, {
|
|
|
26
24
|
onReady?: ((...args: any[]) => any) | undefined;
|
|
27
25
|
}>, {
|
|
28
26
|
size: Size;
|
|
29
|
-
required: boolean;
|
|
30
27
|
disabled: boolean;
|
|
31
|
-
name: string;
|
|
32
28
|
placeholder: string;
|
|
33
|
-
toolbar: ToolbarOption[];
|
|
29
|
+
toolbar: ToolbarOption[] | string[];
|
|
34
30
|
editor: "classic" | "inline" | "balloon";
|
|
35
31
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
36
32
|
export default _default;
|
|
@@ -71,7 +71,7 @@ declare const rowsInternal: import("vue").Ref<{
|
|
|
71
71
|
minus: (duration: import("luxon").DurationLike) => import("luxon").DateTime<boolean>;
|
|
72
72
|
startOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").StartOfOptions) => import("luxon").DateTime<boolean>;
|
|
73
73
|
endOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").EndOfOptions) => import("luxon").DateTime<boolean>;
|
|
74
|
-
toFormat: (
|
|
74
|
+
toFormat: (format: string, options?: import("luxon").LocaleOptions) => string;
|
|
75
75
|
toLocaleString: (formatOpts?: import("luxon").DateTimeFormatOptions, opts?: import("luxon").LocaleOptions) => string;
|
|
76
76
|
toLocaleParts: (opts?: import("luxon").DateTimeFormatOptions) => Intl.DateTimeFormatPart[];
|
|
77
77
|
toISO: (opts?: import("luxon").ToISOTimeOptions) => string | null;
|
|
@@ -154,7 +154,7 @@ declare const rowsInternal: import("vue").Ref<{
|
|
|
154
154
|
minus: (duration: import("luxon").DurationLike) => import("luxon").DateTime<boolean>;
|
|
155
155
|
startOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").StartOfOptions) => import("luxon").DateTime<boolean>;
|
|
156
156
|
endOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").EndOfOptions) => import("luxon").DateTime<boolean>;
|
|
157
|
-
toFormat: (
|
|
157
|
+
toFormat: (format: string, options?: import("luxon").LocaleOptions) => string;
|
|
158
158
|
toLocaleString: (formatOpts?: import("luxon").DateTimeFormatOptions, opts?: import("luxon").LocaleOptions) => string;
|
|
159
159
|
toLocaleParts: (opts?: import("luxon").DateTimeFormatOptions) => Intl.DateTimeFormatPart[];
|
|
160
160
|
toISO: (opts?: import("luxon").ToISOTimeOptions) => string | null;
|
|
@@ -252,7 +252,7 @@ declare const rowsInternal: import("vue").Ref<{
|
|
|
252
252
|
minus: (duration: import("luxon").DurationLike) => import("luxon").DateTime<boolean>;
|
|
253
253
|
startOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").StartOfOptions) => import("luxon").DateTime<boolean>;
|
|
254
254
|
endOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").EndOfOptions) => import("luxon").DateTime<boolean>;
|
|
255
|
-
toFormat: (
|
|
255
|
+
toFormat: (format: string, options?: import("luxon").LocaleOptions) => string;
|
|
256
256
|
toLocaleString: (formatOpts?: import("luxon").DateTimeFormatOptions, opts?: import("luxon").LocaleOptions) => string;
|
|
257
257
|
toLocaleParts: (opts?: import("luxon").DateTimeFormatOptions) => Intl.DateTimeFormatPart[];
|
|
258
258
|
toISO: (opts?: import("luxon").ToISOTimeOptions) => string | null;
|
|
@@ -335,7 +335,7 @@ declare const rowsInternal: import("vue").Ref<{
|
|
|
335
335
|
minus: (duration: import("luxon").DurationLike) => import("luxon").DateTime<boolean>;
|
|
336
336
|
startOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").StartOfOptions) => import("luxon").DateTime<boolean>;
|
|
337
337
|
endOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").EndOfOptions) => import("luxon").DateTime<boolean>;
|
|
338
|
-
toFormat: (
|
|
338
|
+
toFormat: (format: string, options?: import("luxon").LocaleOptions) => string;
|
|
339
339
|
toLocaleString: (formatOpts?: import("luxon").DateTimeFormatOptions, opts?: import("luxon").LocaleOptions) => string;
|
|
340
340
|
toLocaleParts: (opts?: import("luxon").DateTimeFormatOptions) => Intl.DateTimeFormatPart[];
|
|
341
341
|
toISO: (opts?: import("luxon").ToISOTimeOptions) => string | null;
|
|
@@ -429,7 +429,7 @@ declare const groups: import("vue").Ref<{
|
|
|
429
429
|
minus: (duration: import("luxon").DurationLike) => import("luxon").DateTime<boolean>;
|
|
430
430
|
startOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").StartOfOptions) => import("luxon").DateTime<boolean>;
|
|
431
431
|
endOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").EndOfOptions) => import("luxon").DateTime<boolean>;
|
|
432
|
-
toFormat: (
|
|
432
|
+
toFormat: (format: string, options?: import("luxon").LocaleOptions) => string;
|
|
433
433
|
toLocaleString: (formatOpts?: import("luxon").DateTimeFormatOptions, opts?: import("luxon").LocaleOptions) => string;
|
|
434
434
|
toLocaleParts: (opts?: import("luxon").DateTimeFormatOptions) => Intl.DateTimeFormatPart[];
|
|
435
435
|
toISO: (opts?: import("luxon").ToISOTimeOptions) => string | null;
|
|
@@ -518,7 +518,7 @@ declare const groups: import("vue").Ref<{
|
|
|
518
518
|
minus: (duration: import("luxon").DurationLike) => import("luxon").DateTime<boolean>;
|
|
519
519
|
startOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").StartOfOptions) => import("luxon").DateTime<boolean>;
|
|
520
520
|
endOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").EndOfOptions) => import("luxon").DateTime<boolean>;
|
|
521
|
-
toFormat: (
|
|
521
|
+
toFormat: (format: string, options?: import("luxon").LocaleOptions) => string;
|
|
522
522
|
toLocaleString: (formatOpts?: import("luxon").DateTimeFormatOptions, opts?: import("luxon").LocaleOptions) => string;
|
|
523
523
|
toLocaleParts: (opts?: import("luxon").DateTimeFormatOptions) => Intl.DateTimeFormatPart[];
|
|
524
524
|
toISO: (opts?: import("luxon").ToISOTimeOptions) => string | null;
|
|
@@ -608,7 +608,7 @@ declare const ticks: import("vue").Ref<{
|
|
|
608
608
|
minus: (duration: import("luxon").DurationLike) => import("luxon").DateTime<boolean>;
|
|
609
609
|
startOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").StartOfOptions) => import("luxon").DateTime<boolean>;
|
|
610
610
|
endOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").EndOfOptions) => import("luxon").DateTime<boolean>;
|
|
611
|
-
toFormat: (
|
|
611
|
+
toFormat: (format: string, options?: import("luxon").LocaleOptions) => string;
|
|
612
612
|
toLocaleString: (formatOpts?: import("luxon").DateTimeFormatOptions, opts?: import("luxon").LocaleOptions) => string;
|
|
613
613
|
toLocaleParts: (opts?: import("luxon").DateTimeFormatOptions) => Intl.DateTimeFormatPart[];
|
|
614
614
|
toISO: (opts?: import("luxon").ToISOTimeOptions) => string | null;
|
|
@@ -697,7 +697,7 @@ declare const ticks: import("vue").Ref<{
|
|
|
697
697
|
minus: (duration: import("luxon").DurationLike) => import("luxon").DateTime<boolean>;
|
|
698
698
|
startOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").StartOfOptions) => import("luxon").DateTime<boolean>;
|
|
699
699
|
endOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").EndOfOptions) => import("luxon").DateTime<boolean>;
|
|
700
|
-
toFormat: (
|
|
700
|
+
toFormat: (format: string, options?: import("luxon").LocaleOptions) => string;
|
|
701
701
|
toLocaleString: (formatOpts?: import("luxon").DateTimeFormatOptions, opts?: import("luxon").LocaleOptions) => string;
|
|
702
702
|
toLocaleParts: (opts?: import("luxon").DateTimeFormatOptions) => Intl.DateTimeFormatPart[];
|
|
703
703
|
toISO: (opts?: import("luxon").ToISOTimeOptions) => string | null;
|
|
@@ -802,7 +802,7 @@ declare var __VLS_1: {
|
|
|
802
802
|
minus: (duration: import("luxon").DurationLike) => import("luxon").DateTime<boolean>;
|
|
803
803
|
startOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").StartOfOptions) => import("luxon").DateTime<boolean>;
|
|
804
804
|
endOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").EndOfOptions) => import("luxon").DateTime<boolean>;
|
|
805
|
-
toFormat: (
|
|
805
|
+
toFormat: (format: string, options?: import("luxon").LocaleOptions) => string;
|
|
806
806
|
toLocaleString: (formatOpts?: import("luxon").DateTimeFormatOptions, opts?: import("luxon").LocaleOptions) => string;
|
|
807
807
|
toLocaleParts: (opts?: import("luxon").DateTimeFormatOptions) => Intl.DateTimeFormatPart[];
|
|
808
808
|
toISO: (opts?: import("luxon").ToISOTimeOptions) => string | null;
|
|
@@ -885,7 +885,7 @@ declare var __VLS_1: {
|
|
|
885
885
|
minus: (duration: import("luxon").DurationLike) => import("luxon").DateTime<boolean>;
|
|
886
886
|
startOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").StartOfOptions) => import("luxon").DateTime<boolean>;
|
|
887
887
|
endOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").EndOfOptions) => import("luxon").DateTime<boolean>;
|
|
888
|
-
toFormat: (
|
|
888
|
+
toFormat: (format: string, options?: import("luxon").LocaleOptions) => string;
|
|
889
889
|
toLocaleString: (formatOpts?: import("luxon").DateTimeFormatOptions, opts?: import("luxon").LocaleOptions) => string;
|
|
890
890
|
toLocaleParts: (opts?: import("luxon").DateTimeFormatOptions) => Intl.DateTimeFormatPart[];
|
|
891
891
|
toISO: (opts?: import("luxon").ToISOTimeOptions) => string | null;
|
|
@@ -981,7 +981,7 @@ declare var __VLS_1: {
|
|
|
981
981
|
minus: (duration: import("luxon").DurationLike) => import("luxon").DateTime<boolean>;
|
|
982
982
|
startOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").StartOfOptions) => import("luxon").DateTime<boolean>;
|
|
983
983
|
endOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").EndOfOptions) => import("luxon").DateTime<boolean>;
|
|
984
|
-
toFormat: (
|
|
984
|
+
toFormat: (format: string, options?: import("luxon").LocaleOptions) => string;
|
|
985
985
|
toLocaleString: (formatOpts?: import("luxon").DateTimeFormatOptions, opts?: import("luxon").LocaleOptions) => string;
|
|
986
986
|
toLocaleParts: (opts?: import("luxon").DateTimeFormatOptions) => Intl.DateTimeFormatPart[];
|
|
987
987
|
toISO: (opts?: import("luxon").ToISOTimeOptions) => string | null;
|
|
@@ -1064,7 +1064,7 @@ declare var __VLS_1: {
|
|
|
1064
1064
|
minus: (duration: import("luxon").DurationLike) => import("luxon").DateTime<boolean>;
|
|
1065
1065
|
startOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").StartOfOptions) => import("luxon").DateTime<boolean>;
|
|
1066
1066
|
endOf: (unit: import("luxon").DateTimeUnit, opts?: import("luxon").EndOfOptions) => import("luxon").DateTime<boolean>;
|
|
1067
|
-
toFormat: (
|
|
1067
|
+
toFormat: (format: string, options?: import("luxon").LocaleOptions) => string;
|
|
1068
1068
|
toLocaleString: (formatOpts?: import("luxon").DateTimeFormatOptions, opts?: import("luxon").LocaleOptions) => string;
|
|
1069
1069
|
toLocaleParts: (opts?: import("luxon").DateTimeFormatOptions) => Intl.DateTimeFormatPart[];
|
|
1070
1070
|
toISO: (opts?: import("luxon").ToISOTimeOptions) => string | null;
|
|
@@ -2,9 +2,14 @@ import { Size } from '@/utils/sizes';
|
|
|
2
2
|
import { ToolbarOption } from '@/types/ToolbarOption';
|
|
3
3
|
type __VLS_Props = {
|
|
4
4
|
modelValue: string | null | undefined;
|
|
5
|
+
driver?: 'ckeditor' | 'tiptap';
|
|
6
|
+
/**
|
|
7
|
+
* Defines the CKEditor layout style.
|
|
8
|
+
* Only applicable when `driver` is 'ckeditor'.
|
|
9
|
+
*/
|
|
5
10
|
editor?: 'classic' | 'inline' | 'balloon';
|
|
6
11
|
size?: Size;
|
|
7
|
-
toolbar?: ToolbarOption[];
|
|
12
|
+
toolbar?: ToolbarOption[] | string[];
|
|
8
13
|
placeholder?: string;
|
|
9
14
|
disabled?: boolean;
|
|
10
15
|
required?: boolean;
|
|
@@ -28,7 +33,8 @@ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {
|
|
|
28
33
|
name: string;
|
|
29
34
|
placeholder: string;
|
|
30
35
|
hasError: boolean;
|
|
31
|
-
toolbar: ToolbarOption[];
|
|
36
|
+
toolbar: ToolbarOption[] | string[];
|
|
32
37
|
editor: "classic" | "inline" | "balloon";
|
|
38
|
+
driver: "ckeditor" | "tiptap";
|
|
33
39
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
34
40
|
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
modelValue: string | null | undefined;
|
|
3
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
4
|
+
hasError?: boolean;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
toolbar?: string[];
|
|
8
|
+
};
|
|
9
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
10
|
+
"update:modelValue": (...args: any[]) => void;
|
|
11
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
12
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
13
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sprintify-ui",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.82",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "rimraf dist && vue-tsc && vite build",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@tailwindcss/typography": "^0.5.8",
|
|
22
22
|
"@vueuse/core": "^10.0.0",
|
|
23
23
|
"axios": "^0.26.1",
|
|
24
|
-
"ckeditor5": "^
|
|
24
|
+
"ckeditor5": "^47.3.0",
|
|
25
25
|
"croppie": "^2.6.5",
|
|
26
26
|
"flatpickr": "^4.6.13",
|
|
27
27
|
"humanize-duration": "^3.0.0",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"tailwind-merge": "^2.4.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@ckeditor/ckeditor5-vue": "^7.3.0",
|
|
47
46
|
"@babel/core": "^7.24.0",
|
|
47
|
+
"@ckeditor/ckeditor5-vue": "^7.3.0",
|
|
48
48
|
"@commitlint/cli": "^17.8.1",
|
|
49
49
|
"@commitlint/config-conventional": "^17.8.1",
|
|
50
50
|
"@iconify/vue": "^4.1.1",
|
|
@@ -57,6 +57,9 @@
|
|
|
57
57
|
"@tailwindcss/aspect-ratio": "^0.4.2",
|
|
58
58
|
"@tailwindcss/forms": "^0.5.7",
|
|
59
59
|
"@tailwindcss/typography": "^0.5.10",
|
|
60
|
+
"@tiptap/pm": "^3.13.0",
|
|
61
|
+
"@tiptap/starter-kit": "^3.13.0",
|
|
62
|
+
"@tiptap/vue-3": "^3.13.0",
|
|
60
63
|
"@types/croppie": "^2.6.4",
|
|
61
64
|
"@types/google.maps": "^3.55.4",
|
|
62
65
|
"@types/humanize-duration": "^3.27.4",
|
|
@@ -74,6 +77,7 @@
|
|
|
74
77
|
"autoprefixer": "^10.4.18",
|
|
75
78
|
"axios": "^0.26.1",
|
|
76
79
|
"babel-loader": "^8.3.0",
|
|
80
|
+
"ckeditor5": "^47.3.0",
|
|
77
81
|
"croppie": "^2.6.5",
|
|
78
82
|
"cz-conventional-changelog": "^3.3.0",
|
|
79
83
|
"eslint": "^8.57.0",
|
|
@@ -89,7 +93,6 @@
|
|
|
89
93
|
"maska": "^3.0.4",
|
|
90
94
|
"object-hash": "^3.0.0",
|
|
91
95
|
"object-to-formdata": "^4.5.1",
|
|
92
|
-
"ckeditor5": "^44.1.0",
|
|
93
96
|
"pinia": "^2.1.7",
|
|
94
97
|
"postcss": "^8.4.36",
|
|
95
98
|
"postcss-import": "^15.1.0",
|
|
@@ -102,6 +105,7 @@
|
|
|
102
105
|
"standard-version": "^9.5.0",
|
|
103
106
|
"storybook": "^8.3.0",
|
|
104
107
|
"tailwindcss": "^3.4.1",
|
|
108
|
+
"tiptap-footnotes": "^3.0.1",
|
|
105
109
|
"typescript": "^5.6.3",
|
|
106
110
|
"unplugin-auto-import": "^0.12.2",
|
|
107
111
|
"vite": "^5.4.5",
|
|
@@ -268,4 +268,35 @@ body {
|
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
|
-
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** TipTap */
|
|
274
|
+
|
|
275
|
+
body .tiptap {
|
|
276
|
+
|
|
277
|
+
ol.footnotes {
|
|
278
|
+
margin-top: 20px;
|
|
279
|
+
padding: 20px 0;
|
|
280
|
+
list-style-type: decimal;
|
|
281
|
+
padding-left: 13px;
|
|
282
|
+
font-size: 0.8em;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
ol.footnotes:has(li) {
|
|
286
|
+
@apply border-t border-slate-300;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
ol.footnotes li p {
|
|
290
|
+
margin: 0px;
|
|
291
|
+
line-height: 0.9em;
|
|
292
|
+
@apply text-slate-500;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
p.is-editor-empty:first-child::before {
|
|
296
|
+
@apply text-slate-400;
|
|
297
|
+
content: attr(data-placeholder);
|
|
298
|
+
float: left;
|
|
299
|
+
height: 0;
|
|
300
|
+
pointer-events: none;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
:editor="editorInternal"
|
|
5
5
|
:config="config"
|
|
6
6
|
:disabled="disabled"
|
|
7
|
-
:name="name"
|
|
8
7
|
@update:model-value="emit('update:modelValue', $event)"
|
|
9
8
|
@focus="emit('focus', $event)"
|
|
10
9
|
@blur="emit('blur', $event)"
|
|
@@ -16,7 +15,6 @@
|
|
|
16
15
|
<script lang="ts" setup>
|
|
17
16
|
import { ClassicEditor, InlineEditor, BalloonEditor, Essentials, SourceEditing, MediaEmbed, Paragraph, Bold, Italic, List, Link, Autoformat, Heading, Underline, Code, CodeBlock, Table, TableToolbar, Image, ImageResize, ImageStyle, ImageToolbar, ImageInsert, AutoImage, Base64UploadAdapter, PasteFromOffice, BlockToolbar, Font, FindAndReplace, RemoveFormat } from 'ckeditor5';
|
|
18
17
|
import { Ckeditor } from '@ckeditor/ckeditor5-vue';
|
|
19
|
-
|
|
20
18
|
import { Size } from '@/utils/sizes';
|
|
21
19
|
import { ToolbarOption } from '@/types/ToolbarOption';
|
|
22
20
|
|
|
@@ -24,21 +22,37 @@ const props = withDefaults(defineProps<{
|
|
|
24
22
|
modelValue: string | null | undefined;
|
|
25
23
|
editor?: 'classic' | 'inline' | 'balloon';
|
|
26
24
|
size?: Size;
|
|
27
|
-
toolbar?: ToolbarOption[];
|
|
25
|
+
toolbar?: ToolbarOption[] | string[];
|
|
28
26
|
placeholder?: string;
|
|
29
27
|
disabled?: boolean;
|
|
30
|
-
required?: boolean;
|
|
31
|
-
name?: string;
|
|
32
28
|
}>(), {
|
|
33
29
|
editor: 'classic',
|
|
34
30
|
size: 'md',
|
|
35
31
|
toolbar() {
|
|
36
|
-
return [
|
|
32
|
+
return [
|
|
33
|
+
'undo',
|
|
34
|
+
'redo',
|
|
35
|
+
'|',
|
|
36
|
+
'sourceEditing',
|
|
37
|
+
'heading',
|
|
38
|
+
'bold',
|
|
39
|
+
'italic',
|
|
40
|
+
'underline',
|
|
41
|
+
'|',
|
|
42
|
+
'link',
|
|
43
|
+
'insertImage',
|
|
44
|
+
'|',
|
|
45
|
+
'numberedList',
|
|
46
|
+
'bulletedList',
|
|
47
|
+
'|',
|
|
48
|
+
'code',
|
|
49
|
+
'codeblock',
|
|
50
|
+
'|',
|
|
51
|
+
'insertTable'
|
|
52
|
+
] as ToolbarOption[];
|
|
37
53
|
},
|
|
38
54
|
placeholder: '',
|
|
39
55
|
disabled: false,
|
|
40
|
-
required: false,
|
|
41
|
-
name: '',
|
|
42
56
|
hasError: false,
|
|
43
57
|
});
|
|
44
58
|
|
|
@@ -19,6 +19,10 @@ export default {
|
|
|
19
19
|
placeholder: "This is a custom placeholder...",
|
|
20
20
|
},
|
|
21
21
|
argTypes: {
|
|
22
|
+
driver: {
|
|
23
|
+
control: { type: "select" },
|
|
24
|
+
options: ["ckeditor", "tiptap"],
|
|
25
|
+
},
|
|
22
26
|
editor: {
|
|
23
27
|
control: { type: "select" },
|
|
24
28
|
options: ["classic", "inline", "balloon"],
|
|
@@ -42,6 +46,11 @@ const Template = (args) => ({
|
|
|
42
46
|
`,
|
|
43
47
|
});
|
|
44
48
|
|
|
49
|
+
export const TipTapEditor = Template.bind({});
|
|
50
|
+
TipTapEditor.args = {
|
|
51
|
+
driver: "tiptap",
|
|
52
|
+
};
|
|
53
|
+
|
|
45
54
|
export const ClassicEditor = Template.bind({});
|
|
46
55
|
ClassicEditor.args = {
|
|
47
56
|
editor: "classic",
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
<template>
|
|
2
|
+
<div v-if="driver == 'tiptap'">
|
|
3
|
+
<BaseTipTap
|
|
4
|
+
:model-value="modelValue"
|
|
5
|
+
:size="sizeInternal"
|
|
6
|
+
:disabled="disabled"
|
|
7
|
+
:has-error="hasErrorInternal"
|
|
8
|
+
:placeholder="placeholder"
|
|
9
|
+
:toolbar="toolbar"
|
|
10
|
+
@update:model-value="emitUpdate"
|
|
11
|
+
/>
|
|
12
|
+
</div>
|
|
2
13
|
<div
|
|
14
|
+
v-else
|
|
3
15
|
class="base-rich-text relative"
|
|
4
16
|
:class="[
|
|
5
17
|
hasErrorInternal ? 'error' : '',
|
|
@@ -18,8 +30,6 @@
|
|
|
18
30
|
:toolbar="toolbar"
|
|
19
31
|
:placeholder="placeholder"
|
|
20
32
|
:disabled="disabled"
|
|
21
|
-
:required="requiredInternal"
|
|
22
|
-
:name="nameInternal"
|
|
23
33
|
@update:model-value="emitUpdate"
|
|
24
34
|
@focus="emit('focus', $event)"
|
|
25
35
|
@blur="emit('blur', $event)"
|
|
@@ -32,25 +42,30 @@
|
|
|
32
42
|
import { useField } from '@/composables/field';
|
|
33
43
|
import { Size } from '@/utils/sizes';
|
|
34
44
|
import { ToolbarOption } from '@/types/ToolbarOption';
|
|
45
|
+
import BaseTipTap from './BaseTipTap.vue';
|
|
35
46
|
|
|
36
47
|
const BaseCkeditor = defineAsyncComponent(() => import('./BaseCkeditor.vue'));
|
|
37
48
|
|
|
38
49
|
const props = withDefaults(defineProps<{
|
|
39
50
|
modelValue: string | null | undefined;
|
|
51
|
+
driver?: 'ckeditor' | 'tiptap';
|
|
52
|
+
/**
|
|
53
|
+
* Defines the CKEditor layout style.
|
|
54
|
+
* Only applicable when `driver` is 'ckeditor'.
|
|
55
|
+
*/
|
|
40
56
|
editor?: 'classic' | 'inline' | 'balloon';
|
|
41
57
|
size?: Size;
|
|
42
|
-
toolbar?: ToolbarOption[];
|
|
58
|
+
toolbar?: ToolbarOption[] | string[];
|
|
43
59
|
placeholder?: string;
|
|
44
60
|
disabled?: boolean;
|
|
45
61
|
required?: boolean;
|
|
46
62
|
name?: string;
|
|
47
63
|
hasError?: boolean;
|
|
48
64
|
}>(), {
|
|
65
|
+
driver: 'ckeditor',
|
|
49
66
|
editor: 'classic',
|
|
50
67
|
size: 'md',
|
|
51
|
-
toolbar
|
|
52
|
-
return ['undo', 'redo', '|', 'heading', 'bold', 'italic', 'underline', '|', 'link', 'insertImage', '|', 'numberedList', 'bulletedList', '|', 'code', 'codeblock', '|', 'insertTable'] as ToolbarOption[];
|
|
53
|
-
},
|
|
68
|
+
toolbar: undefined,
|
|
54
69
|
placeholder: '',
|
|
55
70
|
disabled: false,
|
|
56
71
|
required: false,
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="border rounded-md overflow-hidden bg-white || tiptap"
|
|
4
|
+
:class="[
|
|
5
|
+
hasError ? 'border-red-500' : 'border-slate-300',
|
|
6
|
+
]"
|
|
7
|
+
>
|
|
8
|
+
<div class="divide-x px-1 py-1 border-b flex">
|
|
9
|
+
<button
|
|
10
|
+
v-for="action in filteredActions"
|
|
11
|
+
:key="action.name"
|
|
12
|
+
:class="[buttonClass, editor.isActive(action.name) ? 'bg-slate-200' : '']"
|
|
13
|
+
type="button"
|
|
14
|
+
:disabled="disabled"
|
|
15
|
+
@click="action.command()"
|
|
16
|
+
>
|
|
17
|
+
<BaseIcon
|
|
18
|
+
class="h-5 w-5"
|
|
19
|
+
:icon="action.icon"
|
|
20
|
+
/>
|
|
21
|
+
</button>
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
<div
|
|
25
|
+
class="bg-white p-5"
|
|
26
|
+
:class="[disabled ? 'cursor-not-allowed' : '']"
|
|
27
|
+
>
|
|
28
|
+
<editor-content
|
|
29
|
+
v-if="editor"
|
|
30
|
+
:editor="editor"
|
|
31
|
+
/>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<script setup lang="ts">
|
|
37
|
+
import { Editor, EditorContent } from '@tiptap/vue-3';
|
|
38
|
+
import Document from '@tiptap/extension-document';
|
|
39
|
+
import Link from '@tiptap/extension-link';
|
|
40
|
+
import { Placeholder } from '@tiptap/extensions'
|
|
41
|
+
import { Footnotes, FootnoteReference, Footnote } from "tiptap-footnotes";
|
|
42
|
+
import StarterKit from '@tiptap/starter-kit';
|
|
43
|
+
|
|
44
|
+
const emit = defineEmits(['update:modelValue']);
|
|
45
|
+
|
|
46
|
+
const props = defineProps<{
|
|
47
|
+
modelValue: string | null | undefined;
|
|
48
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
49
|
+
hasError?: boolean;
|
|
50
|
+
disabled?: boolean;
|
|
51
|
+
placeholder?: string;
|
|
52
|
+
toolbar?: string[];
|
|
53
|
+
}>();
|
|
54
|
+
|
|
55
|
+
const editor = new Editor({
|
|
56
|
+
editable: !props.disabled,
|
|
57
|
+
extensions: [
|
|
58
|
+
StarterKit.configure({
|
|
59
|
+
document: false,
|
|
60
|
+
link: false,
|
|
61
|
+
}),
|
|
62
|
+
Document.extend({
|
|
63
|
+
content: "block+ footnotes?",
|
|
64
|
+
}),
|
|
65
|
+
Link.configure({
|
|
66
|
+
openOnClick: false,
|
|
67
|
+
defaultProtocol: 'https',
|
|
68
|
+
enableClickSelection: true,
|
|
69
|
+
}),
|
|
70
|
+
Placeholder.configure({
|
|
71
|
+
placeholder: props.placeholder || 'Start typing here...',
|
|
72
|
+
}),
|
|
73
|
+
Footnotes,
|
|
74
|
+
Footnote,
|
|
75
|
+
FootnoteReference,
|
|
76
|
+
],
|
|
77
|
+
editorProps: {
|
|
78
|
+
attributes: {
|
|
79
|
+
class: 'prose prose-sm mx-auto max-w-full focus:outline-none',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
content: props.modelValue,
|
|
83
|
+
onUpdate: () => {
|
|
84
|
+
emit('update:modelValue', editor?.getHTML() || '');
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
watch(
|
|
89
|
+
() => props.modelValue,
|
|
90
|
+
(newValue) => {
|
|
91
|
+
const isSame = editor?.getHTML() === newValue;
|
|
92
|
+
|
|
93
|
+
if (isSame) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
editor?.commands.setContent(newValue ?? '');
|
|
98
|
+
},
|
|
99
|
+
{ immediate: true },
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
watch(
|
|
103
|
+
() => props.disabled,
|
|
104
|
+
(newValue) => {
|
|
105
|
+
editor?.setEditable(!newValue);
|
|
106
|
+
},
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
watch(
|
|
110
|
+
() => props.size,
|
|
111
|
+
(newValue) => {
|
|
112
|
+
|
|
113
|
+
const lookup = {
|
|
114
|
+
'xs': 'prose-sm',
|
|
115
|
+
'sm': 'prose-sm',
|
|
116
|
+
'md': 'prose-sm',
|
|
117
|
+
'lg': 'prose-md',
|
|
118
|
+
'xl': 'prose-lg',
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const sizeClass = lookup[newValue || 'md'] ?? '';
|
|
122
|
+
|
|
123
|
+
editor?.view.setProps({
|
|
124
|
+
attributes: {
|
|
125
|
+
class: `mx-auto max-w-full prose focus:outline-none ${sizeClass}`
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
},
|
|
129
|
+
{ immediate: true },
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
onBeforeUnmount(() => {
|
|
133
|
+
if (editor) {
|
|
134
|
+
editor.destroy();
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
function setLink() {
|
|
139
|
+
const previousUrl = editor.getAttributes('link').href;
|
|
140
|
+
const url = window.prompt('URL', previousUrl);
|
|
141
|
+
|
|
142
|
+
// cancelled
|
|
143
|
+
if (url === null) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// empty
|
|
148
|
+
if (url === '') {
|
|
149
|
+
editor.chain().focus().extendMarkRange('link').unsetLink().run();
|
|
150
|
+
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// update link
|
|
155
|
+
editor.chain().focus().extendMarkRange('link').setLink({ href: url }).run();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const buttonClass = computed(() => {
|
|
159
|
+
const sizeClass = {
|
|
160
|
+
xs: 'p-1',
|
|
161
|
+
sm: 'p-1.5',
|
|
162
|
+
md: 'p-2',
|
|
163
|
+
lg: 'p-2.5',
|
|
164
|
+
xl: 'p-3',
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return [
|
|
168
|
+
'hover:bg-slate-100',
|
|
169
|
+
'disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-white',
|
|
170
|
+
sizeClass[props.size || 'md'] || sizeClass['md'],
|
|
171
|
+
];
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
interface Action {
|
|
175
|
+
name: string;
|
|
176
|
+
icon: string;
|
|
177
|
+
command: () => void;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const actions = computed<Action[]>(() => {
|
|
181
|
+
return [
|
|
182
|
+
{
|
|
183
|
+
name: 'undo',
|
|
184
|
+
icon: 'mdi:undo-variant',
|
|
185
|
+
command: () => editor.chain().focus().undo().run(),
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
name: 'redo',
|
|
189
|
+
icon: 'mdi:redo-variant',
|
|
190
|
+
command: () => editor.chain().focus().redo().run(),
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: 'paragraph',
|
|
194
|
+
icon: 'material-symbols:format-paragraph',
|
|
195
|
+
command: () => editor.chain().focus().setParagraph().run(),
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: 'heading-2',
|
|
199
|
+
icon: 'material-symbols:format-h2',
|
|
200
|
+
command: () => editor.chain().focus().setHeading({ level: 2 }).run(),
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
name: 'heading-3',
|
|
204
|
+
icon: 'material-symbols:format-h3',
|
|
205
|
+
command: () => editor.chain().focus().setHeading({ level: 3 }).run(),
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
name: 'bold',
|
|
209
|
+
icon: 'material-symbols:format-bold',
|
|
210
|
+
command: () => editor.chain().focus().toggleBold().run(),
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
name: 'italic',
|
|
214
|
+
icon: 'material-symbols:format-italic',
|
|
215
|
+
command: () => editor.chain().focus().toggleItalic().run(),
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
name: 'underline',
|
|
219
|
+
icon: 'material-symbols:format-underlined',
|
|
220
|
+
command: () => editor.chain().focus().toggleUnderline().run(),
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
name: 'link',
|
|
224
|
+
icon: 'material-symbols:link',
|
|
225
|
+
command: () => setLink(),
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
name: 'unlink',
|
|
229
|
+
icon: 'material-symbols:link-off',
|
|
230
|
+
command: () => editor.chain().focus().unsetLink().run(),
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
name: 'bulletList',
|
|
234
|
+
icon: 'material-symbols:format-list-bulleted',
|
|
235
|
+
command: () => editor.chain().focus().toggleBulletList().run(),
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
name: 'orderedList',
|
|
239
|
+
icon: 'material-symbols:format-list-numbered',
|
|
240
|
+
command: () => editor.chain().focus().toggleOrderedList().run(),
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
name: 'footnote',
|
|
244
|
+
icon: 'material-symbols:edit-note-outline',
|
|
245
|
+
command: () => editor?.commands.addFootnote(),
|
|
246
|
+
},
|
|
247
|
+
|
|
248
|
+
];
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
const filteredActions = computed(() => {
|
|
252
|
+
if (!props.toolbar || props.toolbar.length === 0) {
|
|
253
|
+
return actions.value;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return actions.value.filter(action => props.toolbar?.includes(action.name));
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
</script>
|