edytor 0.0.7 → 0.0.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 +225 -5
- package/dist/block/block.svelte.d.ts +123 -0
- package/dist/block/block.svelte.js +430 -0
- package/dist/block/block.utils.d.ts +82 -0
- package/dist/block/block.utils.js +499 -0
- package/dist/block/content.svelte.d.ts +14 -0
- package/dist/block/content.svelte.js +40 -0
- package/dist/block/inlineBlock.svelte.d.ts +30 -0
- package/dist/block/inlineBlock.svelte.js +53 -0
- package/dist/components/Block.svelte +27 -0
- package/dist/components/Block.svelte.d.ts +7 -0
- package/dist/components/Content.svelte +44 -0
- package/dist/components/Content.svelte.d.ts +7 -0
- package/dist/components/Edytor.svelte +165 -0
- package/dist/components/Edytor.svelte.d.ts +33 -0
- package/dist/components/InlineBlock.svelte +17 -0
- package/dist/components/InlineBlock.svelte.d.ts +7 -0
- package/dist/components/Mark.svelte +38 -0
- package/dist/components/Mark.svelte.d.ts +11 -0
- package/dist/components/ReadonlyEditor.svelte +46 -0
- package/dist/components/ReadonlyEditor.svelte.d.ts +4 -0
- package/dist/components/Text.svelte +37 -0
- package/dist/components/Text.svelte.d.ts +7 -0
- package/dist/components/readonlyElements.svelte.d.ts +82 -0
- package/dist/components/readonlyElements.svelte.js +144 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +4 -0
- package/dist/dnd.svelte.d.ts +17 -0
- package/dist/dnd.svelte.js +125 -0
- package/dist/edytor.svelte.d.ts +94 -0
- package/dist/edytor.svelte.js +262 -0
- package/dist/edytor.utils.d.ts +3 -0
- package/dist/edytor.utils.js +78 -0
- package/dist/events/onBeforeInput.d.ts +2 -2
- package/dist/events/onBeforeInput.js +338 -0
- package/dist/events/onKeyDown.d.ts +2 -69
- package/dist/events/onKeyDown.js +18 -0
- package/dist/hotkeys.d.ts +27 -0
- package/dist/hotkeys.js +282 -0
- package/dist/index.d.ts +1 -5
- package/dist/index.js +2 -8
- package/dist/localProvider.d.ts +82 -0
- package/dist/localProvider.js +267 -0
- package/dist/plugins/arrowMove/arrowMove.d.ts +2 -0
- package/dist/plugins/arrowMove/arrowMove.js +66 -0
- package/dist/plugins/code/CodePlugin.svelte +218 -0
- package/dist/plugins/code/CodePlugin.svelte.d.ts +23 -0
- package/dist/plugins/code/prism.css +141 -0
- package/dist/plugins/image/ImagePlugin.svelte +22 -0
- package/dist/plugins/image/ImagePlugin.svelte.d.ts +20 -0
- package/dist/plugins/mention/MentionPlugin.svelte +40 -0
- package/dist/plugins/mention/MentionPlugin.svelte.d.ts +20 -0
- package/dist/plugins/richtext/RichTextPlugin.svelte +241 -0
- package/dist/plugins/richtext/RichTextPlugin.svelte.d.ts +26 -0
- package/dist/plugins.d.ts +202 -0
- package/dist/plugins.js +19 -0
- package/dist/selection/selection.svelte.d.ts +68 -0
- package/dist/selection/selection.svelte.js +391 -0
- package/dist/selection/selection.utils.d.ts +14 -0
- package/dist/selection/selection.utils.js +153 -0
- package/dist/text/deltas.d.ts +11 -0
- package/dist/text/deltas.js +109 -0
- package/dist/text/text.svelte.d.ts +70 -0
- package/dist/text/text.svelte.js +119 -0
- package/dist/text/text.utils.d.ts +40 -0
- package/dist/text/text.utils.js +174 -0
- package/dist/utils/json.d.ts +32 -0
- package/dist/utils/json.js +2 -0
- package/dist/utils/jsx.d.ts +25 -0
- package/dist/utils/jsx.js +66 -0
- package/dist/utils/serialize.d.ts +1 -0
- package/dist/utils/serialize.js +1 -0
- package/dist/utils.d.ts +6 -0
- package/dist/utils.js +19 -0
- package/package.json +81 -33
- package/dist/edytor.cjs.development.js +0 -1762
- package/dist/edytor.cjs.development.js.map +0 -1
- package/dist/edytor.cjs.production.min.js +0 -2
- package/dist/edytor.cjs.production.min.js.map +0 -1
- package/dist/edytor.esm.js +0 -1691
- package/dist/edytor.esm.js.map +0 -1
- package/dist/events/index.d.ts +0 -3
- package/dist/events/onDrop.d.ts +0 -3
- package/dist/operations/deleteText.d.ts +0 -7
- package/dist/operations/formatText.d.ts +0 -20
- package/dist/operations/index.d.ts +0 -9
- package/dist/operations/insertText.d.ts +0 -5
- package/dist/operations/merge.d.ts +0 -3
- package/dist/operations/moveNode.d.ts +0 -12
- package/dist/operations/nestNode.d.ts +0 -2
- package/dist/operations/removeEmptyText.d.ts +0 -2
- package/dist/operations/splitLeaf.d.ts +0 -2
- package/dist/operations/splitNode.d.ts +0 -9
- package/dist/types.d.ts +0 -140
- package/dist/utils/common.d.ts +0 -17
- package/dist/utils/dropper.d.ts +0 -26
- package/dist/utils/index.d.ts +0 -6
- package/dist/utils/leaves.d.ts +0 -34
- package/dist/utils/nodes.d.ts +0 -14
- package/dist/utils/selection.d.ts +0 -51
- package/dist/utils/yClasses/EdytorDoc.d.ts +0 -16
- package/dist/utils/yClasses/index.d.ts +0 -3
- package/dist/utils/yClasses/yLeaf.d.ts +0 -7
- package/dist/utils/yClasses/yNode.d.ts +0 -12
- package/dist/yjs/index.d.ts +0 -1
- package/dist/yjs/wsProvider.d.ts +0 -1
- package/index.ts +0 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {} from '../../plugins.js';
|
|
2
|
+
import { tick } from 'svelte';
|
|
3
|
+
export const arrowMovePlugin = (edytor) => {
|
|
4
|
+
return {
|
|
5
|
+
hotkeys: {
|
|
6
|
+
'mod+arrowdown': ({ prevent }) => {
|
|
7
|
+
const selectedBlocks = edytor.selection.selectedBlocks;
|
|
8
|
+
if (selectedBlocks.size === 1) {
|
|
9
|
+
const selectedBlock = selectedBlocks.values().next().value;
|
|
10
|
+
if (!selectedBlock)
|
|
11
|
+
return;
|
|
12
|
+
prevent(() => {
|
|
13
|
+
const path = selectedBlock.path;
|
|
14
|
+
console.log({ path: [...path] });
|
|
15
|
+
if (selectedBlock.parent &&
|
|
16
|
+
path?.at(-1) === selectedBlock.parent?.children.length - 1) {
|
|
17
|
+
// If the block is nested and is the last child, we need to unest the block i.e pop the last path index
|
|
18
|
+
path.pop();
|
|
19
|
+
}
|
|
20
|
+
// Then we just increment the last index
|
|
21
|
+
path[path.length - 1]++;
|
|
22
|
+
if (selectedBlock?.nextBlock?.hasChildren &&
|
|
23
|
+
!selectedBlock?.nextBlock?.definition.island) {
|
|
24
|
+
path.push(0);
|
|
25
|
+
}
|
|
26
|
+
const newBlock = selectedBlock.moveBlock({ path });
|
|
27
|
+
if (newBlock) {
|
|
28
|
+
tick().then(() => {
|
|
29
|
+
edytor.selection.selectBlocks(newBlock);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
'mod+arrowup': ({ prevent }) => {
|
|
36
|
+
const selectedBlocks = edytor.selection.selectedBlocks;
|
|
37
|
+
if (selectedBlocks.size === 1) {
|
|
38
|
+
const selectedBlock = selectedBlocks.values().next().value;
|
|
39
|
+
if (!selectedBlock)
|
|
40
|
+
return;
|
|
41
|
+
prevent(() => {
|
|
42
|
+
const path = selectedBlock.path;
|
|
43
|
+
if (path?.at(-1) === 0) {
|
|
44
|
+
// If the block is nested and is the first child, we need to unest the block i.e pop the last path index
|
|
45
|
+
path.pop();
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
// Other wise just decrement the last index
|
|
49
|
+
path[path.length - 1]--;
|
|
50
|
+
}
|
|
51
|
+
if (selectedBlock?.previousBlock?.hasChildren &&
|
|
52
|
+
!selectedBlock?.previousBlock?.definition.island) {
|
|
53
|
+
path.push(selectedBlock.previousBlock.children.length);
|
|
54
|
+
}
|
|
55
|
+
const newBlock = selectedBlock.moveBlock({ path });
|
|
56
|
+
if (newBlock) {
|
|
57
|
+
tick().then(() => {
|
|
58
|
+
edytor.selection.selectBlocks(newBlock);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
};
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import Prism from 'prismjs';
|
|
3
|
+
import './prism.css';
|
|
4
|
+
import 'prismjs/components/prism-jsx';
|
|
5
|
+
import 'prismjs/components/prism-css';
|
|
6
|
+
import type { Plugin, MarkSnippetPayload, BlockSnippetPayload } from '../../plugins.js';
|
|
7
|
+
import type { JSONText } from '../../utils/json.js';
|
|
8
|
+
import { id, prevent } from '../../utils.js';
|
|
9
|
+
import { Text } from '../../text/text.svelte.js';
|
|
10
|
+
import { Block } from '../../block/block.svelte.js';
|
|
11
|
+
|
|
12
|
+
import * as Y from 'yjs';
|
|
13
|
+
|
|
14
|
+
export const codePlugin: Plugin = (edytor) => {
|
|
15
|
+
return {
|
|
16
|
+
hotkeys: {
|
|
17
|
+
'mod+a': ({ prevent }) => {
|
|
18
|
+
const { islandRoot, startBlock, isAtEndOfBlock, isAtStartOfBlock } =
|
|
19
|
+
edytor.selection.state;
|
|
20
|
+
if (
|
|
21
|
+
startBlock?.type === 'codeLine' &&
|
|
22
|
+
!edytor.selection.selectedBlocks.size &&
|
|
23
|
+
!(isAtEndOfBlock && isAtStartOfBlock)
|
|
24
|
+
) {
|
|
25
|
+
prevent(() => {
|
|
26
|
+
const firstText = islandRoot?.firstEditableText;
|
|
27
|
+
let lastText = islandRoot?.lastEditableText;
|
|
28
|
+
if (firstText && lastText && firstText instanceof Text && lastText instanceof Text) {
|
|
29
|
+
edytor.selection.setAtTextsRange(firstText, lastText);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
escape: () => {
|
|
35
|
+
const { startBlock } = edytor.selection.state;
|
|
36
|
+
if (startBlock?.type === 'codeLine' && startBlock?.suggestions) {
|
|
37
|
+
startBlock.suggestions = null;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
tab: ({ prevent }) => {
|
|
41
|
+
const { startText, yStart, startBlock } = edytor.selection.state;
|
|
42
|
+
if (startText?.parent.type === 'codeLine') {
|
|
43
|
+
prevent(() => {
|
|
44
|
+
if (startBlock?.suggestions) {
|
|
45
|
+
startBlock.acceptSuggestedText();
|
|
46
|
+
edytor.selection.setAtTextOffset(startText, startText.yText.length);
|
|
47
|
+
} else {
|
|
48
|
+
if (startText) {
|
|
49
|
+
startText.insertText({ value: '\t' });
|
|
50
|
+
edytor.selection.setAtTextOffset(startText, yStart + 1);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
'shift+enter': () => {
|
|
57
|
+
const { startText } = edytor.selection.state;
|
|
58
|
+
if (startText?.parent.type === 'codeLine') {
|
|
59
|
+
prevent(() => {
|
|
60
|
+
const event = new InputEvent('', {
|
|
61
|
+
inputType: 'insertParagraph'
|
|
62
|
+
});
|
|
63
|
+
edytor.onBeforeInput(event);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
defaultBlock: (parent) => {
|
|
69
|
+
if (parent.type === 'code' || parent.type === 'codeLine') {
|
|
70
|
+
return 'codeLine';
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
onBeforeOperation: ({ operation, payload, block }) => {
|
|
74
|
+
if (block.closestNextBlock?.type === 'code' && operation === 'mergeBlockForward') {
|
|
75
|
+
if (block.isEmpty) {
|
|
76
|
+
prevent(() => {
|
|
77
|
+
block.mergeBlockBackward();
|
|
78
|
+
});
|
|
79
|
+
} else {
|
|
80
|
+
prevent();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (block.type === 'codeLine') {
|
|
84
|
+
const selection = edytor.selection.state;
|
|
85
|
+
const isCollapsed = selection.isCollapsed;
|
|
86
|
+
if (operation === 'insertText') {
|
|
87
|
+
if (isCollapsed) {
|
|
88
|
+
if (payload.value === '{') {
|
|
89
|
+
payload.value = '{}';
|
|
90
|
+
}
|
|
91
|
+
if (payload.value === '[') {
|
|
92
|
+
payload.value = '[]';
|
|
93
|
+
}
|
|
94
|
+
if (payload.value === '(') {
|
|
95
|
+
payload.value = '()';
|
|
96
|
+
}
|
|
97
|
+
if (payload.value === '"') {
|
|
98
|
+
payload.value = '""';
|
|
99
|
+
}
|
|
100
|
+
if (payload.value === "'") {
|
|
101
|
+
payload.value = "''";
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (operation === 'mergeBlockBackward' && block.parent.children.length === 1) {
|
|
107
|
+
prevent();
|
|
108
|
+
}
|
|
109
|
+
if (
|
|
110
|
+
operation === 'mergeBlockForward' &&
|
|
111
|
+
block.index === block.parent.children.length - 1
|
|
112
|
+
) {
|
|
113
|
+
prevent();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
blocks: {
|
|
119
|
+
code: {
|
|
120
|
+
snippet: code,
|
|
121
|
+
island: true
|
|
122
|
+
},
|
|
123
|
+
codeLine: {
|
|
124
|
+
snippet: codeLine,
|
|
125
|
+
transformText: ({ text }) => {
|
|
126
|
+
const tokens = Prism.tokenize(text.stringContent, Prism.languages['jsx']);
|
|
127
|
+
return tokens.map((token) => {
|
|
128
|
+
if (typeof token === 'string') {
|
|
129
|
+
return {
|
|
130
|
+
text: token
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
marks: { codeToken: token.type },
|
|
135
|
+
text: token.content
|
|
136
|
+
};
|
|
137
|
+
}) as JSONText[];
|
|
138
|
+
},
|
|
139
|
+
normalizeContent: ({ block }) => {
|
|
140
|
+
// here we need to check if the code line has soft line breaks and if so, we need to insert a new code line after the current one.
|
|
141
|
+
const firstContent = block.content[0];
|
|
142
|
+
if (!(firstContent instanceof Text)) return;
|
|
143
|
+
|
|
144
|
+
const yText = firstContent.yText;
|
|
145
|
+
if (!(yText instanceof Y.Text)) return;
|
|
146
|
+
|
|
147
|
+
const content = yText.toString();
|
|
148
|
+
const lines = content.split('\n');
|
|
149
|
+
|
|
150
|
+
if (lines.length > 1) {
|
|
151
|
+
// Remove the current content
|
|
152
|
+
yText.delete(0, content.length);
|
|
153
|
+
// Insert the first line back
|
|
154
|
+
yText.insert(0, lines[0]);
|
|
155
|
+
// Create new code lines for each remaining line
|
|
156
|
+
for (let i = 1; i < lines.length; i++) {
|
|
157
|
+
const newBlock = new Block({
|
|
158
|
+
block: {
|
|
159
|
+
type: 'codeLine',
|
|
160
|
+
content: [{ text: lines[i] }]
|
|
161
|
+
},
|
|
162
|
+
parent: block.parent
|
|
163
|
+
});
|
|
164
|
+
block.parent.yChildren.insert(block.index + i, [newBlock.yBlock]);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
marks: {
|
|
171
|
+
codeToken
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
</script>
|
|
176
|
+
|
|
177
|
+
{#snippet code({ block, children }: BlockSnippetPayload)}
|
|
178
|
+
<div use:block.attach class="card rounded grid gap-2 bg-neutral-600 p-1">
|
|
179
|
+
<div use:block.void class="text-xs flex justify-between">
|
|
180
|
+
<code>html</code>
|
|
181
|
+
<div>
|
|
182
|
+
<button
|
|
183
|
+
onclick={(e) => {
|
|
184
|
+
e.preventDefault();
|
|
185
|
+
e.stopPropagation();
|
|
186
|
+
// navigator.clipboard.writeText(block.content.stringContent);
|
|
187
|
+
}}
|
|
188
|
+
>
|
|
189
|
+
Copy
|
|
190
|
+
</button>
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
<pre use:block.attach class="language-jsx"><code class="language-jsx"
|
|
194
|
+
>{@render children?.()}</code
|
|
195
|
+
></pre>
|
|
196
|
+
</div>
|
|
197
|
+
{/snippet}
|
|
198
|
+
|
|
199
|
+
{#snippet codeLine({ content, block }: BlockSnippetPayload)}
|
|
200
|
+
<div
|
|
201
|
+
onclick={() => {
|
|
202
|
+
if (block.suggestions) {
|
|
203
|
+
block.suggestions = null;
|
|
204
|
+
} else {
|
|
205
|
+
block.suggestText({ value: "const a = 'hello' \n const b = 'world'" });
|
|
206
|
+
}
|
|
207
|
+
}}
|
|
208
|
+
class="hover:bg-neutral-700"
|
|
209
|
+
style:tab-size="7px"
|
|
210
|
+
use:block.attach
|
|
211
|
+
>
|
|
212
|
+
{@render content()}
|
|
213
|
+
</div>
|
|
214
|
+
{/snippet}
|
|
215
|
+
|
|
216
|
+
{#snippet codeToken({ content, mark }: MarkSnippetPayload)}
|
|
217
|
+
<span class="token {mark}">{@render content()}</span>
|
|
218
|
+
{/snippet}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import './prism.css';
|
|
2
|
+
import 'prismjs/components/prism-jsx';
|
|
3
|
+
import 'prismjs/components/prism-css';
|
|
4
|
+
import type { Plugin } from '../../plugins.js';
|
|
5
|
+
export declare const codePlugin: Plugin;
|
|
6
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
7
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
8
|
+
$$bindings?: Bindings;
|
|
9
|
+
} & Exports;
|
|
10
|
+
(internal: unknown, props: {
|
|
11
|
+
$$events?: Events;
|
|
12
|
+
$$slots?: Slots;
|
|
13
|
+
}): Exports & {
|
|
14
|
+
$set?: any;
|
|
15
|
+
$on?: any;
|
|
16
|
+
};
|
|
17
|
+
z_$$bindings?: Bindings;
|
|
18
|
+
}
|
|
19
|
+
declare const CodePlugin: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
20
|
+
[evt: string]: CustomEvent<any>;
|
|
21
|
+
}, {}, {}, string>;
|
|
22
|
+
type CodePlugin = InstanceType<typeof CodePlugin>;
|
|
23
|
+
export default CodePlugin;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* atom-dark theme for `prism.js`
|
|
3
|
+
* Based on Atom's `atom-dark` theme: https://github.com/atom/atom-dark-syntax
|
|
4
|
+
* @author Joe Gibson (@gibsjose)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
code[class*='language-'],
|
|
8
|
+
pre[class*='language-'] {
|
|
9
|
+
color: #c5c8c6;
|
|
10
|
+
text-shadow: 0 1px rgba(0, 0, 0, 0.3);
|
|
11
|
+
font-family: Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;
|
|
12
|
+
direction: ltr;
|
|
13
|
+
text-align: left;
|
|
14
|
+
white-space: pre;
|
|
15
|
+
word-spacing: normal;
|
|
16
|
+
word-break: normal;
|
|
17
|
+
line-height: 1.5;
|
|
18
|
+
|
|
19
|
+
-moz-tab-size: 4;
|
|
20
|
+
-o-tab-size: 4;
|
|
21
|
+
tab-size: 4;
|
|
22
|
+
|
|
23
|
+
-webkit-hyphens: none;
|
|
24
|
+
-moz-hyphens: none;
|
|
25
|
+
-ms-hyphens: none;
|
|
26
|
+
hyphens: none;
|
|
27
|
+
font-size: 12px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* Code blocks */
|
|
31
|
+
pre[class*='language-'] {
|
|
32
|
+
overflow: auto;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
:not(pre) > code[class*='language-'],
|
|
36
|
+
pre[class*='language-'] {
|
|
37
|
+
/* background: #1d1f21; */
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* Inline code */
|
|
41
|
+
:not(pre) > code[class*='language-'] {
|
|
42
|
+
padding: 0.1em;
|
|
43
|
+
border-radius: 0.3em;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.token.comment,
|
|
47
|
+
.token.prolog,
|
|
48
|
+
.token.doctype,
|
|
49
|
+
.token.cdata {
|
|
50
|
+
color: #7c7c7c;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.token.punctuation {
|
|
54
|
+
color: #c5c8c6;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.namespace {
|
|
58
|
+
opacity: 0.7;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.token.property,
|
|
62
|
+
.token.keyword,
|
|
63
|
+
.token.tag {
|
|
64
|
+
color: #96cbfe;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.token.class-name {
|
|
68
|
+
color: #ffffb6;
|
|
69
|
+
text-decoration: underline;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.token.boolean,
|
|
73
|
+
.token.constant {
|
|
74
|
+
color: #99cc99;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.token.symbol,
|
|
78
|
+
.token.deleted {
|
|
79
|
+
color: #f92672;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.token.number {
|
|
83
|
+
color: #ff73fd;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.token.selector,
|
|
87
|
+
.token.attr-name,
|
|
88
|
+
.token.string,
|
|
89
|
+
.token.char,
|
|
90
|
+
.token.builtin,
|
|
91
|
+
.token.inserted {
|
|
92
|
+
color: #a8ff60;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.token.variable {
|
|
96
|
+
color: #c6c5fe;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.token.operator {
|
|
100
|
+
color: #ededed;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.token.entity {
|
|
104
|
+
color: #ffffb6;
|
|
105
|
+
cursor: help;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.token.url {
|
|
109
|
+
color: #96cbfe;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.language-css .token.string,
|
|
113
|
+
.style .token.string {
|
|
114
|
+
color: #87c38a;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.token.atrule,
|
|
118
|
+
.token.attr-value {
|
|
119
|
+
color: #f9ee98;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.token.function {
|
|
123
|
+
color: #dad085;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.token.regex {
|
|
127
|
+
color: #e9c062;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.token.important {
|
|
131
|
+
color: #fd971f;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.token.important,
|
|
135
|
+
.token.bold {
|
|
136
|
+
font-weight: bold;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.token.italic {
|
|
140
|
+
font-style: italic;
|
|
141
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { Plugin, BlockSnippetPayload } from '../../plugins.js';
|
|
3
|
+
export const imagePlugin: Plugin = (edytor) => {
|
|
4
|
+
return {
|
|
5
|
+
blocks: {
|
|
6
|
+
image: {
|
|
7
|
+
void: true,
|
|
8
|
+
snippet: image
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
{#snippet image({ block, content }: BlockSnippetPayload)}
|
|
16
|
+
<figure class="flex flex-col gap-1" use:block.attach>
|
|
17
|
+
<img src={'https://placehold.co/600x400'} />
|
|
18
|
+
<figcaption class="text-sm block">
|
|
19
|
+
{@render content()}
|
|
20
|
+
</figcaption>
|
|
21
|
+
</figure>
|
|
22
|
+
{/snippet}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Plugin } from '../../plugins.js';
|
|
2
|
+
export declare const imagePlugin: Plugin;
|
|
3
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
4
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
5
|
+
$$bindings?: Bindings;
|
|
6
|
+
} & Exports;
|
|
7
|
+
(internal: unknown, props: {
|
|
8
|
+
$$events?: Events;
|
|
9
|
+
$$slots?: Slots;
|
|
10
|
+
}): Exports & {
|
|
11
|
+
$set?: any;
|
|
12
|
+
$on?: any;
|
|
13
|
+
};
|
|
14
|
+
z_$$bindings?: Bindings;
|
|
15
|
+
}
|
|
16
|
+
declare const ImagePlugin: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
}, {}, {}, string>;
|
|
19
|
+
type ImagePlugin = InstanceType<typeof ImagePlugin>;
|
|
20
|
+
export default ImagePlugin;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { type Plugin, type InlineBlockSnippetPayload } from '../../plugins.js';
|
|
3
|
+
export const mentionPlugin: Plugin = (edytor) => {
|
|
4
|
+
return {
|
|
5
|
+
onBeforeOperation: ({ operation, payload, block, prevent }) => {
|
|
6
|
+
if (operation === 'insertText' && payload.value === '@') {
|
|
7
|
+
const { yStart, startText } = edytor.selection.state;
|
|
8
|
+
if (!startText) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
prevent(() => {
|
|
13
|
+
const newText = block.addInlineBlock({
|
|
14
|
+
index: yStart,
|
|
15
|
+
text: startText,
|
|
16
|
+
block: {
|
|
17
|
+
type: 'mention',
|
|
18
|
+
data: {}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
edytor.selection.setAtTextOffset(newText.id, 0);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
inlineBlocks: {
|
|
27
|
+
mention: {
|
|
28
|
+
snippet: mention
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<script>
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
{#snippet mention({ block }: InlineBlockSnippetPayload)}
|
|
39
|
+
<kbd data-edytor-mention use:block.attach>@mention</kbd>
|
|
40
|
+
{/snippet}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Plugin } from '../../plugins.js';
|
|
2
|
+
export declare const mentionPlugin: Plugin;
|
|
3
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
4
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
5
|
+
$$bindings?: Bindings;
|
|
6
|
+
} & Exports;
|
|
7
|
+
(internal: unknown, props: {
|
|
8
|
+
$$events?: Events;
|
|
9
|
+
$$slots?: Slots;
|
|
10
|
+
}): Exports & {
|
|
11
|
+
$set?: any;
|
|
12
|
+
$on?: any;
|
|
13
|
+
};
|
|
14
|
+
z_$$bindings?: Bindings;
|
|
15
|
+
}
|
|
16
|
+
declare const MentionPlugin: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
}, {}, {}, string>;
|
|
19
|
+
type MentionPlugin = InstanceType<typeof MentionPlugin>;
|
|
20
|
+
export default MentionPlugin;
|