<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[GoTipe Engineering]]></title><description><![CDATA[Practical notes from GoTipe: Markdown byte preservation, editor integration, collaboration and AI edit review. Runnable examples for TypeScript and Rust/WASM. T]]></description><link>https://gotipe.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6b0973a6af415f26e6fe24c2/e8605a0c-d3dd-43a6-9571-1e2d4aa6e26d.webp</url><title>GoTipe Engineering</title><link>https://gotipe.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Mon, 30 Nov 2026 23:50:56 GMT</lastBuildDate><atom:link href="https://gotipe.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[GoTipe in Next.js: the callback that stopped prerendering]]></title><description><![CDATA[Fix the GoTipe Next.js callback boundary with a client wrapper. Two tested files show where onChange belongs and what a passing build verifies.]]></description><link>https://gotipe.hashnode.dev/gotipe-in-nextjs-the-callback-that-stopped-prerendering</link><guid isPermaLink="true">https://gotipe.hashnode.dev/gotipe-in-nextjs-the-callback-that-stopped-prerendering</guid><category><![CDATA[Next.js]]></category><category><![CDATA[React]]></category><category><![CDATA[TypeScript]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[GoTipe]]></dc:creator><pubDate>Sun, 29 Nov 2026 15:23:08 GMT</pubDate><content:encoded><![CDATA[<p>While checking GoTipe's Next.js integration, we added an <code>onChange</code> callback to <code>Editor</code> in <code>app/page.tsx</code>. Its entire body was <code>console.log(editor.getJSON())</code>. The <a href="https://github.com/veniameen/gotipe/tree/9be5bfebb999263c2cc82aebc8eb52ffe5418bd5/examples/nextjs">updated starter guide</a> now includes the wrapper used below.</p>
<p>Compilation passed. TypeScript passed. Prerendering <code>/</code> failed:</p>
<blockquote>
<p>Event handlers cannot be passed to Client Component props.</p>
</blockquote>
<p>GoTipe supplies the block editor; the application supplies the saving logic. This check used a console callback, with no storage service involved.</p>
<h2>Two files, two responsibilities</h2>
<p>The relevant files were already different kinds of component:</p>
<ul>
<li><code>app/page.tsx</code> was a Server Component. That was where we had defined the callback.</li>
<li><code>components/editor.tsx</code> began with <code>"use client"</code>. Its code wires <code>onChange</code> to editor updates, passing the GoTipe editor instance.</li>
</ul>
<p>Putting <code>"use client"</code> in the editor file does not make a function declared in its server parent serializable. Next.js documents that requirement at the <a href="https://nextjs.org/docs/app/api-reference/directives/use-client">client boundary</a>.</p>
<p>We moved the callback into a small client wrapper. Add <code>components/document-editor.tsx</code> alongside the starter's existing editor:</p>
<pre><code class="language-tsx">"use client";

import type { Document } from "@gotipe/core";
import { Editor } from "./editor";

export function DocumentEditor({
  initialContent,
}: {
  initialContent: Document | string;
}) {
  return (
    &lt;Editor
      initialContent={initialContent}
      onChange={(editor) =&gt; console.log(editor.getJSON())}
    /&gt;
  );
}
</code></pre>
<p>Then replace <code>app/page.tsx</code> with this caller; the server sends an HTML string and the client creates the function:</p>
<pre><code class="language-tsx">import { DocumentEditor } from "@/components/document-editor";

export default function Home() {
  return (
    &lt;main&gt;
      &lt;DocumentEditor initialContent="&lt;p&gt;Saved document&lt;/p&gt;" /&gt;
    &lt;/main&gt;
  );
}
</code></pre>
<p>The string supplies the initial document. GoTipe JSON works here too. The starter reads <code>initialContent</code> once, when creating the editor, so changing that prop later does not load another document. The <a href="https://gotipe.com/docs/concepts/content-formats/?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=nextjs_client_callback">content formats</a> reference describes those inputs.</p>
<h2>What changed in the build</h2>
<p>The standalone <code>npx --no-install tsc --noEmit</code> check passed. So did <code>npm run build</code>, including prerendering <code>/</code>. The failing and repaired builds both used default Turbopack and one build worker.</p>
<p>To reproduce, use the creation command from the starter README, install its dependencies, add these two files and run the checks. We used Node.js 24.12.0, Next.js 16.4.6, React 19.3.1, <code>@gotipe/core@0.1.6</code> and <code>@gotipe/block-editor@0.1.6</code> in an isolated consumer.</p>
<p>The callback still only logs JSON; a real integration replaces its body with application-owned saving, request ordering and error handling. We verified the exact snippets with types and a production build; browser callback delivery, persistence and deployment were outside this check. The successful build resolves the component-boundary error and it does not demonstrate that any edit was saved.</p>
<p>The starter code and core packages are MIT-licensed. GoTipe's ready-made editor UI and themes use <a href="https://gotipe.com/docs/resources/licensing/?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=nextjs_client_callback">commercial licenses</a>. This post was drafted with AI. The exact snippets passed TypeScript and Next.js production-build checks with the versions listed above.</p>
]]></content:encoded></item><item><title><![CDATA[GoTipe image uploads: save the path, resolve the URL]]></title><description><![CDATA[Save a stable image path in GoTipe, revoke a display URL, then reopen the document. A runnable Node.js example with explicit storage limits.]]></description><link>https://gotipe.hashnode.dev/gotipe-image-uploads-save-the-path-resolve-the-url</link><guid isPermaLink="true">https://gotipe.hashnode.dev/gotipe-image-uploads-save-the-path-resolve-the-url</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[GoTipe]]></dc:creator><pubDate>Sun, 29 Nov 2026 13:32:56 GMT</pubDate><content:encoded><![CDATA[<p>An image preview seems to work, and it appears that the upload is complete. But if the app saves that preview's <code>blob:</code> URL in the document, once that URL is revoked, the saved string no longer works to fetch the image; the file may still be present.</p>
<p>GoTipe is a block editor library with an application-owned storage contract. Its <code>saveAsset</code> helper function will pass a file to the host's <code>saveAsset</code> callback. The <code>saveAsset</code> callback stores the bytes and returns a reference that will be placed in the document; the <code>resolveAsset</code> callback will convert the reference into a URL to display.</p>
<p>Here, the reference is stored as <code>assets/pixel.png</code>. When the host is asked to resolve the reference, it will read the file and create a new object URL. Changing the display URL does not require changing the document's <code>src</code> attribute.</p>
<h2>Revoke the URL, then reopen the document</h2>
<p>This example uses a temporary directory and one small PNG. The script writes both the image and the document JSON to disk, destroys the first editor, and creates a new one from the saved JSON. The assertions check the fetched bytes against the original bytes.</p>
<p>Save the JavaScript code below as <code>asset-path-check.mjs</code> in a new directory. We ran the whole script twice, using Node.js 24.12.0 and the pinned version of the published package shown here:</p>
<pre><code class="language-sh">npm init -y
npm install --save-exact @gotipe/core@0.1.6
node asset-path-check.mjs
</code></pre>
<pre><code class="language-js">import assert from "node:assert/strict";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { createEditor, saveAsset } from "@gotipe/core/js";
import { Image, Paragraph } from "@gotipe/core/extensions";

const png = Buffer.from(
  "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+jRZkAAAAASUVORK5CYII=",
  "base64",
);
const directory = mkdtempSync(join(tmpdir(), "gotipe-asset-path-"));
const storedPath = "assets/pixel.png";
const assetFile = join(directory, storedPath);
const documentFile = join(directory, "document.json");
const displayUrls = new Set();
let editor;
try {
  const host = {
    async saveAsset(file, info) {
      assert.deepEqual(info, {
        kind: "image", name: "pixel.png", mediaType: "image/png", size: png.length,
      });
      mkdirSync(join(directory, "assets"));
      writeFileSync(assetFile, Buffer.from(await file.arrayBuffer()), { flag: "wx" });
      return { src: storedPath, name: info.name };
    },
    resolveAsset(src) {
      if (!src.startsWith("assets/")) return src;
      if (src !== storedPath || !existsSync(assetFile)) return null;
      const url = URL.createObjectURL(new Blob([readFileSync(assetFile)], { type: "image/png" }));
      displayUrls.add(url);
      return url;
    },
  };
  const saved = await saveAsset(host, new File([png], "pixel.png", { type: "image/png" }), "image");
  assert.deepEqual(saved, { src: storedPath, name: "pixel.png" });
  editor = await createEditor({ extensions: [Paragraph, Image], host });
  assert.equal(editor.chain().insertBlockAfter("image", {
    src: saved.src, alt: "One-pixel test image",
  }).run(), true);
  writeFileSync(documentFile, JSON.stringify(editor.getJSON()), { flag: "wx" });
  const documentBytes = readFileSync(documentFile);
  const image = editor.getJSON().blocks.find(block =&gt; block.type === "image");
  assert.equal(image.attrs.src, storedPath);
  const firstUrl = await host.resolveAsset(image.attrs.src);
  assert.deepEqual(Buffer.from(await (await fetch(firstUrl)).arrayBuffer()), png);
  assert.equal(documentBytes.toString().includes("blob:"), false);

  URL.revokeObjectURL(firstUrl);
  displayUrls.delete(firstUrl);
  await assert.rejects(() =&gt; fetch(firstUrl));
  editor.destroy();
  editor = await createEditor({
    extensions: [Paragraph, Image], host,
    content: JSON.parse(readFileSync(documentFile, "utf8")),
  });
  const restored = editor.getJSON().blocks.find(block =&gt; block.type === "image");
  assert.equal(restored.attrs.src, storedPath);
  const secondUrl = await host.resolveAsset(restored.attrs.src);
  assert.notEqual(secondUrl, firstUrl);
  assert.deepEqual(Buffer.from(await (await fetch(secondUrl)).arrayBuffer()), png);
  assert.deepEqual(readFileSync(documentFile), documentBytes);
  assert.equal(host.resolveAsset("assets/missing.png"), null);
  console.log("Saved document source: assets/pixel.png; no blob URL stored.");
  console.log("The first display URL worked, then failed after revocation.");
  console.log("Reloaded document: same stored path, new working display URL.");
  console.log("Resolved image bytes and the unchanged document file matched.");
  console.log("Node.js host-contract test only; no browser renderer or cloud upload.");
} finally {
  editor?.destroy();
  for (const url of displayUrls) URL.revokeObjectURL(url);
  rmSync(directory, { recursive: true, force: true });
}
</code></pre>
<p>A successful run will print out five lines of confirmation text, with the last being <code>Node.js host-contract test only; no browser renderer or cloud upload.</code> An assertion failure stops the script.</p>
<p>The first URL returns the correct bytes; the URL is revoked explicitly, and the next fetch fails. The second editor still stores <code>assets/pixel.png</code> as the image's <code>src</code>, and resolving that path returns a different URL that works. The saved document file is unchanged, byte-for-byte.</p>
<h2>What the application still owns</h2>
<p>The script is running the resolver directly in Node.js and it is not rendering the image in the browser or testing a cloud upload. The URL revocation is deliberate and GoTipe has not detected an expired URL or updated the URL automatically.</p>
<p>The host must hold onto the bytes of the asset and manage the URLs it creates. This fixture deletes its temporary files and releases its URLs at the end. It checks reopening within one process, not long-term storage. Its fixed path is not a production filename policy.</p>
<p>The <a href="https://gotipe.com/docs/concepts/host/?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=image_asset_paths">host contract</a> describes the two callbacks. The <a href="https://gotipe.com/docs/extensions/media/?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=image_asset_paths">media reference</a> covers image commands and attributes.</p>
<p>The core package used here is MIT-licensed. GoTipe's ready-made editor UI and themes use commercial licenses. This post was drafted with AI. The example was executed against the pinned package version above.</p>
]]></content:encoded></item><item><title><![CDATA[Saving Markdown with GoTipe: keep the source snapshot]]></title><description><![CDATA[Keep GoTipe’s source snapshot through two saves. Run a Node.js test of task edits, YAML, spacing and exact file bytes.]]></description><link>https://gotipe.hashnode.dev/saving-markdown-with-gotipe-keep-the-source-snapshot</link><guid isPermaLink="true">https://gotipe.hashnode.dev/saving-markdown-with-gotipe-keep-the-source-snapshot</guid><category><![CDATA[markdown]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[GoTipe]]></dc:creator><pubDate>Sun, 29 Nov 2026 12:50:20 GMT</pubDate><content:encoded><![CDATA[<p>Our fixture was a release note that had two tasks, a heading, and a YAML field naming the Docs team in its front matter; we opened it in GoTipe's headless JavaScript editor, checked one task, saved it, unchecked the task and saved it again. GoTipe is a block editor library for apps that store Markdown.</p>
<h2>1. The team is outside the document</h2>
<p>The parser outputs a document and a snapshot of the source; the snapshot contains a field <code>team: "Docs"</code>, which will be removed if you serialize the edited document without the snapshot; the heading will change from an underlined Setext heading to <code># Release notes</code>.</p>
<p>This control is a string stored in memory; the test script checks the value without writing to disk. Storing only the JSON of the editor document would leave the saving routine without the original front matter.</p>
<h2>2. Three spaces still mean three spaces</h2>
<p>The first file saved should be exactly the same as the original except for the substitution <code>[ ]</code> to <code>[x]</code> at 'Review the résumé'. The three spaces in '<code>Keep   this spacing.</code>', the accents, the byte order mark, and the Windows CRLF line endings are also included in the buffer comparison.</p>
<p>These details are in the actual UTF-8 files, not the terminal or Markdown viewer representation; any change to an unmodified byte would cause the assertion to fail, regardless of how similar the output looked.</p>
<h2>3. A snapshot for the next save</h2>
<p>Through a separate public command uncheck the task and pass in <code>first.snapshot</code> to the serializer. The second output file will be identical to the original bytes. This is the session you want. Serialize the current document, keep the snapshot that was returned, and use that for the next save. <code>PageEditor</code> takes care of that for you.</p>
<p>To execute the fixture, you'll have to install the packages in a fresh directory, save the script as <code>snapshot-check.mjs</code>, and then run <code>node snapshot-check.mjs</code>. The script will delete the temporary files it creates.</p>
<pre><code class="language-sh">npm init -y
npm install --save-exact @gotipe/markdown@0.1.3 @gotipe/core@0.1.6
</code></pre>
<pre><code class="language-js">import assert from "node:assert/strict";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { createEditor } from "@gotipe/core/js";
import { Heading, Paragraph, TodoList } from "@gotipe/core/extensions";
import { parseMarkdown, serializeMarkdown } from "@gotipe/markdown";

const original = "\uFEFF" + [
  "---", 'team: "Docs"', "---", "", "Release notes", "=============", "",
  "Keep   this spacing.", "", "- [ ] Review the résumé", "- [x] Package the build", "",
].join("\r\n");
const directory = mkdtempSync(join(tmpdir(), "gotipe-snapshot-"));
let editor;
try {
  const input = join(directory, "release.md");
  const checkedFile = join(directory, "release-checked.md");
  const resetFile = join(directory, "release-reset.md");
  writeFileSync(input, original, { flag: "wx" });
  const { doc, snapshot } = parseMarkdown(readFileSync(input, "utf8"));
  editor = await createEditor({
    extensions: [Paragraph, Heading, TodoList], content: doc,
  });
  const list = doc.blocks.find(block =&gt; block.type === "todoList");
  assert.ok(list);
  const task = list.children[0];
  assert.equal(task.content[0].text, "Review the résumé");
  assert.equal(task.attrs.checked, false);

  assert.equal(editor.chain().setBlockAttrs(task.id, { checked: true }).run(), true);
  const first = serializeMarkdown(editor.getJSON(), snapshot);
  writeFileSync(checkedFile, first.text, { flag: "wx" });
  const expected = original.replace("- [ ] Review", "- [x] Review");
  assert.deepEqual(readFileSync(checkedFile), Buffer.from(expected, "utf8"));

  const withoutSnapshot = serializeMarkdown(editor.getJSON()).text;
  assert.notEqual(withoutSnapshot, first.text);
  assert.equal(withoutSnapshot.includes('team: "Docs"'), false);
  assert.ok(withoutSnapshot.includes("# Release notes"));

  assert.equal(editor.chain().setBlockAttrs(task.id, { checked: false }).run(), true);
  const second = serializeMarkdown(editor.getJSON(), first.snapshot);
  writeFileSync(resetFile, second.text, { flag: "wx" });
  assert.deepEqual(readFileSync(resetFile), readFileSync(input));
  console.log("First save: only the task marker changed.");
  console.log("BOM, front matter, Setext heading, spacing and CRLF matched.");
  console.log("Without a snapshot: front matter missing; heading becomes ATX.");
  console.log("Second save with the returned snapshot: original bytes restored.");
} finally {
  editor?.destroy();
  rmSync(directory, { recursive: true, force: true });
}
</code></pre>
<p>The three extensions apply to this fixture; other document structures will require their own extensions and tests. Changed blocks may be normalized. There is only one writer here; a save in the production environment still requires a revision check at the application level for concurrent changes.</p>
<p>See the <a href="https://gotipe.com/docs/conversion/markdown/?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=markdown_snapshot">Markdown snapshot contract</a> and <a href="https://gotipe.com/docs/guides/edit-markdown-without-reformatting/?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=markdown_snapshot">file-editing guide</a> for integration details.</p>
<p>The Markdown codec and core packages used here are MIT-licensed. GoTipe's ready-made editor UI and themes use commercial licenses. This post was drafted with AI. The example was executed against the pinned package versions above.</p>
]]></content:encoded></item><item><title><![CDATA[Migrating from Tiptap to GoTipe: read the conversion report]]></title><description><![CDATA[Run a Node.js migration test for Tiptap JSON. Check preserved custom nodes, unmapped fields and the app behavior still to port.]]></description><link>https://gotipe.hashnode.dev/migrating-from-tiptap-to-gotipe-read-the-conversion-report</link><guid isPermaLink="true">https://gotipe.hashnode.dev/migrating-from-tiptap-to-gotipe-read-the-conversion-report</guid><category><![CDATA[tiptap]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[GoTipe]]></dc:creator><pubDate>Sun, 29 Nov 2026 12:07:58 GMT</pubDate><content:encoded><![CDATA[<p>The converted heading still reads "Approval", at level two. Its owner is less obvious: "QA" is sitting in <code>unmapped</code>, outside the document. Save just the document and you leave it behind. That is one reason to read the conversion report before writing the result back to storage.</p>
<p>GoTipe is a block editor library for apps that store Markdown. Its migration package reads Tiptap-exported JSON without loading the source editor runtime, so you can inspect the input before touching your components or imports.</p>
<h2>Audit the original export</h2>
<p>Preserve the original exports and work with copies. Include your custom nodes in those fixtures. Plain paragraphs won't show what happens to an approval gate.</p>
<p>Call <code>convertProseMirrorToGoTipe</code> and look at <code>document</code> together with <code>preserved</code>, <code>unmapped</code>, and <code>warnings</code>. Keep the full result and its original export while mapping the nodes. Warnings alone don't give you an inventory of every unmapped field. The sample document uses a bold paragraph, an approval node and a level-two heading with <code>releaseOwner: "QA"</code>.</p>
<p>Install the tested packages in a fresh directory. Save the script as <code>migration-check.mjs</code> and run <code>node migration-check.mjs</code>.</p>
<pre><code class="language-sh">npm init -y
npm install --save-exact @gotipe/migration@0.1.1 @gotipe/core@0.1.6
</code></pre>
<pre><code class="language-js">import assert from "node:assert/strict";
import { convertProseMirrorToGoTipe, UnsupportedContent } from "@gotipe/migration";

const source = {
  type: "doc",
  content: [
    { type: "paragraph", content: [
      { type: "text", text: "Ship after sign-off.", marks: [{ type: "bold" }] },
    ] },
    { type: "heading", attrs: { level: 2, releaseOwner: "QA" }, content: [
      { type: "text", text: "Approval" },
    ] },
    { type: "approvalGate", attrs: { team: "QA", required: 2 }, content: [
      { type: "text", text: "Release candidate" },
    ] },
  ],
};
const before = structuredClone(source);
const result = convertProseMirrorToGoTipe(source);
const [paragraph, heading, raw] = result.document.blocks;

assert.deepEqual(source, before);
assert.deepEqual(result.document.blocks.map(b =&gt; b.type),
  ["paragraph", "heading", "markdownRaw"]);
assert.deepEqual(paragraph.content, [
  { text: "Ship after sign-off.", marks: [{ type: "bold", attrs: {} }] },
]);
assert.deepEqual(heading.attrs, { level: 2 });
assert.deepEqual(heading.content, [{ text: "Approval", marks: [] }]);
assert.deepEqual(result.unmapped, [{
  blockId: heading.id, path: "content[1].attrs", sourceType: "heading",
  fields: { releaseOwner: "QA" },
}]);
assert.deepEqual(raw.attrs, { kind: "json" });
assert.deepEqual(JSON.parse(raw.content), source.content[2]);
assert.equal(result.preservedNodes, 1);
assert.equal(result.skippedNodes, 0);
assert.deepEqual(result.preserved.map(({ blockId, path, sourceType }) =&gt;
  ({ blockId, path, sourceType })), [
  { blockId: raw.id, path: "content[2]", sourceType: "approvalGate" },
]);
assert.equal(result.warnings.length, 2);
assert.throws(() =&gt; convertProseMirrorToGoTipe(source, { strict: true }),
  error =&gt; error instanceof UnsupportedContent &amp;&amp; error.path === "content[2]");

// Strict mode rejects unknown nodes; it does not reject every unmapped field.
const known = convertProseMirrorToGoTipe({
  type: "doc", content: source.content.slice(0, 2),
}, { strict: true });
assert.equal(known.preserved.length, 0);
assert.deepEqual(known.unmapped.map(item =&gt; item.fields), [{ releaseOwner: "QA" }]);

const needsReview = result.preserved.length &gt; 0 || result.unmapped.length &gt; 0
  || result.warnings.length &gt; 0;
assert.equal(needsReview, true);
console.log("Block types:", result.document.blocks.map(b =&gt; b.type).join(", "));
console.log("Source unchanged; bold text, heading and raw JSON assertions passed.");
console.log("releaseOwner remains in unmapped, outside the document.");
console.log("Audit decision:", needsReview ? "review" : "ready-for-validation");
console.log("Strict mode refused content[2]; known-node metadata still needs review.");
console.log("No editor UI, storage write or approval workflow was executed.");
</code></pre>
<p>The audit decision is <code>review</code>. These assertions examine conversion in memory; the script doesn't write storage or open an editor. Strict mode rejects the unknown approval node, but a known heading can have fields left in <code>unmapped</code>.</p>
<h2>Follow the data</h2>
<p>The paragraph retains its bold span, and the heading keeps level two. The two application-specific pieces take separate routes.</p>
<p>The <code>approvalGate</code> node, with <code>team: "QA"</code> and <code>required: 2</code>, becomes a <code>markdownRaw</code> block holding a JSON string. Parse that string and you recover the source subtree, including its <code>team</code>, <code>required</code> count and child text. This is the data you need to map. The approval widget and its logic are still yours to implement.</p>
<p>The heading's <code>releaseOwner</code> value is in <code>result.unmapped[0].fields</code>, not in <code>result.document</code>. Saving only the converted document would discard that owner field. Decide where it belongs in your application before overwriting stored content.</p>
<h2>Test the workflow too</h2>
<p>If you're retaining raw blocks, your schema needs to accommodate <code>markdownRaw</code>. Port the approval rule and its editing control, then validate the converted document against the extensions your app actually loads.</p>
<p>Try releasing with one approval and then with two in your app as well. Check that editing and saving the document keeps its mapped owner and approval details intact. Conversion is only a piece of a migration's success.</p>
<p>A batch audit and the report fields are explained in the <a href="https://gotipe.com/docs/guides/audit-tiptap-json-before-migration/?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=tiptap_migration">saved-JSON audit guide</a>. Editor components and custom extensions are covered by the <a href="https://gotipe.com/docs/conversion/from-tiptap/?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=tiptap_migration">Tiptap migration guide</a>.</p>
<p><code>@gotipe/migration</code> and <code>@gotipe/core</code> are MIT-licensed. GoTipe's ready-made editor UI and theme use commercial licenses. This post was drafted with AI. The example was executed against the pinned versions above.</p>
]]></content:encoded></item><item><title><![CDATA[Test an AI edit against the bytes in a Markdown file]]></title><description><![CDATA[Run a Node.js test that preserves Markdown BOM, CRLF and front matter while applying an anchored AI edit and rejecting ambiguous matches.]]></description><link>https://gotipe.hashnode.dev/test-an-ai-edit-against-the-bytes-in-a-markdown-file</link><guid isPermaLink="true">https://gotipe.hashnode.dev/test-an-ai-edit-against-the-bytes-in-a-markdown-file</guid><category><![CDATA[markdown]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[GoTipe]]></dc:creator><pubDate>Fri, 27 Nov 2026 12:36:31 GMT</pubDate><content:encoded><![CDATA[<p>The owner field changes from Jo to Casey. That adds three characters before the status line, so the character positions have shifted since the assistant prepared its proposal against the older release note.</p>
<p>Only the line <code>Status: queued.</code> needs to change to <code>Status: ready.</code> Saving the old document would also switch the owner back to Jo.</p>
<p>GoTipe is a block editor library for apps that store Markdown. You don’t need an editor UI for this test: it uses the headless Markdown and suggestions packages.</p>
<p>The table shows the owner and status values; the YAML front matter and formatting are omitted here.</p>
<table>
<thead>
<tr>
<th>Line</th>
<th>Original</th>
<th>Current</th>
<th>After the edit</th>
</tr>
</thead>
<tbody><tr>
<td>Owner</td>
<td>Jo</td>
<td>Casey</td>
<td>Casey</td>
</tr>
<tr>
<td>Status</td>
<td>queued</td>
<td>queued</td>
<td>ready</td>
</tr>
</tbody></table>
<h2>Run the example</h2>
<p>For this GoTipe example, the expected output is the current text with queued replaced by ready. The test compares UTF-8 buffers with that output. It’ll fail if the owner gets reverted, CRLF changes to LF, the byte order mark is dropped, or the YAML front matter changes.</p>
<p>Run the Node.js script in a fresh directory. No model or API key needed; the proposal is a static object.</p>
<pre><code class="language-sh">npm init -y
npm install --save-exact @gotipe/markdown@0.1.3 @gotipe/suggestions@0.1.3 @gotipe/core@0.1.6
</code></pre>
<pre><code class="language-js">// Save as review-note.mjs and run node review-note.mjs.
import assert from "node:assert/strict";
import { parseMarkdown, serializeMarkdown } from "@gotipe/markdown";
import { applyAnchoredEdits } from "@gotipe/suggestions";

const original = "\uFEFF---\r\nteam: Docs\r\n---\r\n\r\nOwner: Jo.\r\n\r\nStatus: queued.\r\n";
const proposal = { before: "Status: ", quote: "queued", after: ".", text: "ready" };
const current = original.replace("Owner: Jo.", "Owner: Casey.");

const edit = applyAnchoredEdits(current, [proposal]);
assert.equal(edit.ok, true);
const { doc, snapshot } = parseMarkdown(edit.text);
const saved = serializeMarkdown(doc, snapshot).text;
assert.deepEqual(Buffer.from(saved), Buffer.from(current.replace("queued", "ready")));

const duplicate = current + "\r\nStatus: queued.\r\n";
assert.deepEqual(applyAnchoredEdits(duplicate, [proposal]), {
  ok: false, reason: "ambiguous", index: 0
});
console.log("Byte check passed; duplicate status needs review.");
</code></pre>
<p><code>applyAnchoredEdits</code> finds the combined <code>before</code>, <code>quote</code>, and <code>after</code> text in the current text. Here, it finds one instance of <code>Status: queued.</code> The longer owner name doesn’t affect the match.</p>
<p>Just add another status line and there are two equally good matches. The last assertion checks for <code>ambiguous</code>. The failure result has no replacement text; your program decides how to show the conflict to the reviewer.</p>
<p>Look at where parsing happens: after the source edit in the example script. The resulting document and snapshot go to the serializer without further edits; the assertion checks that round trip.</p>
<p>Editing a parsed block needs its own test; modified blocks may be written as normalized Markdown. These buffers are all in memory—there’s no Markdown file reading or writing in the script.</p>
<h2>Save against the revision you read</h2>
<p>With shared storage, make saving conditional on the stored revision matching the revision you read. If someone saves different changes between your read and write, reload the current text and reapply the proposal. Otherwise, your save could overwrite their changes even if the anchor matches correctly.</p>
<p>For the byte check on disk, see the <a href="https://gotipe.com/docs/guides/edit-markdown-without-reformatting/?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=editor_guides">file-editing guide</a>. For batches of proposals and missing targets, see the <a href="https://gotipe.com/docs/guides/apply-ai-edits-after-the-document-changes/?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=editor_guides">anchored-edit guide</a>.</p>
<p>The Markdown codec and headless suggestions package used here are MIT-licensed. This post was drafted with AI. The example was executed against the package versions shown above.</p>
]]></content:encoded></item></channel></rss>