@placeholderco/placeholder-ui 1.0.12 → 2.0.0
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/LICENSE +1 -1
- package/README.md +134 -130
- package/dist/app.css +178 -0
- package/dist/bootstrap.min.css +3600 -0
- package/dist/cards/GitCard.svelte +115 -0
- package/dist/cards/GitCard.svelte.d.ts +22 -0
- package/dist/display/Avatar.svelte +29 -17
- package/dist/display/Avatar.svelte.d.ts +12 -2
- package/dist/display/LinkCollection.svelte +40 -18
- package/dist/display/LinkCollection.svelte.d.ts +9 -2
- package/dist/display/Paper.svelte +31 -19
- package/dist/display/Paper.svelte.d.ts +12 -3
- package/dist/display/alert/Alert.svelte +129 -0
- package/dist/display/alert/Alert.svelte.d.ts +15 -0
- package/dist/display/alert/AlertVariant.d.ts +1 -0
- package/dist/display/alert/AlertVariant.js +1 -0
- package/dist/display/filetree/FileTree.svelte +259 -0
- package/dist/display/filetree/FileTree.svelte.d.ts +76 -0
- package/dist/display/filetree/FileTreeItem.svelte +396 -0
- package/dist/display/filetree/FileTreeItem.svelte.d.ts +40 -0
- package/dist/display/filetree/FileTreeNode.d.ts +46 -0
- package/dist/display/filetree/FileTreeNode.js +115 -0
- package/dist/display/filetree/index.d.ts +5 -0
- package/dist/display/filetree/index.js +3 -0
- package/dist/editors/CodeMirror.svelte +306 -0
- package/dist/editors/CodeMirror.svelte.d.ts +31 -0
- package/dist/editors/tiptap/LinkActionMenu.svelte +307 -0
- package/dist/editors/tiptap/LinkActionMenu.svelte.d.ts +8 -0
- package/dist/editors/tiptap/TipTap.svelte +856 -0
- package/dist/editors/tiptap/TipTap.svelte.d.ts +54 -0
- package/dist/editors/tiptap/TipTapBubble.svelte +790 -0
- package/dist/editors/tiptap/TipTapBubble.svelte.d.ts +44 -0
- package/dist/editors/tiptap/collaboration.d.ts +55 -0
- package/dist/editors/tiptap/collaboration.js +1 -0
- package/dist/editors/tiptap/extensions/Alert.d.ts +18 -0
- package/dist/editors/tiptap/extensions/Alert.js +72 -0
- package/dist/editors/tiptap/extensions/CodeBlockEditor.d.ts +21 -0
- package/dist/editors/tiptap/extensions/CodeBlockEditor.js +326 -0
- package/dist/editors/tiptap/extensions/Div.d.ts +19 -0
- package/dist/editors/tiptap/extensions/Div.js +89 -0
- package/dist/editors/tiptap/extensions/Span.d.ts +5 -0
- package/dist/editors/tiptap/extensions/Span.js +56 -0
- package/dist/editors/tiptap/extensions/codeBlockEditor.css +236 -0
- package/dist/editors/tiptap/extensions/codeBlockLanguages.d.ts +17 -0
- package/dist/editors/tiptap/extensions/codeBlockLanguages.js +124 -0
- package/dist/editors/tiptap/extensions/index.d.ts +7 -0
- package/dist/editors/tiptap/extensions/index.js +5 -0
- package/dist/editors/tiptap/toolbar/AlertButton.svelte +261 -0
- package/dist/editors/tiptap/toolbar/AlertButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/AlignCenterButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/AlignCenterButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/AlignJustifyButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/AlignJustifyButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/AlignLeftButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/AlignLeftButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/AlignRightButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/AlignRightButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/BoldButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/BoldButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/BulletListButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/BulletListButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/CodeBlockButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/CodeBlockButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/CodeButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/CodeButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/ColorButton.svelte +299 -0
- package/dist/editors/tiptap/toolbar/ColorButton.svelte.d.ts +20 -0
- package/dist/editors/tiptap/toolbar/DocumentButton.svelte +58 -0
- package/dist/editors/tiptap/toolbar/DocumentButton.svelte.d.ts +9 -0
- package/dist/editors/tiptap/toolbar/HeadingButton.svelte +30 -0
- package/dist/editors/tiptap/toolbar/HeadingButton.svelte.d.ts +8 -0
- package/dist/editors/tiptap/toolbar/HtmlButton.svelte +68 -0
- package/dist/editors/tiptap/toolbar/HtmlButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/ImageButton.svelte +54 -0
- package/dist/editors/tiptap/toolbar/ImageButton.svelte.d.ts +8 -0
- package/dist/editors/tiptap/toolbar/ItalicButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/ItalicButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/LinkButton.svelte +257 -0
- package/dist/editors/tiptap/toolbar/LinkButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/OrderedListButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/OrderedListButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/RedoButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/RedoButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/StrikethroughButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/StrikethroughButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/SubscriptButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/SubscriptButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/SuperscriptButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/SuperscriptButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/TableButton.svelte +258 -0
- package/dist/editors/tiptap/toolbar/TableButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/ToolbarButton.svelte +84 -0
- package/dist/editors/tiptap/toolbar/ToolbarButton.svelte.d.ts +10 -0
- package/dist/editors/tiptap/toolbar/UnderlineButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/UnderlineButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/UndoButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/UndoButton.svelte.d.ts +7 -0
- package/dist/form/Autocomplete.svelte +86 -135
- package/dist/form/Autocomplete.svelte.d.ts +6 -8
- package/dist/form/AutocompleteMulti.svelte +385 -227
- package/dist/form/AutocompleteMulti.svelte.d.ts +59 -10
- package/dist/form/Checkbox.svelte +59 -54
- package/dist/form/Checkbox.svelte.d.ts +14 -5
- package/dist/form/Chips.svelte +29 -13
- package/dist/form/Chips.svelte.d.ts +16 -2
- package/dist/form/ComboBox.svelte +30 -20
- package/dist/form/ComboBox.svelte.d.ts +1 -1
- package/dist/form/ComboBoxItemBuilder.svelte +161 -188
- package/dist/form/ComboBoxItemBuilder.svelte.d.ts +19 -2
- package/dist/form/ComboBoxMulti.svelte +38 -24
- package/dist/form/ComboBoxMulti.svelte.d.ts +1 -1
- package/dist/form/CronBuilder.svelte +84 -67
- package/dist/form/CronBuilder.svelte.d.ts +16 -3
- package/dist/form/DatePicker.svelte +148 -195
- package/dist/form/DateRangePicker.svelte +101 -98
- package/dist/form/DateTimePicker.svelte +167 -208
- package/dist/form/DateTimePicker.svelte.d.ts +10 -2
- package/dist/form/FormGroup.svelte +33 -10
- package/dist/form/FormGroup.svelte.d.ts +12 -2
- package/dist/form/Number.svelte +70 -47
- package/dist/form/Number.svelte.d.ts +36 -6
- package/dist/form/Radio.svelte +18 -18
- package/dist/form/RadioGroup.svelte +23 -12
- package/dist/form/RadioGroup.svelte.d.ts +13 -2
- package/dist/form/SegmentedControl.svelte +76 -56
- package/dist/form/SegmentedControl.svelte.d.ts +9 -4
- package/dist/form/Select.svelte +150 -233
- package/dist/form/Select.svelte.d.ts +29 -5
- package/dist/form/SelectMulti.svelte +163 -277
- package/dist/form/SelectMulti.svelte.d.ts +36 -7
- package/dist/form/Slider.svelte +183 -269
- package/dist/form/Slider.svelte.d.ts +32 -17
- package/dist/form/StringArrayBuilder.svelte +249 -0
- package/dist/form/StringArrayBuilder.svelte.d.ts +15 -0
- package/dist/form/Switch.svelte +164 -106
- package/dist/form/Switch.svelte.d.ts +22 -3
- package/dist/form/TextArea.svelte +49 -29
- package/dist/form/TextArea.svelte.d.ts +23 -3
- package/dist/form/Textbox.svelte +69 -68
- package/dist/form/Textbox.svelte.d.ts +32 -4
- package/dist/form/TimePicker.svelte +42 -47
- package/dist/form/TimePicker.svelte.d.ts +12 -2
- package/dist/form/comboBoxCore.svelte.d.ts +99 -0
- package/dist/form/comboBoxCore.svelte.js +243 -0
- package/dist/icon/Icon.svelte +8 -3
- package/dist/icon/Icon.svelte.d.ts +8 -3
- package/dist/icon/file-type-bmp.svg +1 -0
- package/dist/icon/file-type-csv.svg +1 -0
- package/dist/icon/file-type-doc.svg +1 -0
- package/dist/icon/file-type-docx.svg +1 -0
- package/dist/icon/file-type-jpg.svg +1 -0
- package/dist/icon/file-type-pdf.svg +1 -0
- package/dist/icon/file-type-png.svg +1 -0
- package/dist/icon/file-type-ppt.svg +1 -0
- package/dist/icon/file-type-svg.svg +1 -0
- package/dist/icon/file-type-txt.svg +1 -0
- package/dist/icon/file-type-xls.svg +1 -0
- package/dist/icon/file-type-zip.svg +1 -0
- package/dist/icon/index.d.ts +166 -151
- package/dist/icon/index.js +166 -152
- package/dist/icon/logo-placeholder.svg +6 -0
- package/dist/icon/source-code.svg +1 -0
- package/dist/icon/sun-moon.svg +1 -0
- package/dist/icon/table.svg +6 -0
- package/dist/index.d.ts +87 -26
- package/dist/index.js +25 -28
- package/dist/layout/AppShell.svelte +12 -162
- package/dist/layout/AppShell.svelte.d.ts +6 -27
- package/dist/layout/CustomNavbar.svelte +9 -7
- package/dist/layout/CustomNavbar.svelte.d.ts +4 -2
- package/dist/layout/Navbar.svelte +161 -129
- package/dist/layout/Navbar.svelte.d.ts +29 -15
- package/dist/layout/NavbarItemDisplay.svelte +2 -2
- package/dist/layout/NavbarItemView.svelte +182 -0
- package/dist/layout/NavbarItemView.svelte.d.ts +10 -0
- package/dist/layout/Sidenav.svelte +280 -341
- package/dist/layout/Sidenav.svelte.d.ts +36 -4
- package/dist/models/ComboBoxItem.d.ts +2 -0
- package/dist/models/Employee.d.ts +53 -0
- package/dist/models/Employee.js +23 -0
- package/dist/models/Hyperlink.d.ts +3 -1
- package/dist/models/LinkCollectionItem.d.ts +3 -1
- package/dist/models/NavbarItem.d.ts +6 -2
- package/dist/theme.svelte.d.ts +0 -1
- package/dist/theme.svelte.js +46 -58
- package/dist/ui/Accordion.svelte +81 -242
- package/dist/ui/Accordion.svelte.d.ts +37 -14
- package/dist/ui/AccordionItem.svelte +303 -0
- package/dist/ui/AccordionItem.svelte.d.ts +21 -0
- package/dist/ui/ActionIcon.svelte +25 -21
- package/dist/ui/ActionIcon.svelte.d.ts +15 -2
- package/dist/ui/Badge.svelte +163 -171
- package/dist/ui/Badge.svelte.d.ts +13 -5
- package/dist/ui/Button.svelte +178 -205
- package/dist/ui/Button.svelte.d.ts +19 -2
- package/dist/ui/ButtonVariant.d.ts +15 -1
- package/dist/ui/ContextMenu.svelte +146 -0
- package/dist/ui/ContextMenu.svelte.d.ts +37 -0
- package/dist/ui/ContextMenuList.svelte +188 -0
- package/dist/ui/ContextMenuList.svelte.d.ts +12 -0
- package/dist/ui/Dialog.svelte +183 -111
- package/dist/ui/Dialog.svelte.d.ts +21 -4
- package/dist/ui/Drawer.svelte +237 -184
- package/dist/ui/Drawer.svelte.d.ts +20 -2
- package/dist/ui/Dropdown.svelte +24 -14
- package/dist/ui/Dropdown.svelte.d.ts +11 -2
- package/dist/ui/Dropzone.svelte +159 -57
- package/dist/ui/Dropzone.svelte.d.ts +29 -2
- package/dist/ui/Link.svelte +12 -4
- package/dist/ui/Link.svelte.d.ts +8 -2
- package/dist/ui/Loader.svelte +23 -18
- package/dist/ui/Loader.svelte.d.ts +5 -2
- package/dist/ui/Logo.svelte +37 -0
- package/dist/ui/Logo.svelte.d.ts +16 -0
- package/dist/ui/MultiSortable.svelte +287 -0
- package/dist/ui/MultiSortable.svelte.d.ts +50 -0
- package/dist/ui/Pagination.svelte +15 -9
- package/dist/ui/Pagination.svelte.d.ts +6 -2
- package/dist/ui/Popover.svelte +43 -65
- package/dist/ui/Popover.svelte.d.ts +14 -5
- package/dist/ui/ProgressBar.svelte +28 -30
- package/dist/ui/ProgressBarVariant.d.ts +7 -1
- package/dist/ui/SegmentedControl.svelte +0 -0
- package/dist/ui/SegmentedControl.svelte.d.ts +26 -0
- package/dist/ui/Sortable.svelte +163 -0
- package/dist/ui/Sortable.svelte.d.ts +47 -0
- package/dist/ui/Table.svelte +383 -80
- package/dist/ui/Table.svelte.d.ts +43 -2
- package/dist/ui/Tabs.svelte +22 -18
- package/dist/ui/Tabs.svelte.d.ts +6 -2
- package/dist/ui/ThemeSwitcher.svelte +26 -7
- package/dist/ui/ThemeSwitcher.svelte.d.ts +4 -2
- package/dist/ui/Tooltip.svelte +312 -180
- package/dist/ui/Tooltip.svelte.d.ts +4 -3
- package/dist/uiTheme.svelte.d.ts +86 -0
- package/dist/uiTheme.svelte.js +214 -0
- package/dist/util/DateFunctions.js +1 -1
- package/dist/util/DragDrop.d.ts +50 -0
- package/dist/util/DragDrop.js +154 -0
- package/dist/util/NavigateTo.js +2 -2
- package/dist/util/dayjs.d.ts +4 -0
- package/dist/util/dayjs.js +15 -0
- package/package.json +66 -26
- package/dist/display/Alert.svelte +0 -179
- package/dist/display/Alert.svelte.d.ts +0 -13
- package/dist/form/FileInput.svelte +0 -235
- package/dist/form/FileInput.svelte.d.ts +0 -23
- package/dist/form/PasswordInput.svelte +0 -253
- package/dist/form/PasswordInput.svelte.d.ts +0 -34
- package/dist/form/Rating.svelte +0 -235
- package/dist/form/Rating.svelte.d.ts +0 -21
- package/dist/styles/components.css +0 -199
- package/dist/styles/dark.css +0 -146
- package/dist/styles/index.css +0 -116
- package/dist/styles/reset.css +0 -110
- package/dist/styles/semantic.css +0 -86
- package/dist/styles/tokens.css +0 -203
- package/dist/styles/utilities.css +0 -523
- package/dist/ui/Breadcrumbs.svelte +0 -131
- package/dist/ui/Breadcrumbs.svelte.d.ts +0 -16
- package/dist/ui/LoadingOverlay.svelte +0 -53
- package/dist/ui/LoadingOverlay.svelte.d.ts +0 -11
- package/dist/ui/Progress.svelte +0 -191
- package/dist/ui/Progress.svelte.d.ts +0 -15
- package/dist/ui/RingProgress.svelte +0 -141
- package/dist/ui/RingProgress.svelte.d.ts +0 -18
- package/dist/ui/Skeleton.svelte +0 -85
- package/dist/ui/Skeleton.svelte.d.ts +0 -12
- package/dist/ui/Stepper.svelte +0 -355
- package/dist/ui/Stepper.svelte.d.ts +0 -24
- package/dist/ui/Timeline.svelte +0 -225
- package/dist/ui/Timeline.svelte.d.ts +0 -23
- /package/dist/{actions → util}/ClickOutside.d.ts +0 -0
- /package/dist/{actions → util}/ClickOutside.js +0 -0
- /package/dist/{transitions → util}/Transitions.d.ts +0 -0
- /package/dist/{transitions → util}/Transitions.js +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Editor } from '@tiptap/core'
|
|
3
|
+
import ToolbarButton from './ToolbarButton.svelte'
|
|
4
|
+
import Dialog from '../../../ui/Dialog.svelte'
|
|
5
|
+
import Button from '../../../ui/Button.svelte'
|
|
6
|
+
import CodeMirror from '../../CodeMirror.svelte'
|
|
7
|
+
import { iconCode } from '../../../icon/index.js'
|
|
8
|
+
import { themeState } from '../../../theme.svelte.js'
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
editor: Editor
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let { editor }: Props = $props()
|
|
15
|
+
|
|
16
|
+
let showDialog = $state(false)
|
|
17
|
+
let htmlContent = $state('')
|
|
18
|
+
let codeMirrorRef: any
|
|
19
|
+
|
|
20
|
+
const openHtmlEditor = () => {
|
|
21
|
+
htmlContent = editor.getHTML()
|
|
22
|
+
showDialog = true
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const closeDialog = () => {
|
|
26
|
+
showDialog = false
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const saveHtml = () => {
|
|
30
|
+
if (codeMirrorRef) {
|
|
31
|
+
const newHtml = codeMirrorRef.getValue()
|
|
32
|
+
editor.commands.setContent(newHtml)
|
|
33
|
+
}
|
|
34
|
+
closeDialog()
|
|
35
|
+
}
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<ToolbarButton
|
|
39
|
+
icon={iconCode}
|
|
40
|
+
title="Edit HTML"
|
|
41
|
+
onclick={openHtmlEditor}
|
|
42
|
+
/>
|
|
43
|
+
|
|
44
|
+
<Dialog bind:show={showDialog} title="Edit HTML" size="full" preventOverflow={false}>
|
|
45
|
+
<div class="html-editor-container">
|
|
46
|
+
<CodeMirror
|
|
47
|
+
bind:this={codeMirrorRef}
|
|
48
|
+
value={htmlContent}
|
|
49
|
+
language="html"
|
|
50
|
+
theme={themeState.isDarkMode ? 'dark' : 'light'}
|
|
51
|
+
height="100%"
|
|
52
|
+
/>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
{#snippet footer()}
|
|
56
|
+
<Button variant="secondary" onclick={closeDialog}>Cancel</Button>
|
|
57
|
+
<Button onclick={saveHtml}>Save</Button>
|
|
58
|
+
{/snippet}
|
|
59
|
+
</Dialog>
|
|
60
|
+
|
|
61
|
+
<style>
|
|
62
|
+
.html-editor-container {
|
|
63
|
+
width: 100%;
|
|
64
|
+
height: calc(100vh - 200px);
|
|
65
|
+
max-height: 600px;
|
|
66
|
+
min-height: 300px;
|
|
67
|
+
}
|
|
68
|
+
</style>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Editor } from '@tiptap/core'
|
|
3
|
+
import ToolbarButton from './ToolbarButton.svelte'
|
|
4
|
+
import { iconPhoto } from '../../../icon/index.js'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
editor: Editor
|
|
8
|
+
onImageUpload?: (file: File) => Promise<string | null>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let { editor, onImageUpload }: Props = $props()
|
|
12
|
+
|
|
13
|
+
let fileInputElement: HTMLInputElement | undefined = $state()
|
|
14
|
+
|
|
15
|
+
const handleFileSelect = async (event: Event) => {
|
|
16
|
+
const target = event.target as HTMLInputElement
|
|
17
|
+
const file = target.files?.[0]
|
|
18
|
+
|
|
19
|
+
if (!file || !onImageUpload) return
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
const imageUrl = await onImageUpload(file)
|
|
23
|
+
|
|
24
|
+
if (imageUrl) {
|
|
25
|
+
editor.chain().focus().setImage({ src: imageUrl }).run()
|
|
26
|
+
}
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error('Failed to upload image:', error)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Reset the input
|
|
32
|
+
if (fileInputElement) {
|
|
33
|
+
fileInputElement.value = ''
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const openFilePicker = () => {
|
|
38
|
+
fileInputElement?.click()
|
|
39
|
+
}
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<input
|
|
43
|
+
type="file"
|
|
44
|
+
accept="image/*"
|
|
45
|
+
bind:this={fileInputElement}
|
|
46
|
+
onchange={handleFileSelect}
|
|
47
|
+
style="display: none;"
|
|
48
|
+
/>
|
|
49
|
+
|
|
50
|
+
<ToolbarButton
|
|
51
|
+
icon={iconPhoto}
|
|
52
|
+
title="Add Image"
|
|
53
|
+
onclick={openFilePicker}
|
|
54
|
+
/>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/core';
|
|
2
|
+
interface Props {
|
|
3
|
+
editor: Editor;
|
|
4
|
+
onImageUpload?: (file: File) => Promise<string | null>;
|
|
5
|
+
}
|
|
6
|
+
declare const ImageButton: import("svelte").Component<Props, {}, "">;
|
|
7
|
+
type ImageButton = ReturnType<typeof ImageButton>;
|
|
8
|
+
export default ImageButton;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Editor } from '@tiptap/core'
|
|
3
|
+
import ToolbarButton from './ToolbarButton.svelte'
|
|
4
|
+
import { iconItalic } from '../../../icon/index.js'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
editor: Editor
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
let { editor }: Props = $props()
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<ToolbarButton
|
|
14
|
+
icon={iconItalic}
|
|
15
|
+
title="Italic"
|
|
16
|
+
active={editor.isActive('italic')}
|
|
17
|
+
onclick={() => editor.chain().focus().toggleItalic().run()}
|
|
18
|
+
/>
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Editor } from '@tiptap/core'
|
|
3
|
+
import ToolbarButton from './ToolbarButton.svelte'
|
|
4
|
+
import { iconLink } from '../../../icon/index.js'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
editor: Editor
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
let { editor }: Props = $props()
|
|
11
|
+
|
|
12
|
+
let showLinkInput = $state(false)
|
|
13
|
+
let linkUrl = $state('')
|
|
14
|
+
let linkOpenInNewTab = $state(false)
|
|
15
|
+
let linkInputElement: HTMLInputElement | undefined = $state()
|
|
16
|
+
let linkDropdownElement: HTMLDivElement | undefined = $state()
|
|
17
|
+
|
|
18
|
+
const toggleLink = () => {
|
|
19
|
+
const attrs = editor.getAttributes('link')
|
|
20
|
+
linkUrl = attrs?.href || ''
|
|
21
|
+
linkOpenInNewTab = attrs?.target === '_blank'
|
|
22
|
+
showLinkInput = !showLinkInput
|
|
23
|
+
|
|
24
|
+
if (showLinkInput) {
|
|
25
|
+
setTimeout(() => {
|
|
26
|
+
linkInputElement?.focus()
|
|
27
|
+
linkInputElement?.select()
|
|
28
|
+
}, 0)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const setLink = () => {
|
|
33
|
+
if (linkUrl === '') {
|
|
34
|
+
editor.chain().focus().extendMarkRange('link').unsetLink().run()
|
|
35
|
+
} else {
|
|
36
|
+
const linkAttrs: { href: string; target?: string; rel?: string } = { href: linkUrl }
|
|
37
|
+
if (linkOpenInNewTab) {
|
|
38
|
+
linkAttrs.target = '_blank'
|
|
39
|
+
linkAttrs.rel = 'noopener noreferrer'
|
|
40
|
+
}
|
|
41
|
+
editor.chain().focus().extendMarkRange('link').setLink(linkAttrs).run()
|
|
42
|
+
}
|
|
43
|
+
showLinkInput = false
|
|
44
|
+
linkUrl = ''
|
|
45
|
+
linkOpenInNewTab = false
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const updateLinkTarget = () => {
|
|
49
|
+
if (!linkUrl) return
|
|
50
|
+
|
|
51
|
+
const linkAttrs: { href: string; target?: string; rel?: string } = { href: linkUrl }
|
|
52
|
+
if (linkOpenInNewTab) {
|
|
53
|
+
linkAttrs.target = '_blank'
|
|
54
|
+
linkAttrs.rel = 'noopener noreferrer'
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (editor.isActive('link')) {
|
|
58
|
+
editor.chain().focus().extendMarkRange('link').setLink(linkAttrs).run()
|
|
59
|
+
} else if (!editor.state.selection.empty) {
|
|
60
|
+
editor.chain().focus().setLink(linkAttrs).run()
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const removeLink = () => {
|
|
65
|
+
editor.chain().focus().extendMarkRange('link').unsetLink().run()
|
|
66
|
+
showLinkInput = false
|
|
67
|
+
linkUrl = ''
|
|
68
|
+
linkOpenInNewTab = false
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const handleLinkKeydown = (e: KeyboardEvent) => {
|
|
72
|
+
if (e.key === 'Enter') {
|
|
73
|
+
e.preventDefault()
|
|
74
|
+
setLink()
|
|
75
|
+
} else if (e.key === 'Escape') {
|
|
76
|
+
showLinkInput = false
|
|
77
|
+
linkUrl = ''
|
|
78
|
+
linkOpenInNewTab = false
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
</script>
|
|
82
|
+
|
|
83
|
+
<div style="position: relative; display: inline-block;">
|
|
84
|
+
<ToolbarButton
|
|
85
|
+
icon={iconLink}
|
|
86
|
+
title="Link"
|
|
87
|
+
active={editor.isActive('link')}
|
|
88
|
+
onclick={toggleLink}
|
|
89
|
+
/>
|
|
90
|
+
|
|
91
|
+
{#if showLinkInput}
|
|
92
|
+
<div class="link-dropdown" bind:this={linkDropdownElement}>
|
|
93
|
+
<div class="link-input-row">
|
|
94
|
+
<input
|
|
95
|
+
type="text"
|
|
96
|
+
bind:this={linkInputElement}
|
|
97
|
+
bind:value={linkUrl}
|
|
98
|
+
onkeydown={handleLinkKeydown}
|
|
99
|
+
placeholder="Enter URL"
|
|
100
|
+
class="link-input"
|
|
101
|
+
/>
|
|
102
|
+
<button onclick={setLink} class="link-submit-button" title="Apply">✓</button>
|
|
103
|
+
{#if editor.isActive('link')}
|
|
104
|
+
<button onclick={removeLink} class="link-remove-button" title="Remove Link">✕</button>
|
|
105
|
+
{/if}
|
|
106
|
+
</div>
|
|
107
|
+
<label class="link-checkbox-label">
|
|
108
|
+
<input
|
|
109
|
+
type="checkbox"
|
|
110
|
+
bind:checked={linkOpenInNewTab}
|
|
111
|
+
onchange={updateLinkTarget}
|
|
112
|
+
class="link-checkbox"
|
|
113
|
+
/>
|
|
114
|
+
<span>Open in new tab</span>
|
|
115
|
+
</label>
|
|
116
|
+
</div>
|
|
117
|
+
{/if}
|
|
118
|
+
</div>
|
|
119
|
+
|
|
120
|
+
<style>
|
|
121
|
+
.link-dropdown {
|
|
122
|
+
position: absolute;
|
|
123
|
+
top: 100%;
|
|
124
|
+
left: 0;
|
|
125
|
+
margin-top: 4px;
|
|
126
|
+
display: flex;
|
|
127
|
+
flex-direction: column;
|
|
128
|
+
gap: 8px;
|
|
129
|
+
padding: 8px;
|
|
130
|
+
background: var(--paper-body-bg);
|
|
131
|
+
border: 1px solid var(--border-color);
|
|
132
|
+
border-radius: 4px;
|
|
133
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
134
|
+
z-index: 1000;
|
|
135
|
+
min-width: 320px;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
:global(.dark) .link-dropdown {
|
|
139
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.link-input-row {
|
|
143
|
+
display: flex;
|
|
144
|
+
gap: 4px;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.link-input {
|
|
148
|
+
flex: 1;
|
|
149
|
+
padding: 6px 10px;
|
|
150
|
+
border: 1px solid var(--border-color);
|
|
151
|
+
border-radius: 4px;
|
|
152
|
+
font-size: 14px;
|
|
153
|
+
outline: none;
|
|
154
|
+
font-family: inherit;
|
|
155
|
+
background: var(--paper-body-bg);
|
|
156
|
+
color: var(--text-color);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.link-input::placeholder {
|
|
160
|
+
color: var(--placeholder-color);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.link-input:focus {
|
|
164
|
+
border-color: var(--ui-primary);
|
|
165
|
+
box-shadow: 0 0 0 2px rgba(var(--ui-primary-rgbc), 0.1);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
:global(.dark) .link-input:focus {
|
|
169
|
+
border-color: var(--ui-accent);
|
|
170
|
+
box-shadow: 0 0 0 2px rgba(var(--ui-accent-rgbc), 0.1);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.link-checkbox-label {
|
|
174
|
+
display: flex;
|
|
175
|
+
align-items: center;
|
|
176
|
+
gap: 6px;
|
|
177
|
+
font-size: 14px;
|
|
178
|
+
color: var(--text-color);
|
|
179
|
+
cursor: pointer;
|
|
180
|
+
user-select: none;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.link-checkbox {
|
|
184
|
+
width: 16px;
|
|
185
|
+
height: 16px;
|
|
186
|
+
cursor: pointer;
|
|
187
|
+
accent-color: var(--ui-primary);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
:global(.dark) .link-checkbox {
|
|
191
|
+
accent-color: var(--ui-accent);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.link-checkbox-label:hover {
|
|
195
|
+
color: var(--ui-primary);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
:global(.dark) .link-checkbox-label:hover {
|
|
199
|
+
color: var(--ui-accent);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.link-submit-button {
|
|
203
|
+
display: flex;
|
|
204
|
+
align-items: center;
|
|
205
|
+
justify-content: center;
|
|
206
|
+
padding: 6px 12px;
|
|
207
|
+
border: none;
|
|
208
|
+
background: var(--ui-primary);
|
|
209
|
+
color: white;
|
|
210
|
+
border-radius: 4px;
|
|
211
|
+
cursor: pointer;
|
|
212
|
+
font-size: 16px;
|
|
213
|
+
font-weight: bold;
|
|
214
|
+
transition: background 0.15s ease;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.link-submit-button:hover {
|
|
218
|
+
background: var(--ui-tertiary-dark);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
:global(.dark) .link-submit-button {
|
|
222
|
+
background: var(--ui-accent);
|
|
223
|
+
color: var(--ui-primary);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
:global(.dark) .link-submit-button:hover {
|
|
227
|
+
background: var(--ui-accent-dark);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.link-remove-button {
|
|
231
|
+
display: flex;
|
|
232
|
+
align-items: center;
|
|
233
|
+
justify-content: center;
|
|
234
|
+
padding: 6px 12px;
|
|
235
|
+
border: none;
|
|
236
|
+
background: var(--ui-tertiary);
|
|
237
|
+
color: var(--ui-primary);
|
|
238
|
+
border-radius: 4px;
|
|
239
|
+
cursor: pointer;
|
|
240
|
+
font-size: 16px;
|
|
241
|
+
font-weight: bold;
|
|
242
|
+
transition: background 0.15s ease;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.link-remove-button:hover {
|
|
246
|
+
background: var(--ui-tertiary-dark);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
:global(.dark) .link-remove-button {
|
|
250
|
+
background: var(--ui-accent);
|
|
251
|
+
color: var(--ui-primary);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
:global(.dark) .link-remove-button:hover {
|
|
255
|
+
background: var(--ui-accent-dark);
|
|
256
|
+
}
|
|
257
|
+
</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Editor } from '@tiptap/core'
|
|
3
|
+
import ToolbarButton from './ToolbarButton.svelte'
|
|
4
|
+
import { iconListNumbers } from '../../../icon/index.js'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
editor: Editor
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
let { editor }: Props = $props()
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<ToolbarButton
|
|
14
|
+
icon={iconListNumbers}
|
|
15
|
+
title="Numbered List"
|
|
16
|
+
active={editor.isActive('orderedList')}
|
|
17
|
+
onclick={() => editor.chain().focus().toggleOrderedList().run()}
|
|
18
|
+
/>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Editor } from '@tiptap/core'
|
|
3
|
+
import ToolbarButton from './ToolbarButton.svelte'
|
|
4
|
+
import { iconArrowForwardUp } from '../../../icon/index.js'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
editor: Editor
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
let { editor }: Props = $props()
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<ToolbarButton
|
|
14
|
+
icon={iconArrowForwardUp}
|
|
15
|
+
title="Redo"
|
|
16
|
+
disabled={!editor.can().redo()}
|
|
17
|
+
onclick={() => editor.chain().focus().redo().run()}
|
|
18
|
+
/>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Editor } from '@tiptap/core'
|
|
3
|
+
import ToolbarButton from './ToolbarButton.svelte'
|
|
4
|
+
import { iconStrikethrough } from '../../../icon/index.js'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
editor: Editor
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
let { editor }: Props = $props()
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<ToolbarButton
|
|
14
|
+
icon={iconStrikethrough}
|
|
15
|
+
title="Strikethrough"
|
|
16
|
+
active={editor.isActive('strike')}
|
|
17
|
+
onclick={() => editor.chain().focus().toggleStrike().run()}
|
|
18
|
+
/>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/core';
|
|
2
|
+
interface Props {
|
|
3
|
+
editor: Editor;
|
|
4
|
+
}
|
|
5
|
+
declare const StrikethroughButton: import("svelte").Component<Props, {}, "">;
|
|
6
|
+
type StrikethroughButton = ReturnType<typeof StrikethroughButton>;
|
|
7
|
+
export default StrikethroughButton;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Editor } from '@tiptap/core'
|
|
3
|
+
import ToolbarButton from './ToolbarButton.svelte'
|
|
4
|
+
import { iconSubscript } from '../../../icon/index.js'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
editor: Editor
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
let { editor }: Props = $props()
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<ToolbarButton
|
|
14
|
+
icon={iconSubscript}
|
|
15
|
+
title="Subscript"
|
|
16
|
+
active={editor.isActive('subscript')}
|
|
17
|
+
onclick={() => editor.chain().focus().toggleSubscript().run()}
|
|
18
|
+
/>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Editor } from '@tiptap/core'
|
|
3
|
+
import ToolbarButton from './ToolbarButton.svelte'
|
|
4
|
+
import { iconSuperscript } from '../../../icon/index.js'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
editor: Editor
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
let { editor }: Props = $props()
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<ToolbarButton
|
|
14
|
+
icon={iconSuperscript}
|
|
15
|
+
title="Superscript"
|
|
16
|
+
active={editor.isActive('superscript')}
|
|
17
|
+
onclick={() => editor.chain().focus().toggleSuperscript().run()}
|
|
18
|
+
/>
|