@flexiui/svelte-rich-text 0.0.33 → 0.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/RichText.svelte
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { TableKit } from "@tiptap/extension-table";
|
|
5
5
|
import { CellSelection } from "prosemirror-tables";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import { NodeLineHeight } from "./extensions/NodeLineHeight";
|
|
8
8
|
import { MediaGridExtension } from "./extensions/MediaGrid/MediaGrid";
|
|
9
9
|
import { MediaGridItemExtension } from "./extensions/MediaGrid/MediaGridItem";
|
|
10
10
|
import {
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
docMarginInline?: string;
|
|
65
65
|
docMarginBlock?: string;
|
|
66
66
|
docRadius?: string;
|
|
67
|
-
}
|
|
67
|
+
};
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
let {
|
|
@@ -92,24 +92,24 @@
|
|
|
92
92
|
|
|
93
93
|
let editor = $state() as Readable<Editor>;
|
|
94
94
|
const defaultEditorConfig = {
|
|
95
|
-
editorBgColor:
|
|
96
|
-
editorRadius:
|
|
95
|
+
editorBgColor: "transparent",
|
|
96
|
+
editorRadius: "12px",
|
|
97
97
|
toolbarStickyPosition: 0,
|
|
98
|
-
toolbarBgColor:
|
|
98
|
+
toolbarBgColor: "#242424",
|
|
99
99
|
toolbarZIndex: 10,
|
|
100
|
-
toolbarPadding:
|
|
101
|
-
toolbarGap:
|
|
102
|
-
docMaxWidth:
|
|
103
|
-
docPadding:
|
|
104
|
-
docBg:
|
|
105
|
-
docMarginInline:
|
|
106
|
-
docMarginBlock:
|
|
107
|
-
docRadius:
|
|
100
|
+
toolbarPadding: "8px",
|
|
101
|
+
toolbarGap: "5px",
|
|
102
|
+
docMaxWidth: "1024px",
|
|
103
|
+
docPadding: "2rem",
|
|
104
|
+
docBg: "transparent",
|
|
105
|
+
docMarginInline: "auto",
|
|
106
|
+
docMarginBlock: "2rem",
|
|
107
|
+
docRadius: "0",
|
|
108
108
|
};
|
|
109
109
|
|
|
110
110
|
let editorConfig = $state({
|
|
111
111
|
...defaultEditorConfig,
|
|
112
|
-
...(config ?? {})
|
|
112
|
+
...(config ?? {}),
|
|
113
113
|
});
|
|
114
114
|
|
|
115
115
|
const extensions = [
|
|
@@ -283,58 +283,63 @@
|
|
|
283
283
|
content,
|
|
284
284
|
editorProps: {
|
|
285
285
|
attributes: {
|
|
286
|
-
class: "fl-rich-text-content-
|
|
286
|
+
class: "fl-rich-text-content-doc",
|
|
287
287
|
},
|
|
288
288
|
handleKeyDown: (view, event) => {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
289
|
+
if (event.key === "Enter" && !event.ctrlKey) {
|
|
290
|
+
enterPressed = true;
|
|
291
|
+
|
|
292
|
+
setTimeout(() => {
|
|
293
|
+
enterPressed = false;
|
|
294
|
+
const { from } = view.state.selection;
|
|
295
|
+
|
|
296
|
+
// Obtener el nodo de ProseMirror en la posición actual
|
|
297
|
+
const pos = view.state.doc.resolve(from);
|
|
298
|
+
const nodeBefore = pos.node(pos.depth);
|
|
299
|
+
const parentNode = pos.node(pos.depth - 1);
|
|
300
|
+
|
|
301
|
+
// console.log("Node type:", nodeBefore.type.name);
|
|
302
|
+
// console.log("Parent node type:", parentNode?.type.name);
|
|
303
|
+
|
|
304
|
+
// Solo ejecutar si estamos en un párrafo Y el padre no es una lista
|
|
305
|
+
const isInList =
|
|
306
|
+
parentNode?.type.name === "listItem" ||
|
|
307
|
+
parentNode?.type.name === "bulletList" ||
|
|
308
|
+
parentNode?.type.name === "orderedList";
|
|
309
|
+
|
|
310
|
+
if (nodeBefore.type.name === "paragraph" && !isInList) {
|
|
311
|
+
const domAtPos = view.domAtPos(from);
|
|
312
|
+
let element = domAtPos.node;
|
|
313
|
+
|
|
314
|
+
if (element.nodeType === Node.TEXT_NODE) {
|
|
315
|
+
element = element.parentElement;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (element instanceof HTMLElement) {
|
|
319
|
+
const computedSize =
|
|
320
|
+
window.getComputedStyle(element).fontSize;
|
|
321
|
+
const computedLineHeight =
|
|
322
|
+
window.getComputedStyle(element).lineHeight;
|
|
323
|
+
// console.log({ computedSize, computedLineHeight });
|
|
324
|
+
|
|
325
|
+
const lineHeightPx = parseFloat(
|
|
326
|
+
computedLineHeight.replace("px", "")
|
|
327
|
+
);
|
|
328
|
+
const fontSizePx = parseFloat(computedSize.replace("px", ""));
|
|
329
|
+
|
|
330
|
+
const lineHeightUnitless = lineHeightPx / fontSizePx;
|
|
331
|
+
|
|
332
|
+
// console.log(lineHeightUnitless.toFixed(2)); // ej: "x.xx"
|
|
333
|
+
|
|
334
|
+
fontSize = Math.round(Number(computedSize.replace("px", "")));
|
|
335
|
+
$editor.chain().focus().unsetFontSize().run();
|
|
336
|
+
|
|
337
|
+
$editor.chain().focus().unsetNodeLineHeight().run();
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}, 200);
|
|
341
|
+
}
|
|
342
|
+
},
|
|
338
343
|
},
|
|
339
344
|
onTransaction: ({ editor, transaction }) => {
|
|
340
345
|
editorEvents.onTransaction({ editor, transaction });
|
|
@@ -359,11 +364,12 @@
|
|
|
359
364
|
// Obtener el font-size computado
|
|
360
365
|
if (element instanceof HTMLElement) {
|
|
361
366
|
const computedSize = window.getComputedStyle(element).fontSize;
|
|
362
|
-
const computedLineHeight =
|
|
367
|
+
const computedLineHeight =
|
|
368
|
+
window.getComputedStyle(element).lineHeight;
|
|
363
369
|
// console.log("Get element font size:", computedSize);
|
|
364
370
|
// console.log("Get element line height:", computedLineHeight);
|
|
365
|
-
const lineHeightPx = parseFloat(computedLineHeight.replace("px", ""))
|
|
366
|
-
const fontSizePx = parseFloat(computedSize.replace("px", ""))
|
|
371
|
+
const lineHeightPx = parseFloat(computedLineHeight.replace("px", ""));
|
|
372
|
+
const fontSizePx = parseFloat(computedSize.replace("px", ""));
|
|
367
373
|
const lineHeightUnitless = lineHeightPx / fontSizePx;
|
|
368
374
|
|
|
369
375
|
// console.log(lineHeightUnitless.toFixed(2)); // ej: "x.xx"
|
|
@@ -385,8 +391,6 @@
|
|
|
385
391
|
} else {
|
|
386
392
|
lineHeight = Number(lineHeightUnitless.toFixed(2));
|
|
387
393
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
394
|
}
|
|
391
395
|
},
|
|
392
396
|
|
|
@@ -535,9 +539,7 @@
|
|
|
535
539
|
}
|
|
536
540
|
|
|
537
541
|
function handleRangeInput(e: any) {
|
|
538
|
-
|
|
539
|
-
$editor.commands.setNodeLineHeight(lineHeight.toString())
|
|
540
|
-
|
|
542
|
+
$editor.commands.setNodeLineHeight(lineHeight.toString());
|
|
541
543
|
}
|
|
542
544
|
|
|
543
545
|
function addAudio() {
|
|
@@ -547,38 +549,39 @@
|
|
|
547
549
|
alert("Please enter a valid URL");
|
|
548
550
|
return;
|
|
549
551
|
}
|
|
550
|
-
|
|
551
|
-
$editor.chain().focus().setAudio({ src, controls: true }).run()
|
|
552
|
-
|
|
552
|
+
|
|
553
|
+
$editor.chain().focus().setAudio({ src, controls: true }).run();
|
|
553
554
|
}
|
|
554
555
|
|
|
555
556
|
function addImage() {
|
|
556
|
-
const previousSrc = $editor.getAttributes("image").src;
|
|
557
|
+
const previousSrc = $editor.getAttributes("image").src;
|
|
557
558
|
const src = window.prompt("Enter the URL of the image:", previousSrc);
|
|
558
559
|
|
|
559
560
|
if (!src) {
|
|
560
561
|
alert("Please enter a valid URL");
|
|
561
562
|
return;
|
|
562
563
|
}
|
|
563
|
-
|
|
564
|
-
$editor.chain().focus().setImage({ src }).run()
|
|
565
|
-
|
|
564
|
+
|
|
565
|
+
$editor.chain().focus().setImage({ src }).run();
|
|
566
566
|
}
|
|
567
567
|
|
|
568
568
|
function addMediaGrid() {
|
|
569
|
-
|
|
570
|
-
$editor.chain().focus().insertGrid({ cols: 2 }).run()
|
|
571
|
-
|
|
569
|
+
$editor.chain().focus().insertGrid({ cols: 2 }).run();
|
|
572
570
|
}
|
|
573
571
|
|
|
574
|
-
function addTable(){
|
|
575
|
-
$editor
|
|
572
|
+
function addTable() {
|
|
573
|
+
$editor
|
|
574
|
+
.chain()
|
|
575
|
+
.focus()
|
|
576
|
+
.insertTable({ rows: 3, cols: 3, withHeaderRow: true })
|
|
577
|
+
.run();
|
|
576
578
|
}
|
|
577
579
|
</script>
|
|
578
580
|
|
|
579
|
-
<div
|
|
580
|
-
class="fl-rich-text {className}"
|
|
581
|
-
|
|
581
|
+
<div
|
|
582
|
+
class="fl-rich-text {className}"
|
|
583
|
+
class:editable
|
|
584
|
+
style="
|
|
582
585
|
--fl-editor-radius: {editorConfig.editorRadius};
|
|
583
586
|
--fl-editor-bg: {editorConfig.editorBgColor};
|
|
584
587
|
--fl-toolbar-sticky-position: {editorConfig.toolbarStickyPosition}px;
|
|
@@ -594,7 +597,6 @@ style="
|
|
|
594
597
|
--fl-doc-radius: {editorConfig.docRadius};
|
|
595
598
|
"
|
|
596
599
|
>
|
|
597
|
-
|
|
598
600
|
{#if editor}
|
|
599
601
|
<header class="fl-rich-text-toolbar">
|
|
600
602
|
<!-- Undo/Redo -->
|
|
@@ -924,35 +926,80 @@ style="
|
|
|
924
926
|
<!-- Font size editor -->
|
|
925
927
|
<div role="group" class="fl-rich-text-toolbar-group">
|
|
926
928
|
<div class="fl-font-size-editor">
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
929
|
+
<button
|
|
930
|
+
type="button"
|
|
931
|
+
aria-label="Decrease font size"
|
|
932
|
+
onclick={decrementFontSize}
|
|
933
|
+
class="fl-font-size-editor-button"
|
|
934
|
+
>
|
|
935
|
+
<svg
|
|
936
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
937
|
+
width="24"
|
|
938
|
+
height="24"
|
|
939
|
+
viewBox="0 0 24 24"
|
|
940
|
+
fill="none"
|
|
941
|
+
stroke="currentColor"
|
|
942
|
+
stroke-width="2"
|
|
943
|
+
stroke-linecap="round"
|
|
944
|
+
stroke-linejoin="round"
|
|
945
|
+
class="icon icon-tabler icons-tabler-outline icon-tabler-minus"
|
|
946
|
+
><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path
|
|
947
|
+
d="M5 12l14 0"
|
|
948
|
+
/></svg
|
|
934
949
|
>
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
950
|
+
</button>
|
|
951
|
+
<input type="text" bind:value={fontSize} />
|
|
952
|
+
<button
|
|
953
|
+
type="button"
|
|
954
|
+
aria-label="Increase font size"
|
|
955
|
+
onclick={incrementFontSize}
|
|
956
|
+
class="fl-font-size-editor-button"
|
|
957
|
+
>
|
|
958
|
+
<svg
|
|
959
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
960
|
+
width="24"
|
|
961
|
+
height="24"
|
|
962
|
+
viewBox="0 0 24 24"
|
|
963
|
+
fill="none"
|
|
964
|
+
stroke="currentColor"
|
|
965
|
+
stroke-width="2"
|
|
966
|
+
stroke-linecap="round"
|
|
967
|
+
stroke-linejoin="round"
|
|
968
|
+
class="icon icon-tabler icons-tabler-outline icon-tabler-plus"
|
|
969
|
+
><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path
|
|
970
|
+
d="M12 5l0 14"
|
|
971
|
+
/><path d="M5 12l14 0" /></svg
|
|
943
972
|
>
|
|
973
|
+
</button>
|
|
944
974
|
</div>
|
|
945
975
|
</div>
|
|
946
976
|
|
|
947
977
|
<!-- Line height -->
|
|
948
978
|
<div role="group" class="fl-rich-text-toolbar-group">
|
|
949
|
-
<button
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
979
|
+
<button
|
|
980
|
+
class="fl-font-size-button"
|
|
981
|
+
aria-label="Line height"
|
|
982
|
+
type="button"
|
|
983
|
+
onclick={(e) =>
|
|
984
|
+
toogleDropdown(e.currentTarget, "line-height-dropdown")}
|
|
954
985
|
>
|
|
955
|
-
<svg
|
|
986
|
+
<svg
|
|
987
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
988
|
+
width="16"
|
|
989
|
+
height="16"
|
|
990
|
+
viewBox="0 0 24 24"
|
|
991
|
+
fill="none"
|
|
992
|
+
stroke="currentColor"
|
|
993
|
+
stroke-width="2"
|
|
994
|
+
stroke-linecap="round"
|
|
995
|
+
stroke-linejoin="round"
|
|
996
|
+
class="icon icon-tabler icons-tabler-outline icon-tabler-line-height"
|
|
997
|
+
><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path
|
|
998
|
+
d="M3 8l3 -3l3 3"
|
|
999
|
+
/><path d="M3 16l3 3l3 -3" /><path d="M6 5l0 14" /><path
|
|
1000
|
+
d="M13 6l7 0"
|
|
1001
|
+
/><path d="M13 12l7 0" /><path d="M13 18l7 0" /></svg
|
|
1002
|
+
>
|
|
956
1003
|
|
|
957
1004
|
<svg
|
|
958
1005
|
class="toogle-dropdown-button-icon"
|
|
@@ -1277,7 +1324,17 @@ style="
|
|
|
1277
1324
|
aria-label="Image"
|
|
1278
1325
|
class:is-active={$editor.isActive("image")}
|
|
1279
1326
|
>
|
|
1280
|
-
<svg
|
|
1327
|
+
<svg
|
|
1328
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
1329
|
+
width="24"
|
|
1330
|
+
height="24"
|
|
1331
|
+
viewBox="0 0 24 24"
|
|
1332
|
+
fill="currentColor"
|
|
1333
|
+
class="icon icon-tabler icons-tabler-filled icon-tabler-photo"
|
|
1334
|
+
><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path
|
|
1335
|
+
d="M8.813 11.612c.457 -.38 .918 -.38 1.386 .011l.108 .098l4.986 4.986l.094 .083a1 1 0 0 0 1.403 -1.403l-.083 -.094l-1.292 -1.293l.292 -.293l.106 -.095c.457 -.38 .918 -.38 1.386 .011l.108 .098l4.674 4.675a4 4 0 0 1 -3.775 3.599l-.206 .005h-12a4 4 0 0 1 -3.98 -3.603l6.687 -6.69l.106 -.095zm9.187 -9.612a4 4 0 0 1 3.995 3.8l.005 .2v9.585l-3.293 -3.292l-.15 -.137c-1.256 -1.095 -2.85 -1.097 -4.096 -.017l-.154 .14l-.307 .306l-2.293 -2.292l-.15 -.137c-1.256 -1.095 -2.85 -1.097 -4.096 -.017l-.154 .14l-5.307 5.306v-9.585a4 4 0 0 1 3.8 -3.995l.2 -.005h12zm-2.99 5l-.127 .007a1 1 0 0 0 0 1.986l.117 .007l.127 -.007a1 1 0 0 0 0 -1.986l-.117 -.007z"
|
|
1336
|
+
/></svg
|
|
1337
|
+
>
|
|
1281
1338
|
</button>
|
|
1282
1339
|
<!-- Audio -->
|
|
1283
1340
|
<button
|
|
@@ -1286,7 +1343,7 @@ style="
|
|
|
1286
1343
|
aria-label="Audio"
|
|
1287
1344
|
class:is-active={$editor.isActive("audio")}
|
|
1288
1345
|
>
|
|
1289
|
-
|
|
1346
|
+
Audio
|
|
1290
1347
|
</button>
|
|
1291
1348
|
</div>
|
|
1292
1349
|
|
|
@@ -1299,7 +1356,23 @@ style="
|
|
|
1299
1356
|
aria-label="Media grid"
|
|
1300
1357
|
class:is-active={$editor.isActive("MediaGridComponent")}
|
|
1301
1358
|
>
|
|
1302
|
-
<svg
|
|
1359
|
+
<svg
|
|
1360
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
1361
|
+
width="24"
|
|
1362
|
+
height="24"
|
|
1363
|
+
viewBox="0 0 24 24"
|
|
1364
|
+
fill="currentColor"
|
|
1365
|
+
class="icon icon-tabler icons-tabler-filled icon-tabler-layout-grid"
|
|
1366
|
+
><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path
|
|
1367
|
+
d="M9 3a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-4a2 2 0 0 1 -2 -2v-4a2 2 0 0 1 2 -2z"
|
|
1368
|
+
/><path
|
|
1369
|
+
d="M19 3a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-4a2 2 0 0 1 -2 -2v-4a2 2 0 0 1 2 -2z"
|
|
1370
|
+
/><path
|
|
1371
|
+
d="M9 13a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-4a2 2 0 0 1 -2 -2v-4a2 2 0 0 1 2 -2z"
|
|
1372
|
+
/><path
|
|
1373
|
+
d="M19 13a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-4a2 2 0 0 1 -2 -2v-4a2 2 0 0 1 2 -2z"
|
|
1374
|
+
/></svg
|
|
1375
|
+
>
|
|
1303
1376
|
</button>
|
|
1304
1377
|
<!-- Table -->
|
|
1305
1378
|
<button
|
|
@@ -1308,7 +1381,21 @@ style="
|
|
|
1308
1381
|
aria-label="Table"
|
|
1309
1382
|
class:is-active={$editor.isActive("table")}
|
|
1310
1383
|
>
|
|
1311
|
-
<svg
|
|
1384
|
+
<svg
|
|
1385
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
1386
|
+
width="24"
|
|
1387
|
+
height="24"
|
|
1388
|
+
viewBox="0 0 24 24"
|
|
1389
|
+
fill="none"
|
|
1390
|
+
stroke="currentColor"
|
|
1391
|
+
stroke-width="2"
|
|
1392
|
+
stroke-linecap="round"
|
|
1393
|
+
stroke-linejoin="round"
|
|
1394
|
+
class="icon icon-tabler icons-tabler-outline icon-tabler-table"
|
|
1395
|
+
><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path
|
|
1396
|
+
d="M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14"
|
|
1397
|
+
/><path d="M3 10h18" /><path d="M10 3v18" /></svg
|
|
1398
|
+
>
|
|
1312
1399
|
</button>
|
|
1313
1400
|
</div>
|
|
1314
1401
|
|
|
@@ -1959,12 +2046,18 @@ style="
|
|
|
1959
2046
|
{/if}
|
|
1960
2047
|
</div>
|
|
1961
2048
|
{:else if activeDropdownType === "line-height-dropdown"}
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
2049
|
+
<div class="fl-range-element">
|
|
2050
|
+
<span class="fl-range-element-value">
|
|
2051
|
+
{lineHeight.toFixed(2)}
|
|
2052
|
+
</span>
|
|
2053
|
+
<input
|
|
2054
|
+
oninput={handleRangeInput}
|
|
2055
|
+
type="range"
|
|
2056
|
+
min="0.5"
|
|
2057
|
+
max="4"
|
|
2058
|
+
step="0.05"
|
|
2059
|
+
bind:value={lineHeight}
|
|
2060
|
+
/>
|
|
2061
|
+
</div>
|
|
1969
2062
|
{/if}
|
|
1970
2063
|
</div>
|
|
@@ -1,2 +1,19 @@
|
|
|
1
1
|
import { Node } from '@tiptap/core';
|
|
2
|
+
interface InsertGridOptions {
|
|
3
|
+
cols?: number;
|
|
4
|
+
}
|
|
5
|
+
declare module '@tiptap/core' {
|
|
6
|
+
interface Commands<ReturnType> {
|
|
7
|
+
MediaGridComponent: {
|
|
8
|
+
/**
|
|
9
|
+
* Añade un elemento de audio personalizado
|
|
10
|
+
* @example
|
|
11
|
+
* editor.commands.setAudio({ src: '/audio.mp3', controls: true })
|
|
12
|
+
*/
|
|
13
|
+
insertGrid: (options?: InsertGridOptions) => ReturnType;
|
|
14
|
+
addGridItem: () => ReturnType;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
2
18
|
export declare const MediaGridExtension: Node<any, any>;
|
|
19
|
+
export {};
|
|
@@ -19,43 +19,43 @@ export const MediaGridExtension = Node.create({
|
|
|
19
19
|
},
|
|
20
20
|
cols: {
|
|
21
21
|
default: 2,
|
|
22
|
-
parseHTML: element =>
|
|
22
|
+
parseHTML: element => {
|
|
23
|
+
return element.dataset.cols;
|
|
24
|
+
},
|
|
23
25
|
renderHTML: attrs => ({ 'data-cols': attrs.cols }),
|
|
24
26
|
},
|
|
25
27
|
gap: {
|
|
26
28
|
default: '1rem',
|
|
27
|
-
parseHTML: element => element.
|
|
29
|
+
parseHTML: element => element.dataset.gap,
|
|
28
30
|
renderHTML: attrs => ({ 'data-gap': attrs.gap }),
|
|
29
31
|
},
|
|
30
32
|
showIndicator: {
|
|
31
33
|
default: false,
|
|
32
|
-
parseHTML: element => element.
|
|
34
|
+
parseHTML: element => element.dataset.showIndicator,
|
|
33
35
|
renderHTML: attrs => ({ 'data-show-indicator': attrs.showIndicator }),
|
|
34
36
|
},
|
|
35
37
|
indicatorType: {
|
|
36
38
|
default: 'numeric', // 'numeric' | 'alphabetic'
|
|
37
|
-
parseHTML: element => element.
|
|
39
|
+
parseHTML: element => element.dataset.indicatorType,
|
|
38
40
|
renderHTML: attrs => ({ 'data-indicator-type': attrs.indicatorType }),
|
|
39
41
|
}
|
|
40
42
|
};
|
|
41
43
|
},
|
|
42
44
|
parseHTML() {
|
|
43
|
-
return [
|
|
45
|
+
return [
|
|
46
|
+
{
|
|
47
|
+
tag: 'media-grid-component',
|
|
48
|
+
}
|
|
49
|
+
];
|
|
44
50
|
},
|
|
45
51
|
renderHTML({ HTMLAttributes }) {
|
|
46
|
-
return ['
|
|
52
|
+
return ['media-grid-component', mergeAttributes(HTMLAttributes), 0];
|
|
47
53
|
},
|
|
48
54
|
addCommands() {
|
|
49
55
|
return {
|
|
50
56
|
insertGrid: (options) => ({ tr, state, dispatch }) => {
|
|
51
57
|
const { schema } = state;
|
|
52
58
|
const cols = options?.cols || 2;
|
|
53
|
-
// const items = Array.from({ length: cols }, () =>
|
|
54
|
-
// schema.nodes.gridItem.create(
|
|
55
|
-
// null,
|
|
56
|
-
// schema.nodes.image.create({ src: 'https://placehold.co/800x400' })
|
|
57
|
-
// )
|
|
58
|
-
// )
|
|
59
59
|
const items = Array.from({ length: cols }, () => schema.nodes.gridItem.create() // 👈 sin contenido
|
|
60
60
|
);
|
|
61
61
|
const grid = this.type.create({ cols }, items);
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
const { node, updateAttributes, selected, getPos, editor }: NodeViewProps = $props();
|
|
7
7
|
|
|
8
|
+
console.log(node);
|
|
8
9
|
let cols = $state(node.attrs.cols || 2);
|
|
9
10
|
let gap = $state(node.attrs.gap || 1);
|
|
10
11
|
let showIndicator = $state(node.attrs.showIndicator || false);
|
|
@@ -101,7 +102,7 @@
|
|
|
101
102
|
oninput={handleShowIndicatorChange}
|
|
102
103
|
type="checkbox"
|
|
103
104
|
id="show-indicator"
|
|
104
|
-
|
|
105
|
+
checked={showIndicator}
|
|
105
106
|
/>
|
|
106
107
|
Show indicators
|
|
107
108
|
</label>
|
package/dist/styles.css
CHANGED
|
@@ -264,14 +264,18 @@
|
|
|
264
264
|
flex-direction: column;
|
|
265
265
|
text-align: left;
|
|
266
266
|
min-height: 56px;
|
|
267
|
-
border-radius: var(--fl-doc-radius, 12px);
|
|
268
267
|
box-sizing: border-box;
|
|
269
|
-
|
|
268
|
+
width: 100%;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.fl-rich-text-content-doc {
|
|
270
272
|
padding: var(--fl-doc-padding, 2rem);
|
|
271
273
|
background: var(--fl-doc-bg, transparent);
|
|
274
|
+
border-radius: var(--fl-doc-radius, 12px);
|
|
275
|
+
width: 100%;
|
|
276
|
+
max-width: var(--fl-doc-max-width, 1024px);
|
|
272
277
|
margin-inline: var(--fl-doc-margin-inline, auto);
|
|
273
278
|
margin-block: var(--fl-doc-margin-block, 2rem);
|
|
274
|
-
|
|
275
279
|
}
|
|
276
280
|
|
|
277
281
|
.fl-toolbar-dropdown-panel {
|
|
@@ -588,8 +592,8 @@
|
|
|
588
592
|
position: absolute;
|
|
589
593
|
left: 10px;
|
|
590
594
|
top: 10px;
|
|
591
|
-
width:
|
|
592
|
-
height:
|
|
595
|
+
width: 26px;
|
|
596
|
+
height: 26px;
|
|
593
597
|
display: flex;
|
|
594
598
|
align-items: center;
|
|
595
599
|
justify-content: center;
|
|
@@ -597,7 +601,10 @@
|
|
|
597
601
|
border-radius: 100%;
|
|
598
602
|
color: #fff;
|
|
599
603
|
font-weight: 600;
|
|
600
|
-
font-size:
|
|
604
|
+
font-size: 16px;
|
|
605
|
+
text-align: center;
|
|
606
|
+
font-family: monospace;
|
|
607
|
+
text-transform: uppercase;
|
|
601
608
|
}
|
|
602
609
|
}
|
|
603
610
|
|