I am looking to incorporate overtype to a website I'm building, and in doing so Codex brought a bug to my attention that looks legit to me. Below is the bug report it wrote for me:
Changing the Web Component's toolbar setting can modify user-entered Markdown. Reproduced with the unmodified overtype@2.4.2/dist/overtype-webcomponent.min.js bundle in Chrome, without a framework or HTMX.
Reproduction
- Create an
<overtype-editor toolbar></overtype-editor> and load the Web Component bundle.
- Type or paste this Markdown into the editor:
```python
print("\n")
```
- Remove the toolbar attribute:
const el = document.querySelector('overtype-editor');
const before = el.getValue();
el.removeAttribute('toolbar');
const after = el.getValue();
console.log(before === after); // false
The literal backslash-n inside the Python string becomes an actual newline. The editor's stored Markdown now contains:
Expected: changing a display setting preserves the current Markdown exactly.
Cause and proposed fix
The component mirrors edits into its value attribute verbatim in _handleChange / _updateValueAttribute. Changing toolbar calls _reinitializeEditor, which initializes again from that attribute and runs _decodeValue. This decodes user-entered \n, \r, and \t sequences a second time. Statistics and auto-resize changes use the same rebuild path.
Component source
Decoding escapes in an explicitly supplied HTML value attribute is documented behavior and should remain supported. Rather than disabling decoding, could _reinitializeEditor pass its captured currentValue directly to initialization as an already-decoded value, overriding the attribute-derived value before the new editor is constructed? Use an explicit sentinel such as undefined so an empty document is preserved too.
Suggested regression tests:
- Initial HTML
value and explicit subsequent value attribute updates still decode escapes as documented.
- User-entered literal
\n, \r, and \t survive repeated toolbar, statistics, and auto-resize toggles unchanged.
- Empty content remains empty after those toggles.
I am looking to incorporate overtype to a website I'm building, and in doing so
Codexbrought a bug to my attention that looks legit to me. Below is the bug report it wrote for me:Changing the Web Component's toolbar setting can modify user-entered Markdown. Reproduced with the unmodified
overtype@2.4.2/dist/overtype-webcomponent.min.jsbundle in Chrome, without a framework or HTMX.Reproduction
<overtype-editor toolbar></overtype-editor>and load the Web Component bundle.The literal backslash-n inside the Python string becomes an actual newline. The editor's stored Markdown now contains:
Expected: changing a display setting preserves the current Markdown exactly.
Cause and proposed fix
The component mirrors edits into its
valueattribute verbatim in_handleChange/_updateValueAttribute. Changingtoolbarcalls_reinitializeEditor, which initializes again from that attribute and runs_decodeValue. This decodes user-entered\n,\r, and\tsequences a second time. Statistics and auto-resize changes use the same rebuild path.Component source
Decoding escapes in an explicitly supplied HTML
valueattribute is documented behavior and should remain supported. Rather than disabling decoding, could_reinitializeEditorpass its capturedcurrentValuedirectly to initialization as an already-decoded value, overriding the attribute-derived value before the new editor is constructed? Use an explicit sentinel such asundefinedso an empty document is preserved too.Suggested regression tests:
valueand explicit subsequentvalueattribute updates still decode escapes as documented.\n,\r, and\tsurvive repeated toolbar, statistics, and auto-resize toggles unchanged.