Webflow editor integration

From vallafederico/webflow-dev-setup · View interactive version

Webflow editor integration is an AI agent skill from the GitHub repository vallafederico/webflow-dev-setup. Handle Webflow Designer/Editor mode vs Published site behavior. Use when detecting the editor, disabling custom animations in the designer, or managing features based on the environment.

How to use this skill

Skill file

Webflow Editor Integration

This skill explains how to ensure your custom code doesn't interfere with the Webflow Designer/Editor while providing full functionality on the published site.

Editor Detection

Import onEditor from @/modules/_. It calls your function now and again whenever the editor state changes, and releases its listener in onDestroy:

import { onEditor } from "@/modules/_";

export default function (element: HTMLElement, dataset: DOMStringMap) {
  onEditor((isEditor) => {
    if (isEditor) {
      // Logic for Webflow Designer (Editor)
      element.classList.add("is-editor");
      element.style.pointerEvents = "none"; // Avoid blocking clicks in Designer
      // Reset any transforms or opacity applied by custom JS
      element.style.transform = "none";
      element.style.opacity = "1";
    } else {
      // Logic for Published Site
      element.classList.remove("is-editor");
      element.style.pointerEvents = "auto";
    }
  });
}

Don't call handleEditor from @webflow/detect-editor in a module: it has no release, so the listener outlives the page. onEditor wraps it. handleEditor is for library code such as src/lib/scroll.ts.

House rule: `editor/handled`

A module that calls Raf.add, onView, new SplitText or an animating GSAP method (gsap.to, gsap.timeline, ...) must also call onEditor, or pnpm check fails. Scroll and onTrack are exempt, because src/lib/scroll.ts already stops Lenis in the editor. The rule only checks that onEditor is called, so make the callback do the work. See House Rules.

Best Practices

Example: Conditional Viewport Detection

onView doesn't start observing until you call start() (or pass autoStart: true), so the editor callback can switch it on and off:

const observer = onView(element, {
  callback: ({ isIn }) => {
    element.classList.toggle("animate-in", isIn);
  },
});

onEditor((isEditor) => {
  if (isEditor) {
    observer.stop();
    element.classList.remove("animate-in");
  } else {
    observer.start();
  }
});
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.