Use wrapper in example

This commit is contained in:
Andras Schmelczer 2025-07-04 03:09:11 +01:00
parent 1bc6117045
commit ae5940718e
6 changed files with 44 additions and 40 deletions

View file

@ -1,3 +0,0 @@
reconcile.js
reconcile_bg.wasm

View file

@ -1,4 +1,4 @@
import init, { mergeTextWithHistory } from "./reconcile.js";
import { init, reconcileWithHistory } from "./dist/index.js";
const originalTextArea = document.getElementById("original");
const leftTextArea = document.getElementById("left");
@ -37,16 +37,15 @@ function updateMergedText() {
const left = leftTextArea.value;
const right = rightTextArea.value;
const results = mergeTextWithHistory(original, left, right);
const results = reconcileWithHistory(original, left, right);
mergedTextArea.innerHTML = "";
for (const result of results) {
for (const {text, history} of results.history) {
const span = document.createElement("span");
span.className = result.history();
span.textContent = result.text();
span.className = history;
span.textContent = text;
mergedTextArea.appendChild(span);
result.free();
}
}