AFFiNE icon indicating copy to clipboard operation
AFFiNE copied to clipboard

Programmable Widgets and Custom Code Blocks (like Notion Widgets)

Open ghost opened this issue 1 month ago • 2 comments

Description

I’d love to see support for programmable widgets and custom scripting/code blocks inside AFFiNE pages — similar to Notion widgets or Obsidian’s Templater / Dataview plugins.

💡 What this feature does

Enables users to create and embed interactive blocks (like timers, calculators, counters, or custom logic apps) using a sandboxed scripting environment — ideally based on TypeScript or JavaScript.

⚙️ How it could work

  • 🧱 Add a new Custom Block Type that supports embedded script execution (TypeScript sandbox).
  • 🎨 Allow defining inputs/outputs (buttons, sliders, text, graphs, etc.).
  • 🔄 Logic and state should sync via OctoBase and CRDT (Yjs) just like any normal AFFiNE document data.
  • 🧰 Optionally introduce a Widget Gallery where community-created widgets can be shared, imported, and reused.
  • 🔒 Ensure execution in a secure sandbox (e.g., QuickJS / Web Worker) for safety and performance.

🧮 Example Widgets

  • Timer / Stopwatch ⏱️
  • To-Do Progress Counter ✅
  • API Data Fetch Block (e.g., Weather, GitHub Stats) 🌤️
  • Inline Calculator or Unit Converter 🔢
  • Countdown / Reminder Blocks 📅

This would transform AFFiNE into a dynamic workspace — not just a note-taking app, but a programmable canvas for automation, dashboards, and data visualization.

Use case

This feature would be useful for:

👩‍💻 Developers / Power Users — to prototype scripts, dashboards, or tools directly inside AFFiNE.
🎓 Students / Researchers — to run small calculations, timers, and trackers while studying.
🏢 Teams / Managers — to track progress, create dashboards, or embed live stats within project pages.

Example Scenario:
A “Daily Planner” page could show a real-time countdown timer, a progress chart, and a scripted summary block updating based on task completion — all written within AFFiNE, no external integrations required.

Anything else?

🚀 Benefits

  • Expands AFFiNE from static documents → to interactive programmable notebooks.
  • Encourages community-driven extensions and creativity.
  • Increases adoption among developers and productivity enthusiasts.
  • Makes AFFiNE competitive with Notion and Obsidian for dynamic workflows.

Are you willing to submit a PR?

  • [x] Yes I'd like to help by submitting a PR!

ghost avatar Nov 12 '25 00:11 ghost

Issue Status: 🆕 *Untriaged

*🆕 Untriaged

The team has not yet reviewed the issue. We usually do it within one business day. Docs: https://github.com/toeverything/AFFiNE/blob/canary/docs/issue-triaging.md

This is an automatic reply by the bot.

affine-issue-bot[bot] avatar Nov 12 '25 00:11 affine-issue-bot[bot]

This would be wonderful. I hope the devs prioritize this. It could lead to a rich marketplace as well.

skandavc18 avatar Nov 25 '25 03:11 skandavc18