diff --git a/.vscode/settings.json b/.vscode/settings.json index e6c9453..450f6a0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,10 +1,7 @@ { - "jest.jestCommandLine": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest", - "jest.rootPath": "plugin", "files.exclude": { "**/dist": true, "**/node_modules": true, - "**/.sqlx": true, "**/snapshots": true, } -} +} \ No newline at end of file diff --git a/examples/website/index.html b/examples/website/index.html index fdfc1b2..83bfafb 100644 --- a/examples/website/index.html +++ b/examples/website/index.html @@ -23,39 +23,110 @@ -
-

3-Way Text Merge

-

Use this tool to merge three versions of a text.

-
+
+
+

3-Way Text Merge

+

+ The + reconcile + solves a fundamental challenge in collaborative editing: + what happens when multiple people edit the same text + simultaneously? + reconcile(parent: str, left: str, right: str) -> + str + takes conflicting concurrent edits and intelligently merges + them into a unified result. Beyond basic conflict + resolution, it offers sophisticated merging heuristics, + flexible tokenization options, and cursor position tracking. +

+

+ The algorithm begins with your chosen tokenizer, then + applies Myers' diff algorithm to compare the original text + with both conflicting versions. These diffs undergo + transformation to preserve meaningful change sequences, + before a final merge strategy—inspired by Operational + Transformation (OT)—reconciles all conflicting modifications + without losing any edits. +

+

+ For more details, see the + README. +

+
-
-
- - -
+
+
+ + +
-
- - -
+
+ + +
-
- - -
+
+ + +
-
-
+
+ +
- - - + + + diff --git a/examples/website/script.js b/examples/website/script.js index dce83b0..6690834 100644 --- a/examples/website/script.js +++ b/examples/website/script.js @@ -5,13 +5,7 @@ const leftTextArea = document.getElementById("left"); const rightTextArea = document.getElementById("right"); const mergedTextArea = document.getElementById("merged"); -const sampleTexts = [ - "The quick brown fox jumps over the lazy dog.", - "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", - "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium.", - "A journey of a thousand miles begins with a single step.", - "To be, or not to be, that is the question.", -]; +const sampleText = `The \`reconcile\` Rust library is embedded on this page a WASM module and it powers these text boxes. Experiment with the "Original", "First concurrent edit", and "Second concurrent edit" text boxes to watch competing changes merge in real-time within the "Deconflicted result" box. Here, you will see color-coded tokens marking the origin of each token, including ones that got deleted. The result highly depends on the tokenization strategy, for example, deciding how casing or white-spacing is taken into account.`; async function run() { await init(); @@ -19,6 +13,7 @@ async function run() { originalTextArea.addEventListener("input", updateMergedText); leftTextArea.addEventListener("input", updateMergedText); rightTextArea.addEventListener("input", updateMergedText); + window.addEventListener("resize", resizeTextAreas); loadSample(); updateMergedText(); @@ -29,7 +24,15 @@ async function run() { leftTextArea.selectionEnd = leftTextArea.value.length; } +function resizeTextAreas() { + autoResize(originalTextArea); + autoResize(leftTextArea); + autoResize(rightTextArea); +} + function updateMergedText() { + resizeTextAreas(); + const original = originalTextArea.value; const left = leftTextArea.value; const right = rightTextArea.value; @@ -48,11 +51,18 @@ function updateMergedText() { } function loadSample() { - const randomIndex = Math.floor(Math.random() * sampleTexts.length); - const text = sampleTexts[randomIndex]; - originalTextArea.value = text; - leftTextArea.value = text; - rightTextArea.value = text; + originalTextArea.value = sampleText; + leftTextArea.value = + sampleText.replace("color", "colour") + + " Check out what's the most complex conflict you can come up with!"; + rightTextArea.value = sampleText + .replace(", for example,", " such as") + .replace("WASM", "WebAssembly"); +} + +function autoResize(textarea) { + textarea.style.height = "auto"; + textarea.style.height = textarea.scrollHeight + "px"; } run(); diff --git a/examples/website/style.css b/examples/website/style.css index 3de3fa3..7d5fe7a 100644 --- a/examples/website/style.css +++ b/examples/website/style.css @@ -11,24 +11,33 @@ body { body { font-family: "Segoe UI", Arial, sans-serif; - background: linear-gradient(135deg, #f8fafc 0%, #e0e7ef 100%); color: #23272f; + overflow-y: auto; +} + +.page-wrapper { display: flex; flex-direction: column; justify-content: space-between; + min-height: 100%; + background: linear-gradient(135deg, #f8fafc 0%, #e0e7ef 100%); } header { - padding: 32px 20px 0 20px; - - text-align: center; + padding: 32px 32px 0 32px; } header > h1 { font-size: 2.5rem; font-weight: 700; color: #2451a6; - margin-bottom: 8px; + margin-bottom: 24px; + text-align: center; +} + +p, +p * { + user-select: text; } header > p { @@ -37,16 +46,18 @@ header > p { margin-bottom: 0; } +header > p:not(:first-of-type) { + margin-top: 16px; +} + main { - flex: 1; display: grid; - grid-template-rows: auto auto auto; + grid-template-rows: min-content; grid-template-columns: 1fr 1fr; gap: 20px; justify-items: center; align-items: center; padding: 32px 12vw 32px 12vw; - min-height: 540px; } .diamond-parent { @@ -70,6 +81,15 @@ main { align-items: center; } +.diamond-result label { + display: flex; + align-items: center; +} + +.diamond-result svg { + margin-left: 6px; +} + .text-area-card { display: flex; flex-direction: column; @@ -108,12 +128,10 @@ textarea { resize: none; outline: none; margin-bottom: 0; - height: 100%; } #merged { width: 100%; - text-align: left; user-select: text; } @@ -143,39 +161,42 @@ textarea { @media (max-width: 768px) { main { grid-template-columns: 1fr; - grid-template-rows: auto auto auto auto auto; - } - - main > * { - grid-column: 1; + grid-template-rows: auto auto auto auto; } .diamond-parent { + grid-column: 1; grid-row: 1; } .diamond-left { + grid-column: 1; grid-row: 2; } .diamond-right { + grid-column: 1; grid-row: 3; } .diamond-result { - grid-row: 5; + grid-column: 1; + grid-row: 4; } } footer { + padding: 16px; + width: 100%; position: relative; - margin-top: 32px; - padding: 28px 0 18px 0; - text-align: center; + display: flex; + justify-content: center; + align-items: center; color: #5a6272; font-size: 1rem; box-shadow: 0 -4px 12px 0 rgba(28, 28, 87, 0.1), 0 -1px 2px 0 rgba(1, 1, 3, 0.1); + background-color: #fff; } .github-link > svg { diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh index abd0054..11cde48 100755 --- a/scripts/bump-version.sh +++ b/scripts/bump-version.sh @@ -28,8 +28,6 @@ cargo set-version --bump $1 wasm-pack build --target web --features wasm - - # Commit and tag git add . git commit -m "Bump versions to $TAG"