Files
rea/website/public/showcase/notion/index.html
T
ysopwnableandGitHub a6ba772c08 docs(website): add Notion case study and improve onboarding
The Electron guide currently uses a teaching fixture. Add a real Notion clipboard case with REA findings, short source excerpts and responsive figures, alongside the existing DX-Ball reconstruction.

- Trace the saved Notion 7.6.1 preload API through its wrappers to the clipboard receiver. Attribute the separate web-cache module probes to their original harness. Public content uses relative source locations and generic example data; packages and complete captures stay local.
- Add a Showcases index and links from the homepage and JavaScript guide. Simplify homepage copy while preserving the approved headline and closing question.
- Show copyable agent installation prompts and the direct setup command. Keep terminal cursors blinking consistently and respect reduced-motion settings.
- Provide one Notes example ZIP. Generate it from the six public source files before website checks and manual Pages deployment; verify its contents against the source. Pages remains manual-only.

Validation:
- `npm run check:fast`
- `python3 scripts/prepare-website.py` and `python3 scripts/verify-website.py`
- Browser checks at `/` and `/rea/`: downloads, prompt/command copying, responsive layouts, keyboard navigation, reduced motion and DX-Ball comparison controls.
- Published REA 4.1.0 preload analysis and feature traces; source/claim/privacy review.
- Real Hopper/Ghidra verification: not performed (website-only change).
2026-10-07 20:59:56 +08:00

478 lines
20 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Following Notion's clipboard through Electron — REA</title>
<meta
name="description"
content="Follow Notion's clipboard API through Electron's preload, IPC wrappers and main process, with short code excerpts and a look at its rich clipboard format."
/>
<meta name="theme-color" content="#ffffff" />
<link rel="icon" href="../../assets/favicon.svg" type="image/svg+xml" />
<link rel="stylesheet" href="../../assets/styles.css" />
<script src="../../assets/main.js" defer></script>
</head>
<body>
<a class="skip-link" href="#main">Skip to content</a>
<header class="site-header">
<div class="container header-inner">
<a class="brand" href="../../" aria-label="REA home"
><span class="brand-name">REA</span
><span class="brand-caption">Reverse Engineer Anything</span></a
>
<nav class="navigation" aria-label="Main navigation">
<a href="../">Showcases</a>
<a class="nav-start" href="../../get-started/">Get started</a>
<a href="../../guides/">Guides</a>
<a href="https://github.com/morluto/rea">GitHub</a>
</nav>
</div>
</header>
<main id="main" class="container">
<div class="page-heading">
<p class="breadcrumb">
<a href="../../">Home</a> / <a href="../">Showcases</a> / Notion
</p>
<p class="eyebrow">Case study · Electron</p>
<h1>Following a copy<br />through Notion.</h1>
<p class="lede">
A familiar action leads through several files. Follow Notion's
clipboard API from the page, through Electron, to the system
clipboard.
</p>
<p class="page-meta">Notion Desktop 7.6.1 · JavaScript · REA</p>
</div>
<figure class="workflow-figure">
<p class="figure-title">The bridge inside Notion's desktop package</p>
<ol class="flow-steps notion-bridge-flow">
<li>
<span class="flow-label">01 · Page-facing API</span>
<span class="flow-node"><code>clipboard.write(data)</code></span>
<span class="flow-note"
>The preload exposes a callable method.</span
>
</li>
<li>
<span class="flow-label">02 · Preload wrapper</span>
<span class="flow-node"><code>ipcRenderer.invoke</code></span>
<span class="flow-note"
>The wrapper sends the channel and arguments.</span
>
</li>
<li>
<span class="flow-label">03 · Main-process handler</span>
<span class="flow-node"><code>ipcMain.handle</code></span>
<span class="flow-note"
>The receiver checks which page sent it.</span
>
</li>
<li>
<span class="flow-label">04 · System clipboard</span>
<span class="flow-node"><code>clipboard.write(data)</code></span>
<span class="flow-note"
>Electron writes the supplied text and HTML.</span
>
</li>
</ol>
<p class="flow-result">
One channel joins the two sides:
<code class="notion-channel">notion:clipboard:write</code>
</p>
<figcaption>
The packaged code uses the same channel in the preload and main
process. Resolving the wrappers reveals the Electron calls behind
those names.
</figcaption>
</figure>
<div class="article-layout">
<nav class="contents" aria-label="On this page">
<p>In this case study</p>
<ul>
<li><a href="#clipboard">Follow the clipboard bridge</a></li>
<li><a href="#rich-clipboard">Keeping a block's structure</a></li>
<li><a href="#markdown">Markdown becomes blocks</a></li>
<li><a href="#continue">Try another question</a></li>
</ul>
</nav>
<article class="article" aria-label="Notion Electron case study">
<section class="article-section" id="clipboard">
<h2>Where does the copy operation go?</h2>
<p>
The page sees a method called <code>clipboard.write</code>. Its
implementation in the preload is a wrapper. The useful question is
what that wrapper sends, and which code receives it.
</p>
<div class="agent-terminal">
<div class="terminal-header">
<span class="terminal-title"
><span class="terminal-dots" aria-hidden="true"
><i></i><i></i><i></i></span
>Your coding agent</span
><button
class="copy-button"
type="button"
data-copy="notion-prompt"
aria-label="Copy Notion analysis prompt"
>
Copy
</button>
</div>
<p class="terminal-prompt">
<span class="prompt-symbol" aria-hidden="true">›</span
><span id="notion-prompt"
>Use REA to trace how Notion copies text and HTML to the
system clipboard. Show the code at each step.</span
><span class="terminal-cursor" aria-hidden="true"></span>
</p>
</div>
<p class="caption">
An example prompt with Notion's local application package
available to your coding agent.
</p>
<h3 class="small-heading">REA finds where to start reading</h3>
<p>
Analyzing the tab preload with REA locates the API exposed to the
page and the call that sends an IPC request. Both findings come
with source ranges in the minified bundle:
</p>
<figure class="workflow-figure">
<p class="figure-title">REA findings → two places to open</p>
<div class="rea-query-pair">
<div class="code-block">
<div class="code-header"><span>Exposed page API</span></div>
<pre><code>api_key: "__electronApi"
api_status: "dynamic"
source: preload.js:1:22764–22828</code></pre>
</div>
<div class="code-block">
<div class="code-header"><span>Renderer IPC call</span></div>
<pre><code>operation: "invoke"
channel_expression: "e"
source: preload.js:1:6486–6522</code></pre>
</div>
</div>
<figcaption>
Selected fields from a fresh
<code>analyze_javascript_application</code> result on Notion's
tab preload, recorded with REA 4.1.0. Positions use the original
bundle's line and zero-based column.
</figcaption>
</figure>
<p>
The agent opens those locations, finds the clipboard member in the
assembled API, and reads <code>invokerInMain</code>. Its call site
supplies
<code class="notion-channel">notion:clipboard:write</code>. That
name gives the agent something precise to look for in the main
bundle. The four excerpts below show the route it connects.
</p>
<h3 class="small-heading">Four short pieces of code</h3>
<p class="caption">
Simplified from the packaged JavaScript, with readable variable
names. Unrelated members are omitted.
</p>
<ol class="rea-queries">
<li>
<h4>Start at the API exposed to the page</h4>
<div class="code-block">
<div class="code-header">
<span>tab_browser_view/preload.js · API member</span
><button
class="copy-button"
type="button"
data-copy="notion-preload-source"
aria-label="Copy Notion preload excerpt"
>
Copy
</button>
</div>
<pre><code id="notion-preload-source">const clipboardApi = {
write: invokerInMain(<span class="notion-channel">"notion:clipboard:write"</span>)
};
// Included in the API exposed through contextBridge:
// window.__electronApi.clipboard</code></pre>
</div>
<p>
This member supplies the channel name. The implementation of
<code>invokerInMain</code> tells us how the request leaves the
page's process.
</p>
</li>
<li>
<h4>Resolve the preload's wrapper</h4>
<div class="code-block">
<div class="code-header">
<span>tab_browser_view/preload.js · IPC helper</span
><button
class="copy-button"
type="button"
data-copy="notion-invoke-source"
aria-label="Copy Notion invoke wrapper excerpt"
>
Copy
</button>
</div>
<pre><code id="notion-invoke-source">function invokerInMain(channel) {
return (...args) =&gt; invokeInMainAndReturnResult(channel, ...args);
}
function invokeInMainAndReturnResult(channel, ...args) {
return ipcRenderer.invoke(channel, ...args);
}</code></pre>
</div>
<p>
The returned function forwards the arguments through
Electron's request-and-response IPC. We can now look for
<code class="notion-channel">notion:clipboard:write</code>
on the main-process side.
</p>
</li>
<li>
<h4>Check how the receiver is registered</h4>
<div class="code-block">
<div class="code-header">
<span>main/index.js · handler helper</span
><button
class="copy-button"
type="button"
data-copy="notion-handler-source"
aria-label="Copy Notion handler wrapper excerpt"
>
Copy
</button>
</div>
<pre><code id="notion-handler-source">const handleRequestFromRenderer = {
addListener(channel, handler) {
ipcMain.handle(channel, handler);
}
};</code></pre>
</div>
<p>
The main process uses another wrapper. Its
<code>addListener</code> method registers an
<code>ipcMain.handle</code> receiver for that channel.
</p>
</li>
<li>
<h4>Find the write and its sender check</h4>
<div class="code-block">
<div class="code-header">
<span>main/index.js · clipboard receiver</span
><button
class="copy-button"
type="button"
data-copy="notion-write-source"
aria-label="Copy Notion clipboard receiver excerpt"
>
Copy
</button>
</div>
<pre><code id="notion-write-source">handleRequestFromRenderer.addListener(
<span class="notion-channel">"notion:clipboard:write"</span>,
(event, data) =&gt;
isNotionWebContents(event.sender)
? clipboard.write(data)
: undefined
);</code></pre>
</div>
<p>
This is the destination. After checking the sender, the
handler passes the supplied data to Electron's clipboard API.
The channel and the two resolved wrappers connect the exposed
method to this call.
</p>
</li>
</ol>
</section>
<section class="article-section" id="rich-clipboard">
<h2>How does a copied block keep its structure?</h2>
<p>
The cached web editor adds a small detail to programmatic copies.
It sends text and HTML through
<code>electronApi.clipboard.write</code>, while keeping Notion's
private block data in a local virtual clipboard. An ID in the HTML
connects the two.
</p>
<figure class="workflow-figure">
<p class="figure-title">One copy, two representations</p>
<div class="notion-clipboard-grid">
<div class="code-block">
<div class="code-header">
<span>Sent to the system clipboard</span>
</div>
<pre><code>text: "Project notes"
html: "&lt;p&gt;Project notes&lt;/p&gt;"
+ "&lt;!-- notionvc: <span class="notion-channel">&lt;copy-id&gt;</span> --&gt;"</code></pre>
</div>
<div class="code-block">
<div class="code-header">
<span>Kept in the local virtual clipboard</span>
</div>
<pre><code>id: <span class="notion-channel">&lt;copy-id&gt;</span>
mimeTypes:
text/_notion-blocks-v3-production
→ structured block data</code></pre>
</div>
</div>
<ol
class="notion-mini-flow"
aria-label="Restoring rich clipboard data on paste"
>
<li>Read the HTML ID</li>
<li>Find the same local ID</li>
<li>Restore private formats</li>
</ol>
<figcaption>
Illustrative text and ID. The saved module probe recovered the
private formats when IDs matched; a stale entry left only the
ordinary text and HTML.
</figcaption>
</figure>
<p>
On paste, the reader looks for the marker and checks it against
the saved copy. A matching ID reconnects the text to its richer
representation. This explains why the HTML carries more than
visible content.
</p>
<p class="caption">
Web assets cached on July 13, 2026. The desktop-package bridge
above and this web-side format are separate pieces of the
investigation.
</p>
</section>
<section class="article-section" id="markdown">
<h2>From Markdown to structured blocks</h2>
<p>
The same investigation also recovered Notion's Markdown
processing. A small table makes the internal format easy to see:
its rows and cells become data that the block renderer can use.
</p>
<figure class="workflow-figure">
<p class="figure-title">
A table through Notion's Markdown parser
</p>
<div class="notion-table-example">
<div class="code-block">
<div class="code-header"><span>Markdown input</span></div>
<pre><code>| A | B |
| - | - |
| 1 | 2 |</code></pre>
</div>
<div class="code-block">
<div class="code-header">
<span>Structured parser output · excerpt</span>
</div>
<pre><code>table · headerRow: true
table_row
cells: ["A"], ["B"]
table_row
cells: ["1"], ["2"]</code></pre>
</div>
</div>
<figcaption>
A saved extracted-module probe of web parser
<code>422457</code>. Both page and chat filters preserve this
table. The tree shows the recorded rows and cell text.
</figcaption>
</figure>
<p>
Finding that transformation required separating the ordinary
paste/import path from the structured Markdown and AI/chat
parsers. Each has its own entry point and intermediate format.
</p>
</section>
<section class="article-section" id="continue">
<h2>Try another question</h2>
<p>
Start with one feature and follow the code that crosses a process
boundary. A named API, a literal channel and its receiver are
useful places to begin.
</p>
<details class="evidence-details">
<summary>Another path: the offline SQLite connection</summary>
<p>
Notion's renderer requests <code>getSqliteMeta</code> through
IPC. The main process creates a message channel and gives one
port to the renderer and the other to a SQLite utility process.
Subsequent statement batches and results travel over that port.
</p>
<p>
Following this handoff explains where the database work runs,
and why tracing only the initial IPC request misses the later
conversation.
</p>
</details>
<details class="evidence-details">
<summary>Sources and how to read the excerpts</summary>
<p>
The clipboard bridge comes from Notion Desktop 7.6.1's
<code>app.asar</code>: the tab preload and
<code>main/index.js</code>. The excerpts expand minified
variable names and omit unrelated code; the sender-check helper
is shown with its underlying
<code>isNotionWebContents</code> call.
</p>
<p>
The virtual clipboard and Markdown examples come from web assets
cached on July 13, 2026, including modules <code>747001</code>,
<code>58169</code>, <code>736810</code> and <code>422457</code>.
Those assets have their own version. Saved probes executed
extracted modules and small harnesses; their outputs describe
those probes rather than a captured desktop UI session.
</p>
<p>
The REA result shown here is a focused analysis of the saved tab
preload, recorded with the published REA 4.1.0 package. It
locates the API and invoke operation. The clipboard member and
matching receiver are connected by reading their wrapper
implementations in the package.
</p>
</details>
<ul class="reading-list">
<li>
<a href="../../guides/javascript/"
>JavaScript application guide</a
><span
>Follow a small Electron application's export feature.</span
>
</li>
<li>
<a href="../dx-ball/">DX-Ball reconstruction</a
><span
>Follow native instructions to a checked C function.</span
>
</li>
</ul>
<div class="actions">
<a class="button" href="../../get-started/"
>Start with your own target</a
>
</div>
</section>
</article>
</div>
</main>
<footer class="site-footer">
<div class="container footer-inner">
<p>REA · Reverse Engineer Anything</p>
<div class="footer-links">
<a href="https://github.com/morluto/rea">Source</a
><a href="https://github.com/morluto/rea/blob/main/LICENSE"
>MIT license</a
><a href="https://discord.gg/GkcryMnJDM">Community</a>
</div>
</div>
</footer>
<p class="sr-only" id="copy-status" role="status" aria-live="polite"></p>
</body>
</html>