Skip to content

Commit

Permalink
add persistence of edits
Browse files Browse the repository at this point in the history
  • Loading branch information
lebalz committed Aug 2, 2021
1 parent 67c5618 commit 339c52f
Show file tree
Hide file tree
Showing 8 changed files with 410 additions and 178 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,19 @@ t.write("I love Brython!", font=("Arial", 20, "normal"))

results in an live editable code block:

![Brython Demo](brython-demo.gif)
![Brython Demo](brython-demo.gif)

## Options

A brython live code block can have additional options in the meta string:

- `title=Some-Text` The title shown in the codeblock header. The title must be unique per page. Single hyphens/underscores (`-` and `_`) are replaced by a space, double hyphens/underscores are replaced with a single hyphen/undescore: `title=Foo-Bar--Bazz` => `Foo Bar-Bazz`; `title=Foo_Bar__Bazz` => `Foo Bar_Bazz`
- `persistent` when added, the reset button will not be shown.


# Storage

User edited code is stored in the localStorage. To lookup the edits, id's for each codeblock are generated after the following rules:

- `title` is present -> use a sanitized version as the key.
- `title` is not present -> all codeblocks on the page are enumerated and the index number is used as the key. !! Saved Edits are probably not correctly applied.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docusaurus-live-brython",
"version": "0.0.1-beta.4.21",
"version": "0.0.1-beta.4.58",
"description": "Docusaurus live code block component for python.",
"main": "src/index.js",
"publishConfig": {
Expand All @@ -20,6 +20,7 @@
"@fortawesome/react-fontawesome": "^0.1.14",
"ace-builds": "^1.4.12",
"clsx": "^1.1.1",
"lodash": "^4.17.21",
"react-ace": "^9.4.1",
"react-draggable": "^4.4.3"
},
Expand Down
Loading

0 comments on commit 339c52f

Please sign in to comment.