@flowdrop/flowdrop 1.0.1 → 1.2.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/README.md +50 -50
- package/dist/adapters/WorkflowAdapter.d.ts +1 -1
- package/dist/adapters/WorkflowAdapter.js +25 -25
- package/dist/adapters/agentspec/AgentSpecAdapter.d.ts +2 -2
- package/dist/adapters/agentspec/AgentSpecAdapter.js +133 -122
- package/dist/adapters/agentspec/agentAdapter.d.ts +2 -2
- package/dist/adapters/agentspec/agentAdapter.js +10 -10
- package/dist/adapters/agentspec/autoLayout.d.ts +1 -1
- package/dist/adapters/agentspec/autoLayout.js +2 -2
- package/dist/adapters/agentspec/componentTypeDefaults.d.ts +1 -1
- package/dist/adapters/agentspec/componentTypeDefaults.js +120 -120
- package/dist/adapters/agentspec/defaultNodeTypes.d.ts +2 -2
- package/dist/adapters/agentspec/defaultNodeTypes.js +307 -307
- package/dist/adapters/agentspec/index.d.ts +10 -10
- package/dist/adapters/agentspec/index.js +6 -6
- package/dist/adapters/agentspec/validator.d.ts +2 -2
- package/dist/adapters/agentspec/validator.js +22 -20
- package/dist/api/enhanced-client.d.ts +3 -3
- package/dist/api/enhanced-client.js +73 -72
- package/dist/components/App.svelte +1090 -961
- package/dist/components/App.svelte.d.ts +9 -6
- package/dist/components/CanvasBanner.stories.svelte +23 -20
- package/dist/components/CanvasBanner.stories.svelte.d.ts +1 -1
- package/dist/components/CanvasBanner.svelte +52 -46
- package/dist/components/ConfigForm.svelte +1164 -1065
- package/dist/components/ConfigForm.svelte.d.ts +2 -2
- package/dist/components/ConfigModal.svelte +180 -180
- package/dist/components/ConfigModal.svelte.d.ts +1 -1
- package/dist/components/ConfigPanel.stories.svelte +35 -35
- package/dist/components/ConfigPanel.stories.svelte.d.ts +1 -1
- package/dist/components/ConfigPanel.svelte +178 -167
- package/dist/components/ConfigPanel.svelte.d.ts +1 -1
- package/dist/components/ConnectionLine.svelte +25 -25
- package/dist/components/EdgeRefresher.svelte +26 -26
- package/dist/components/FlowDropEdge.stories.svelte +179 -143
- package/dist/components/FlowDropEdge.svelte +147 -147
- package/dist/components/FlowDropEdge.svelte.d.ts +1 -1
- package/dist/components/FlowDropZone.svelte +63 -60
- package/dist/components/FlowDropZone.svelte.d.ts +1 -1
- package/dist/components/LoadingSpinner.stories.svelte +19 -19
- package/dist/components/LoadingSpinner.stories.svelte.d.ts +1 -1
- package/dist/components/LoadingSpinner.svelte +21 -21
- package/dist/components/LoadingSpinner.svelte.d.ts +1 -1
- package/dist/components/Logo.stories.svelte +13 -13
- package/dist/components/Logo.stories.svelte.d.ts +1 -1
- package/dist/components/Logo.svelte +101 -95
- package/dist/components/LogsSidebar.svelte +553 -546
- package/dist/components/LogsSidebar.svelte.d.ts +1 -1
- package/dist/components/MarkdownDisplay.stories.svelte +29 -23
- package/dist/components/MarkdownDisplay.stories.svelte.d.ts +1 -1
- package/dist/components/MarkdownDisplay.svelte +16 -14
- package/dist/components/Navbar.stories.svelte +43 -38
- package/dist/components/Navbar.stories.svelte.d.ts +1 -1
- package/dist/components/Navbar.svelte +760 -706
- package/dist/components/Navbar.svelte.d.ts +1 -1
- package/dist/components/NodeSidebar.svelte +905 -746
- package/dist/components/NodeSidebar.svelte.d.ts +5 -1
- package/dist/components/NodeStatusOverlay.stories.svelte +82 -70
- package/dist/components/NodeStatusOverlay.stories.svelte.d.ts +1 -1
- package/dist/components/NodeStatusOverlay.svelte +295 -280
- package/dist/components/NodeStatusOverlay.svelte.d.ts +3 -3
- package/dist/components/PipelineStatus.svelte +326 -300
- package/dist/components/PipelineStatus.svelte.d.ts +4 -4
- package/dist/components/PortCoordinateTracker.svelte +49 -47
- package/dist/components/PortCoordinateTracker.svelte.d.ts +1 -1
- package/dist/components/ReadOnlyDetails.svelte +156 -156
- package/dist/components/SchemaForm.stories.svelte +106 -98
- package/dist/components/SchemaForm.stories.svelte.d.ts +1 -1
- package/dist/components/SchemaForm.svelte +490 -463
- package/dist/components/SchemaForm.svelte.d.ts +2 -2
- package/dist/components/SettingsModal.svelte +226 -223
- package/dist/components/SettingsModal.svelte.d.ts +1 -1
- package/dist/components/SettingsPanel.svelte +637 -601
- package/dist/components/SettingsPanel.svelte.d.ts +1 -1
- package/dist/components/StatusIcon.stories.svelte +62 -49
- package/dist/components/StatusIcon.stories.svelte.d.ts +1 -1
- package/dist/components/StatusIcon.svelte +87 -87
- package/dist/components/StatusIcon.svelte.d.ts +2 -2
- package/dist/components/StatusLabel.stories.svelte +12 -12
- package/dist/components/StatusLabel.stories.svelte.d.ts +1 -1
- package/dist/components/StatusLabel.svelte +19 -19
- package/dist/components/ThemeToggle.stories.svelte +16 -16
- package/dist/components/ThemeToggle.stories.svelte.d.ts +1 -1
- package/dist/components/ThemeToggle.svelte +180 -169
- package/dist/components/ThemeToggle.svelte.d.ts +1 -1
- package/dist/components/UniversalNode.svelte +150 -138
- package/dist/components/UniversalNode.svelte.d.ts +3 -3
- package/dist/components/WorkflowEditor.svelte +1069 -1014
- package/dist/components/WorkflowEditor.svelte.d.ts +4 -4
- package/dist/components/form/FormArray.svelte +1034 -973
- package/dist/components/form/FormArray.svelte.d.ts +1 -1
- package/dist/components/form/FormAutocomplete.svelte +1021 -978
- package/dist/components/form/FormAutocomplete.svelte.d.ts +1 -1
- package/dist/components/form/FormCheckboxGroup.stories.svelte +23 -20
- package/dist/components/form/FormCheckboxGroup.stories.svelte.d.ts +1 -1
- package/dist/components/form/FormCheckboxGroup.svelte +136 -136
- package/dist/components/form/FormCodeEditor.svelte +452 -434
- package/dist/components/form/FormField.svelte +366 -355
- package/dist/components/form/FormField.svelte.d.ts +2 -2
- package/dist/components/form/FormFieldLight.svelte +400 -384
- package/dist/components/form/FormFieldLight.svelte.d.ts +1 -1
- package/dist/components/form/FormFieldWrapper.stories.svelte +42 -42
- package/dist/components/form/FormFieldWrapper.stories.svelte.d.ts +1 -1
- package/dist/components/form/FormFieldWrapper.svelte +100 -93
- package/dist/components/form/FormFieldWrapper.svelte.d.ts +1 -1
- package/dist/components/form/FormFieldset.svelte +108 -108
- package/dist/components/form/FormFieldset.svelte.d.ts +2 -2
- package/dist/components/form/FormMarkdownEditor.svelte +758 -725
- package/dist/components/form/FormNumberField.stories.svelte +25 -25
- package/dist/components/form/FormNumberField.stories.svelte.d.ts +1 -1
- package/dist/components/form/FormNumberField.svelte +88 -88
- package/dist/components/form/FormRangeField.stories.svelte +20 -20
- package/dist/components/form/FormRangeField.stories.svelte.d.ts +1 -1
- package/dist/components/form/FormRangeField.svelte +234 -226
- package/dist/components/form/FormSelect.stories.svelte +38 -38
- package/dist/components/form/FormSelect.stories.svelte.d.ts +1 -1
- package/dist/components/form/FormSelect.svelte +101 -101
- package/dist/components/form/FormSelect.svelte.d.ts +1 -1
- package/dist/components/form/FormTemplateEditor.svelte +847 -798
- package/dist/components/form/FormTemplateEditor.svelte.d.ts +1 -1
- package/dist/components/form/FormTextField.stories.svelte +29 -23
- package/dist/components/form/FormTextField.stories.svelte.d.ts +1 -1
- package/dist/components/form/FormTextField.svelte +68 -68
- package/dist/components/form/FormTextarea.stories.svelte +28 -25
- package/dist/components/form/FormTextarea.stories.svelte.d.ts +1 -1
- package/dist/components/form/FormTextarea.svelte +74 -74
- package/dist/components/form/FormToggle.stories.svelte +23 -20
- package/dist/components/form/FormToggle.stories.svelte.d.ts +1 -1
- package/dist/components/form/FormToggle.svelte +98 -98
- package/dist/components/form/FormUISchemaRenderer.svelte +120 -113
- package/dist/components/form/FormUISchemaRenderer.svelte.d.ts +3 -3
- package/dist/components/form/index.d.ts +19 -19
- package/dist/components/form/index.js +18 -18
- package/dist/components/form/templateAutocomplete.d.ts +2 -2
- package/dist/components/form/templateAutocomplete.js +64 -55
- package/dist/components/form/types.d.ts +6 -6
- package/dist/components/form/types.js +9 -4
- package/dist/components/icons/AlertCircleIcon.svelte +11 -0
- package/dist/components/icons/AlertCircleIcon.svelte.d.ts +26 -0
- package/dist/components/icons/CogIcon.svelte +11 -0
- package/dist/components/icons/CogIcon.svelte.d.ts +26 -0
- package/dist/components/interrupt/ChoicePrompt.stories.svelte +54 -38
- package/dist/components/interrupt/ChoicePrompt.stories.svelte.d.ts +1 -1
- package/dist/components/interrupt/ChoicePrompt.svelte +407 -383
- package/dist/components/interrupt/ChoicePrompt.svelte.d.ts +1 -1
- package/dist/components/interrupt/ConfirmationPrompt.stories.svelte +48 -48
- package/dist/components/interrupt/ConfirmationPrompt.stories.svelte.d.ts +1 -1
- package/dist/components/interrupt/ConfirmationPrompt.svelte +280 -274
- package/dist/components/interrupt/ConfirmationPrompt.svelte.d.ts +1 -1
- package/dist/components/interrupt/FormPrompt.svelte +223 -218
- package/dist/components/interrupt/FormPrompt.svelte.d.ts +1 -1
- package/dist/components/interrupt/InterruptBubble.svelte +617 -583
- package/dist/components/interrupt/InterruptBubble.svelte.d.ts +2 -2
- package/dist/components/interrupt/ReviewPrompt.stories.svelte +66 -56
- package/dist/components/interrupt/ReviewPrompt.stories.svelte.d.ts +1 -1
- package/dist/components/interrupt/ReviewPrompt.svelte +861 -841
- package/dist/components/interrupt/ReviewPrompt.svelte.d.ts +1 -1
- package/dist/components/interrupt/TextInputPrompt.stories.svelte +38 -33
- package/dist/components/interrupt/TextInputPrompt.stories.svelte.d.ts +1 -1
- package/dist/components/interrupt/TextInputPrompt.svelte +333 -328
- package/dist/components/interrupt/TextInputPrompt.svelte.d.ts +1 -1
- package/dist/components/interrupt/index.d.ts +5 -5
- package/dist/components/interrupt/index.js +5 -5
- package/dist/components/layouts/MainLayout.svelte +724 -691
- package/dist/components/layouts/MainLayout.svelte.d.ts +6 -6
- package/dist/components/nodes/GatewayNode.stories.svelte +100 -99
- package/dist/components/nodes/GatewayNode.svelte +605 -571
- package/dist/components/nodes/GatewayNode.svelte.d.ts +3 -3
- package/dist/components/nodes/IdeaNode.stories.svelte +44 -43
- package/dist/components/nodes/IdeaNode.svelte +451 -437
- package/dist/components/nodes/IdeaNode.svelte.d.ts +1 -1
- package/dist/components/nodes/NotesNode.stories.svelte +65 -64
- package/dist/components/nodes/NotesNode.svelte +380 -369
- package/dist/components/nodes/NotesNode.svelte.d.ts +1 -1
- package/dist/components/nodes/SimpleNode.stories.svelte +145 -144
- package/dist/components/nodes/SimpleNode.svelte +486 -424
- package/dist/components/nodes/SimpleNode.svelte.d.ts +1 -1
- package/dist/components/nodes/SquareNode.stories.svelte +73 -73
- package/dist/components/nodes/SquareNode.svelte +439 -380
- package/dist/components/nodes/SquareNode.svelte.d.ts +1 -1
- package/dist/components/nodes/TerminalNode.stories.svelte +13 -13
- package/dist/components/nodes/TerminalNode.svelte +709 -670
- package/dist/components/nodes/TerminalNode.svelte.d.ts +1 -1
- package/dist/components/nodes/ToolNode.stories.svelte +181 -180
- package/dist/components/nodes/ToolNode.svelte +505 -447
- package/dist/components/nodes/ToolNode.svelte.d.ts +1 -1
- package/dist/components/nodes/WorkflowNode.stories.svelte +70 -46
- package/dist/components/nodes/WorkflowNode.svelte +621 -551
- package/dist/components/nodes/WorkflowNode.svelte.d.ts +3 -3
- package/dist/components/playground/ChatPanel.svelte +945 -889
- package/dist/components/playground/ExecutionLogs.svelte +495 -472
- package/dist/components/playground/InputCollector.svelte +449 -428
- package/dist/components/playground/MessageBubble.stories.svelte +47 -47
- package/dist/components/playground/MessageBubble.stories.svelte.d.ts +1 -1
- package/dist/components/playground/MessageBubble.svelte +626 -610
- package/dist/components/playground/MessageBubble.svelte.d.ts +1 -1
- package/dist/components/playground/Playground.svelte +1088 -1057
- package/dist/components/playground/Playground.svelte.d.ts +3 -3
- package/dist/components/playground/PlaygroundModal.svelte +208 -204
- package/dist/components/playground/PlaygroundModal.svelte.d.ts +3 -3
- package/dist/components/playground/SessionManager.svelte +527 -521
- package/dist/components/playground/SessionManager.svelte.d.ts +1 -1
- package/dist/config/agentSpecEndpoints.d.ts +1 -1
- package/dist/config/agentSpecEndpoints.js +20 -20
- package/dist/config/constants.js +2 -2
- package/dist/config/defaultCategories.d.ts +1 -1
- package/dist/config/defaultCategories.js +86 -86
- package/dist/config/defaultPortConfig.d.ts +1 -1
- package/dist/config/defaultPortConfig.js +144 -144
- package/dist/config/endpoints.d.ts +4 -4
- package/dist/config/endpoints.js +65 -65
- package/dist/config/runtimeConfig.d.ts +2 -2
- package/dist/config/runtimeConfig.js +8 -8
- package/dist/core/index.d.ts +63 -59
- package/dist/core/index.js +35 -33
- package/dist/display/index.d.ts +2 -2
- package/dist/display/index.js +2 -2
- package/dist/editor/index.d.ts +62 -62
- package/dist/editor/index.js +53 -53
- package/dist/form/code.d.ts +5 -5
- package/dist/form/code.js +14 -14
- package/dist/form/fieldRegistry.d.ts +3 -3
- package/dist/form/fieldRegistry.js +11 -9
- package/dist/form/full.d.ts +8 -8
- package/dist/form/full.js +9 -9
- package/dist/form/index.d.ts +18 -18
- package/dist/form/index.js +16 -16
- package/dist/form/markdown.d.ts +4 -4
- package/dist/form/markdown.js +8 -8
- package/dist/helpers/proximityConnect.d.ts +3 -3
- package/dist/helpers/proximityConnect.js +34 -32
- package/dist/helpers/workflowEditorHelper.d.ts +5 -5
- package/dist/helpers/workflowEditorHelper.js +108 -96
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/dist/mocks/app-environment.js +2 -2
- package/dist/mocks/app-forms.js +9 -9
- package/dist/mocks/app-navigation.js +11 -11
- package/dist/mocks/app-stores.js +8 -8
- package/dist/playground/index.d.ts +19 -19
- package/dist/playground/index.js +16 -16
- package/dist/playground/mount.d.ts +3 -3
- package/dist/playground/mount.js +24 -24
- package/dist/registry/builtinFormats.js +13 -13
- package/dist/registry/builtinNodes.d.ts +2 -2
- package/dist/registry/builtinNodes.js +77 -77
- package/dist/registry/index.d.ts +4 -4
- package/dist/registry/index.js +4 -4
- package/dist/registry/nodeComponentRegistry.d.ts +8 -8
- package/dist/registry/nodeComponentRegistry.js +11 -9
- package/dist/registry/plugin.d.ts +2 -2
- package/dist/registry/plugin.js +11 -11
- package/dist/registry/workflowFormatRegistry.d.ts +3 -3
- package/dist/registry/workflowFormatRegistry.js +2 -2
- package/dist/schema/index.d.ts +1 -1
- package/dist/schema/index.js +2 -2
- package/dist/services/agentSpecExecutionService.d.ts +3 -3
- package/dist/services/agentSpecExecutionService.js +59 -55
- package/dist/services/api.d.ts +2 -2
- package/dist/services/api.js +37 -37
- package/dist/services/apiVariableService.d.ts +1 -1
- package/dist/services/apiVariableService.js +41 -34
- package/dist/services/autoSaveService.js +8 -8
- package/dist/services/categoriesApi.d.ts +2 -2
- package/dist/services/categoriesApi.js +8 -8
- package/dist/services/draftStorage.d.ts +1 -1
- package/dist/services/draftStorage.js +11 -11
- package/dist/services/dynamicSchemaService.d.ts +1 -1
- package/dist/services/dynamicSchemaService.js +41 -39
- package/dist/services/globalSave.d.ts +2 -2
- package/dist/services/globalSave.js +41 -38
- package/dist/services/historyService.d.ts +1 -1
- package/dist/services/historyService.js +8 -8
- package/dist/services/interruptService.d.ts +1 -1
- package/dist/services/interruptService.js +35 -29
- package/dist/services/nodeExecutionService.d.ts +1 -1
- package/dist/services/nodeExecutionService.js +45 -44
- package/dist/services/playgroundService.d.ts +1 -1
- package/dist/services/playgroundService.js +29 -29
- package/dist/services/portConfigApi.d.ts +2 -2
- package/dist/services/portConfigApi.js +8 -8
- package/dist/services/settingsService.d.ts +2 -2
- package/dist/services/settingsService.js +25 -19
- package/dist/services/toastService.d.ts +4 -4
- package/dist/services/toastService.js +33 -33
- package/dist/services/variableService.d.ts +1 -1
- package/dist/services/variableService.js +36 -36
- package/dist/services/workflowStorage.d.ts +2 -2
- package/dist/services/workflowStorage.js +13 -13
- package/dist/settings/index.d.ts +7 -7
- package/dist/settings/index.js +6 -6
- package/dist/skins/default.d.ts +2 -0
- package/dist/skins/default.js +1 -0
- package/dist/skins/index.d.ts +13 -0
- package/dist/skins/index.js +30 -0
- package/dist/skins/slate.d.ts +2 -0
- package/dist/skins/slate.js +78 -0
- package/dist/stores/categoriesStore.svelte.d.ts +1 -1
- package/dist/stores/categoriesStore.svelte.js +5 -5
- package/dist/stores/editorStateMachine.svelte.d.ts +2 -2
- package/dist/stores/editorStateMachine.svelte.js +65 -33
- package/dist/stores/historyStore.svelte.d.ts +4 -4
- package/dist/stores/historyStore.svelte.js +4 -4
- package/dist/stores/interruptStore.svelte.d.ts +3 -3
- package/dist/stores/interruptStore.svelte.js +21 -21
- package/dist/stores/playgroundStore.svelte.d.ts +2 -2
- package/dist/stores/playgroundStore.svelte.js +25 -18
- package/dist/stores/portCoordinateStore.svelte.d.ts +2 -2
- package/dist/stores/portCoordinateStore.svelte.js +15 -8
- package/dist/stores/settingsStore.svelte.d.ts +2 -2
- package/dist/stores/settingsStore.svelte.js +62 -57
- package/dist/stores/workflowStore.svelte.d.ts +3 -3
- package/dist/stores/workflowStore.svelte.js +50 -47
- package/dist/stories/CanvasDecorator.svelte +35 -32
- package/dist/stories/CanvasDecorator.svelte.d.ts +2 -2
- package/dist/stories/EdgeDecorator.svelte +102 -99
- package/dist/stories/EdgeDecorator.svelte.d.ts +1 -1
- package/dist/stories/NodeDecorator.svelte +59 -53
- package/dist/stories/NodeDecorator.svelte.d.ts +1 -1
- package/dist/stories/utils.d.ts +2 -2
- package/dist/stories/utils.js +105 -67
- package/dist/styles/base.css +599 -595
- package/dist/styles/toast.css +14 -14
- package/dist/styles/tokens.css +409 -378
- package/dist/svelte-app.d.ts +12 -9
- package/dist/svelte-app.js +40 -39
- package/dist/themes/default.d.ts +2 -0
- package/dist/themes/default.js +9 -0
- package/dist/themes/index.d.ts +13 -0
- package/dist/themes/index.js +44 -0
- package/dist/themes/minimal.d.ts +2 -0
- package/dist/themes/minimal.js +11 -0
- package/dist/types/agentspec.d.ts +18 -18
- package/dist/types/agentspec.js +2 -2
- package/dist/types/auth.d.ts +1 -1
- package/dist/types/auth.js +6 -6
- package/dist/types/config.d.ts +6 -6
- package/dist/types/events.d.ts +2 -2
- package/dist/types/events.js +2 -2
- package/dist/types/index.d.ts +32 -32
- package/dist/types/index.js +6 -6
- package/dist/types/interrupt.d.ts +6 -6
- package/dist/types/interrupt.js +21 -21
- package/dist/types/interruptState.d.ts +12 -12
- package/dist/types/interruptState.js +66 -66
- package/dist/types/playground.d.ts +7 -7
- package/dist/types/playground.js +14 -14
- package/dist/types/settings.d.ts +5 -3
- package/dist/types/settings.js +25 -18
- package/dist/types/skin.d.ts +31 -0
- package/dist/types/skin.js +1 -0
- package/dist/types/theme.d.ts +35 -0
- package/dist/types/theme.js +1 -0
- package/dist/types/uischema.d.ts +4 -4
- package/dist/types/uischema.js +3 -3
- package/dist/utils/colors.d.ts +1 -1
- package/dist/utils/colors.js +97 -95
- package/dist/utils/config.d.ts +2 -2
- package/dist/utils/config.js +48 -48
- package/dist/utils/connections.d.ts +2 -2
- package/dist/utils/connections.js +15 -15
- package/dist/utils/errors.js +3 -3
- package/dist/utils/fetchWithAuth.d.ts +1 -1
- package/dist/utils/fetchWithAuth.js +2 -2
- package/dist/utils/handleIds.d.ts +2 -2
- package/dist/utils/handleIds.js +8 -8
- package/dist/utils/handlePositioning.d.ts +1 -1
- package/dist/utils/handlePositioning.js +2 -2
- package/dist/utils/icons.d.ts +1 -1
- package/dist/utils/icons.js +74 -74
- package/dist/utils/logger.d.ts +1 -1
- package/dist/utils/logger.js +7 -7
- package/dist/utils/nodeStatus.d.ts +1 -1
- package/dist/utils/nodeStatus.js +48 -48
- package/dist/utils/nodeTypes.d.ts +1 -1
- package/dist/utils/nodeTypes.js +21 -20
- package/dist/utils/nodeWrapper.d.ts +7 -7
- package/dist/utils/nodeWrapper.js +21 -19
- package/dist/utils/performanceUtils.d.ts +1 -1
- package/dist/utils/performanceUtils.js +2 -1
- package/dist/utils/sanitize.js +1 -1
- package/dist/utils/uischema.d.ts +2 -2
- package/dist/utils/uischema.js +8 -8
- package/dist/utils/validation.js +20 -8
- package/package.json +1 -1
|
@@ -17,736 +17,769 @@
|
|
|
17
17
|
-->
|
|
18
18
|
|
|
19
19
|
<script lang="ts">
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
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
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
20
|
+
import { onMount, onDestroy } from "svelte";
|
|
21
|
+
import {
|
|
22
|
+
EditorView,
|
|
23
|
+
lineNumbers,
|
|
24
|
+
drawSelection,
|
|
25
|
+
keymap,
|
|
26
|
+
} from "@codemirror/view";
|
|
27
|
+
import { EditorState, Compartment } from "@codemirror/state";
|
|
28
|
+
import {
|
|
29
|
+
history,
|
|
30
|
+
historyKeymap,
|
|
31
|
+
defaultKeymap,
|
|
32
|
+
indentWithTab,
|
|
33
|
+
} from "@codemirror/commands";
|
|
34
|
+
import { highlightSpecialChars, highlightActiveLine } from "@codemirror/view";
|
|
35
|
+
import {
|
|
36
|
+
syntaxHighlighting,
|
|
37
|
+
defaultHighlightStyle,
|
|
38
|
+
} from "@codemirror/language";
|
|
39
|
+
import { markdown } from "@codemirror/lang-markdown";
|
|
40
|
+
import { oneDark } from "@codemirror/theme-one-dark";
|
|
41
|
+
|
|
42
|
+
interface Props {
|
|
43
|
+
/** Field identifier */
|
|
44
|
+
id: string;
|
|
45
|
+
/** Current value (markdown string) */
|
|
46
|
+
value: string;
|
|
47
|
+
/** Placeholder text shown when empty */
|
|
48
|
+
placeholder?: string;
|
|
49
|
+
/** Whether the field is required */
|
|
50
|
+
required?: boolean;
|
|
51
|
+
/** Editor height - "auto" or specific value like "300px" */
|
|
52
|
+
height?: string;
|
|
53
|
+
/** Whether to show the toolbar */
|
|
54
|
+
showToolbar?: boolean;
|
|
55
|
+
/** Whether to show the status bar */
|
|
56
|
+
showStatusBar?: boolean;
|
|
57
|
+
/** Whether to enable spell checking */
|
|
58
|
+
spellChecker?: boolean;
|
|
59
|
+
/** Whether to enable autosave */
|
|
60
|
+
autosave?: boolean;
|
|
61
|
+
/** Autosave delay in milliseconds */
|
|
62
|
+
autosaveDelay?: number;
|
|
63
|
+
/** Whether the field is disabled (read-only) */
|
|
64
|
+
disabled?: boolean;
|
|
65
|
+
/** Whether to use dark theme */
|
|
66
|
+
darkTheme?: boolean;
|
|
67
|
+
/** ARIA description ID */
|
|
68
|
+
ariaDescribedBy?: string;
|
|
69
|
+
/** Callback when value changes */
|
|
70
|
+
onChange: (value: string) => void;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
let {
|
|
74
|
+
id,
|
|
75
|
+
value = "",
|
|
76
|
+
placeholder = "Write your markdown here...",
|
|
77
|
+
required = false,
|
|
78
|
+
height = "300px",
|
|
79
|
+
showToolbar = true,
|
|
80
|
+
showStatusBar = true,
|
|
81
|
+
spellChecker = false,
|
|
82
|
+
autosave = false,
|
|
83
|
+
autosaveDelay = 10000,
|
|
84
|
+
disabled = false,
|
|
85
|
+
darkTheme = false,
|
|
86
|
+
ariaDescribedBy,
|
|
87
|
+
onChange,
|
|
88
|
+
}: Props = $props();
|
|
89
|
+
|
|
90
|
+
/** Reference to the editor container element */
|
|
91
|
+
let containerRef: HTMLDivElement | undefined = $state(undefined);
|
|
92
|
+
|
|
93
|
+
/** CodeMirror editor instance */
|
|
94
|
+
let editorView: EditorView | undefined = $state(undefined);
|
|
95
|
+
|
|
96
|
+
/** Flag to prevent update loops */
|
|
97
|
+
let isInternalUpdate = false;
|
|
98
|
+
|
|
99
|
+
/** Flag to skip $effect when change originated from the editor */
|
|
100
|
+
let isEditorUpdate = false;
|
|
101
|
+
|
|
102
|
+
/** Status bar stats */
|
|
103
|
+
let wordCount = $state(0);
|
|
104
|
+
let lineCount = $state(0);
|
|
105
|
+
let charCount = $state(0);
|
|
106
|
+
|
|
107
|
+
/** Autosave timer */
|
|
108
|
+
let autosaveTimer: ReturnType<typeof setTimeout> | undefined;
|
|
109
|
+
|
|
110
|
+
/** Theme compartment for dynamic theme switching */
|
|
111
|
+
const themeCompartment = new Compartment();
|
|
112
|
+
|
|
113
|
+
// ── Toolbar actions ──────────────────────────────────────
|
|
114
|
+
|
|
115
|
+
type ToolbarAction = {
|
|
116
|
+
id: string;
|
|
117
|
+
label: string;
|
|
118
|
+
icon: string;
|
|
119
|
+
/** If true, icon is an SVG string rendered with {@html} */
|
|
120
|
+
isSvg?: boolean;
|
|
121
|
+
shortcut?: string;
|
|
122
|
+
action: () => void;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// Inline SVG icons (heroicons outline, 16x16)
|
|
126
|
+
const icons = {
|
|
127
|
+
link: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" width="16" height="16"><path d="M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"/><path d="M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"/></svg>',
|
|
128
|
+
image:
|
|
129
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" width="16" height="16"><path fill-rule="evenodd" d="M1 5.25A2.25 2.25 0 0 1 3.25 3h13.5A2.25 2.25 0 0 1 19 5.25v9.5A2.25 2.25 0 0 1 16.75 17H3.25A2.25 2.25 0 0 1 1 14.75v-9.5Zm1.5 5.81v3.69c0 .414.336.75.75.75h13.5a.75.75 0 0 0 .75-.75v-2.69l-2.22-2.219a.75.75 0 0 0-1.06 0l-1.91 1.909.47.47a.75.75 0 1 1-1.06 1.06L6.53 8.091a.75.75 0 0 0-1.06 0L2.5 11.06Zm6.5-3.31a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0Z" clip-rule="evenodd"/></svg>',
|
|
130
|
+
table:
|
|
131
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" width="16" height="16"><path fill-rule="evenodd" d="M.99 5.24A2.25 2.25 0 0 1 3.25 3h13.5A2.25 2.25 0 0 1 19 5.25v9.5A2.25 2.25 0 0 1 16.75 17H3.25A2.25 2.25 0 0 1 1 14.75v-9.5Zm8.26 4.51v3.75h1.5v-3.75h-1.5Zm1.5-1.5v-3.75h-1.5v3.75h1.5Zm-3-3.75H3.25a.75.75 0 0 0-.75.75v3h5.25v-3.75Zm-5.25 5.25v3.75c0 .414.336.75.75.75h4.5v-4.5H2.5Zm14.5 0h-5.25v4.5h4.5a.75.75 0 0 0 .75-.75v-3.75Zm0-1.5v-3a.75.75 0 0 0-.75-.75h-4.5v3.75H17Z" clip-rule="evenodd"/></svg>',
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
function wrapSelection(before: string, after: string) {
|
|
135
|
+
if (!editorView) return;
|
|
136
|
+
const { from, to } = editorView.state.selection.main;
|
|
137
|
+
const selected = editorView.state.sliceDoc(from, to);
|
|
138
|
+
const replacement = `${before}${selected || "text"}${after}`;
|
|
139
|
+
editorView.dispatch({
|
|
140
|
+
changes: { from, to, insert: replacement },
|
|
141
|
+
selection: {
|
|
142
|
+
anchor: selected ? from + before.length : from + before.length,
|
|
143
|
+
head: selected
|
|
144
|
+
? from + before.length + selected.length
|
|
145
|
+
: from + before.length + 4,
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
editorView.focus();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function prefixLine(prefix: string) {
|
|
152
|
+
if (!editorView) return;
|
|
153
|
+
const { from } = editorView.state.selection.main;
|
|
154
|
+
const line = editorView.state.doc.lineAt(from);
|
|
155
|
+
const currentText = line.text;
|
|
156
|
+
|
|
157
|
+
// If already has this prefix, remove it (toggle)
|
|
158
|
+
if (currentText.startsWith(prefix)) {
|
|
159
|
+
editorView.dispatch({
|
|
160
|
+
changes: { from: line.from, to: line.from + prefix.length, insert: "" },
|
|
161
|
+
});
|
|
162
|
+
} else {
|
|
163
|
+
// Remove any existing heading prefix before adding new one
|
|
164
|
+
const headingMatch = currentText.match(/^#{1,6}\s/);
|
|
165
|
+
const removeLen = headingMatch ? headingMatch[0].length : 0;
|
|
166
|
+
editorView.dispatch({
|
|
167
|
+
changes: { from: line.from, to: line.from + removeLen, insert: prefix },
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
editorView.focus();
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function insertAtCursor(text: string) {
|
|
174
|
+
if (!editorView) return;
|
|
175
|
+
const { from, to } = editorView.state.selection.main;
|
|
176
|
+
editorView.dispatch({
|
|
177
|
+
changes: { from, to, insert: text },
|
|
178
|
+
selection: { anchor: from + text.length },
|
|
179
|
+
});
|
|
180
|
+
editorView.focus();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const toolbarActions: (ToolbarAction | "|")[] = [
|
|
184
|
+
{
|
|
185
|
+
id: "bold",
|
|
186
|
+
label: "Bold",
|
|
187
|
+
icon: "B",
|
|
188
|
+
shortcut: "Mod-b",
|
|
189
|
+
action: () => wrapSelection("**", "**"),
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
id: "italic",
|
|
193
|
+
label: "Italic",
|
|
194
|
+
icon: "I",
|
|
195
|
+
shortcut: "Mod-i",
|
|
196
|
+
action: () => wrapSelection("_", "_"),
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
id: "strikethrough",
|
|
200
|
+
label: "Strikethrough",
|
|
201
|
+
icon: "S",
|
|
202
|
+
action: () => wrapSelection("~~", "~~"),
|
|
203
|
+
},
|
|
204
|
+
"|",
|
|
205
|
+
{
|
|
206
|
+
id: "heading-1",
|
|
207
|
+
label: "Heading 1",
|
|
208
|
+
icon: "H1",
|
|
209
|
+
action: () => prefixLine("# "),
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
id: "heading-2",
|
|
213
|
+
label: "Heading 2",
|
|
214
|
+
icon: "H2",
|
|
215
|
+
action: () => prefixLine("## "),
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
id: "heading-3",
|
|
219
|
+
label: "Heading 3",
|
|
220
|
+
icon: "H3",
|
|
221
|
+
action: () => prefixLine("### "),
|
|
222
|
+
},
|
|
223
|
+
"|",
|
|
224
|
+
{
|
|
225
|
+
id: "quote",
|
|
226
|
+
label: "Quote",
|
|
227
|
+
icon: '"',
|
|
228
|
+
action: () => prefixLine("> "),
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
id: "unordered-list",
|
|
232
|
+
label: "Unordered List",
|
|
233
|
+
icon: "•",
|
|
234
|
+
action: () => prefixLine("- "),
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
id: "ordered-list",
|
|
238
|
+
label: "Ordered List",
|
|
239
|
+
icon: "1.",
|
|
240
|
+
action: () => prefixLine("1. "),
|
|
241
|
+
},
|
|
242
|
+
"|",
|
|
243
|
+
{
|
|
244
|
+
id: "link",
|
|
245
|
+
label: "Link",
|
|
246
|
+
icon: icons.link,
|
|
247
|
+
isSvg: true,
|
|
248
|
+
shortcut: "Mod-k",
|
|
249
|
+
action: () => {
|
|
250
|
+
if (!editorView) return;
|
|
251
|
+
const { from, to } = editorView.state.selection.main;
|
|
252
|
+
const selected = editorView.state.sliceDoc(from, to);
|
|
253
|
+
const text = selected || "link text";
|
|
254
|
+
const replacement = `[${text}](url)`;
|
|
255
|
+
editorView.dispatch({
|
|
256
|
+
changes: { from, to, insert: replacement },
|
|
257
|
+
selection: {
|
|
258
|
+
anchor: from + text.length + 3,
|
|
259
|
+
head: from + text.length + 6,
|
|
260
|
+
},
|
|
261
|
+
});
|
|
262
|
+
editorView.focus();
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
id: "image",
|
|
267
|
+
label: "Image",
|
|
268
|
+
icon: icons.image,
|
|
269
|
+
isSvg: true,
|
|
270
|
+
action: () => insertAtCursor(""),
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
id: "table",
|
|
274
|
+
label: "Table",
|
|
275
|
+
icon: icons.table,
|
|
276
|
+
isSvg: true,
|
|
277
|
+
action: () =>
|
|
278
|
+
insertAtCursor(
|
|
279
|
+
"\n| Header | Header |\n| ------ | ------ |\n| Cell | Cell |\n",
|
|
280
|
+
),
|
|
281
|
+
},
|
|
282
|
+
];
|
|
283
|
+
|
|
284
|
+
// ── CM6 Keyboard shortcuts for toolbar actions ───────────
|
|
285
|
+
|
|
286
|
+
function createToolbarKeymap() {
|
|
287
|
+
return keymap.of([
|
|
288
|
+
{
|
|
289
|
+
key: "Mod-b",
|
|
290
|
+
run: () => {
|
|
291
|
+
wrapSelection("**", "**");
|
|
292
|
+
return true;
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
key: "Mod-i",
|
|
297
|
+
run: () => {
|
|
298
|
+
wrapSelection("_", "_");
|
|
299
|
+
return true;
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
key: "Mod-k",
|
|
304
|
+
run: () => {
|
|
305
|
+
const action = toolbarActions.find(
|
|
306
|
+
(a) => a !== "|" && a.id === "link",
|
|
307
|
+
);
|
|
308
|
+
if (action && action !== "|") action.action();
|
|
309
|
+
return true;
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
key: "Mod-h",
|
|
314
|
+
run: () => {
|
|
315
|
+
prefixLine("## ");
|
|
316
|
+
return true;
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
key: "Mod-'",
|
|
321
|
+
run: () => {
|
|
322
|
+
prefixLine("> ");
|
|
323
|
+
return true;
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
key: "Mod-l",
|
|
328
|
+
run: () => {
|
|
329
|
+
prefixLine("- ");
|
|
330
|
+
return true;
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
]);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// ── Stats computation ────────────────────────────────────
|
|
337
|
+
|
|
338
|
+
function updateStats(doc: { toString: () => string; lines: number }) {
|
|
339
|
+
const text = doc.toString();
|
|
340
|
+
charCount = text.length;
|
|
341
|
+
lineCount = doc.lines;
|
|
342
|
+
const trimmed = text.trim();
|
|
343
|
+
wordCount = trimmed ? trimmed.split(/\s+/).length : 0;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// ── Editor setup ─────────────────────────────────────────
|
|
347
|
+
|
|
348
|
+
function createExtensions() {
|
|
349
|
+
const extensions = [
|
|
350
|
+
lineNumbers(),
|
|
351
|
+
highlightSpecialChars(),
|
|
352
|
+
highlightActiveLine(),
|
|
353
|
+
drawSelection(),
|
|
354
|
+
|
|
355
|
+
// Editing features (skip when read-only)
|
|
356
|
+
...(disabled
|
|
357
|
+
? [EditorState.readOnly.of(true), EditorView.editable.of(false)]
|
|
358
|
+
: [
|
|
359
|
+
history(),
|
|
360
|
+
keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab]),
|
|
361
|
+
createToolbarKeymap(),
|
|
362
|
+
]),
|
|
363
|
+
|
|
364
|
+
// Theme
|
|
365
|
+
themeCompartment.of(
|
|
366
|
+
darkTheme
|
|
367
|
+
? oneDark
|
|
368
|
+
: syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
|
|
369
|
+
),
|
|
370
|
+
|
|
371
|
+
// Markdown language support
|
|
372
|
+
markdown(),
|
|
373
|
+
|
|
374
|
+
// Update listener
|
|
375
|
+
EditorView.updateListener.of((update) => {
|
|
376
|
+
if (!update.docChanged || isInternalUpdate) return;
|
|
377
|
+
|
|
378
|
+
const content = update.state.doc.toString();
|
|
379
|
+
isEditorUpdate = true;
|
|
380
|
+
onChange(content);
|
|
381
|
+
|
|
382
|
+
updateStats(update.state.doc);
|
|
383
|
+
|
|
384
|
+
// Autosave
|
|
385
|
+
if (autosave) {
|
|
386
|
+
clearTimeout(autosaveTimer);
|
|
387
|
+
autosaveTimer = setTimeout(() => {
|
|
388
|
+
try {
|
|
389
|
+
localStorage.setItem(`flowdrop-markdown-${id}`, content);
|
|
390
|
+
} catch {
|
|
391
|
+
// localStorage may be full or unavailable
|
|
392
|
+
}
|
|
393
|
+
}, autosaveDelay);
|
|
394
|
+
}
|
|
395
|
+
}),
|
|
396
|
+
|
|
397
|
+
// Custom theme
|
|
398
|
+
EditorView.theme({
|
|
399
|
+
"&": {
|
|
400
|
+
height: height,
|
|
401
|
+
fontSize: "var(--fd-text-sm, 0.8125rem)",
|
|
402
|
+
fontFamily:
|
|
403
|
+
"'JetBrains Mono', 'Fira Code', 'Monaco', 'Menlo', monospace",
|
|
404
|
+
},
|
|
405
|
+
".cm-scroller": {
|
|
406
|
+
overflow: "auto",
|
|
407
|
+
},
|
|
408
|
+
".cm-content": {
|
|
409
|
+
minHeight: "100px",
|
|
410
|
+
padding: "0.5rem 0",
|
|
411
|
+
},
|
|
412
|
+
"&.cm-focused": {
|
|
413
|
+
outline: "none",
|
|
414
|
+
},
|
|
415
|
+
}),
|
|
416
|
+
EditorView.lineWrapping,
|
|
417
|
+
|
|
418
|
+
// Accessibility
|
|
419
|
+
EditorView.contentAttributes.of({
|
|
420
|
+
"aria-label": "Markdown editor",
|
|
421
|
+
"aria-multiline": "true",
|
|
422
|
+
}),
|
|
423
|
+
];
|
|
424
|
+
|
|
425
|
+
return extensions;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
onMount(() => {
|
|
429
|
+
if (!containerRef) return;
|
|
430
|
+
|
|
431
|
+
// Load autosaved content if available
|
|
432
|
+
let initialContent = value;
|
|
433
|
+
if (autosave) {
|
|
434
|
+
try {
|
|
435
|
+
const saved = localStorage.getItem(`flowdrop-markdown-${id}`);
|
|
436
|
+
if (saved !== null) {
|
|
437
|
+
initialContent = saved;
|
|
438
|
+
onChange(saved);
|
|
439
|
+
}
|
|
440
|
+
} catch {
|
|
441
|
+
// localStorage unavailable
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
editorView = new EditorView({
|
|
446
|
+
state: EditorState.create({
|
|
447
|
+
doc: initialContent,
|
|
448
|
+
extensions: createExtensions(),
|
|
449
|
+
}),
|
|
450
|
+
parent: containerRef,
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
updateStats(editorView.state.doc);
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
onDestroy(() => {
|
|
457
|
+
if (autosaveTimer) clearTimeout(autosaveTimer);
|
|
458
|
+
if (editorView) editorView.destroy();
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Update editor content when value prop changes externally
|
|
463
|
+
*/
|
|
464
|
+
$effect(() => {
|
|
465
|
+
if (!editorView) return;
|
|
466
|
+
|
|
467
|
+
// Skip if the change originated from the editor itself
|
|
468
|
+
if (isEditorUpdate) {
|
|
469
|
+
isEditorUpdate = false;
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
const currentContent = editorView.state.doc.toString();
|
|
474
|
+
if (value !== currentContent && !isInternalUpdate) {
|
|
475
|
+
isInternalUpdate = true;
|
|
476
|
+
editorView.dispatch({
|
|
477
|
+
changes: {
|
|
478
|
+
from: 0,
|
|
479
|
+
to: editorView.state.doc.length,
|
|
480
|
+
insert: value,
|
|
481
|
+
},
|
|
482
|
+
});
|
|
483
|
+
isInternalUpdate = false;
|
|
484
|
+
updateStats(editorView.state.doc);
|
|
485
|
+
}
|
|
486
|
+
});
|
|
465
487
|
</script>
|
|
466
488
|
|
|
467
489
|
<div
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
490
|
+
class="form-markdown-editor"
|
|
491
|
+
class:form-markdown-editor--dark={darkTheme}
|
|
492
|
+
style="--editor-height: {height}"
|
|
471
493
|
>
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
494
|
+
<!-- Hidden input for form submission compatibility -->
|
|
495
|
+
<input
|
|
496
|
+
type="hidden"
|
|
497
|
+
{id}
|
|
498
|
+
name={id}
|
|
499
|
+
{value}
|
|
500
|
+
aria-describedby={ariaDescribedBy}
|
|
501
|
+
aria-required={required}
|
|
502
|
+
/>
|
|
503
|
+
|
|
504
|
+
<!-- Toolbar -->
|
|
505
|
+
{#if showToolbar && !disabled}
|
|
506
|
+
<div
|
|
507
|
+
class="form-markdown-editor__toolbar"
|
|
508
|
+
role="toolbar"
|
|
509
|
+
aria-label="Markdown formatting"
|
|
510
|
+
>
|
|
511
|
+
{#each toolbarActions as item}
|
|
512
|
+
{#if item === "|"}
|
|
513
|
+
<span class="form-markdown-editor__separator"></span>
|
|
514
|
+
{:else}
|
|
515
|
+
<button
|
|
516
|
+
type="button"
|
|
517
|
+
class="form-markdown-editor__btn"
|
|
518
|
+
title="{item.label}{item.shortcut
|
|
519
|
+
? ` (${item.shortcut.replace('Mod', '⌘')})`
|
|
520
|
+
: ''}"
|
|
521
|
+
onclick={item.action}
|
|
522
|
+
>
|
|
523
|
+
{#if item.isSvg}
|
|
524
|
+
<span class="form-markdown-editor__btn-svg"
|
|
525
|
+
>{@html item.icon}</span
|
|
526
|
+
>
|
|
527
|
+
{:else}
|
|
528
|
+
<span
|
|
529
|
+
class="form-markdown-editor__btn-icon"
|
|
530
|
+
class:form-markdown-editor__btn-icon--bold={item.id === "bold"}
|
|
531
|
+
class:form-markdown-editor__btn-icon--italic={item.id ===
|
|
532
|
+
"italic"}
|
|
533
|
+
class:form-markdown-editor__btn-icon--strike={item.id ===
|
|
534
|
+
"strikethrough"}>{item.icon}</span
|
|
535
|
+
>
|
|
536
|
+
{/if}
|
|
537
|
+
</button>
|
|
538
|
+
{/if}
|
|
539
|
+
{/each}
|
|
540
|
+
</div>
|
|
541
|
+
{/if}
|
|
542
|
+
|
|
543
|
+
<!-- CodeMirror container -->
|
|
544
|
+
<div bind:this={containerRef} class="form-markdown-editor__body"></div>
|
|
545
|
+
|
|
546
|
+
<!-- Status bar -->
|
|
547
|
+
{#if showStatusBar}
|
|
548
|
+
<div class="form-markdown-editor__status">
|
|
549
|
+
<span>words: {wordCount}</span>
|
|
550
|
+
<span>lines: {lineCount}</span>
|
|
551
|
+
<span>characters: {charCount}</span>
|
|
552
|
+
</div>
|
|
553
|
+
{/if}
|
|
523
554
|
</div>
|
|
524
555
|
|
|
525
556
|
<style>
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
557
|
+
.form-markdown-editor {
|
|
558
|
+
position: relative;
|
|
559
|
+
width: 100%;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/* ── Toolbar ───────────────────────────────────── */
|
|
563
|
+
|
|
564
|
+
.form-markdown-editor__toolbar {
|
|
565
|
+
display: flex;
|
|
566
|
+
align-items: center;
|
|
567
|
+
gap: 0.125rem;
|
|
568
|
+
border: 1px solid var(--fd-border);
|
|
569
|
+
border-bottom: none;
|
|
570
|
+
border-radius: var(--fd-radius-lg) var(--fd-radius-lg) 0 0;
|
|
571
|
+
background-color: var(--fd-subtle);
|
|
572
|
+
padding: 0.375rem 0.5rem;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
.form-markdown-editor__btn {
|
|
576
|
+
display: flex;
|
|
577
|
+
align-items: center;
|
|
578
|
+
justify-content: center;
|
|
579
|
+
width: 2rem;
|
|
580
|
+
height: 2rem;
|
|
581
|
+
border: none;
|
|
582
|
+
border-radius: var(--fd-radius-md);
|
|
583
|
+
background: none;
|
|
584
|
+
color: var(--fd-muted-foreground);
|
|
585
|
+
cursor: pointer;
|
|
586
|
+
font-size: 0.8125rem;
|
|
587
|
+
transition: all var(--fd-transition-fast);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
.form-markdown-editor__btn:hover {
|
|
591
|
+
background-color: var(--fd-border);
|
|
592
|
+
color: var(--fd-foreground);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
.form-markdown-editor__btn-icon--bold {
|
|
596
|
+
font-weight: 700;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
.form-markdown-editor__btn-icon--italic {
|
|
600
|
+
font-style: italic;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
.form-markdown-editor__btn-icon--strike {
|
|
604
|
+
text-decoration: line-through;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
.form-markdown-editor__btn-svg {
|
|
608
|
+
display: flex;
|
|
609
|
+
align-items: center;
|
|
610
|
+
justify-content: center;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
.form-markdown-editor__separator {
|
|
614
|
+
width: 1px;
|
|
615
|
+
height: 1.25rem;
|
|
616
|
+
background-color: var(--fd-border-strong);
|
|
617
|
+
margin: 0 0.25rem;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/* ── Editor body ───────────────────────────────── */
|
|
621
|
+
|
|
622
|
+
.form-markdown-editor__body {
|
|
623
|
+
border: 1px solid var(--fd-border);
|
|
624
|
+
border-radius: var(--fd-radius-lg);
|
|
625
|
+
overflow: hidden;
|
|
626
|
+
background-color: var(--fd-muted);
|
|
627
|
+
transition: border-color var(--fd-transition-normal);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/* When toolbar is present, remove top radius */
|
|
631
|
+
.form-markdown-editor__toolbar + .form-markdown-editor__body {
|
|
632
|
+
border-top: none;
|
|
633
|
+
border-radius: 0;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
.form-markdown-editor__body:hover {
|
|
637
|
+
border-color: var(--fd-border-strong);
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
.form-markdown-editor__body:focus-within {
|
|
641
|
+
border-color: var(--fd-primary);
|
|
642
|
+
background-color: var(--fd-background);
|
|
643
|
+
box-shadow:
|
|
644
|
+
0 0 0 3px var(--fd-primary-muted),
|
|
645
|
+
var(--fd-shadow-sm);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/* ── Status bar ────────────────────────────────── */
|
|
649
|
+
|
|
650
|
+
.form-markdown-editor__status {
|
|
651
|
+
display: flex;
|
|
652
|
+
gap: 1rem;
|
|
653
|
+
justify-content: flex-end;
|
|
654
|
+
border: 1px solid var(--fd-border);
|
|
655
|
+
border-top: none;
|
|
656
|
+
border-radius: 0 0 var(--fd-radius-lg) var(--fd-radius-lg);
|
|
657
|
+
background-color: var(--fd-muted);
|
|
658
|
+
padding: 0.375rem 0.75rem;
|
|
659
|
+
font-size: var(--fd-text-xs);
|
|
660
|
+
color: var(--fd-muted-foreground);
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/* When no toolbar, body gets top radius */
|
|
664
|
+
.form-markdown-editor:not(:has(.form-markdown-editor__toolbar))
|
|
665
|
+
.form-markdown-editor__body {
|
|
666
|
+
border-radius: var(--fd-radius-lg) var(--fd-radius-lg) 0 0;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
/* When no status bar, body gets bottom radius */
|
|
670
|
+
.form-markdown-editor:not(:has(.form-markdown-editor__status))
|
|
671
|
+
.form-markdown-editor__body {
|
|
672
|
+
border-radius: 0 0 var(--fd-radius-lg) var(--fd-radius-lg);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/* When no toolbar AND no status bar, body gets full radius */
|
|
676
|
+
.form-markdown-editor:not(:has(.form-markdown-editor__toolbar)):not(
|
|
677
|
+
:has(.form-markdown-editor__status)
|
|
678
|
+
)
|
|
679
|
+
.form-markdown-editor__body {
|
|
680
|
+
border-radius: var(--fd-radius-lg);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/* ── CM6 overrides ─────────────────────────────── */
|
|
684
|
+
/* Design tokens (--fd-*) auto-resolve for dark mode via [data-theme='dark'] */
|
|
685
|
+
/* !important needed to override oneDark's JS-injected styles */
|
|
686
|
+
|
|
687
|
+
.form-markdown-editor__body :global(.cm-editor) {
|
|
688
|
+
height: var(--editor-height, 300px);
|
|
689
|
+
background-color: var(--fd-muted) !important;
|
|
690
|
+
color: var(--fd-foreground) !important;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
.form-markdown-editor__body :global(.cm-scroller) {
|
|
694
|
+
overflow: auto;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
.form-markdown-editor__body :global(.cm-content) {
|
|
698
|
+
color: var(--fd-foreground) !important;
|
|
699
|
+
caret-color: var(--fd-foreground) !important;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
.form-markdown-editor__body :global(.cm-line) {
|
|
703
|
+
color: var(--fd-foreground) !important;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
.form-markdown-editor__body :global(.cm-gutters) {
|
|
707
|
+
background-color: var(--fd-subtle) !important;
|
|
708
|
+
border-right: 1px solid var(--fd-border);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
.form-markdown-editor__body :global(.cm-linenumber) {
|
|
712
|
+
color: var(--fd-muted-foreground) !important;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
.form-markdown-editor__body :global(.cm-cursor) {
|
|
716
|
+
border-left-color: var(--fd-muted-foreground) !important;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
.form-markdown-editor__body :global(.cm-activeLine) {
|
|
720
|
+
background-color: var(--fd-subtle) !important;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
.form-markdown-editor__body :global(.cm-activeLineGutter) {
|
|
724
|
+
background-color: var(--fd-subtle) !important;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/* ── Markdown syntax styling ───────────────────── */
|
|
728
|
+
|
|
729
|
+
.form-markdown-editor__body :global(.cm-header-1) {
|
|
730
|
+
font-size: 1.25rem;
|
|
731
|
+
line-height: 1.4;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
.form-markdown-editor__body :global(.cm-header-2) {
|
|
735
|
+
font-size: 1.125rem;
|
|
736
|
+
line-height: 1.4;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
.form-markdown-editor__body :global(.cm-header-3) {
|
|
740
|
+
font-size: 1rem;
|
|
741
|
+
line-height: 1.4;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
.form-markdown-editor__body :global(.cm-header) {
|
|
745
|
+
font-weight: 600;
|
|
746
|
+
color: var(--fd-foreground) !important;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
.form-markdown-editor__body :global(.cm-processingInstruction) {
|
|
750
|
+
color: var(--fd-success) !important;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
.form-markdown-editor__body :global(.cm-emphasis) {
|
|
754
|
+
color: var(--fd-foreground) !important;
|
|
755
|
+
font-style: italic;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
.form-markdown-editor__body :global(.cm-strong) {
|
|
759
|
+
color: var(--fd-foreground) !important;
|
|
760
|
+
font-weight: 700;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
.form-markdown-editor__body :global(.cm-strikethrough) {
|
|
764
|
+
color: var(--fd-muted-foreground) !important;
|
|
765
|
+
text-decoration: line-through;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
.form-markdown-editor__body :global(.cm-url) {
|
|
769
|
+
color: var(--fd-primary) !important;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
.form-markdown-editor__body :global(.cm-link) {
|
|
773
|
+
color: var(--fd-primary) !important;
|
|
774
|
+
text-decoration: underline;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
.form-markdown-editor__body :global(.cm-meta) {
|
|
778
|
+
color: var(--fd-muted-foreground) !important;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
.form-markdown-editor__body :global(.cm-quote) {
|
|
782
|
+
color: var(--fd-success) !important;
|
|
783
|
+
font-style: italic;
|
|
784
|
+
}
|
|
752
785
|
</style>
|