Compare commits
2 Commits
8da06bc939
...
f8a94455cd
| Author | SHA1 | Date | |
|---|---|---|---|
| f8a94455cd | |||
| e98a099127 |
|
|
@ -36,7 +36,7 @@ function addSaver(editor, saveUrl, page, beforeSave) {
|
|||
save() {
|
||||
return editor.save()
|
||||
.then(outputData => {
|
||||
beforeSave()
|
||||
beforeSave(outputData)
|
||||
let data = {
|
||||
'json': 1,
|
||||
'p': page,
|
||||
|
|
@ -429,8 +429,12 @@ function Editor(holder, input) {
|
|||
let saveUrl = element.dataset.saveurl;
|
||||
let page = element.dataset.page;
|
||||
|
||||
let beforeSave = (curDoc) => {
|
||||
indicator.setText('saving...')
|
||||
}
|
||||
|
||||
addIndicator(
|
||||
addSaver(editor, saveUrl, page, () => indicator.setText('saving...')),
|
||||
addSaver(editor, saveUrl, page, beforeSave),
|
||||
indicator
|
||||
).save().then(() => indicator.done())
|
||||
})
|
||||
|
|
|
|||
|
|
@ -73,8 +73,10 @@ function editor(root, inputData, options) {
|
|||
|
||||
function save() {
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
if (store.hasChanged()) {
|
||||
resolve(store.debug().result)
|
||||
let result = store.debug().result
|
||||
resolve(result)
|
||||
store.clearChanged()
|
||||
}
|
||||
});
|
||||
|
|
@ -146,7 +148,7 @@ function editor(root, inputData, options) {
|
|||
location.href = '/edit/' + id;
|
||||
})
|
||||
}
|
||||
return true;
|
||||
return true;
|
||||
})
|
||||
cursor.set(0)
|
||||
renderUpdate()
|
||||
|
|
@ -318,9 +320,12 @@ function editor(root, inputData, options) {
|
|||
|
||||
let hideLevel = 99999;
|
||||
|
||||
let closedFolds = JSON.parse(localStorage.getItem('closed-folds') || '{}') || {}
|
||||
|
||||
$enter.each(function (index, li) {
|
||||
let storeId = enterData[index]
|
||||
let value = rootData.value(storeId)
|
||||
value.fold = closedFolds[value.id] ? 'closed' : 'open'
|
||||
|
||||
let hasChildren = false;
|
||||
if (index + 1 < last) {
|
||||
|
|
@ -356,6 +361,8 @@ function editor(root, inputData, options) {
|
|||
|
||||
_.each(exitData, function (storeId, index) {
|
||||
let value = rootData.value(storeId)
|
||||
value.fold = closedFolds[value.id] ? 'closed' : 'open'
|
||||
|
||||
let $li = newItem(value)
|
||||
.css('margin-left', (value.indented * 32) + 'px')
|
||||
.toggleClass('selected', cursor.atPosition(index + $enter.length))
|
||||
|
|
@ -425,6 +432,7 @@ function editor(root, inputData, options) {
|
|||
|
||||
let newPosition = store.moveBefore(startID, stopID)
|
||||
cursor.set(newPosition[0])
|
||||
// fix indent
|
||||
|
||||
_.defer(() => {
|
||||
trigger('change')
|
||||
|
|
@ -724,7 +732,7 @@ function editor(root, inputData, options) {
|
|||
'{': '{}',
|
||||
}
|
||||
|
||||
let c = prefix[prefix.length-1]
|
||||
let c = prefix[prefix.length - 1]
|
||||
let braceSet = braces[c]
|
||||
|
||||
let prefixCount = _(prefix)
|
||||
|
|
|
|||
|
|
@ -203,9 +203,20 @@ function Store(inputData) {
|
|||
values[currentId] = newValue
|
||||
changed = true
|
||||
}
|
||||
updateFold(currentId, newValue.fold === 'open')
|
||||
return currentId
|
||||
}
|
||||
|
||||
function updateFold(id, open) {
|
||||
let closedFolds = JSON.parse(localStorage.getItem("closed-folds") || '{}') || {}
|
||||
if (!open) {
|
||||
closedFolds[id] = true
|
||||
} else {
|
||||
delete closedFolds[id]
|
||||
}
|
||||
localStorage.setItem('closed-folds', JSON.stringify(closedFolds))
|
||||
}
|
||||
|
||||
function length() {
|
||||
return idList.length;
|
||||
}
|
||||
|
|
@ -309,7 +320,7 @@ function Store(inputData) {
|
|||
let first = index(from)
|
||||
let i = 0
|
||||
while (i < n) {
|
||||
value(idList[first+i]).indented += diff
|
||||
value(idList[first + i]).indented += diff
|
||||
i++
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user