Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions src/SliceSimulator.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import type { SliceZone } from "@prismicio/client";
import {
SimulatorManager,
StateEventType,
Expand All @@ -10,14 +11,27 @@
simulatorClass,
simulatorRootClass,
} from "@prismicio/simulator/kit";
import type { Snippet } from "svelte";
import type { ClassValue } from "svelte/elements";

const defaultProps = getDefaultProps();

export let zIndex = defaultProps.zIndex;
export let background = defaultProps.background;
type Props = {
zIndex?: number;
background?: string;
class?: ClassValue;
children: Snippet<[{ slices: SliceZone }]>;
};

let slices = getDefaultSlices();
let message = getDefaultMessage();
const {
zIndex = defaultProps.zIndex,
background = defaultProps.background,
class: classes,
children,
}: Props = $props();

let slices = $state(getDefaultSlices());
let message = $state(getDefaultMessage());

if (typeof window !== "undefined") {
const simulatorManager = new SimulatorManager();
Expand All @@ -42,7 +56,7 @@
</script>

<div
class="{simulatorClass} {$$props.class}"
class={[simulatorClass, classes]}
style="z-index: {zIndex}; position: fixed; top: 0; left: 0; width: 100%; height: 100vh; overflow: auto; background: {background}"
>
{#if message}
Expand All @@ -51,15 +65,15 @@
{@html message}
</article>
{:else if slices.length}
<!-- svelte-ignore a11y-no-static-element-interactions -->
<!-- svelte-ignore a11y_no_static_element_interactions, event_directive_deprecated -->

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary event_directive_deprecated svelte-ignore for new syntax

Low Severity

The event_directive_deprecated svelte-ignore directive was newly added in this PR, but it's unnecessary. This warning only fires when using the old on:click syntax — the code already uses the new onclick/onsubmit/onkeypress attributes (lines 72–74), so the warning will never trigger. The stale ignore directive is misleading and suggests the old syntax is still in use.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e71dd15. Configure here.

<div
id="root"
class={simulatorRootClass}
on:click={onClickHandler}
on:submit={disableEventHandler}
on:keypress={disableEventHandler}
onclick={onClickHandler}
onsubmit={disableEventHandler}
onkeypress={disableEventHandler}
>
<slot {slices} />
{@render children({ slices })}
</div>
{/if}
</div>
8 changes: 6 additions & 2 deletions test/PrismicLinkTestWrapper.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ passing slot content to the PrismicLink component is not easy in tests.

import { PrismicLink } from "../src";

export let field: FilledLinkToWebField;
export let children: string | undefined = undefined;
type Props = {
field: FilledLinkToWebField;
children?: string;
};

const { field, children }: Props = $props();
</script>

{#if children}
Expand Down