{"id":47968269,"url":"https://github.com/michael/web-editing","last_synced_at":"2026-04-04T10:40:15.078Z","repository":{"id":323925477,"uuid":"1055490444","full_name":"michael/web-editing","owner":"michael","description":"This repository is soley there to track bugs related to contenteditable and input events.","archived":false,"fork":false,"pushed_at":"2025-11-12T21:00:31.000Z","size":11,"stargazers_count":0,"open_issues_count":16,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-12T22:18:27.256Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michael.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-12T10:43:43.000Z","updated_at":"2025-11-12T21:00:35.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/michael/web-editing","commit_stats":null,"previous_names":["michael/web-editing"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/michael/web-editing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michael%2Fweb-editing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michael%2Fweb-editing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michael%2Fweb-editing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michael%2Fweb-editing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michael","download_url":"https://codeload.github.com/michael/web-editing/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michael%2Fweb-editing/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31397055,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T10:20:44.708Z","status":"ssl_error","status_checked_at":"2026-04-04T10:20:06.846Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-04T10:40:13.562Z","updated_at":"2026-04-04T10:40:15.070Z","avatar_url":"https://github.com/michael.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Background\n\nBetween 2011 and 2020 I was working on [Substance.js](https://github.com/substance/substance), a JavaScript library for web-based content editing. We also built [Texture](https://elifesciences.org/labs/8de87c33/texture-an-open-science-manuscript-editor) (also see [paper](https://www.ncbi.nlm.nih.gov/books/NBK425544/)), a visual editor for scientific manuscripts (think LaTeX but with WYSIWYG editing).\n\nSince summer 2024, I'm spending more than 50% of my time developing [Svedit](https://svedit.dev), a lightweight library designed to enable building [in-place editable websites](https://editable.website) I'm building this directly on top of web API's, rather than using an existing library (ProseMirror, Lexical,...).\n\n# Findings\n\nCompared to pre 2020, the Situation got much better with introduction of the `beforeinput` and new API's that are part of [Input Events Level 2 spec](https://www.w3.org/TR/input-events-2/). Currently, I'm able to handle almost all inputs myself, apply a change to my internal model, which then triggers an incremental rerender, updating the DOM accordingly.\n\nWhat still gives me troubles is handling composition events. I have some workarounds in place, such as disabling incremental rendering, but I'd hope this could be done in a better way.\n\n# Top 4 Requests\n\n## Ability to rollback DOM changes of a composition at oncompositionend stage\n\n```js\nfunction oncompositionend(event) {\n\t// Make sure the DOM is in the exact same state as before the composition started\n  event.resetDOM();\n  // Apply the finished composition to the document\n  doc.apply(doc.tr.insert_text(event.data));\n  // Incremental reactive-rerendering can take place safely\n}\n```\n\nThis is just a simplified example. See [#13](https://github.com/michael/web-editing/issues/13).\n\n## Ability to capture event.getTargetRanges() at oncompositionstart stage\n\nCurrently `event.getTargetRanges()` can only be captured at the onbeforeinput stage, which is not just inconvenient, but also unsufficient in edge cases where an `oncompositionend` is directly following an `oncompositionend` with no `onbeforeinput/oninput` in between (e.g. turn dictation on and off on Samsung-Android).\n\nIt would be great, if `oncompositionstart` would reveal which target range is part of the composition that is about to start.\n\nSee [#11](https://github.com/michael/web-editing/issues/11).\n\n## Ability to cancel composition events at the very beginning\n\nI found a workaround, that prevents my editor to crash when you start a composition for a given selection.\n\n```js\nfunction oncompositionstart(event) {\n  // eg. when multiple nodes are selected, or inside a cursor trap\n  if (doc.selection.type !== 'text') {\n    const dom_selection = window.getSelection();\n    dom_selection.removeAllRanges();\n  } else {\n    // handle the IME, when you have text cursor/selection.\n  }\n}\n```\n\nHowever, I'd rather **be able to cancel composition events at the very beginning** (not somewhere in between - which I understand interferes with OS-specific implementations of IMEs).\n\nSee [#6](https://github.com/michael/web-editing/issues/6).\n\n## Ability create and handle custom history events\n\nThe problem is that when I handle input myself (`onbeforeinput` with `event.preventDefault()`) no history entries are created. Hence when you use the browser's native undo (e.g. Edit \u003e Undo) or other triggers/shortcuts, they don't fire `historyUndo` and `historyRedo` events.\n\nIn order to allow not just rich text editors, but any apps (e.g. Figma) utilize the native history events, an API for creating and handling custom history events is needed.\n\nSee [#1](https://github.com/michael/web-editing/issues/1).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichael%2Fweb-editing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichael%2Fweb-editing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichael%2Fweb-editing/lists"}