@flexiui/svelte-rich-text 0.0.24 → 0.0.26
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/AudioPlayerSimple.svelte +7 -0
- package/dist/AudioPlayerSimple.svelte.d.ts +25 -0
- package/dist/RichText.svelte +110 -5
- package/dist/extensions/Audio.d.ts +29 -0
- package/dist/extensions/Audio.js +123 -0
- package/dist/extensions/AudioPlayer.svelte +622 -0
- package/dist/extensions/AudioPlayer.svelte.d.ts +20 -0
- package/dist/extensions/AudioPlayerWrapper.svelte +123 -0
- package/dist/extensions/AudioPlayerWrapper.svelte.d.ts +21 -0
- package/dist/extensions/MediaGrid/MediaGrid.d.ts +2 -0
- package/dist/extensions/MediaGrid/MediaGrid.js +90 -0
- package/dist/extensions/MediaGrid/MediaGrid.svelte +265 -0
- package/dist/extensions/MediaGrid/MediaGrid.svelte.d.ts +14 -0
- package/dist/extensions/MediaGrid/MediaGridItem.d.ts +2 -0
- package/dist/extensions/MediaGrid/MediaGridItem.js +24 -0
- package/dist/extensions/MediaGrid/MediaGridItem.svelte +484 -0
- package/dist/extensions/MediaGrid/MediaGridItem.svelte.d.ts +14 -0
- package/dist/extensions/MediaGrid/auth-service.d.ts +1 -0
- package/dist/extensions/MediaGrid/auth-service.js +11 -0
- package/dist/extensions/Table/CustomTableCell.d.ts +19 -0
- package/dist/extensions/Table/CustomTableCell.js +86 -0
- package/dist/extensions/Table/CustomTableHeader.d.ts +1 -0
- package/dist/extensions/Table/CustomTableHeader.js +33 -0
- package/dist/extensions/Table/TableCellControls.d.ts +0 -0
- package/dist/extensions/Table/TableCellControls.js +0 -0
- package/dist/extensions/Table/TableCellNodeView.svelte +576 -0
- package/dist/extensions/Table/TableCellNodeView.svelte.d.ts +14 -0
- package/dist/extensions/Table/TableCellSelection.d.ts +12 -0
- package/dist/extensions/Table/TableCellSelection.js +35 -0
- package/dist/extensions/audioStore.d.ts +1 -0
- package/dist/extensions/audioStore.js +2 -0
- package/dist/extensions/extensions.d.ts +7 -0
- package/dist/extensions/extensions.js +86 -0
- package/dist/styles.css +182 -0
- package/package.json +2 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} AudioPlayerSimpleProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} AudioPlayerSimpleEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} AudioPlayerSimpleSlots */
|
|
4
|
+
export default class AudioPlayerSimple extends SvelteComponentTyped<{
|
|
5
|
+
name: any;
|
|
6
|
+
src: any;
|
|
7
|
+
}, {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
}, {}> {
|
|
10
|
+
}
|
|
11
|
+
export type AudioPlayerSimpleProps = typeof __propDef.props;
|
|
12
|
+
export type AudioPlayerSimpleEvents = typeof __propDef.events;
|
|
13
|
+
export type AudioPlayerSimpleSlots = typeof __propDef.slots;
|
|
14
|
+
import { SvelteComponentTyped } from "svelte";
|
|
15
|
+
declare const __propDef: {
|
|
16
|
+
props: {
|
|
17
|
+
name: any;
|
|
18
|
+
src: any;
|
|
19
|
+
};
|
|
20
|
+
events: {
|
|
21
|
+
[evt: string]: CustomEvent<any>;
|
|
22
|
+
};
|
|
23
|
+
slots: {};
|
|
24
|
+
};
|
|
25
|
+
export {};
|
package/dist/RichText.svelte
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { CustomTableHeader } from "./extensions/Table/CustomTableHeader";
|
|
3
|
+
import { CustomTableCell } from "./extensions/Table/CustomTableCell";
|
|
4
|
+
import { TableKit } from "@tiptap/extension-table";
|
|
5
|
+
import { CellSelection } from "prosemirror-tables";
|
|
6
|
+
|
|
2
7
|
import { NodeLineHeight } from './extensions/NodeLineHeight';
|
|
8
|
+
import { MediaGridExtension } from "./extensions/MediaGrid/MediaGrid";
|
|
9
|
+
import { MediaGridItemExtension } from "./extensions/MediaGrid/MediaGridItem";
|
|
3
10
|
import {
|
|
4
11
|
Mathematics,
|
|
5
12
|
migrateMathStrings,
|
|
@@ -16,8 +23,8 @@
|
|
|
16
23
|
import StarterKit from "@tiptap/starter-kit";
|
|
17
24
|
import Highlight from "@tiptap/extension-highlight";
|
|
18
25
|
import TextAlign from "@tiptap/extension-text-align";
|
|
19
|
-
import
|
|
20
|
-
import
|
|
26
|
+
import Image from "@tiptap/extension-image";
|
|
27
|
+
import { Audio } from "./extensions/Audio";
|
|
21
28
|
import { ListKit } from "@tiptap/extension-list";
|
|
22
29
|
import { TextStyleKit } from "@tiptap/extension-text-style";
|
|
23
30
|
import { EnhancedLink } from "./extensions/EnhancedLink";
|
|
@@ -83,6 +90,12 @@
|
|
|
83
90
|
listKeymap: false,
|
|
84
91
|
}),
|
|
85
92
|
EnhancedLink,
|
|
93
|
+
Audio.configure({
|
|
94
|
+
HTMLAttributes: { class: "audio-player" },
|
|
95
|
+
}),
|
|
96
|
+
Image.configure({
|
|
97
|
+
inline: true,
|
|
98
|
+
}),
|
|
86
99
|
ListKit,
|
|
87
100
|
TextAlign.configure({
|
|
88
101
|
types: [
|
|
@@ -126,6 +139,20 @@
|
|
|
126
139
|
},
|
|
127
140
|
}),
|
|
128
141
|
NodeLineHeight,
|
|
142
|
+
MediaGridExtension,
|
|
143
|
+
MediaGridItemExtension,
|
|
144
|
+
TableKit.configure({
|
|
145
|
+
table: {
|
|
146
|
+
HTMLAttributes: { class: "fl-table-editable" },
|
|
147
|
+
resizable: true,
|
|
148
|
+
},
|
|
149
|
+
}),
|
|
150
|
+
CustomTableCell.configure({
|
|
151
|
+
HTMLAttributes: { class: "fl-cell-editable" },
|
|
152
|
+
}),
|
|
153
|
+
CustomTableHeader.configure({
|
|
154
|
+
HTMLAttributes: { class: "fl-cell-editable" },
|
|
155
|
+
}),
|
|
129
156
|
...customExtensions,
|
|
130
157
|
];
|
|
131
158
|
|
|
@@ -473,15 +500,48 @@
|
|
|
473
500
|
|
|
474
501
|
function handleRangeInput(e: any) {
|
|
475
502
|
|
|
503
|
+
$editor.commands.setNodeLineHeight(lineHeight.toString())
|
|
476
504
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function addAudio() {
|
|
508
|
+
const previousSrc = $editor.getAttributes("audio").src;
|
|
509
|
+
const src = window.prompt("Enter the URL of the audio:", previousSrc);
|
|
510
|
+
if (!src) {
|
|
511
|
+
alert("Please enter a valid URL");
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
$editor.chain().focus().setAudio({ src, controls: true }).run()
|
|
480
516
|
|
|
481
517
|
}
|
|
518
|
+
|
|
519
|
+
function addImage() {
|
|
520
|
+
const previousSrc = $editor.getAttributes("image").src;
|
|
521
|
+
const src = window.prompt("Enter the URL of the image:", previousSrc);
|
|
522
|
+
|
|
523
|
+
if (!src) {
|
|
524
|
+
alert("Please enter a valid URL");
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
$editor.chain().focus().setImage({ src }).run()
|
|
529
|
+
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
function addMediaGrid() {
|
|
533
|
+
|
|
534
|
+
$editor.chain().focus().insertGrid({ cols: 2 }).run()
|
|
535
|
+
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
function addTable(){
|
|
539
|
+
$editor.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run()
|
|
540
|
+
}
|
|
482
541
|
</script>
|
|
483
542
|
|
|
484
543
|
<div class="fl-rich-text {className}" class:editable>
|
|
544
|
+
|
|
485
545
|
{#if editor}
|
|
486
546
|
<header class="fl-rich-text-toolbar">
|
|
487
547
|
<!-- Undo/Redo -->
|
|
@@ -507,6 +567,7 @@
|
|
|
507
567
|
></path></svg
|
|
508
568
|
>
|
|
509
569
|
</button>
|
|
570
|
+
|
|
510
571
|
<button
|
|
511
572
|
type="button"
|
|
512
573
|
onclick={() => $editor.chain().focus().redo().run()}
|
|
@@ -1154,6 +1215,50 @@
|
|
|
1154
1215
|
</button>
|
|
1155
1216
|
</div>
|
|
1156
1217
|
|
|
1218
|
+
<!-- Audio & image -->
|
|
1219
|
+
<div role="group" class="fl-rich-text-toolbar-group">
|
|
1220
|
+
<!-- Image -->
|
|
1221
|
+
<button
|
|
1222
|
+
type="button"
|
|
1223
|
+
onclick={addImage}
|
|
1224
|
+
aria-label="Image"
|
|
1225
|
+
class:is-active={$editor.isActive("image")}
|
|
1226
|
+
>
|
|
1227
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="icon icon-tabler icons-tabler-filled icon-tabler-photo"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path 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" /></svg>
|
|
1228
|
+
</button>
|
|
1229
|
+
<!-- Audio -->
|
|
1230
|
+
<button
|
|
1231
|
+
type="button"
|
|
1232
|
+
onclick={addAudio}
|
|
1233
|
+
aria-label="Audio"
|
|
1234
|
+
class:is-active={$editor.isActive("audio")}
|
|
1235
|
+
>
|
|
1236
|
+
Audio
|
|
1237
|
+
</button>
|
|
1238
|
+
</div>
|
|
1239
|
+
|
|
1240
|
+
<!-- Media Grid & Table -->
|
|
1241
|
+
<div role="group" class="fl-rich-text-toolbar-group">
|
|
1242
|
+
<!-- Grid -->
|
|
1243
|
+
<button
|
|
1244
|
+
type="button"
|
|
1245
|
+
onclick={addMediaGrid}
|
|
1246
|
+
aria-label="Media grid"
|
|
1247
|
+
class:is-active={$editor.isActive("MediaGridComponent")}
|
|
1248
|
+
>
|
|
1249
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="icon icon-tabler icons-tabler-filled icon-tabler-layout-grid"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path 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" /><path 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" /><path 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" /><path 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" /></svg>
|
|
1250
|
+
</button>
|
|
1251
|
+
<!-- Table -->
|
|
1252
|
+
<button
|
|
1253
|
+
type="button"
|
|
1254
|
+
onclick={addTable}
|
|
1255
|
+
aria-label="Table"
|
|
1256
|
+
class:is-active={$editor.isActive("table")}
|
|
1257
|
+
>
|
|
1258
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-table"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path 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" /><path d="M3 10h18" /><path d="M10 3v18" /></svg>
|
|
1259
|
+
</button>
|
|
1260
|
+
</div>
|
|
1261
|
+
|
|
1157
1262
|
<!-- Text align, clear formatting, clear nodes -->
|
|
1158
1263
|
<div role="group" class="fl-rich-text-toolbar-group">
|
|
1159
1264
|
<!-- Text align left -->
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
export interface AudioOptions {
|
|
3
|
+
inline: boolean;
|
|
4
|
+
allowBase64: boolean;
|
|
5
|
+
HTMLAttributes: Record<string, any>;
|
|
6
|
+
}
|
|
7
|
+
export interface SetAudioOptions {
|
|
8
|
+
src: string;
|
|
9
|
+
controls?: boolean;
|
|
10
|
+
autoplay?: boolean;
|
|
11
|
+
loop?: boolean;
|
|
12
|
+
colorPlay?: string;
|
|
13
|
+
colorBar?: string;
|
|
14
|
+
maxWidth?: string;
|
|
15
|
+
}
|
|
16
|
+
declare module '@tiptap/core' {
|
|
17
|
+
interface Commands<ReturnType> {
|
|
18
|
+
audio: {
|
|
19
|
+
/**
|
|
20
|
+
* Añade un elemento de audio personalizado
|
|
21
|
+
* @example
|
|
22
|
+
* editor.commands.setAudio({ src: '/audio.mp3', controls: true })
|
|
23
|
+
*/
|
|
24
|
+
setAudio: (options: SetAudioOptions) => ReturnType;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export declare const inputRegex: RegExp;
|
|
29
|
+
export declare const Audio: Node<AudioOptions, any>;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Node, mergeAttributes, nodeInputRule } from '@tiptap/core';
|
|
2
|
+
import { SvelteNodeViewRenderer } from 'svelte-tiptap';
|
|
3
|
+
import AudioPlayer from './AudioPlayerWrapper.svelte';
|
|
4
|
+
export const inputRegex = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;
|
|
5
|
+
export const Audio = Node.create({
|
|
6
|
+
name: 'audio',
|
|
7
|
+
addOptions() {
|
|
8
|
+
return {
|
|
9
|
+
inline: false,
|
|
10
|
+
allowBase64: false,
|
|
11
|
+
HTMLAttributes: {},
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
inline() {
|
|
15
|
+
return this.options.inline;
|
|
16
|
+
},
|
|
17
|
+
group() {
|
|
18
|
+
return this.options.inline ? 'inline' : 'block';
|
|
19
|
+
},
|
|
20
|
+
atom: true,
|
|
21
|
+
draggable: true,
|
|
22
|
+
addAttributes() {
|
|
23
|
+
return {
|
|
24
|
+
src: {
|
|
25
|
+
default: null,
|
|
26
|
+
},
|
|
27
|
+
controls: {
|
|
28
|
+
default: true,
|
|
29
|
+
parseHTML: el => el.hasAttribute('controls'),
|
|
30
|
+
renderHTML: attrs => (attrs.controls ? { controls: true } : {}),
|
|
31
|
+
},
|
|
32
|
+
autoplay: {
|
|
33
|
+
default: false,
|
|
34
|
+
parseHTML: el => el.hasAttribute('autoplay'),
|
|
35
|
+
renderHTML: attrs => (attrs.autoplay ? { autoplay: true } : {}),
|
|
36
|
+
},
|
|
37
|
+
loop: {
|
|
38
|
+
default: false,
|
|
39
|
+
parseHTML: el => el.hasAttribute('loop'),
|
|
40
|
+
renderHTML: attrs => (attrs.loop ? { loop: true } : {}),
|
|
41
|
+
},
|
|
42
|
+
colorPlay: {
|
|
43
|
+
default: '#333',
|
|
44
|
+
parseHTML: el => el.getAttribute('data-color-play') || '#333',
|
|
45
|
+
renderHTML: attrs => ({
|
|
46
|
+
'data-color-play': attrs.colorPlay,
|
|
47
|
+
}),
|
|
48
|
+
},
|
|
49
|
+
colorBar: {
|
|
50
|
+
default: '#888',
|
|
51
|
+
parseHTML: el => el.getAttribute('data-color-bar') || '#888',
|
|
52
|
+
renderHTML: attrs => ({
|
|
53
|
+
'data-color-bar': attrs.colorBar,
|
|
54
|
+
}),
|
|
55
|
+
},
|
|
56
|
+
maxWidth: {
|
|
57
|
+
default: '100%',
|
|
58
|
+
parseHTML: el => el.getAttribute('data-max-width') || '100%',
|
|
59
|
+
renderHTML: attrs => ({
|
|
60
|
+
'data-max-width': attrs.maxWidth,
|
|
61
|
+
}),
|
|
62
|
+
},
|
|
63
|
+
id: {
|
|
64
|
+
default: "fl-audio-" + Math.random().toString(36).slice(2),
|
|
65
|
+
parseHTML: el => el.getAttribute('data-id') || null,
|
|
66
|
+
renderHTML: attrs => ({
|
|
67
|
+
'data-id': attrs.id,
|
|
68
|
+
}),
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
parseHTML() {
|
|
73
|
+
return [
|
|
74
|
+
{
|
|
75
|
+
tag: 'audio-player',
|
|
76
|
+
getAttrs: el => {
|
|
77
|
+
if (!(el instanceof HTMLElement))
|
|
78
|
+
return false;
|
|
79
|
+
return {
|
|
80
|
+
src: el.getAttribute('src'),
|
|
81
|
+
controls: el.hasAttribute('controls'),
|
|
82
|
+
autoplay: el.hasAttribute('autoplay'),
|
|
83
|
+
loop: el.hasAttribute('loop'),
|
|
84
|
+
colorPlay: el.getAttribute('data-color-play') || '#333',
|
|
85
|
+
colorBar: el.getAttribute('data-color-bar') || '#888',
|
|
86
|
+
maxWidth: el.getAttribute('data-max-width') || '100%',
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
},
|
|
92
|
+
renderHTML({ HTMLAttributes }) {
|
|
93
|
+
return [
|
|
94
|
+
'audio-player',
|
|
95
|
+
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
|
|
96
|
+
];
|
|
97
|
+
},
|
|
98
|
+
addNodeView() {
|
|
99
|
+
return SvelteNodeViewRenderer(AudioPlayer);
|
|
100
|
+
},
|
|
101
|
+
addCommands() {
|
|
102
|
+
return {
|
|
103
|
+
setAudio: options => ({ commands }) => {
|
|
104
|
+
return commands.insertContent({
|
|
105
|
+
type: this.name,
|
|
106
|
+
attrs: options,
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
},
|
|
111
|
+
addInputRules() {
|
|
112
|
+
return [
|
|
113
|
+
nodeInputRule({
|
|
114
|
+
find: inputRegex,
|
|
115
|
+
type: this.type,
|
|
116
|
+
getAttributes: match => {
|
|
117
|
+
const [, , , src] = match;
|
|
118
|
+
return { src, controls: true };
|
|
119
|
+
},
|
|
120
|
+
}),
|
|
121
|
+
];
|
|
122
|
+
},
|
|
123
|
+
});
|