@sierra-95/svelte-scaffold 1.0.9 → 1.0.10
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/README.md +8 -8
- package/dist/Hooks/preview.d.ts +2 -1
- package/dist/Hooks/preview.js +4 -4
- package/dist/components/Core/Alerts/Backdrop/backdrop.svelte +26 -26
- package/dist/components/Core/Alerts/Modal/modal.svelte +40 -40
- package/dist/components/Core/Alerts/Toast/toast.css +38 -38
- package/dist/components/Core/Alerts/Toast/toast.svelte +32 -32
- package/dist/components/Core/Alerts/Wrapper/wrapper.svelte +18 -18
- package/dist/components/Core/Alerts/site-under-maintenance/site-under-maintenance.svelte +33 -33
- package/dist/components/Core/Form/Hr/hr.svelte +10 -10
- package/dist/components/Core/Form/Input/FileInput/fileInput.svelte +158 -158
- package/dist/components/Core/Form/Input/FileInput/preview.svelte +50 -50
- package/dist/components/Core/Form/Input/SearchBar/search.svelte +68 -68
- package/dist/components/Core/Form/Input/input/input.svelte +16 -16
- package/dist/components/Core/Form/Input/password/password.svelte +26 -26
- package/dist/components/Core/Menus/DropdownContainer/dropdown.svelte +94 -94
- package/dist/components/Core/Menus/MenuItem/menuItem.svelte +43 -43
- package/dist/components/Core/Menus/UserMenu/profile.svelte +34 -34
- package/dist/components/Core/others/Button/Flip/button.css +50 -50
- package/dist/components/Core/others/Button/Flip/button.svelte +79 -79
- package/dist/components/Core/others/Button/Marquee/button.css +36 -36
- package/dist/components/Core/others/Button/Marquee/button.svelte +58 -58
- package/dist/components/Core/others/Button/Swipe/button.css +32 -32
- package/dist/components/Core/others/Button/Swipe/button.svelte +57 -57
- package/dist/components/Core/others/Button/default/button.css +60 -60
- package/dist/components/Core/others/Button/default/button.svelte +124 -124
- package/dist/components/Core/others/Button/select/select.svelte +28 -28
- package/dist/components/Core/others/Button/theme/theme.css +121 -121
- package/dist/components/Core/others/Button/theme/theme.svelte +67 -67
- package/dist/components/Core/others/Button/times/times.svelte +24 -24
- package/dist/components/Core/others/Clock/Date/date.svelte +25 -25
- package/dist/components/Core/others/Clock/Time/time.svelte +35 -35
- package/dist/components/Core/others/Previews/Audio/audio.svelte +61 -61
- package/dist/components/Core/others/Previews/Document/documents.svelte +36 -36
- package/dist/components/Core/others/Previews/GenericFile/genericFile.svelte +25 -25
- package/dist/components/Core/others/Previews/Image/image.svelte +26 -26
- package/dist/components/Core/others/Previews/Video/video.svelte +28 -28
- package/dist/components/Core/others/Progress/CircularProgress/CircularProgress.svelte +55 -55
- package/dist/components/Core/others/Progress/CustomProgress/customProgress.svelte +64 -64
- package/dist/components/Core/others/Progress/LinearProgress/LinearProgress.css +60 -60
- package/dist/components/Core/others/Progress/LinearProgress/LinearProgress.svelte +86 -86
- package/dist/components/Modules/Editor/Hooks/extractContent.js +14 -14
- package/dist/components/Modules/Editor/Hooks/extractImage.js +30 -30
- package/dist/components/Modules/Editor/Hooks/insertImage.js +26 -26
- package/dist/components/Modules/Editor/Hooks/insertYoutube.js +34 -34
- package/dist/components/Modules/Editor/Marks/Links/links.svelte +78 -78
- package/dist/components/Modules/Editor/Marks/TextFormatting/textFormatting.svelte +32 -32
- package/dist/components/Modules/Editor/Nodes/Headings/heading.svelte +58 -58
- package/dist/components/Modules/Editor/Nodes/History/history.svelte +21 -21
- package/dist/components/Modules/Editor/Nodes/Images/images.svelte +85 -85
- package/dist/components/Modules/Editor/Nodes/Lists/lists.svelte +30 -30
- package/dist/components/Modules/Editor/Nodes/TextAlign/textAlign.svelte +55 -55
- package/dist/components/Modules/Editor/Nodes/TextColor/styles.css +18 -18
- package/dist/components/Modules/Editor/Nodes/TextColor/textColor.svelte +88 -88
- package/dist/components/Modules/Editor/Nodes/Youtube/youtube.svelte +32 -32
- package/dist/components/Modules/Editor/colors.js +21 -21
- package/dist/components/Modules/Editor/controls.svelte +71 -71
- package/dist/components/Modules/Editor/extensions.js +59 -59
- package/dist/components/Modules/Editor/main.svelte +41 -41
- package/dist/components/Modules/Editor/save.svelte +28 -28
- package/dist/components/Modules/Editor/styles/controls.css +68 -68
- package/dist/components/Modules/Editor/styles/main.css +42 -42
- package/dist/components/Modules/Editor/tools.js +22 -22
- package/dist/components/Modules/FilePicker/cloudStore.svelte +101 -98
- package/dist/components/Modules/FilePicker/controls.svelte +167 -141
- package/dist/components/Modules/FilePicker/controls.svelte.d.ts +4 -19
- package/dist/components/Modules/FilePicker/filePicker.svelte +59 -59
- package/dist/components/Modules/FilePicker/file_properties.svelte +33 -0
- package/dist/components/Modules/FilePicker/file_properties.svelte.d.ts +11 -0
- package/dist/components/Modules/FilePicker/previews.svelte +22 -22
- package/dist/components/Modules/Layout/Header/header.css +37 -37
- package/dist/components/Modules/Layout/Header/header.svelte +31 -31
- package/dist/components/Modules/Layout/Menu/menu.css +53 -53
- package/dist/components/Modules/Layout/Menu/menu.svelte +129 -129
- package/dist/components/Modules/Layout/background.svelte +28 -28
- package/dist/components/Modules/Layout/collapse.svelte +24 -24
- package/dist/components/Modules/Layout/main.css +31 -31
- package/dist/components/Modules/Layout/main.svelte +110 -110
- package/dist/global.css +246 -246
- package/dist/index.d.ts +1 -0
- package/dist/stores/core/general.js +4 -4
- package/dist/stores/core/ismobile.js +14 -14
- package/dist/stores/core/modal.js +35 -35
- package/dist/stores/modules/fileInput.d.ts +11 -4
- package/dist/stores/modules/fileInput.js +1 -1
- package/package.json +75 -75
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
.pure-material-progress-linear {
|
|
2
|
-
-webkit-appearance: none;
|
|
3
|
-
-moz-appearance: none;
|
|
4
|
-
appearance: none;
|
|
5
|
-
border: none;
|
|
6
|
-
height: 0.25em;
|
|
7
|
-
background-color: rgba( 33, 150, 243, 0.12);
|
|
8
|
-
font-size: 16px;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.pure-material-progress-linear::-webkit-progress-bar {
|
|
12
|
-
background-color: transparent;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/* Determinate */
|
|
16
|
-
.pure-material-progress-linear::-webkit-progress-value {
|
|
17
|
-
background-color: currentColor;
|
|
18
|
-
transition: all 0.2s;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.pure-material-progress-linear::-moz-progress-bar {
|
|
22
|
-
background-color: currentColor;
|
|
23
|
-
transition: all 0.2s;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.pure-material-progress-linear::-ms-fill {
|
|
27
|
-
border: none;
|
|
28
|
-
background-color: currentColor;
|
|
29
|
-
transition: all 0.2s;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/* Indeterminate */
|
|
33
|
-
.pure-material-progress-linear:indeterminate {
|
|
34
|
-
background-size: 200% 100%;
|
|
35
|
-
background-image: linear-gradient(to right, transparent 50%, currentColor 50%, currentColor 60%, transparent 60%, transparent 71.5%, currentColor 71.5%, currentColor 84%, transparent 84%);
|
|
36
|
-
animation: pure-material-progress-linear 2s infinite linear;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.pure-material-progress-linear:indeterminate::-moz-progress-bar {
|
|
40
|
-
background-color: transparent;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.pure-material-progress-linear:indeterminate::-ms-fill {
|
|
44
|
-
animation-name: none;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@keyframes pure-material-progress-linear {
|
|
48
|
-
0% {
|
|
49
|
-
background-size: 200% 100%;
|
|
50
|
-
background-position: left -31.25% top 0%;
|
|
51
|
-
}
|
|
52
|
-
50% {
|
|
53
|
-
background-size: 800% 100%;
|
|
54
|
-
background-position: left -49% top 0%;
|
|
55
|
-
}
|
|
56
|
-
100% {
|
|
57
|
-
background-size: 400% 100%;
|
|
58
|
-
background-position: left -102% top 0%;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
1
|
+
.pure-material-progress-linear {
|
|
2
|
+
-webkit-appearance: none;
|
|
3
|
+
-moz-appearance: none;
|
|
4
|
+
appearance: none;
|
|
5
|
+
border: none;
|
|
6
|
+
height: 0.25em;
|
|
7
|
+
background-color: rgba( 33, 150, 243, 0.12);
|
|
8
|
+
font-size: 16px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.pure-material-progress-linear::-webkit-progress-bar {
|
|
12
|
+
background-color: transparent;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/* Determinate */
|
|
16
|
+
.pure-material-progress-linear::-webkit-progress-value {
|
|
17
|
+
background-color: currentColor;
|
|
18
|
+
transition: all 0.2s;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.pure-material-progress-linear::-moz-progress-bar {
|
|
22
|
+
background-color: currentColor;
|
|
23
|
+
transition: all 0.2s;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.pure-material-progress-linear::-ms-fill {
|
|
27
|
+
border: none;
|
|
28
|
+
background-color: currentColor;
|
|
29
|
+
transition: all 0.2s;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Indeterminate */
|
|
33
|
+
.pure-material-progress-linear:indeterminate {
|
|
34
|
+
background-size: 200% 100%;
|
|
35
|
+
background-image: linear-gradient(to right, transparent 50%, currentColor 50%, currentColor 60%, transparent 60%, transparent 71.5%, currentColor 71.5%, currentColor 84%, transparent 84%);
|
|
36
|
+
animation: pure-material-progress-linear 2s infinite linear;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.pure-material-progress-linear:indeterminate::-moz-progress-bar {
|
|
40
|
+
background-color: transparent;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.pure-material-progress-linear:indeterminate::-ms-fill {
|
|
44
|
+
animation-name: none;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@keyframes pure-material-progress-linear {
|
|
48
|
+
0% {
|
|
49
|
+
background-size: 200% 100%;
|
|
50
|
+
background-position: left -31.25% top 0%;
|
|
51
|
+
}
|
|
52
|
+
50% {
|
|
53
|
+
background-size: 800% 100%;
|
|
54
|
+
background-position: left -49% top 0%;
|
|
55
|
+
}
|
|
56
|
+
100% {
|
|
57
|
+
background-size: 400% 100%;
|
|
58
|
+
background-position: left -102% top 0%;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
const {
|
|
3
|
-
color = 'var(--primary-bg)',
|
|
4
|
-
} = $props();
|
|
5
|
-
</script>
|
|
6
|
-
<style>.pure-material-progress-linear {
|
|
7
|
-
-webkit-appearance: none;
|
|
8
|
-
-moz-appearance: none;
|
|
9
|
-
appearance: none;
|
|
10
|
-
border: none;
|
|
11
|
-
height: 0.25em;
|
|
12
|
-
background-color: rgba( 33, 150, 243, 0.12);
|
|
13
|
-
font-size: 16px;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.pure-material-progress-linear::-webkit-progress-bar {
|
|
17
|
-
background-color: transparent;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/* Determinate */
|
|
21
|
-
|
|
22
|
-
.pure-material-progress-linear::-webkit-progress-value {
|
|
23
|
-
background-color: currentColor;
|
|
24
|
-
transition: all 0.2s;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.pure-material-progress-linear::-moz-progress-bar {
|
|
28
|
-
background-color: currentColor;
|
|
29
|
-
transition: all 0.2s;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.pure-material-progress-linear::-ms-fill {
|
|
33
|
-
border: none;
|
|
34
|
-
background-color: currentColor;
|
|
35
|
-
transition: all 0.2s;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/* Indeterminate */
|
|
39
|
-
|
|
40
|
-
.pure-material-progress-linear:indeterminate {
|
|
41
|
-
background-size: 200% 100%;
|
|
42
|
-
background-image: linear-gradient(to right, transparent 50%, currentColor 50%, currentColor 60%, transparent 60%, transparent 71.5%, currentColor 71.5%, currentColor 84%, transparent 84%);
|
|
43
|
-
animation: pure-material-progress-linear 2s infinite linear;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.pure-material-progress-linear:indeterminate::-moz-progress-bar {
|
|
47
|
-
background-color: transparent;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.pure-material-progress-linear:indeterminate::-ms-fill {
|
|
51
|
-
animation-name: none;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
@keyframes pure-material-progress-linear {
|
|
55
|
-
0% {
|
|
56
|
-
background-size: 200% 100%;
|
|
57
|
-
background-position: left -31.25% top 0%;
|
|
58
|
-
}
|
|
59
|
-
50% {
|
|
60
|
-
background-size: 800% 100%;
|
|
61
|
-
background-position: left -49% top 0%;
|
|
62
|
-
}
|
|
63
|
-
100% {
|
|
64
|
-
background-size: 400% 100%;
|
|
65
|
-
background-position: left -102% top 0%;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.cover{
|
|
70
|
-
position: relative;
|
|
71
|
-
height: 0.25em;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.child{
|
|
75
|
-
width: 100%;
|
|
76
|
-
position: absolute;
|
|
77
|
-
left: 0;
|
|
78
|
-
right: 0;
|
|
79
|
-
}
|
|
80
|
-
</style>
|
|
81
|
-
<div class="cover">
|
|
82
|
-
<progress
|
|
83
|
-
style="color: {color};"
|
|
84
|
-
class="pure-material-progress-linear child"
|
|
85
|
-
></progress>
|
|
86
|
-
</div>
|
|
1
|
+
<script>
|
|
2
|
+
const {
|
|
3
|
+
color = 'var(--primary-bg)',
|
|
4
|
+
} = $props();
|
|
5
|
+
</script>
|
|
6
|
+
<style>.pure-material-progress-linear {
|
|
7
|
+
-webkit-appearance: none;
|
|
8
|
+
-moz-appearance: none;
|
|
9
|
+
appearance: none;
|
|
10
|
+
border: none;
|
|
11
|
+
height: 0.25em;
|
|
12
|
+
background-color: rgba( 33, 150, 243, 0.12);
|
|
13
|
+
font-size: 16px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.pure-material-progress-linear::-webkit-progress-bar {
|
|
17
|
+
background-color: transparent;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* Determinate */
|
|
21
|
+
|
|
22
|
+
.pure-material-progress-linear::-webkit-progress-value {
|
|
23
|
+
background-color: currentColor;
|
|
24
|
+
transition: all 0.2s;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.pure-material-progress-linear::-moz-progress-bar {
|
|
28
|
+
background-color: currentColor;
|
|
29
|
+
transition: all 0.2s;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.pure-material-progress-linear::-ms-fill {
|
|
33
|
+
border: none;
|
|
34
|
+
background-color: currentColor;
|
|
35
|
+
transition: all 0.2s;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* Indeterminate */
|
|
39
|
+
|
|
40
|
+
.pure-material-progress-linear:indeterminate {
|
|
41
|
+
background-size: 200% 100%;
|
|
42
|
+
background-image: linear-gradient(to right, transparent 50%, currentColor 50%, currentColor 60%, transparent 60%, transparent 71.5%, currentColor 71.5%, currentColor 84%, transparent 84%);
|
|
43
|
+
animation: pure-material-progress-linear 2s infinite linear;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.pure-material-progress-linear:indeterminate::-moz-progress-bar {
|
|
47
|
+
background-color: transparent;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.pure-material-progress-linear:indeterminate::-ms-fill {
|
|
51
|
+
animation-name: none;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@keyframes pure-material-progress-linear {
|
|
55
|
+
0% {
|
|
56
|
+
background-size: 200% 100%;
|
|
57
|
+
background-position: left -31.25% top 0%;
|
|
58
|
+
}
|
|
59
|
+
50% {
|
|
60
|
+
background-size: 800% 100%;
|
|
61
|
+
background-position: left -49% top 0%;
|
|
62
|
+
}
|
|
63
|
+
100% {
|
|
64
|
+
background-size: 400% 100%;
|
|
65
|
+
background-position: left -102% top 0%;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.cover{
|
|
70
|
+
position: relative;
|
|
71
|
+
height: 0.25em;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.child{
|
|
75
|
+
width: 100%;
|
|
76
|
+
position: absolute;
|
|
77
|
+
left: 0;
|
|
78
|
+
right: 0;
|
|
79
|
+
}
|
|
80
|
+
</style>
|
|
81
|
+
<div class="cover">
|
|
82
|
+
<progress
|
|
83
|
+
style="color: {color};"
|
|
84
|
+
class="pure-material-progress-linear child"
|
|
85
|
+
></progress>
|
|
86
|
+
</div>
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { setToastMessage } from '../../../../index.js';
|
|
2
|
-
import { extractImagesFromJSON } from '../tools.js';
|
|
3
|
-
/**
|
|
4
|
-
* @param {import('@tiptap/core').Editor} editor
|
|
5
|
-
*/
|
|
6
|
-
export async function exractContent(editor) {
|
|
7
|
-
if (!editor) return;
|
|
8
|
-
try {
|
|
9
|
-
const json_content = editor.getJSON();
|
|
10
|
-
const fnl_imgs = extractImagesFromJSON(json_content);
|
|
11
|
-
return { json_content, images: fnl_imgs };
|
|
12
|
-
}catch (error) {
|
|
13
|
-
setToastMessage('error', 'An error occurred while saving.');
|
|
14
|
-
}
|
|
1
|
+
import { setToastMessage } from '../../../../index.js';
|
|
2
|
+
import { extractImagesFromJSON } from '../tools.js';
|
|
3
|
+
/**
|
|
4
|
+
* @param {import('@tiptap/core').Editor} editor
|
|
5
|
+
*/
|
|
6
|
+
export async function exractContent(editor) {
|
|
7
|
+
if (!editor) return;
|
|
8
|
+
try {
|
|
9
|
+
const json_content = editor.getJSON();
|
|
10
|
+
const fnl_imgs = extractImagesFromJSON(json_content);
|
|
11
|
+
return { json_content, images: fnl_imgs };
|
|
12
|
+
}catch (error) {
|
|
13
|
+
setToastMessage('error', 'An error occurred while saving.');
|
|
14
|
+
}
|
|
15
15
|
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extract all image slugs from a Tiptap JSON document.
|
|
3
|
-
*
|
|
4
|
-
* @param {import('@tiptap/core').JSONContent} json - Tiptap JSON content
|
|
5
|
-
* @returns {string[]} - Array of image slugs
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export function extractImagesFromJSON(json) {
|
|
9
|
-
const slugs = new Set();
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Recursively walk a node and collect image slugs
|
|
13
|
-
* @param {any} node - Node in the JSON tree
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
function walk(node) {
|
|
17
|
-
if (!node) return;
|
|
18
|
-
if (node.type === 'image' && typeof node.attrs?.src === 'string') {
|
|
19
|
-
const url = node.attrs.src;
|
|
20
|
-
const slug = url.split('/').pop();
|
|
21
|
-
if (slug) slugs.add(slug);
|
|
22
|
-
}
|
|
23
|
-
if (node.content && Array.isArray(node.content)) {
|
|
24
|
-
node.content.forEach(walk);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
walk(json);
|
|
29
|
-
return [...slugs];
|
|
30
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Extract all image slugs from a Tiptap JSON document.
|
|
3
|
+
*
|
|
4
|
+
* @param {import('@tiptap/core').JSONContent} json - Tiptap JSON content
|
|
5
|
+
* @returns {string[]} - Array of image slugs
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export function extractImagesFromJSON(json) {
|
|
9
|
+
const slugs = new Set();
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Recursively walk a node and collect image slugs
|
|
13
|
+
* @param {any} node - Node in the JSON tree
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
function walk(node) {
|
|
17
|
+
if (!node) return;
|
|
18
|
+
if (node.type === 'image' && typeof node.attrs?.src === 'string') {
|
|
19
|
+
const url = node.attrs.src;
|
|
20
|
+
const slug = url.split('/').pop();
|
|
21
|
+
if (slug) slugs.add(slug);
|
|
22
|
+
}
|
|
23
|
+
if (node.content && Array.isArray(node.content)) {
|
|
24
|
+
node.content.forEach(walk);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
walk(json);
|
|
29
|
+
return [...slugs];
|
|
30
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
import { TextSelection } from 'prosemirror-state';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @param {string} base64 - Base64 string for the image
|
|
6
|
-
* @param {import('@tiptap/core').Editor} editor - Tiptap editor instance
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export function insertImageAndMoveCursor(base64, editor) {
|
|
10
|
-
const { state, view } = editor;
|
|
11
|
-
const { tr } = state;
|
|
12
|
-
|
|
13
|
-
// 1. Insert the image at the current selection
|
|
14
|
-
const imageNode = editor.schema.nodes.image.create({ src: base64 });
|
|
15
|
-
const pos = tr.selection.$from.after(); // get position after current node
|
|
16
|
-
tr.insert(pos, imageNode);
|
|
17
|
-
|
|
18
|
-
// 2. Insert an empty paragraph after the image
|
|
19
|
-
const paragraph = editor.schema.nodes.paragraph.create();
|
|
20
|
-
tr.insert(pos + 1, paragraph);
|
|
21
|
-
|
|
22
|
-
// 3. Move the cursor inside the new paragraph
|
|
23
|
-
const newSelection = TextSelection.create(tr.doc, pos + 2);
|
|
24
|
-
tr.setSelection(newSelection);
|
|
25
|
-
view.dispatch(tr);
|
|
26
|
-
view.focus();
|
|
1
|
+
|
|
2
|
+
import { TextSelection } from 'prosemirror-state';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param {string} base64 - Base64 string for the image
|
|
6
|
+
* @param {import('@tiptap/core').Editor} editor - Tiptap editor instance
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export function insertImageAndMoveCursor(base64, editor) {
|
|
10
|
+
const { state, view } = editor;
|
|
11
|
+
const { tr } = state;
|
|
12
|
+
|
|
13
|
+
// 1. Insert the image at the current selection
|
|
14
|
+
const imageNode = editor.schema.nodes.image.create({ src: base64 });
|
|
15
|
+
const pos = tr.selection.$from.after(); // get position after current node
|
|
16
|
+
tr.insert(pos, imageNode);
|
|
17
|
+
|
|
18
|
+
// 2. Insert an empty paragraph after the image
|
|
19
|
+
const paragraph = editor.schema.nodes.paragraph.create();
|
|
20
|
+
tr.insert(pos + 1, paragraph);
|
|
21
|
+
|
|
22
|
+
// 3. Move the cursor inside the new paragraph
|
|
23
|
+
const newSelection = TextSelection.create(tr.doc, pos + 2);
|
|
24
|
+
tr.setSelection(newSelection);
|
|
25
|
+
view.dispatch(tr);
|
|
26
|
+
view.focus();
|
|
27
27
|
}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { TextSelection } from 'prosemirror-state';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Prompt for a YouTube URL and insert it into the editor, placing the cursor after it.
|
|
6
|
-
* @param {import('@tiptap/core').Editor} editor - The Tiptap editor instance
|
|
7
|
-
* @param {string} url
|
|
8
|
-
*/
|
|
9
|
-
export function addYoutubeVideo(editor, url) {
|
|
10
|
-
if (!url) return;
|
|
11
|
-
|
|
12
|
-
const { state, view, schema } = editor;
|
|
13
|
-
const { tr } = state;
|
|
14
|
-
|
|
15
|
-
// Create the YouTube video node
|
|
16
|
-
const youtubeNode = schema.nodes.youtube.create({ src: url });
|
|
17
|
-
|
|
18
|
-
// Position after current selection
|
|
19
|
-
const pos = tr.selection.$from.after();
|
|
20
|
-
|
|
21
|
-
// Insert video node at position
|
|
22
|
-
tr.insert(pos, youtubeNode);
|
|
23
|
-
|
|
24
|
-
// Insert empty paragraph after the video node
|
|
25
|
-
const paragraph = schema.nodes.paragraph.create();
|
|
26
|
-
tr.insert(pos + 1, paragraph);
|
|
27
|
-
|
|
28
|
-
// Set cursor inside the new paragraph
|
|
29
|
-
const newSelection = TextSelection.create(tr.doc, pos + 2);
|
|
30
|
-
tr.setSelection(newSelection);
|
|
31
|
-
|
|
32
|
-
// Apply transaction and focus editor
|
|
33
|
-
view.dispatch(tr);
|
|
34
|
-
view.focus();
|
|
1
|
+
import { TextSelection } from 'prosemirror-state';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Prompt for a YouTube URL and insert it into the editor, placing the cursor after it.
|
|
6
|
+
* @param {import('@tiptap/core').Editor} editor - The Tiptap editor instance
|
|
7
|
+
* @param {string} url
|
|
8
|
+
*/
|
|
9
|
+
export function addYoutubeVideo(editor, url) {
|
|
10
|
+
if (!url) return;
|
|
11
|
+
|
|
12
|
+
const { state, view, schema } = editor;
|
|
13
|
+
const { tr } = state;
|
|
14
|
+
|
|
15
|
+
// Create the YouTube video node
|
|
16
|
+
const youtubeNode = schema.nodes.youtube.create({ src: url });
|
|
17
|
+
|
|
18
|
+
// Position after current selection
|
|
19
|
+
const pos = tr.selection.$from.after();
|
|
20
|
+
|
|
21
|
+
// Insert video node at position
|
|
22
|
+
tr.insert(pos, youtubeNode);
|
|
23
|
+
|
|
24
|
+
// Insert empty paragraph after the video node
|
|
25
|
+
const paragraph = schema.nodes.paragraph.create();
|
|
26
|
+
tr.insert(pos + 1, paragraph);
|
|
27
|
+
|
|
28
|
+
// Set cursor inside the new paragraph
|
|
29
|
+
const newSelection = TextSelection.create(tr.doc, pos + 2);
|
|
30
|
+
tr.setSelection(newSelection);
|
|
31
|
+
|
|
32
|
+
// Apply transaction and focus editor
|
|
33
|
+
view.dispatch(tr);
|
|
34
|
+
view.focus();
|
|
35
35
|
}
|
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { Editor } from "@tiptap/core";
|
|
3
|
-
import {modalStore, Input} from '../../../../../index.js'
|
|
4
|
-
|
|
5
|
-
export let editor: Editor;
|
|
6
|
-
|
|
7
|
-
let text = '';
|
|
8
|
-
let url = '';
|
|
9
|
-
|
|
10
|
-
function newLink() {
|
|
11
|
-
modalStore.update(m => ({
|
|
12
|
-
...m,
|
|
13
|
-
open: true,
|
|
14
|
-
title: 'Editor',
|
|
15
|
-
onConfirm: () => {
|
|
16
|
-
setLink(text, url);
|
|
17
|
-
text = '';
|
|
18
|
-
url = '';
|
|
19
|
-
},
|
|
20
|
-
render: addLinkContent
|
|
21
|
-
}));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function setLink(text: string, url: string) {
|
|
25
|
-
editor
|
|
26
|
-
.chain()
|
|
27
|
-
.focus()
|
|
28
|
-
.insertContent(`<a href="${url}" target="_blank" rel="noopener noreferrer">${text}</a>`)
|
|
29
|
-
.insertContent(' ')
|
|
30
|
-
.unsetMark('link')
|
|
31
|
-
.run();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function updateLink() {
|
|
35
|
-
const previousUrl = editor.getAttributes('link').href
|
|
36
|
-
url = previousUrl || '';
|
|
37
|
-
modalStore.update(m => ({
|
|
38
|
-
...m,
|
|
39
|
-
open: true,
|
|
40
|
-
title: 'Editor',
|
|
41
|
-
onConfirm: () => {
|
|
42
|
-
editLink(url);
|
|
43
|
-
url = '';
|
|
44
|
-
},
|
|
45
|
-
onCancel: () => url = '',
|
|
46
|
-
render: editLinkContent
|
|
47
|
-
}));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function editLink(url: string){
|
|
51
|
-
if (url === null) {
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
if (url === '') {
|
|
55
|
-
editor.chain().focus().extendMarkRange('link').unsetLink()
|
|
56
|
-
.run()
|
|
57
|
-
return
|
|
58
|
-
}try {
|
|
59
|
-
editor.chain().focus().extendMarkRange('link').setLink({ href: url }).run()
|
|
60
|
-
} catch (e) {
|
|
61
|
-
const errorMessage = e instanceof Error ? e.message : String(e)
|
|
62
|
-
alert(errorMessage)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
</script>
|
|
67
|
-
|
|
68
|
-
{#snippet addLinkContent()}
|
|
69
|
-
<Input label="Enter Link Text" id="link-text" bind:value={text}/>
|
|
70
|
-
<Input label="Enter Link URL" id="link-url" bind:value={url}/>
|
|
71
|
-
{/snippet}
|
|
72
|
-
|
|
73
|
-
{#snippet editLinkContent()}
|
|
74
|
-
<Input label="Edit Link URL" id="link-url" bind:value={url}/>
|
|
75
|
-
{/snippet}
|
|
76
|
-
|
|
77
|
-
<button aria-label="Link Button" on:click={ editor.isActive('link')? updateLink : newLink} title="Add/Edit Link">
|
|
78
|
-
<i class="fa fa-link"></i>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Editor } from "@tiptap/core";
|
|
3
|
+
import {modalStore, Input} from '../../../../../index.js'
|
|
4
|
+
|
|
5
|
+
export let editor: Editor;
|
|
6
|
+
|
|
7
|
+
let text = '';
|
|
8
|
+
let url = '';
|
|
9
|
+
|
|
10
|
+
function newLink() {
|
|
11
|
+
modalStore.update(m => ({
|
|
12
|
+
...m,
|
|
13
|
+
open: true,
|
|
14
|
+
title: 'Editor',
|
|
15
|
+
onConfirm: () => {
|
|
16
|
+
setLink(text, url);
|
|
17
|
+
text = '';
|
|
18
|
+
url = '';
|
|
19
|
+
},
|
|
20
|
+
render: addLinkContent
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function setLink(text: string, url: string) {
|
|
25
|
+
editor
|
|
26
|
+
.chain()
|
|
27
|
+
.focus()
|
|
28
|
+
.insertContent(`<a href="${url}" target="_blank" rel="noopener noreferrer">${text}</a>`)
|
|
29
|
+
.insertContent(' ')
|
|
30
|
+
.unsetMark('link')
|
|
31
|
+
.run();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function updateLink() {
|
|
35
|
+
const previousUrl = editor.getAttributes('link').href
|
|
36
|
+
url = previousUrl || '';
|
|
37
|
+
modalStore.update(m => ({
|
|
38
|
+
...m,
|
|
39
|
+
open: true,
|
|
40
|
+
title: 'Editor',
|
|
41
|
+
onConfirm: () => {
|
|
42
|
+
editLink(url);
|
|
43
|
+
url = '';
|
|
44
|
+
},
|
|
45
|
+
onCancel: () => url = '',
|
|
46
|
+
render: editLinkContent
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function editLink(url: string){
|
|
51
|
+
if (url === null) {
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
if (url === '') {
|
|
55
|
+
editor.chain().focus().extendMarkRange('link').unsetLink()
|
|
56
|
+
.run()
|
|
57
|
+
return
|
|
58
|
+
}try {
|
|
59
|
+
editor.chain().focus().extendMarkRange('link').setLink({ href: url }).run()
|
|
60
|
+
} catch (e) {
|
|
61
|
+
const errorMessage = e instanceof Error ? e.message : String(e)
|
|
62
|
+
alert(errorMessage)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
{#snippet addLinkContent()}
|
|
69
|
+
<Input label="Enter Link Text" id="link-text" bind:value={text}/>
|
|
70
|
+
<Input label="Enter Link URL" id="link-url" bind:value={url}/>
|
|
71
|
+
{/snippet}
|
|
72
|
+
|
|
73
|
+
{#snippet editLinkContent()}
|
|
74
|
+
<Input label="Edit Link URL" id="link-url" bind:value={url}/>
|
|
75
|
+
{/snippet}
|
|
76
|
+
|
|
77
|
+
<button aria-label="Link Button" on:click={ editor.isActive('link')? updateLink : newLink} title="Add/Edit Link">
|
|
78
|
+
<i class="fa fa-link"></i>
|
|
79
79
|
</button>
|