mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-21 00:03:31 +00:00
* fix(frontend): restore heading sizes in note markdown and keep group notes on id change Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0182GroR5mvi9ksRTMmBT7nE * fix(frontend): scope the note cleanup deferral per note Address local review nits: the header comment overstated the heading ramp (h3 sits at body size in the xs and sm scales), and the mid-update deferral bailed out of cleanup for every group note rather than the one holding the unrendered module. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0182GroR5mvi9ksRTMmBT7nE * perf(frontend): traverse modules without collecting a discarded array Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0182GroR5mvi9ksRTMmBT7nE * test(frontend): show the three markdown prose presets in the kitchen sink The Markdown tab rendered only the default preset, so a change to the shared heading scale could not be compared across the surfaces that use it. The chat sample gains headings for the same reason: it is the only place the assistant bubble renders at panel width without an AI provider. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0182GroR5mvi9ksRTMmBT7nE * refactor(frontend): validate group notes against the flow, not the render A group note's members are module ids, so the flow's own module list decides whether one still exists. Validating against the rendered nodes instead needed a special case for collapsed groups, and still dropped a live module in the pass after its id changed. Both cases are the same mistake, and checking the source of truth removes them together with the collapsedModuleIds parameter. Path completion keeps working off the rendered graph, since it needs the edges, and now skips a note whose members it cannot all see rather than dropping them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0182GroR5mvi9ksRTMmBT7nE * fix(frontend): name a new note "Note", not after its internal type The prefill lands inside the user's own note, and "Free note" / "Group note" are the serialized type, not words anyone says about a note they just drew. The menus that create them already say "Add note". The heading goes to h2 as well: h3 computes to the body size in the note scale, so the prefill's own title did not read as one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0182GroR5mvi9ksRTMmBT7nE * docs(frontend): describe what collapsedModuleIds is still for Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0182GroR5mvi9ksRTMmBT7nE --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
134 lines
3.9 KiB
Svelte
134 lines
3.9 KiB
Svelte
<script lang="ts">
|
|
import { useSvelteFlow } from '@xyflow/svelte'
|
|
import { getOverlayHost } from '$lib/components/common/overlayHost.svelte'
|
|
import ConditionalPortal from '$lib/components/common/drawer/ConditionalPortal.svelte'
|
|
import { StickyNote } from 'lucide-svelte'
|
|
import { getNoteEditorContext } from './noteEditor.svelte'
|
|
import { DEFAULT_NOTE_COLOR } from './noteColors'
|
|
import { fly } from 'svelte/transition'
|
|
import {
|
|
getContextMenuContainerClass,
|
|
CONTEXT_MENU_ITEM_BASE_CLASS,
|
|
CONTEXT_MENU_ITEM_HOVER_CLASS
|
|
} from '../common/contextmenu/contextMenuStyles'
|
|
import { getGraphContext } from './graphContext'
|
|
|
|
interface Props {
|
|
editMode?: boolean
|
|
}
|
|
|
|
let { editMode = false }: Props = $props()
|
|
|
|
const { screenToFlowPosition } = useSvelteFlow()
|
|
const noteEditorContext = getNoteEditorContext()
|
|
|
|
const graphContext = getGraphContext()
|
|
|
|
let contextMenuVisible = $state(false)
|
|
let contextMenuPosition = $state<{ x: number; y: number }>({ x: 0, y: 0 })
|
|
let pendingFlowPosition = $state<{ x: number; y: number } | null>(null)
|
|
|
|
// Coordinates come from the pointer event, so they are viewport-relative. Inside a pane
|
|
// the menu is portalled into it and positioned against it, or its click-catcher would
|
|
// blanket the app chrome around it. The portal is what makes the pane the offset parent
|
|
// the coordinates are then rebased onto — this component otherwise renders inside the
|
|
// graph's `overflow-clip` box, which would both displace and clip the menu.
|
|
const overlayHost = getOverlayHost()
|
|
const hostEl = $derived(overlayHost?.el())
|
|
const posClass = $derived(hostEl ? 'absolute' : 'fixed')
|
|
const menuOrigin = $derived.by(() => {
|
|
const rect = contextMenuVisible ? hostEl?.getBoundingClientRect() : undefined
|
|
return { x: rect?.left ?? 0, y: rect?.top ?? 0 }
|
|
})
|
|
|
|
function handlePaneContextMenu(event: MouseEvent) {
|
|
// Only show context menu in edit mode
|
|
if (!editMode || !noteEditorContext?.noteEditor) {
|
|
return
|
|
}
|
|
|
|
event.preventDefault()
|
|
event.stopPropagation()
|
|
|
|
// Store screen coordinates for context menu positioning
|
|
contextMenuPosition = {
|
|
x: event.clientX,
|
|
y: event.clientY
|
|
}
|
|
|
|
// Convert to flow coordinates for note placement
|
|
pendingFlowPosition = screenToFlowPosition({
|
|
x: event.clientX,
|
|
y: event.clientY
|
|
})
|
|
|
|
contextMenuVisible = true
|
|
}
|
|
|
|
function handleAddStickyNote() {
|
|
if (noteEditorContext?.noteEditor && pendingFlowPosition) {
|
|
noteEditorContext.noteEditor.addNote({
|
|
text: '## Note\nDouble click to edit me',
|
|
position: {
|
|
x: pendingFlowPosition.x,
|
|
y: pendingFlowPosition.y - (graphContext?.yOffset || 0)
|
|
},
|
|
size: { width: 300, height: 200 },
|
|
color: DEFAULT_NOTE_COLOR,
|
|
type: 'free',
|
|
locked: false
|
|
})
|
|
}
|
|
contextMenuVisible = false
|
|
}
|
|
|
|
// Export the handler to be used by parent
|
|
export function onPaneContextMenu(event: MouseEvent) {
|
|
handlePaneContextMenu(event)
|
|
}
|
|
</script>
|
|
|
|
<ConditionalPortal condition={!!hostEl} target={hostEl} class="contents">
|
|
{#if contextMenuVisible}
|
|
<!-- Context menu -->
|
|
<div
|
|
class="{posClass} {getContextMenuContainerClass('z-[9999]')}"
|
|
style="left: {contextMenuPosition.x - menuOrigin.x}px; top: {contextMenuPosition.y -
|
|
menuOrigin.y}px;"
|
|
transition:fly={{ duration: 150, y: -10 }}
|
|
role="menu"
|
|
tabindex="-1"
|
|
onclick={(e) => {
|
|
e.stopPropagation()
|
|
}}
|
|
onkeydown={(e) => {
|
|
if (e.key === 'Escape') {
|
|
contextMenuVisible = false
|
|
}
|
|
}}
|
|
>
|
|
<button
|
|
class="{CONTEXT_MENU_ITEM_BASE_CLASS} {CONTEXT_MENU_ITEM_HOVER_CLASS}"
|
|
onclick={handleAddStickyNote}
|
|
type="button"
|
|
>
|
|
<StickyNote size={14} class="mr-2" />
|
|
<span>Add sticky note</span>
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Invisible click catcher to close context menu -->
|
|
<div
|
|
class="{posClass} inset-0 z-[9998]"
|
|
role="presentation"
|
|
onclick={() => {
|
|
contextMenuVisible = false
|
|
}}
|
|
oncontextmenu={(e) => {
|
|
e.preventDefault()
|
|
contextMenuVisible = false
|
|
}}
|
|
></div>
|
|
{/if}
|
|
</ConditionalPortal>
|