Skip to content

Yet another approach #2

@bburky

Description

@bburky

You could implement this as a contentEditable document and apply regex string replacements to innerHTML to create real HTML <input type=checkbox> checkboxes.

Example:

<body id=t contenteditable=true oninput="localStorage.t=t.innerHTML=t.innerHTML.replace(/\[ ?\]/g,'<input type=checkbox onchange=this.removeAttribute(\'checked\');if(this.checked)this.setAttribute(\'checked\',\'\');localStorage.t=t.innerHTML>')"onload=t.innerHTML=localStorage.t||''>

Issues:

  • You must copy the checked property of each checkbox into its checked attribute so that persistence of the document's innerHTML captures the checkbox states.
  • Modifying innerHTML resets the cursor position. I haven't fixed this, so for the example you must move the cursor to the end every time you enter text.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions