Skip to content

Commit

Permalink
store it with the correct keyName
Browse files Browse the repository at this point in the history
Signed-off-by: Jessica González <[email protected]>
  • Loading branch information
MissAllSunday committed May 26, 2017
1 parent a714937 commit 7487735
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ A summernote plugin for saving and retrieving drafts.

### Setup

requires [store.js](https://github.com/marcuswestin/store.js/) version 2.0 or higher to store drafts.
requires [store.js](https://github.com/marcuswestin/store.js/) version 2.0 or higher to save/get drafts. See the demo code to get a CDN url for it.

Append both sDraftsLoad and sDraftsSave buttons to your summernote toolbar:
Include lib/summernoteDrafts.js and append both sDraftsLoad and sDraftsSave buttons to your summernote toolbar:

```javascript
$('.summernote').summernote({
Expand Down
7 changes: 3 additions & 4 deletions src/summernoteDrafts.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
isoDate = new Date()
.toISOString()
name ?= isoDate
name = options.sDrafts.storePrefix + '-' + name
keyName = options.sDrafts.storePrefix + '-' + name
body = context.code()
store.set name,
store.set keyName,
name: name
sDate: isoDate
body : body
Expand All @@ -105,8 +105,7 @@
for key, draft of drafts
do ->
fDate = if options.sDrafts.dateFormat and typeof options.sDrafts.dateFormat is 'function' then options.sDrafts.dateFormat(draft.sDate) else draft.sDate
fName = draft.name.replace "#{options.sDrafts.storePrefix}-", ""
htmlList += "<li class='list-group-item'><a href='#' class='note-draft' data-draft='#{key}'>#{fName} - <small>#{fDate}</small></a><a href='#' class='label label-danger pull-right delete-draft' data-draft='#{key}'>#{lang.deleteDraft}</a></li>"
htmlList += "<li class='list-group-item'><a href='#' class='note-draft' data-draft='#{key}'>#{draft.name} - <small>#{fDate}</small></a><a href='#' class='label label-danger pull-right delete-draft' data-draft='#{key}'>#{lang.deleteDraft}</a></li>"

context.memo 'button.sDraftsLoad', () ->
button = ui.button
Expand Down

0 comments on commit 7487735

Please sign in to comment.