@flexiui/svelte-rich-text 0.0.60 → 0.0.62
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 +402 -185
- package/dist/RichText.svelte +389 -2084
- package/dist/RichText.svelte.d.ts +10 -55
- package/dist/Toolbar/RenderToolbarButton.svelte +147 -0
- package/dist/Toolbar/RenderToolbarButton.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/ClearFormatting.svelte +31 -0
- package/dist/Toolbar/action-buttons/ClearFormatting.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/ClearNodes.svelte +15 -0
- package/dist/Toolbar/action-buttons/ClearNodes.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/MergeCellsBtn.svelte +31 -0
- package/dist/Toolbar/action-buttons/MergeCellsBtn.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/Redo.svelte +26 -0
- package/dist/Toolbar/action-buttons/Redo.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/SplitCellBtn.svelte +31 -0
- package/dist/Toolbar/action-buttons/SplitCellBtn.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/Undo.svelte +30 -0
- package/dist/Toolbar/action-buttons/Undo.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/marks/Bold.svelte +29 -0
- package/dist/Toolbar/action-buttons/marks/Bold.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/marks/CodeMarkBtn.svelte +33 -0
- package/dist/Toolbar/action-buttons/marks/CodeMarkBtn.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/marks/FontSize.svelte +99 -0
- package/dist/Toolbar/action-buttons/marks/FontSize.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/marks/Italic.svelte +27 -0
- package/dist/Toolbar/action-buttons/marks/Italic.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/marks/LinkBtn.svelte +64 -0
- package/dist/Toolbar/action-buttons/marks/LinkBtn.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/marks/SpecialBox.svelte +21 -0
- package/dist/Toolbar/action-buttons/marks/SpecialBox.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/marks/Strike.svelte +30 -0
- package/dist/Toolbar/action-buttons/marks/Strike.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/marks/TextAlign.svelte +66 -0
- package/dist/Toolbar/action-buttons/marks/TextAlign.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/marks/Underline.svelte +29 -0
- package/dist/Toolbar/action-buttons/marks/Underline.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/nodes/Audio.svelte +60 -0
- package/dist/Toolbar/action-buttons/nodes/Audio.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/nodes/Blockquote.svelte +25 -0
- package/dist/Toolbar/action-buttons/nodes/Blockquote.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/nodes/CodeBlock.svelte +37 -0
- package/dist/Toolbar/action-buttons/nodes/CodeBlock.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/nodes/HardBreakBtn.svelte +26 -0
- package/dist/Toolbar/action-buttons/nodes/HardBreakBtn.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/nodes/HeadingBtn.svelte +78 -0
- package/dist/Toolbar/action-buttons/nodes/HeadingBtn.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/nodes/HorizontalRule.svelte +24 -0
- package/dist/Toolbar/action-buttons/nodes/HorizontalRule.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/nodes/Image.svelte +60 -0
- package/dist/Toolbar/action-buttons/nodes/Image.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/nodes/InlineMath.svelte +50 -0
- package/dist/Toolbar/action-buttons/nodes/InlineMath.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/nodes/ListBtn.svelte +43 -0
- package/dist/Toolbar/action-buttons/nodes/ListBtn.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/nodes/MediaGridBtn.svelte +58 -0
- package/dist/Toolbar/action-buttons/nodes/MediaGridBtn.svelte.d.ts +14 -0
- package/dist/Toolbar/action-buttons/nodes/Table.svelte +60 -0
- package/dist/Toolbar/action-buttons/nodes/Table.svelte.d.ts +14 -0
- package/dist/Toolbar/bubble-menus/BubbleMenuImage.svelte +139 -0
- package/dist/Toolbar/bubble-menus/BubbleMenuImage.svelte.d.ts +14 -0
- package/dist/Toolbar/dropdown-buttons/HeadingsDropdownBtn.svelte +64 -0
- package/dist/Toolbar/dropdown-buttons/HeadingsDropdownBtn.svelte.d.ts +14 -0
- package/dist/Toolbar/dropdown-buttons/HighlightDropdownBtn.svelte +45 -0
- package/dist/Toolbar/dropdown-buttons/HighlightDropdownBtn.svelte.d.ts +14 -0
- package/dist/Toolbar/dropdown-buttons/LineHeightDropdownBtn.svelte +18 -0
- package/dist/Toolbar/dropdown-buttons/LineHeightDropdownBtn.svelte.d.ts +14 -0
- package/dist/Toolbar/dropdown-buttons/ListsDropdownBtn.svelte +188 -0
- package/dist/Toolbar/dropdown-buttons/ListsDropdownBtn.svelte.d.ts +14 -0
- package/dist/Toolbar/dropdown-buttons/TextColorDropdownBtn.svelte +37 -0
- package/dist/Toolbar/dropdown-buttons/TextColorDropdownBtn.svelte.d.ts +14 -0
- package/dist/Toolbar/dropdowns/LineHeightDropdown.svelte +26 -0
- package/dist/Toolbar/dropdowns/LineHeightDropdown.svelte.d.ts +14 -0
- package/dist/Toolbar/toolbar-utils.d.ts +1 -0
- package/dist/Toolbar/toolbar-utils.js +15 -0
- package/dist/extensions/NodeFontSize.d.ts +10 -0
- package/dist/extensions/NodeFontSize.js +53 -0
- package/dist/extensions/SemanticHeadings.d.ts +10 -0
- package/dist/extensions/SemanticHeadings.js +124 -0
- package/dist/extensions/Table/TableCellNodeView.svelte +0 -4
- package/dist/getExtensions.d.ts +7 -0
- package/dist/getExtensions.js +13 -2
- package/dist/styles.css +58 -11
- package/dist/svelte-tiptap-extends/Editor.d.ts +4 -0
- package/dist/svelte-tiptap-extends/Editor.js +4 -0
- package/dist/svelte-tiptap-extends/EditorContent.svelte +62 -0
- package/dist/svelte-tiptap-extends/EditorContent.svelte.d.ts +15 -0
- package/dist/svelte-tiptap-extends/types.d.ts +10 -0
- package/dist/svelte-tiptap-extends/types.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
import { Plugin, PluginKey } from '@tiptap/pm/state';
|
|
3
|
+
export const SemanticHeadings = Extension.create({
|
|
4
|
+
name: 'semanticHeadings',
|
|
5
|
+
addProseMirrorPlugins() {
|
|
6
|
+
return [
|
|
7
|
+
new Plugin({
|
|
8
|
+
key: new PluginKey('semanticHeadings'),
|
|
9
|
+
appendTransaction(transactions, oldState, newState) {
|
|
10
|
+
// Solo validar si hubo cambios en el documento
|
|
11
|
+
if (!transactions.some(tr => tr.docChanged)) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const doc = newState.doc;
|
|
15
|
+
let headings = [];
|
|
16
|
+
let h1Count = 0;
|
|
17
|
+
// Recolectar todos los headings en orden
|
|
18
|
+
doc.descendants((node, pos) => {
|
|
19
|
+
if (node.type.name === 'heading') {
|
|
20
|
+
headings.push({
|
|
21
|
+
level: node.attrs.level,
|
|
22
|
+
pos: pos
|
|
23
|
+
});
|
|
24
|
+
if (node.attrs.level === 1) {
|
|
25
|
+
h1Count++;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
// Solo puede haber un h1
|
|
30
|
+
if (h1Count > 1) {
|
|
31
|
+
return oldState.tr; // Revertir
|
|
32
|
+
}
|
|
33
|
+
// Si no hay headings, todo está bien
|
|
34
|
+
if (headings.length === 0) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
// Validar la jerarquía
|
|
38
|
+
for (let i = 0; i < headings.length; i++) {
|
|
39
|
+
const { level } = headings[i];
|
|
40
|
+
// El primer heading debe ser h1
|
|
41
|
+
if (i === 0 && level !== 1) {
|
|
42
|
+
return oldState.tr; // Revertir
|
|
43
|
+
}
|
|
44
|
+
if (i > 0) {
|
|
45
|
+
const prevLevel = headings[i - 1].level;
|
|
46
|
+
// Solo puede:
|
|
47
|
+
// - Mantener el mismo nivel (excepto h1)
|
|
48
|
+
// - Retroceder a cualquier nivel superior (menor número, excepto h1 si ya existe)
|
|
49
|
+
// - Profundizar solo un nivel (prevLevel + 1)
|
|
50
|
+
const isValid = (level === prevLevel && level !== 1) || // Mismo nivel (pero no h1)
|
|
51
|
+
(level < prevLevel && !(level === 1 && h1Count > 0)) || // Retroceder (pero no a h1 si ya existe)
|
|
52
|
+
level === prevLevel + 1; // Profundizar un nivel
|
|
53
|
+
if (!isValid) {
|
|
54
|
+
return oldState.tr; // Revertir
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return null; // Todo correcto
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
];
|
|
62
|
+
},
|
|
63
|
+
addCommands() {
|
|
64
|
+
return {
|
|
65
|
+
canInsertHeading: (level) => ({ state }) => {
|
|
66
|
+
const doc = state.doc;
|
|
67
|
+
let lastHeadingLevel = null;
|
|
68
|
+
let hasH1 = false;
|
|
69
|
+
// Buscar el último heading y verificar si ya existe h1
|
|
70
|
+
doc.descendants((node) => {
|
|
71
|
+
if (node.type.name === 'heading') {
|
|
72
|
+
lastHeadingLevel = node.attrs.level;
|
|
73
|
+
if (node.attrs.level === 1) {
|
|
74
|
+
hasH1 = true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
// Si no hay headings, solo se permite h1
|
|
79
|
+
if (lastHeadingLevel === null) {
|
|
80
|
+
return level === 1;
|
|
81
|
+
}
|
|
82
|
+
// No permitir h1 si ya existe uno
|
|
83
|
+
if (level === 1 && hasH1) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
// Permitir:
|
|
87
|
+
// - Mismo nivel que el último (excepto h1)
|
|
88
|
+
// - Cualquier nivel superior (retroceder, excepto h1 si ya existe)
|
|
89
|
+
// - Un nivel más profundo
|
|
90
|
+
return ((level === lastHeadingLevel && level !== 1) || // Mismo nivel
|
|
91
|
+
(level < lastHeadingLevel && !(level === 1 && hasH1)) || // Retroceder
|
|
92
|
+
level === lastHeadingLevel + 1 // Profundizar uno
|
|
93
|
+
);
|
|
94
|
+
},
|
|
95
|
+
getAllowedHeadingLevels: () => ({ state }) => {
|
|
96
|
+
const doc = state.doc;
|
|
97
|
+
let lastHeadingLevel = null;
|
|
98
|
+
let hasH1 = false;
|
|
99
|
+
doc.descendants((node) => {
|
|
100
|
+
if (node.type.name === 'heading') {
|
|
101
|
+
lastHeadingLevel = node.attrs.level;
|
|
102
|
+
if (node.attrs.level === 1) {
|
|
103
|
+
hasH1 = true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
if (lastHeadingLevel === null) {
|
|
108
|
+
return [1]; // Solo h1 permitido
|
|
109
|
+
}
|
|
110
|
+
const allowed = [];
|
|
111
|
+
// Permitir todos los niveles desde h2 (o h1 si no existe) hasta el último
|
|
112
|
+
const startLevel = hasH1 ? 2 : 1;
|
|
113
|
+
for (let i = startLevel; i <= lastHeadingLevel; i++) {
|
|
114
|
+
allowed.push(i);
|
|
115
|
+
}
|
|
116
|
+
// Permitir también el siguiente nivel (si no es mayor que 6)
|
|
117
|
+
if (lastHeadingLevel < 6) {
|
|
118
|
+
allowed.push(lastHeadingLevel + 1);
|
|
119
|
+
}
|
|
120
|
+
return allowed;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
});
|
|
@@ -66,10 +66,6 @@ onMount(() => {
|
|
|
66
66
|
if (node?.type?.name !== "tableCell" && node?.type?.name !== "tableHeader")
|
|
67
67
|
return;
|
|
68
68
|
|
|
69
|
-
const nodeEl = editor.view.nodeDOM(getPos());
|
|
70
|
-
// console.log(nodeEl);
|
|
71
|
-
|
|
72
|
-
// console.log("update", transaction);
|
|
73
69
|
|
|
74
70
|
const attrs = node.attrs;
|
|
75
71
|
const { colspan, rowspan, colwidth } = attrs;
|
package/dist/getExtensions.d.ts
CHANGED
package/dist/getExtensions.js
CHANGED
|
@@ -9,15 +9,23 @@ import { Mathematics } from "@tiptap/extension-mathematics";
|
|
|
9
9
|
import { TableKit } from "@tiptap/extension-table";
|
|
10
10
|
import { Audio } from "./extensions/Audio";
|
|
11
11
|
import { NodeLineHeight } from "./extensions/NodeLineHeight";
|
|
12
|
+
import { NodeFontSize } from "./extensions/NodeFontSize";
|
|
12
13
|
import { MediaGridExtension } from "./extensions/MediaGrid/MediaGrid";
|
|
13
14
|
import { MediaGridItemExtension } from "./extensions/MediaGrid/MediaGridItem";
|
|
14
15
|
import { CustomTableCell } from "./extensions/Table/CustomTableCell";
|
|
15
16
|
import { CustomTableHeader } from "./extensions/Table/CustomTableHeader";
|
|
16
17
|
import { EnhancedLink } from "./extensions/EnhancedLink";
|
|
18
|
+
import { SemanticHeadings } from "./extensions/SemanticHeadings";
|
|
17
19
|
import { Heading } from "@tiptap/extension-heading";
|
|
18
20
|
const DocHeading = Heading.extend({
|
|
19
21
|
name: "h1",
|
|
20
|
-
|
|
22
|
+
addCommands() {
|
|
23
|
+
return {
|
|
24
|
+
toggleH1: () => ({ commands }) => {
|
|
25
|
+
return commands.toggleNode('h1', 'paragraph');
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
},
|
|
21
29
|
}).configure({ levels: [1] });
|
|
22
30
|
export function getRichTextExtensions(options) {
|
|
23
31
|
const { editable = false, customExtensions = [] } = options ?? {};
|
|
@@ -25,7 +33,9 @@ export function getRichTextExtensions(options) {
|
|
|
25
33
|
DocHeading,
|
|
26
34
|
Heading.configure({ levels: [2, 3, 4, 5, 6] }),
|
|
27
35
|
Highlight.configure({ multicolor: true }),
|
|
28
|
-
TextStyleKit
|
|
36
|
+
TextStyleKit.configure({
|
|
37
|
+
// fontSize: false
|
|
38
|
+
}),
|
|
29
39
|
StarterKit.configure({
|
|
30
40
|
trailingNode: false,
|
|
31
41
|
link: false,
|
|
@@ -52,6 +62,7 @@ export function getRichTextExtensions(options) {
|
|
|
52
62
|
],
|
|
53
63
|
}),
|
|
54
64
|
NodeLineHeight,
|
|
65
|
+
NodeFontSize,
|
|
55
66
|
MediaGridExtension,
|
|
56
67
|
MediaGridItemExtension,
|
|
57
68
|
TableKit.configure({
|
package/dist/styles.css
CHANGED
|
@@ -12,10 +12,16 @@
|
|
|
12
12
|
--fl-toolbar-sticky-position: 0;
|
|
13
13
|
--fl-toolbar-z-index: 10;
|
|
14
14
|
--fl-toolbar-padding: 6px;
|
|
15
|
+
--fl-toolbar-justify-content: center;
|
|
15
16
|
--fl-toolbar-gap: 5px;
|
|
16
17
|
--fl-toolbar-bg: #242424;
|
|
17
18
|
--fl-toolbar-text-color: currentColor;
|
|
18
19
|
|
|
20
|
+
--fl-toolbar-btn-padding: 0 9px;
|
|
21
|
+
--fl-toolbar-btn-radius: 9px;
|
|
22
|
+
--fl-toolbar-btn-min-height: 34px;
|
|
23
|
+
--fl-toolbar-btn-min-width: var(--fl-toolbar-btn-min-height);
|
|
24
|
+
|
|
19
25
|
--fl-doc-max-width: 1032px;
|
|
20
26
|
--fl-doc-padding: 2rem;
|
|
21
27
|
--fl-doc-bg: transparent;
|
|
@@ -39,6 +45,12 @@
|
|
|
39
45
|
width: 100%;
|
|
40
46
|
}
|
|
41
47
|
|
|
48
|
+
.fl-rich-text-content {
|
|
49
|
+
img {
|
|
50
|
+
max-width: 100%;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
42
54
|
.fl-rich-text-doc {
|
|
43
55
|
padding: var(--fl-doc-padding, 2rem);
|
|
44
56
|
background: var(--fl-doc-bg, transparent);
|
|
@@ -113,11 +125,11 @@
|
|
|
113
125
|
backdrop-filter: blur(16px);
|
|
114
126
|
border-radius: 14px;
|
|
115
127
|
display: flex;
|
|
116
|
-
gap:
|
|
128
|
+
gap: 5px;
|
|
117
129
|
position: relative;
|
|
118
130
|
z-index: 9;
|
|
119
131
|
|
|
120
|
-
button {
|
|
132
|
+
.fl-bubble-menu-mark-button {
|
|
121
133
|
border-radius: 9px;
|
|
122
134
|
border: none;
|
|
123
135
|
display: flex;
|
|
@@ -175,7 +187,7 @@
|
|
|
175
187
|
flex-wrap: nowrap;
|
|
176
188
|
overflow: auto;
|
|
177
189
|
align-items: center;
|
|
178
|
-
justify-content:
|
|
190
|
+
justify-content: var(--fl-toolbar-justify-content);
|
|
179
191
|
gap: var(--fl-toolbar-gap);
|
|
180
192
|
padding: var(--fl-toolbar-padding);
|
|
181
193
|
position: sticky;
|
|
@@ -184,6 +196,7 @@
|
|
|
184
196
|
background: var(--fl-toolbar-bg, #242424);
|
|
185
197
|
color: var(--fl-toolbar-text-color);
|
|
186
198
|
border-radius: var(--fl-editor-radius);
|
|
199
|
+
margin-bottom: calc(var(--fl-toolbar-padding) * -1);
|
|
187
200
|
}
|
|
188
201
|
|
|
189
202
|
.fl-rich-text-toolbar-container {
|
|
@@ -198,11 +211,11 @@
|
|
|
198
211
|
gap: var(--fl-toolbar-gap);
|
|
199
212
|
|
|
200
213
|
button {
|
|
201
|
-
padding:
|
|
214
|
+
padding: var(--fl-toolbar-btn-padding, 0 9px);
|
|
202
215
|
flex: auto;
|
|
203
216
|
border: none;
|
|
204
217
|
background: rgba(255, 255, 255, 0.1);
|
|
205
|
-
border-radius:
|
|
218
|
+
border-radius: var(--fl-toolbar-btn-radius, 9px);
|
|
206
219
|
color: currentColor;
|
|
207
220
|
font-size: 14px;
|
|
208
221
|
display: flex;
|
|
@@ -212,7 +225,8 @@
|
|
|
212
225
|
gap: 2px;
|
|
213
226
|
cursor: pointer;
|
|
214
227
|
line-height: 1;
|
|
215
|
-
min-height:
|
|
228
|
+
min-height: var(--fl-toolbar-btn-min-height, 34px);
|
|
229
|
+
min-width: var(--fl-toolbar-btn-min-width, var(--fl-toolbar-btn-min-height, 34px));
|
|
216
230
|
|
|
217
231
|
&.fl-font-size-button {
|
|
218
232
|
font-size: 14px;
|
|
@@ -361,14 +375,23 @@ button {
|
|
|
361
375
|
}
|
|
362
376
|
}
|
|
363
377
|
|
|
378
|
+
.fl-bubble-menu {
|
|
379
|
+
.fl-font-size-editor {
|
|
380
|
+
min-width: 30px;
|
|
381
|
+
min-height: 30px;
|
|
382
|
+
padding-inline: 6px;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
364
386
|
.fl-font-size-editor {
|
|
365
387
|
display: flex;
|
|
366
388
|
align-items: center;
|
|
367
389
|
gap: 4px;
|
|
368
|
-
padding: 0 6px;
|
|
369
|
-
border-radius:
|
|
390
|
+
padding: var(--fl-toolbar-btn-padding, 0 6px);
|
|
391
|
+
border-radius: var(--fl-toolbar-btn-radius, 9px);
|
|
370
392
|
background: rgba(255, 255, 255, 0.1);
|
|
371
|
-
min-height:
|
|
393
|
+
min-height: var(--fl-toolbar-btn-min-height, 34px);
|
|
394
|
+
min-width: var(--fl-toolbar-btn-min-width, var(--fl-toolbar-btn-min-height, 34px));
|
|
372
395
|
|
|
373
396
|
& button {
|
|
374
397
|
border: none;
|
|
@@ -517,15 +540,39 @@ button {
|
|
|
517
540
|
}
|
|
518
541
|
}
|
|
519
542
|
|
|
520
|
-
.fl-
|
|
543
|
+
.fl-counters-bar {
|
|
521
544
|
background: var(--fl-toolbar-bg, #242424);
|
|
522
545
|
border-top: 1px solid #333;
|
|
523
|
-
padding:
|
|
546
|
+
padding: 9px 12px;
|
|
524
547
|
display: flex;
|
|
525
548
|
align-items: center;
|
|
526
549
|
gap: 12px;
|
|
527
550
|
font-size: 12px;
|
|
528
551
|
color: var(--fl-toolbar-text-color, currentColor);
|
|
552
|
+
border-bottom-left-radius: inherit;
|
|
553
|
+
border-bottom-right-radius: inherit;
|
|
554
|
+
|
|
555
|
+
span {
|
|
556
|
+
color: #ffffffab;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
.fl-character-count {
|
|
561
|
+
display: flex;
|
|
562
|
+
align-items: center;
|
|
563
|
+
gap: 9px;
|
|
564
|
+
|
|
565
|
+
svg {
|
|
566
|
+
color: var(--fl-editor-accent-color);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
&.fl-character-count--warning {
|
|
570
|
+
color: #ff5c33;
|
|
571
|
+
|
|
572
|
+
svg, span {
|
|
573
|
+
color: currentColor;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
529
576
|
}
|
|
530
577
|
|
|
531
578
|
.fl-node-count-text {
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<script lang="ts" generics="T extends keyof SvelteHTMLElements = 'div'">
|
|
2
|
+
import { onDestroy, onMount, tick } from 'svelte';
|
|
3
|
+
import type { SvelteHTMLElements } from 'svelte/elements';
|
|
4
|
+
import type { ComponentInputProps } from './types';
|
|
5
|
+
|
|
6
|
+
type Props = ComponentInputProps<{}> & SvelteHTMLElements[T] & {
|
|
7
|
+
as?: T;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const { editor, children, class: className, as = 'div' as T, ...rest }: Props = $props();
|
|
11
|
+
let element: HTMLElement;
|
|
12
|
+
|
|
13
|
+
const init = async () => {
|
|
14
|
+
await tick();
|
|
15
|
+
if (!element) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!editor?.options.element) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (editor.contentElement) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const editorElement = editor.options.element;
|
|
28
|
+
|
|
29
|
+
if (editorElement instanceof HTMLElement) {
|
|
30
|
+
element.append(...Array.from(editorElement.childNodes));
|
|
31
|
+
editor.setOptions({ element });
|
|
32
|
+
editor.contentElement = element;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
onMount(init);
|
|
37
|
+
|
|
38
|
+
onDestroy(() => {
|
|
39
|
+
if (!editor) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
editor.contentElement = null;
|
|
44
|
+
|
|
45
|
+
const editorElement = editor.options.element;
|
|
46
|
+
|
|
47
|
+
if (editorElement instanceof HTMLElement && editorElement.firstChild) {
|
|
48
|
+
const newElement = document.createElement('div');
|
|
49
|
+
newElement.append(...Array.from(editorElement.childNodes));
|
|
50
|
+
|
|
51
|
+
editor.setOptions({
|
|
52
|
+
element: newElement,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<svelte:element this={as} bind:this={element} class={className} {...rest}>
|
|
59
|
+
{#if children}
|
|
60
|
+
{@render children()}
|
|
61
|
+
{/if}
|
|
62
|
+
</svelte:element>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { SvelteHTMLElements } from 'svelte/elements';
|
|
3
|
+
declare class __sveltets_Render<T extends keyof SvelteHTMLElements = 'div'> {
|
|
4
|
+
props(): Record<string, never>;
|
|
5
|
+
events(): {} & {
|
|
6
|
+
[evt: string]: CustomEvent<any>;
|
|
7
|
+
};
|
|
8
|
+
slots(): {};
|
|
9
|
+
}
|
|
10
|
+
export type EditorContentProps<T extends keyof SvelteHTMLElements = 'div'> = ReturnType<__sveltets_Render<T>['props']>;
|
|
11
|
+
export type EditorContentEvents<T extends keyof SvelteHTMLElements = 'div'> = ReturnType<__sveltets_Render<T>['events']>;
|
|
12
|
+
export type EditorContentSlots<T extends keyof SvelteHTMLElements = 'div'> = ReturnType<__sveltets_Render<T>['slots']>;
|
|
13
|
+
export default class EditorContent<T extends keyof SvelteHTMLElements = 'div'> extends SvelteComponentTyped<EditorContentProps<T>, EditorContentEvents<T>, EditorContentSlots<T>> {
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { Editor } from './Editor';
|
|
3
|
+
export interface TiptapNodeViewContext {
|
|
4
|
+
onDragStart: (event: DragEvent) => void;
|
|
5
|
+
}
|
|
6
|
+
export type ComponentInputProps<T> = Partial<T> & {
|
|
7
|
+
editor: Editor;
|
|
8
|
+
class?: string;
|
|
9
|
+
children?: Snippet;
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|