@flexiui/svelte-rich-text 0.0.52 → 0.0.54
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 +66 -64
- package/dist/RichText.svelte.d.ts +46 -2
- package/dist/extensions/AudioPlayer.svelte +16 -12
- package/dist/renderRichText.d.ts +1 -2
- package/dist/types.d.ts +6 -0
- package/package.json +1 -1
package/dist/RichText.svelte
CHANGED
|
@@ -1,67 +1,69 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
Mathematics,
|
|
4
|
-
migrateMathStrings,
|
|
5
|
-
} from "@tiptap/extension-mathematics";
|
|
6
|
-
|
|
7
|
-
import { HEADINGS, rgbToHex } from "./utils";
|
|
8
|
-
import "./styles.css";
|
|
9
|
-
import "katex/dist/katex.min.css";
|
|
10
|
-
|
|
11
|
-
import { onMount, onDestroy } from "svelte";
|
|
12
|
-
import type { Readable } from "svelte/store";
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
createEditor,
|
|
16
|
-
Editor,
|
|
17
|
-
EditorContent,
|
|
18
|
-
BubbleMenu,
|
|
19
|
-
} from "svelte-tiptap";
|
|
20
|
-
|
|
21
|
-
import { computePosition, offset, autoUpdate } from "@floating-ui/dom";
|
|
22
|
-
import { getRichTextExtensions } from "./getExtensions";
|
|
23
|
-
import { CellSelection } from "prosemirror-tables";
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
id?: string;
|
|
27
|
-
className?: string;
|
|
28
|
-
editable?: boolean;
|
|
29
|
-
content?: string | {type: string, content: any[]} | null;
|
|
30
|
-
customExtensions?: any[];
|
|
31
|
-
editorEvents?: {
|
|
32
|
-
onTransaction?: (params: any) => void;
|
|
33
|
-
onBeforeCreate?: (params: any) => void;
|
|
34
|
-
onCreate?: (params: any) => void;
|
|
35
|
-
onUpdate: (params: any) => void;
|
|
36
|
-
onFocus?: (params: any) => void;
|
|
37
|
-
onBlur?: (params: any) => void;
|
|
38
|
-
onDestroy?: (params: any) => void;
|
|
39
|
-
onDrop?: (params: any) => void;
|
|
40
|
-
onDelete?: (params: any) => void;
|
|
41
|
-
onContentError?: (params: any) => void;
|
|
42
|
-
onSelectionUpdate?: (params: any) => void;
|
|
43
|
-
onPaste?: (params: any) => void;
|
|
44
|
-
};
|
|
45
|
-
config?: {
|
|
46
|
-
editorAccentColor?: string;
|
|
47
|
-
editorBgColor?: string;
|
|
48
|
-
editorRadius?: string;
|
|
49
|
-
toolbarStickyPosition?: number;
|
|
50
|
-
toolbarZIndex?: number;
|
|
51
|
-
toolbarBgColor?: string;
|
|
52
|
-
toolbarTextColor?: string;
|
|
53
|
-
toolbarPadding?: string;
|
|
54
|
-
toolbarGap?: string;
|
|
55
|
-
docMaxWidth?: string;
|
|
56
|
-
docPadding?: string;
|
|
57
|
-
docBg?: string;
|
|
58
|
-
docMarginInline?: string;
|
|
59
|
-
docMarginBlock?: string;
|
|
60
|
-
docRadius?: string;
|
|
61
|
-
docTextColor?: string;
|
|
62
|
-
buttonStyle?: "accent-soft" | "accent-solid";
|
|
63
|
-
};
|
|
64
|
-
}
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
Mathematics,
|
|
4
|
+
migrateMathStrings,
|
|
5
|
+
} from "@tiptap/extension-mathematics";
|
|
6
|
+
|
|
7
|
+
import { HEADINGS, rgbToHex } from "./utils";
|
|
8
|
+
import "./styles.css";
|
|
9
|
+
import "katex/dist/katex.min.css";
|
|
10
|
+
|
|
11
|
+
import { onMount, onDestroy } from "svelte";
|
|
12
|
+
import type { Readable } from "svelte/store";
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
createEditor,
|
|
16
|
+
Editor,
|
|
17
|
+
EditorContent,
|
|
18
|
+
BubbleMenu,
|
|
19
|
+
} from "svelte-tiptap";
|
|
20
|
+
|
|
21
|
+
import { computePosition, offset, autoUpdate } from "@floating-ui/dom";
|
|
22
|
+
import { getRichTextExtensions } from "./getExtensions";
|
|
23
|
+
import { CellSelection } from "prosemirror-tables";
|
|
24
|
+
|
|
25
|
+
export interface Props {
|
|
26
|
+
id?: string;
|
|
27
|
+
className?: string;
|
|
28
|
+
editable?: boolean;
|
|
29
|
+
content?: string | {type: string, content: any[]} | null;
|
|
30
|
+
customExtensions?: any[];
|
|
31
|
+
editorEvents?: {
|
|
32
|
+
onTransaction?: (params: any) => void;
|
|
33
|
+
onBeforeCreate?: (params: any) => void;
|
|
34
|
+
onCreate?: (params: any) => void;
|
|
35
|
+
onUpdate: (params: any) => void;
|
|
36
|
+
onFocus?: (params: any) => void;
|
|
37
|
+
onBlur?: (params: any) => void;
|
|
38
|
+
onDestroy?: (params: any) => void;
|
|
39
|
+
onDrop?: (params: any) => void;
|
|
40
|
+
onDelete?: (params: any) => void;
|
|
41
|
+
onContentError?: (params: any) => void;
|
|
42
|
+
onSelectionUpdate?: (params: any) => void;
|
|
43
|
+
onPaste?: (params: any) => void;
|
|
44
|
+
};
|
|
45
|
+
config?: {
|
|
46
|
+
editorAccentColor?: string;
|
|
47
|
+
editorBgColor?: string;
|
|
48
|
+
editorRadius?: string;
|
|
49
|
+
toolbarStickyPosition?: number;
|
|
50
|
+
toolbarZIndex?: number;
|
|
51
|
+
toolbarBgColor?: string;
|
|
52
|
+
toolbarTextColor?: string;
|
|
53
|
+
toolbarPadding?: string;
|
|
54
|
+
toolbarGap?: string;
|
|
55
|
+
docMaxWidth?: string;
|
|
56
|
+
docPadding?: string;
|
|
57
|
+
docBg?: string;
|
|
58
|
+
docMarginInline?: string;
|
|
59
|
+
docMarginBlock?: string;
|
|
60
|
+
docRadius?: string;
|
|
61
|
+
docTextColor?: string;
|
|
62
|
+
buttonStyle?: "accent-soft" | "accent-solid";
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type RichTextProps = Props;
|
|
65
67
|
|
|
66
68
|
let {
|
|
67
69
|
id = "fl-rich-text-editor",
|
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import "./styles.css";
|
|
3
3
|
import "katex/dist/katex.min.css";
|
|
4
|
+
export interface Props {
|
|
5
|
+
id?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
editable?: boolean;
|
|
8
|
+
content?: string | {
|
|
9
|
+
type: string;
|
|
10
|
+
content: any[];
|
|
11
|
+
} | null;
|
|
12
|
+
customExtensions?: any[];
|
|
13
|
+
editorEvents?: {
|
|
14
|
+
onTransaction?: (params: any) => void;
|
|
15
|
+
onBeforeCreate?: (params: any) => void;
|
|
16
|
+
onCreate?: (params: any) => void;
|
|
17
|
+
onUpdate: (params: any) => void;
|
|
18
|
+
onFocus?: (params: any) => void;
|
|
19
|
+
onBlur?: (params: any) => void;
|
|
20
|
+
onDestroy?: (params: any) => void;
|
|
21
|
+
onDrop?: (params: any) => void;
|
|
22
|
+
onDelete?: (params: any) => void;
|
|
23
|
+
onContentError?: (params: any) => void;
|
|
24
|
+
onSelectionUpdate?: (params: any) => void;
|
|
25
|
+
onPaste?: (params: any) => void;
|
|
26
|
+
};
|
|
27
|
+
config?: {
|
|
28
|
+
editorAccentColor?: string;
|
|
29
|
+
editorBgColor?: string;
|
|
30
|
+
editorRadius?: string;
|
|
31
|
+
toolbarStickyPosition?: number;
|
|
32
|
+
toolbarZIndex?: number;
|
|
33
|
+
toolbarBgColor?: string;
|
|
34
|
+
toolbarTextColor?: string;
|
|
35
|
+
toolbarPadding?: string;
|
|
36
|
+
toolbarGap?: string;
|
|
37
|
+
docMaxWidth?: string;
|
|
38
|
+
docPadding?: string;
|
|
39
|
+
docBg?: string;
|
|
40
|
+
docMarginInline?: string;
|
|
41
|
+
docMarginBlock?: string;
|
|
42
|
+
docRadius?: string;
|
|
43
|
+
docTextColor?: string;
|
|
44
|
+
buttonStyle?: "accent-soft" | "accent-solid";
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export type RichTextProps = Props;
|
|
4
48
|
declare const __propDef: {
|
|
5
49
|
props: Record<string, never>;
|
|
6
50
|
events: {
|
|
@@ -8,9 +52,9 @@ declare const __propDef: {
|
|
|
8
52
|
};
|
|
9
53
|
slots: {};
|
|
10
54
|
};
|
|
11
|
-
|
|
55
|
+
type RichTextProps_ = typeof __propDef.props;
|
|
12
56
|
export type RichTextEvents = typeof __propDef.events;
|
|
13
57
|
export type RichTextSlots = typeof __propDef.slots;
|
|
14
|
-
export default class RichText extends SvelteComponentTyped<
|
|
58
|
+
export default class RichText extends SvelteComponentTyped<RichTextProps_, RichTextEvents, RichTextSlots> {
|
|
15
59
|
}
|
|
16
60
|
export {};
|
|
@@ -45,18 +45,22 @@
|
|
|
45
45
|
|
|
46
46
|
id = id + "-" + Math.random().toString(36).substring(2, 15);
|
|
47
47
|
|
|
48
|
-
audioAttributes.
|
|
49
|
-
|
|
50
|
-
textColor,
|
|
51
|
-
borderRadius,
|
|
52
|
-
accentColor,
|
|
53
|
-
accentColorPaused,
|
|
54
|
-
playBtnBgColor,
|
|
55
|
-
playBtnTextColor,
|
|
56
|
-
colorPlay,
|
|
57
|
-
maxWidth,
|
|
48
|
+
audioAttributes.subscribe((value) => {
|
|
49
|
+
console.log({ value });
|
|
58
50
|
});
|
|
59
51
|
|
|
52
|
+
// audioAttributes.set({
|
|
53
|
+
// bgColor,
|
|
54
|
+
// textColor,
|
|
55
|
+
// borderRadius,
|
|
56
|
+
// accentColor,
|
|
57
|
+
// accentColorPaused,
|
|
58
|
+
// playBtnBgColor,
|
|
59
|
+
// playBtnTextColor,
|
|
60
|
+
// colorPlay,
|
|
61
|
+
// maxWidth,
|
|
62
|
+
// });
|
|
63
|
+
|
|
60
64
|
function formatTime(seconds: number) {
|
|
61
65
|
if (isNaN(seconds) || seconds < 0) return "0:00";
|
|
62
66
|
|
|
@@ -308,10 +312,10 @@ class="audio-player"
|
|
|
308
312
|
{id}
|
|
309
313
|
class:playing
|
|
310
314
|
style={`
|
|
311
|
-
${
|
|
315
|
+
${bgColor && `--player-bg-color: ${rewrite ? bgColor : $audioAttributes.bgColor || bgColor};`}
|
|
312
316
|
${playBtnBgColor && `--player-play-btn-bg: ${playBtnBgColor};`}
|
|
313
317
|
${playBtnTextColor && `--player-play-btn-color: ${playBtnTextColor};`}
|
|
314
|
-
${`--player-primary-color: ${rewrite ? accentColor : $audioAttributes.accentColor};`}
|
|
318
|
+
${`--player-primary-color: ${rewrite ? accentColor : $audioAttributes.accentColor || accentColor};`}
|
|
315
319
|
${accentColorPaused && `--player-progress-default-bg: ${accentColorPaused};`}
|
|
316
320
|
${textColor && `--player-text-color: ${textColor};`}
|
|
317
321
|
${borderRadius && `--player-border-radius: ${borderRadius};`}
|
package/dist/renderRichText.d.ts
CHANGED
package/dist/types.d.ts
ADDED