@mythrantic/svelte-rich-text 0.2.8
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 +289 -0
- package/dist/components/core/blockWrapper.svelte +88 -0
- package/dist/components/core/blockWrapper.svelte.d.ts +19 -0
- package/dist/components/core/editMode.svelte +95 -0
- package/dist/components/core/editMode.svelte.d.ts +16 -0
- package/dist/components/core/main.svelte +196 -0
- package/dist/components/core/main.svelte.d.ts +65 -0
- package/dist/components/core/toolBar.svelte +141 -0
- package/dist/components/core/toolBar.svelte.d.ts +16 -0
- package/dist/components/core/viewMode.svelte +28 -0
- package/dist/components/core/viewMode.svelte.d.ts +25 -0
- package/dist/components/editBlocks/code.svelte +68 -0
- package/dist/components/editBlocks/code.svelte.d.ts +24 -0
- package/dist/components/editBlocks/header.svelte +66 -0
- package/dist/components/editBlocks/header.svelte.d.ts +23 -0
- package/dist/components/editBlocks/img.svelte +47 -0
- package/dist/components/editBlocks/img.svelte.d.ts +24 -0
- package/dist/components/editBlocks/list.svelte +102 -0
- package/dist/components/editBlocks/list.svelte.d.ts +23 -0
- package/dist/components/editBlocks/paragraph.svelte +22 -0
- package/dist/components/editBlocks/paragraph.svelte.d.ts +26 -0
- package/dist/components/editBlocks/quote.svelte +57 -0
- package/dist/components/editBlocks/quote.svelte.d.ts +23 -0
- package/dist/components/editBlocks/space.svelte +24 -0
- package/dist/components/editBlocks/space.svelte.d.ts +22 -0
- package/dist/components/extra/dropDown.svelte +117 -0
- package/dist/components/extra/dropDown.svelte.d.ts +23 -0
- package/dist/components/extra/input.svelte +63 -0
- package/dist/components/extra/input.svelte.d.ts +21 -0
- package/dist/components/extra/select.svelte +50 -0
- package/dist/components/extra/select.svelte.d.ts +30 -0
- package/dist/components/extra/textarea.svelte +40 -0
- package/dist/components/extra/textarea.svelte.d.ts +21 -0
- package/dist/components/extra/upload.svelte +79 -0
- package/dist/components/extra/upload.svelte.d.ts +21 -0
- package/dist/components/icons/closeIcon.svelte +6 -0
- package/dist/components/icons/closeIcon.svelte.d.ts +25 -0
- package/dist/components/icons/closeQuoteIcon.svelte +9 -0
- package/dist/components/icons/closeQuoteIcon.svelte.d.ts +25 -0
- package/dist/components/icons/codeIcon.svelte +12 -0
- package/dist/components/icons/codeIcon.svelte.d.ts +25 -0
- package/dist/components/icons/copyIcon.svelte +12 -0
- package/dist/components/icons/copyIcon.svelte.d.ts +25 -0
- package/dist/components/icons/deleteIcon.svelte +12 -0
- package/dist/components/icons/deleteIcon.svelte.d.ts +25 -0
- package/dist/components/icons/doneIcon.svelte +17 -0
- package/dist/components/icons/doneIcon.svelte.d.ts +25 -0
- package/dist/components/icons/downIcon.svelte +12 -0
- package/dist/components/icons/downIcon.svelte.d.ts +25 -0
- package/dist/components/icons/headerIcon.svelte +12 -0
- package/dist/components/icons/headerIcon.svelte.d.ts +25 -0
- package/dist/components/icons/imageIcon.svelte +12 -0
- package/dist/components/icons/imageIcon.svelte.d.ts +25 -0
- package/dist/components/icons/listIcon.svelte +12 -0
- package/dist/components/icons/listIcon.svelte.d.ts +25 -0
- package/dist/components/icons/menuIcon.svelte +12 -0
- package/dist/components/icons/menuIcon.svelte.d.ts +25 -0
- package/dist/components/icons/openQuoteIcon.svelte +9 -0
- package/dist/components/icons/openQuoteIcon.svelte.d.ts +25 -0
- package/dist/components/icons/paragraphIcon.svelte +12 -0
- package/dist/components/icons/paragraphIcon.svelte.d.ts +25 -0
- package/dist/components/icons/plusIcon.svelte +3 -0
- package/dist/components/icons/plusIcon.svelte.d.ts +25 -0
- package/dist/components/icons/spaceIcon.svelte +9 -0
- package/dist/components/icons/spaceIcon.svelte.d.ts +25 -0
- package/dist/components/icons/upIcon.svelte +12 -0
- package/dist/components/icons/upIcon.svelte.d.ts +25 -0
- package/dist/components/icons/uploadIcon.svelte +9 -0
- package/dist/components/icons/uploadIcon.svelte.d.ts +25 -0
- package/dist/components/viewBlocks/viewCode.svelte +150 -0
- package/dist/components/viewBlocks/viewCode.svelte.d.ts +20 -0
- package/dist/components/viewBlocks/viewHeader.svelte +13 -0
- package/dist/components/viewBlocks/viewHeader.svelte.d.ts +19 -0
- package/dist/components/viewBlocks/viewImage.svelte +35 -0
- package/dist/components/viewBlocks/viewImage.svelte.d.ts +20 -0
- package/dist/components/viewBlocks/viewList.svelte +69 -0
- package/dist/components/viewBlocks/viewList.svelte.d.ts +19 -0
- package/dist/components/viewBlocks/viewParagraph.svelte +12 -0
- package/dist/components/viewBlocks/viewParagraph.svelte.d.ts +18 -0
- package/dist/components/viewBlocks/viewQuote.svelte +29 -0
- package/dist/components/viewBlocks/viewQuote.svelte.d.ts +19 -0
- package/dist/components/viewBlocks/viewSpace.svelte +4 -0
- package/dist/components/viewBlocks/viewSpace.svelte.d.ts +18 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +13 -0
- package/dist/utils/consts.d.ts +96 -0
- package/dist/utils/consts.js +1 -0
- package/dist/utils/functions.d.ts +2 -0
- package/dist/utils/functions.js +12 -0
- package/dist/utils/stores.d.ts +6 -0
- package/dist/utils/stores.js +3 -0
- package/package.json +107 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import { type ComponentType } from 'svelte';
|
|
3
|
+
import type { dataBlock, languages } from '../../utils/consts.js';
|
|
4
|
+
declare const __propDef: {
|
|
5
|
+
props: {
|
|
6
|
+
initialData?: dataBlock[];
|
|
7
|
+
viewMode?: boolean;
|
|
8
|
+
headerFont?: string;
|
|
9
|
+
bodyFont?: string;
|
|
10
|
+
primaryColor?: string;
|
|
11
|
+
secondaryColor?: string;
|
|
12
|
+
textColor?: string;
|
|
13
|
+
bgColor?: string;
|
|
14
|
+
blocksGap?: number;
|
|
15
|
+
marginBlock?: number;
|
|
16
|
+
h1?: string;
|
|
17
|
+
h2?: string;
|
|
18
|
+
h3?: string;
|
|
19
|
+
h4?: string;
|
|
20
|
+
body?: string;
|
|
21
|
+
small?: string;
|
|
22
|
+
lh1?: string;
|
|
23
|
+
lh2?: string;
|
|
24
|
+
lh3?: string;
|
|
25
|
+
lh4?: string;
|
|
26
|
+
lbody?: string;
|
|
27
|
+
customImage?: ComponentType<SvelteComponent<{
|
|
28
|
+
base64: string;
|
|
29
|
+
name: string;
|
|
30
|
+
caption: string;
|
|
31
|
+
}>>;
|
|
32
|
+
customCode?: ComponentType<SvelteComponent<{
|
|
33
|
+
text: string;
|
|
34
|
+
lang: languages;
|
|
35
|
+
}>>;
|
|
36
|
+
customList?: ComponentType<SvelteComponent<{
|
|
37
|
+
items: string[];
|
|
38
|
+
type: "ordered" | "unordered";
|
|
39
|
+
}>>;
|
|
40
|
+
customHeader?: ComponentType<SvelteComponent<{
|
|
41
|
+
text: string;
|
|
42
|
+
level: 1 | 2 | 3 | 4;
|
|
43
|
+
}>>;
|
|
44
|
+
customParagraph?: ComponentType<SvelteComponent<{
|
|
45
|
+
text: string;
|
|
46
|
+
}>>;
|
|
47
|
+
customQuote?: ComponentType<SvelteComponent<{
|
|
48
|
+
text: string;
|
|
49
|
+
owner: string;
|
|
50
|
+
}>>;
|
|
51
|
+
codeBlockLanguages?: languages[];
|
|
52
|
+
};
|
|
53
|
+
events: {
|
|
54
|
+
[evt: string]: CustomEvent<any>;
|
|
55
|
+
};
|
|
56
|
+
slots: {};
|
|
57
|
+
exports?: {};
|
|
58
|
+
bindings?: string;
|
|
59
|
+
};
|
|
60
|
+
export type MainProps = typeof __propDef.props;
|
|
61
|
+
export type MainEvents = typeof __propDef.events;
|
|
62
|
+
export type MainSlots = typeof __propDef.slots;
|
|
63
|
+
export default class Main extends SvelteComponent<MainProps, MainEvents, MainSlots> {
|
|
64
|
+
}
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
<script>import CodeIcon from "../icons/codeIcon.svelte";
|
|
2
|
+
import HeaderIcon from "../icons/headerIcon.svelte";
|
|
3
|
+
import ImageIcon from "../icons/imageIcon.svelte";
|
|
4
|
+
import ListIcon from "../icons/listIcon.svelte";
|
|
5
|
+
import QuoteIcon from "../icons/closeQuoteIcon.svelte";
|
|
6
|
+
import ParagraphIcon from "../icons/paragraphIcon.svelte";
|
|
7
|
+
import PlusIcon from "../icons/plusIcon.svelte";
|
|
8
|
+
import CloseIcon from "../icons/closeIcon.svelte";
|
|
9
|
+
import SpaceIcon from "../icons/spaceIcon.svelte";
|
|
10
|
+
import shortUUID from "short-uuid";
|
|
11
|
+
import { data, workingBlock } from "../../utils/stores";
|
|
12
|
+
import { fade } from "svelte/transition";
|
|
13
|
+
import { elasticIn } from "svelte/easing";
|
|
14
|
+
function add(list, id, name) {
|
|
15
|
+
if (name === "paragraph") {
|
|
16
|
+
list.push({ name, id, data: { text: "hello friend" } });
|
|
17
|
+
} else if (name === "image") {
|
|
18
|
+
list.push({
|
|
19
|
+
name,
|
|
20
|
+
id,
|
|
21
|
+
data: { base64: "", name: "default.png", caption: "default image" }
|
|
22
|
+
});
|
|
23
|
+
} else if (name === "code") {
|
|
24
|
+
list.push({ name, id, data: { text: 'console.log("hello friend")', lang: "plaintext" } });
|
|
25
|
+
} else if (name === "quote") {
|
|
26
|
+
list.push({ name, id, data: { text: "hello friend", owner: "me" } });
|
|
27
|
+
} else if (name === "header") {
|
|
28
|
+
list.push({ name, id, data: { text: "hello friend", level: 4 } });
|
|
29
|
+
} else if (name === "list") {
|
|
30
|
+
list.push({ name, id, data: { items: ["hello friend"], type: "ordered" } });
|
|
31
|
+
} else {
|
|
32
|
+
list.push({ id, name, data: { size: 24 } });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const options = /* @__PURE__ */ new Map([
|
|
36
|
+
["code", CodeIcon],
|
|
37
|
+
["image", ImageIcon],
|
|
38
|
+
["quote", QuoteIcon],
|
|
39
|
+
["header", HeaderIcon],
|
|
40
|
+
["paragraph", ParagraphIcon],
|
|
41
|
+
["list", ListIcon],
|
|
42
|
+
["space", SpaceIcon]
|
|
43
|
+
]);
|
|
44
|
+
let toggle = true;
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<div class="toolBar">
|
|
48
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
49
|
+
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
50
|
+
|
|
51
|
+
<span on:click={() => (toggle = !toggle)} class="control">
|
|
52
|
+
{#if toggle}
|
|
53
|
+
<CloseIcon />
|
|
54
|
+
{:else}
|
|
55
|
+
<PlusIcon />
|
|
56
|
+
{/if}
|
|
57
|
+
</span>
|
|
58
|
+
{#if toggle}
|
|
59
|
+
<div class="options">
|
|
60
|
+
{#each options.entries() as option, index}
|
|
61
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
62
|
+
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
63
|
+
<span
|
|
64
|
+
in:fade|global={{ delay: 80 * index, duration: 300, easing: elasticIn }}
|
|
65
|
+
out:fade|global={{ delay: 80 * (6 - index), duration: 300, easing: elasticIn }}
|
|
66
|
+
data-label={'add ' + option[0]}
|
|
67
|
+
class="option"
|
|
68
|
+
on:click|stopPropagation={() => {
|
|
69
|
+
const id = shortUUID().generate();
|
|
70
|
+
data.update((prev) => {
|
|
71
|
+
add(prev, id, option[0]);
|
|
72
|
+
toggle = true;
|
|
73
|
+
return prev;
|
|
74
|
+
});
|
|
75
|
+
workingBlock.set({ id, state: 'editing' });
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
<svelte:component this={option[1]} />
|
|
79
|
+
</span>
|
|
80
|
+
{/each}
|
|
81
|
+
</div>
|
|
82
|
+
{/if}
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
<style>
|
|
86
|
+
.toolBar {
|
|
87
|
+
margin-top: 30px;
|
|
88
|
+
width: fit-content;
|
|
89
|
+
display: grid;
|
|
90
|
+
align-items: center;
|
|
91
|
+
grid-template-columns: repeat(2, auto);
|
|
92
|
+
gap: 20px;
|
|
93
|
+
}
|
|
94
|
+
.toolBar span {
|
|
95
|
+
display: flex;
|
|
96
|
+
align-items: center;
|
|
97
|
+
justify-content: center;
|
|
98
|
+
width: 36px;
|
|
99
|
+
aspect-ratio: 1/1;
|
|
100
|
+
border-radius: 50%;
|
|
101
|
+
cursor: pointer;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.control {
|
|
105
|
+
border: 1px solid var(--textColor);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.options {
|
|
109
|
+
display: flex;
|
|
110
|
+
align-items: center;
|
|
111
|
+
flex-wrap: wrap;
|
|
112
|
+
justify-content: center;
|
|
113
|
+
gap: 12px;
|
|
114
|
+
}
|
|
115
|
+
.option {
|
|
116
|
+
border: 1px solid var(--primaryColor);
|
|
117
|
+
position: relative;
|
|
118
|
+
}
|
|
119
|
+
.option::after {
|
|
120
|
+
content: attr(data-label);
|
|
121
|
+
position: absolute;
|
|
122
|
+
display: none;
|
|
123
|
+
top: 102%;
|
|
124
|
+
left: 1.2rem;
|
|
125
|
+
width: 120px;
|
|
126
|
+
text-transform: capitalize;
|
|
127
|
+
padding-inline: 6px;
|
|
128
|
+
padding-block: 3px;
|
|
129
|
+
font-size: var(--small);
|
|
130
|
+
font-weight: bold;
|
|
131
|
+
color: var(--textColor);
|
|
132
|
+
background-color: transparent;
|
|
133
|
+
z-index: 99;
|
|
134
|
+
}
|
|
135
|
+
.option:hover::after {
|
|
136
|
+
display: block;
|
|
137
|
+
}
|
|
138
|
+
.option > :global(svg path) {
|
|
139
|
+
fill: var(--primaryColor);
|
|
140
|
+
}
|
|
141
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: Record<string, never>;
|
|
4
|
+
events: {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
};
|
|
7
|
+
slots: {};
|
|
8
|
+
exports?: {};
|
|
9
|
+
bindings?: string;
|
|
10
|
+
};
|
|
11
|
+
export type ToolBarProps = typeof __propDef.props;
|
|
12
|
+
export type ToolBarEvents = typeof __propDef.events;
|
|
13
|
+
export type ToolBarSlots = typeof __propDef.slots;
|
|
14
|
+
export default class ToolBar extends SvelteComponent<ToolBarProps, ToolBarEvents, ToolBarSlots> {
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { data } from '../../utils/stores';
|
|
3
|
+
import ViewCode from '../viewBlocks/viewCode.svelte';
|
|
4
|
+
import ViewHeader from '../viewBlocks/viewHeader.svelte';
|
|
5
|
+
import ViewImage from '../viewBlocks/viewImage.svelte';
|
|
6
|
+
import ViewList from '../viewBlocks/viewList.svelte';
|
|
7
|
+
import ViewParagraph from '../viewBlocks/viewParagraph.svelte';
|
|
8
|
+
import ViewQuote from '../viewBlocks/viewQuote.svelte';
|
|
9
|
+
import ViewSpace from '../viewBlocks/viewSpace.svelte';
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
{#each $data as block}
|
|
13
|
+
{#if block.name == 'code'}
|
|
14
|
+
<ViewCode {...block.data} />
|
|
15
|
+
{:else if block.name == 'header'}
|
|
16
|
+
<ViewHeader {...block.data} />
|
|
17
|
+
{:else if block.name == 'list'}
|
|
18
|
+
<ViewList {...block.data} />
|
|
19
|
+
{:else if block.name == 'image'}
|
|
20
|
+
<ViewImage {...block.data} />
|
|
21
|
+
{:else if block.name == 'quote'}
|
|
22
|
+
<ViewQuote {...block.data} />
|
|
23
|
+
{:else if block.name == 'paragraph'}
|
|
24
|
+
<ViewParagraph {...block.data} />
|
|
25
|
+
{:else}
|
|
26
|
+
<ViewSpace size={block.data.size} />
|
|
27
|
+
{/if}
|
|
28
|
+
{/each}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} ViewModeProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} ViewModeEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} ViewModeSlots */
|
|
4
|
+
export default class ViewMode extends SvelteComponent<{
|
|
5
|
+
[x: string]: never;
|
|
6
|
+
}, {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
}, {}> {
|
|
9
|
+
}
|
|
10
|
+
export type ViewModeProps = typeof __propDef.props;
|
|
11
|
+
export type ViewModeEvents = typeof __propDef.events;
|
|
12
|
+
export type ViewModeSlots = typeof __propDef.slots;
|
|
13
|
+
import { SvelteComponent } from "svelte";
|
|
14
|
+
declare const __propDef: {
|
|
15
|
+
props: {
|
|
16
|
+
[x: string]: never;
|
|
17
|
+
};
|
|
18
|
+
events: {
|
|
19
|
+
[evt: string]: CustomEvent<any>;
|
|
20
|
+
};
|
|
21
|
+
slots: {};
|
|
22
|
+
exports?: {};
|
|
23
|
+
bindings?: string;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<script>import { SvelteComponent, getContext } from "svelte";
|
|
2
|
+
import Select from "../extra/select.svelte";
|
|
3
|
+
import { updateData } from "../../utils/functions";
|
|
4
|
+
import Textarea from "../extra/textarea.svelte";
|
|
5
|
+
export let content;
|
|
6
|
+
export let id;
|
|
7
|
+
export let active = false;
|
|
8
|
+
const languages = getContext("languages");
|
|
9
|
+
const view = getContext("Code");
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
{#if active}
|
|
13
|
+
<div class="codeEdit">
|
|
14
|
+
<Select
|
|
15
|
+
label="Code language"
|
|
16
|
+
preSelected={{ label: content.lang, value: content.lang }}
|
|
17
|
+
elements={languages.map((el) => ({ value: el, label: el }))}
|
|
18
|
+
changeHandler={(detail) => {
|
|
19
|
+
updateData(id, (el) => {
|
|
20
|
+
if (el.name == 'code') el.data.lang = detail.value;
|
|
21
|
+
});
|
|
22
|
+
}}
|
|
23
|
+
/>
|
|
24
|
+
<div>
|
|
25
|
+
<span>The code</span>
|
|
26
|
+
<Textarea
|
|
27
|
+
textLevel={0}
|
|
28
|
+
textContent={content.text}
|
|
29
|
+
changeHandler={(text) => {
|
|
30
|
+
updateData(id, (el) => {
|
|
31
|
+
if (el.name == 'code') el.data.text = text;
|
|
32
|
+
});
|
|
33
|
+
}}
|
|
34
|
+
/>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
{:else}
|
|
38
|
+
<svelte:component this={view} {...content} />
|
|
39
|
+
{/if}
|
|
40
|
+
|
|
41
|
+
<style>
|
|
42
|
+
.codeEdit {
|
|
43
|
+
width: 100%;
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
gap: 15px;
|
|
47
|
+
}
|
|
48
|
+
.codeEdit :global(::-webkit-scrollbar) {
|
|
49
|
+
width: 0.5rem;
|
|
50
|
+
}
|
|
51
|
+
.codeEdit :global(::-webkit-scrollbar-track) {
|
|
52
|
+
background: color-mix(in srgb, var(--secondaryColor) 40%, white 40%);
|
|
53
|
+
}
|
|
54
|
+
.codeEdit :global(::-webkit-scrollbar-thumb) {
|
|
55
|
+
background: var(--secondaryColor);
|
|
56
|
+
}
|
|
57
|
+
.codeEdit div {
|
|
58
|
+
display: flex;
|
|
59
|
+
flex-direction: column;
|
|
60
|
+
gap: 5px;
|
|
61
|
+
}
|
|
62
|
+
.codeEdit div span {
|
|
63
|
+
margin-left: 10px;
|
|
64
|
+
font-weight: bold;
|
|
65
|
+
color: var(--textColor);
|
|
66
|
+
font-size: var(--small);
|
|
67
|
+
}
|
|
68
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { languages } from '../../utils/consts';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
content: {
|
|
6
|
+
text: string;
|
|
7
|
+
lang: languages;
|
|
8
|
+
};
|
|
9
|
+
id: string;
|
|
10
|
+
active?: boolean;
|
|
11
|
+
};
|
|
12
|
+
events: {
|
|
13
|
+
[evt: string]: CustomEvent<any>;
|
|
14
|
+
};
|
|
15
|
+
slots: {};
|
|
16
|
+
exports?: {};
|
|
17
|
+
bindings?: string;
|
|
18
|
+
};
|
|
19
|
+
export type CodeProps = typeof __propDef.props;
|
|
20
|
+
export type CodeEvents = typeof __propDef.events;
|
|
21
|
+
export type CodeSlots = typeof __propDef.slots;
|
|
22
|
+
export default class Code extends SvelteComponent<CodeProps, CodeEvents, CodeSlots> {
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<script>import { SvelteComponent, getContext } from "svelte";
|
|
2
|
+
import Select from "../extra/select.svelte";
|
|
3
|
+
import Textarea from "../extra/textarea.svelte";
|
|
4
|
+
import { updateData } from "../../utils/functions";
|
|
5
|
+
export let content;
|
|
6
|
+
export let id;
|
|
7
|
+
export let active = false;
|
|
8
|
+
const view = getContext("Header");
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
{#if active}
|
|
12
|
+
<div class="headerEdit">
|
|
13
|
+
<Select
|
|
14
|
+
preSelected={{ value: content.level, label: 'h' + content.level }}
|
|
15
|
+
label="Header level"
|
|
16
|
+
elements={[
|
|
17
|
+
{ value: 1, label: 'h1' },
|
|
18
|
+
{ value: 2, label: 'h2' },
|
|
19
|
+
{ value: 3, label: 'h3' },
|
|
20
|
+
{ value: 4, label: 'h4' }
|
|
21
|
+
]}
|
|
22
|
+
changeHandler={(detail) => {
|
|
23
|
+
updateData(id, (prev) => {
|
|
24
|
+
if (prev.name == 'header') {
|
|
25
|
+
prev.data.level = detail.value;
|
|
26
|
+
content.level = detail.value;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}}
|
|
30
|
+
/>
|
|
31
|
+
<div>
|
|
32
|
+
<span>Header content</span>
|
|
33
|
+
<Textarea
|
|
34
|
+
textLevel={content.level}
|
|
35
|
+
textContent={content.text}
|
|
36
|
+
changeHandler={(text) => {
|
|
37
|
+
updateData(id, (prev) => {
|
|
38
|
+
if (prev.name == 'header') prev.data.text = text;
|
|
39
|
+
});
|
|
40
|
+
}}
|
|
41
|
+
/>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
{:else}
|
|
45
|
+
<svelte:component this={view} {...content} />
|
|
46
|
+
{/if}
|
|
47
|
+
|
|
48
|
+
<style>
|
|
49
|
+
.headerEdit {
|
|
50
|
+
width: 100%;
|
|
51
|
+
display: flex;
|
|
52
|
+
flex-direction: column;
|
|
53
|
+
gap: 15px;
|
|
54
|
+
}
|
|
55
|
+
.headerEdit div {
|
|
56
|
+
display: flex;
|
|
57
|
+
flex-direction: column;
|
|
58
|
+
gap: 5px;
|
|
59
|
+
}
|
|
60
|
+
.headerEdit div span {
|
|
61
|
+
margin-left: 10px;
|
|
62
|
+
font-weight: bold;
|
|
63
|
+
color: var(--textColor);
|
|
64
|
+
font-size: var(--small);
|
|
65
|
+
}
|
|
66
|
+
</style>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
content: {
|
|
5
|
+
text: string;
|
|
6
|
+
level: 1 | 2 | 3 | 4;
|
|
7
|
+
};
|
|
8
|
+
id: string;
|
|
9
|
+
active?: boolean;
|
|
10
|
+
};
|
|
11
|
+
events: {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
};
|
|
14
|
+
slots: {};
|
|
15
|
+
exports?: {};
|
|
16
|
+
bindings?: string;
|
|
17
|
+
};
|
|
18
|
+
export type HeaderProps = typeof __propDef.props;
|
|
19
|
+
export type HeaderEvents = typeof __propDef.events;
|
|
20
|
+
export type HeaderSlots = typeof __propDef.slots;
|
|
21
|
+
export default class Header extends SvelteComponent<HeaderProps, HeaderEvents, HeaderSlots> {
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script>import { updateData } from "../../utils/functions";
|
|
2
|
+
import { SvelteComponent, getContext } from "svelte";
|
|
3
|
+
import Input from "../extra/input.svelte";
|
|
4
|
+
import Upload from "../extra/upload.svelte";
|
|
5
|
+
export let content;
|
|
6
|
+
export let id;
|
|
7
|
+
export let active = false;
|
|
8
|
+
const view = getContext("Image");
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
{#if active}
|
|
12
|
+
<div class="imageEdit">
|
|
13
|
+
<Input
|
|
14
|
+
label="Image caption"
|
|
15
|
+
value={content.caption}
|
|
16
|
+
changeHandler={(text) => {
|
|
17
|
+
updateData(id, (el) => {
|
|
18
|
+
if (el.name == 'image') el.data.caption = text;
|
|
19
|
+
});
|
|
20
|
+
}}
|
|
21
|
+
/>
|
|
22
|
+
<Upload
|
|
23
|
+
fileType="image/*"
|
|
24
|
+
label="Image source"
|
|
25
|
+
currentFileName={content.name}
|
|
26
|
+
changeHandler={(base64, fileName) => {
|
|
27
|
+
updateData(id, (el) => {
|
|
28
|
+
if (el.name == 'image') {
|
|
29
|
+
el.data.name = fileName;
|
|
30
|
+
el.data.base64 = base64;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}}
|
|
34
|
+
/>
|
|
35
|
+
</div>
|
|
36
|
+
{:else}
|
|
37
|
+
<svelte:component this={view} {...content} />
|
|
38
|
+
{/if}
|
|
39
|
+
|
|
40
|
+
<style>
|
|
41
|
+
.imageEdit {
|
|
42
|
+
width: 100%;
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-direction: column;
|
|
45
|
+
gap: 15px;
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
content: {
|
|
5
|
+
base64: string;
|
|
6
|
+
name: string;
|
|
7
|
+
caption: string;
|
|
8
|
+
};
|
|
9
|
+
id: string;
|
|
10
|
+
active?: boolean;
|
|
11
|
+
};
|
|
12
|
+
events: {
|
|
13
|
+
[evt: string]: CustomEvent<any>;
|
|
14
|
+
};
|
|
15
|
+
slots: {};
|
|
16
|
+
exports?: {};
|
|
17
|
+
bindings?: string;
|
|
18
|
+
};
|
|
19
|
+
export type ImgProps = typeof __propDef.props;
|
|
20
|
+
export type ImgEvents = typeof __propDef.events;
|
|
21
|
+
export type ImgSlots = typeof __propDef.slots;
|
|
22
|
+
export default class Img extends SvelteComponent<ImgProps, ImgEvents, ImgSlots> {
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<script>import { SvelteComponent, getContext } from "svelte";
|
|
2
|
+
import Select from "../extra/select.svelte";
|
|
3
|
+
import { updateData } from "../../utils/functions";
|
|
4
|
+
import Textarea from "../extra/textarea.svelte";
|
|
5
|
+
import CloseIcon from "../icons/closeIcon.svelte";
|
|
6
|
+
import PlusIcon from "../icons/plusIcon.svelte";
|
|
7
|
+
export let content;
|
|
8
|
+
export let id;
|
|
9
|
+
export let active = false;
|
|
10
|
+
const view = getContext("List");
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
{#if active}
|
|
14
|
+
<div class="listEdit">
|
|
15
|
+
<Select
|
|
16
|
+
label="List type"
|
|
17
|
+
preSelected={{ value: content.type, label: content.type }}
|
|
18
|
+
elements={[
|
|
19
|
+
{ value: 'ordered', label: 'ordered' },
|
|
20
|
+
{ value: 'unordered', label: 'unordered' }
|
|
21
|
+
]}
|
|
22
|
+
changeHandler={(detail) => {
|
|
23
|
+
updateData(id, (el) => {
|
|
24
|
+
if (el.name == 'list') el.data.type = detail.value;
|
|
25
|
+
console.log(el);
|
|
26
|
+
});
|
|
27
|
+
}}
|
|
28
|
+
/>
|
|
29
|
+
<div class="itemsEdit">
|
|
30
|
+
<span>List items</span>
|
|
31
|
+
{#each content.items as item, index}
|
|
32
|
+
<div class="itemEdit">
|
|
33
|
+
<Textarea
|
|
34
|
+
width={90}
|
|
35
|
+
textContent={item}
|
|
36
|
+
textLevel={0}
|
|
37
|
+
changeHandler={(text) => {
|
|
38
|
+
updateData(id, (el) => {
|
|
39
|
+
if (el.name == 'list') el.data.items[index] = text;
|
|
40
|
+
});
|
|
41
|
+
}}
|
|
42
|
+
/>
|
|
43
|
+
<!-- svelte-ignore missing-declaration -->
|
|
44
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
45
|
+
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
46
|
+
<span
|
|
47
|
+
class="control"
|
|
48
|
+
on:click|stopPropagation={() => {
|
|
49
|
+
updateData(id, (el) => {
|
|
50
|
+
if (el.name == 'list') el.data.items.splice(index, 1);
|
|
51
|
+
});
|
|
52
|
+
}}><CloseIcon /></span
|
|
53
|
+
>
|
|
54
|
+
</div>
|
|
55
|
+
{/each}
|
|
56
|
+
<!-- svelte-ignore missing-declaration -->
|
|
57
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
58
|
+
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
59
|
+
<span
|
|
60
|
+
class="control"
|
|
61
|
+
on:click|stopPropagation={() => {
|
|
62
|
+
updateData(id, (el) => {
|
|
63
|
+
if (el.name == 'list') el.data.items.push('');
|
|
64
|
+
});
|
|
65
|
+
}}><PlusIcon /></span
|
|
66
|
+
>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
{:else}
|
|
70
|
+
<svelte:component this={view} {...content} />
|
|
71
|
+
{/if}
|
|
72
|
+
|
|
73
|
+
<style>
|
|
74
|
+
.listEdit {
|
|
75
|
+
width: 100%;
|
|
76
|
+
display: flex;
|
|
77
|
+
flex-direction: column;
|
|
78
|
+
gap: 15px;
|
|
79
|
+
}
|
|
80
|
+
.listEdit .itemsEdit {
|
|
81
|
+
display: flex;
|
|
82
|
+
flex-direction: column;
|
|
83
|
+
gap: 10px;
|
|
84
|
+
}
|
|
85
|
+
.listEdit .itemsEdit .itemEdit {
|
|
86
|
+
display: flex;
|
|
87
|
+
align-items: center;
|
|
88
|
+
gap: 8px;
|
|
89
|
+
}
|
|
90
|
+
.listEdit .itemsEdit .control {
|
|
91
|
+
cursor: pointer;
|
|
92
|
+
}
|
|
93
|
+
.listEdit .itemsEdit span:first-child {
|
|
94
|
+
margin-left: 10px;
|
|
95
|
+
font-weight: bold;
|
|
96
|
+
color: var(--textColor);
|
|
97
|
+
font-size: var(--small);
|
|
98
|
+
}
|
|
99
|
+
.listEdit .itemsEdit span:last-child {
|
|
100
|
+
align-self: center;
|
|
101
|
+
}
|
|
102
|
+
</style>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
content: {
|
|
5
|
+
items: string[];
|
|
6
|
+
type: "ordered" | "unordered";
|
|
7
|
+
};
|
|
8
|
+
id: string;
|
|
9
|
+
active?: boolean;
|
|
10
|
+
};
|
|
11
|
+
events: {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
};
|
|
14
|
+
slots: {};
|
|
15
|
+
exports?: {};
|
|
16
|
+
bindings?: string;
|
|
17
|
+
};
|
|
18
|
+
export type ListProps = typeof __propDef.props;
|
|
19
|
+
export type ListEvents = typeof __propDef.events;
|
|
20
|
+
export type ListSlots = typeof __propDef.slots;
|
|
21
|
+
export default class List extends SvelteComponent<ListProps, ListEvents, ListSlots> {
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script>import { updateData } from "../../utils/functions";
|
|
2
|
+
import { SvelteComponent, getContext } from "svelte";
|
|
3
|
+
import Textarea from "../extra/textarea.svelte";
|
|
4
|
+
export let content;
|
|
5
|
+
export let active = false;
|
|
6
|
+
export let id;
|
|
7
|
+
export let view = getContext("Paragraph");
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
{#if active}
|
|
11
|
+
<Textarea
|
|
12
|
+
textContent={content.text}
|
|
13
|
+
textLevel={0}
|
|
14
|
+
changeHandler={(textContent) => {
|
|
15
|
+
updateData(id, (prev) => {
|
|
16
|
+
if (prev.name == 'paragraph') prev.data.text = textContent;
|
|
17
|
+
});
|
|
18
|
+
}}
|
|
19
|
+
/>
|
|
20
|
+
{:else}
|
|
21
|
+
<svelte:component this={view} text={content.text} />
|
|
22
|
+
{/if}
|