mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-25 20:31:58 +00:00
Compare commits
No commits in common. "0125964dd61859710720d17e1b8534186288ba47" and "e41a78f5b080c6149212639045a0a4aaa993d305" have entirely different histories.
0125964dd6
...
e41a78f5b0
@ -102,7 +102,6 @@
|
|||||||
border-left: solid 1px silver;
|
border-left: solid 1px silver;
|
||||||
}
|
}
|
||||||
.editor .outline .block .block,
|
.editor .outline .block .block,
|
||||||
.editor.crop .outline .block[cropped] .block,
|
|
||||||
.editor.crop .outline .block[cropped] .block[cropped] {
|
.editor.crop .outline .block[cropped] .block[cropped] {
|
||||||
margin-left: var(--item-indent);
|
margin-left: var(--item-indent);
|
||||||
}
|
}
|
||||||
@ -276,7 +275,6 @@ editor .outline .block:focus {
|
|||||||
.editor.crop .outline .block:not([cropped])>.text {
|
.editor.crop .outline .block:not([cropped])>.text {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.editor.crop .outline .block,
|
|
||||||
.editor.crop .outline .block[cropped] {
|
.editor.crop .outline .block[cropped] {
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
@ -285,7 +283,6 @@ editor .outline .block:focus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* toolbar... */
|
|
||||||
.editor .toolbar {
|
.editor .toolbar {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
@ -351,8 +351,7 @@ var tasks = {
|
|||||||
return elem },
|
return elem },
|
||||||
updateCheckboxes: function(editor, elem){
|
updateCheckboxes: function(editor, elem){
|
||||||
elem = this.getCheckbox(editor, elem)
|
elem = this.getCheckbox(editor, elem)
|
||||||
var node = editor.get(elem, false)
|
var node = editor.get(elem)
|
||||||
var data = editor.data(node)
|
|
||||||
var text = node.querySelector('.code')
|
var text = node.querySelector('.code')
|
||||||
// get the checkbox order...
|
// get the checkbox order...
|
||||||
var i = [...node.querySelectorAll('input[type=checkbox]')].indexOf(elem)
|
var i = [...node.querySelectorAll('input[type=checkbox]')].indexOf(elem)
|
||||||
@ -364,12 +363,6 @@ var tasks = {
|
|||||||
to
|
to
|
||||||
: m }
|
: m }
|
||||||
text.value = text.value.replace(/\[[Xx_]\]/g, toggle)
|
text.value = text.value.replace(/\[[Xx_]\]/g, toggle)
|
||||||
// NOTE: status is updated via a timeout set in .__parse__(..)...
|
|
||||||
editor.setUndo(
|
|
||||||
editor.path(node),
|
|
||||||
'update',
|
|
||||||
[editor.path(node),
|
|
||||||
data])
|
|
||||||
return elem },
|
return elem },
|
||||||
toggleCheckbox: function(editor, checkbox, offset){
|
toggleCheckbox: function(editor, checkbox, offset){
|
||||||
checkbox = this.getCheckbox(editor, checkbox, offset)
|
checkbox = this.getCheckbox(editor, checkbox, offset)
|
||||||
@ -403,7 +396,6 @@ var tasks = {
|
|||||||
var node = editor.get(elem)
|
var node = editor.get(elem)
|
||||||
if(node == null){
|
if(node == null){
|
||||||
return }
|
return }
|
||||||
var data = editor.data(elem, false)
|
|
||||||
var text = node.querySelector('.code')
|
var text = node.querySelector('.code')
|
||||||
var value = text.value
|
var value = text.value
|
||||||
var s = text.selectionStart
|
var s = text.selectionStart
|
||||||
@ -421,11 +413,6 @@ var tasks = {
|
|||||||
text.selectionStart = s + (value.length - l)
|
text.selectionStart = s + (value.length - l)
|
||||||
text.selectionEnd = e + (value.length - l)
|
text.selectionEnd = e + (value.length - l)
|
||||||
editor.update(node)
|
editor.update(node)
|
||||||
editor.setUndo(
|
|
||||||
editor.path(node),
|
|
||||||
'update',
|
|
||||||
[editor.path(node),
|
|
||||||
data])
|
|
||||||
return node },
|
return node },
|
||||||
|
|
||||||
__setup__: function(editor){
|
__setup__: function(editor){
|
||||||
@ -437,9 +424,8 @@ var tasks = {
|
|||||||
text = text
|
text = text
|
||||||
.replace(p, handler) }
|
.replace(p, handler) }
|
||||||
return text },
|
return text },
|
||||||
__update_checkboxes_timeout: undefined,
|
|
||||||
__parse__: function(text, editor, elem){
|
__parse__: function(text, editor, elem){
|
||||||
var res = text
|
return text
|
||||||
// block checkboxes...
|
// block checkboxes...
|
||||||
// NOTE: these are separate as we need to align block text
|
// NOTE: these are separate as we need to align block text
|
||||||
// to leading chekbox...
|
// to leading chekbox...
|
||||||
@ -454,15 +440,7 @@ var tasks = {
|
|||||||
this.style(editor, elem, 'check', '<input type="checkbox" checked>'))
|
this.style(editor, elem, 'check', '<input type="checkbox" checked>'))
|
||||||
// completion...
|
// completion...
|
||||||
// XXX add support for being like a todo checkbox...
|
// XXX add support for being like a todo checkbox...
|
||||||
.replace(/(?<!\\)\[[%]\]/gm, '<span class="completion"></span>')
|
.replace(/(?<!\\)\[[%]\]/gm, '<span class="completion"></span>') },
|
||||||
// need to update status...
|
|
||||||
// XXX not sure if this is a good way to do this...
|
|
||||||
if(res != text && this.__update_checkboxes_timeout == null){
|
|
||||||
var that = this
|
|
||||||
this.__update_checkboxes_timeout = setTimeout(function(){
|
|
||||||
that.__update_checkboxes_timeout = undefined
|
|
||||||
that.updateAllStatus(editor) }, 200) }
|
|
||||||
return res },
|
|
||||||
__focusin__: function(evt, editor, elem){
|
__focusin__: function(evt, editor, elem){
|
||||||
elem.classList.contains('block')
|
elem.classList.contains('block')
|
||||||
&& this.selectCheckbox(editor, elem) },
|
&& this.selectCheckbox(editor, elem) },
|
||||||
@ -986,14 +964,8 @@ var Outline = {
|
|||||||
// XXX should we call plugin's __change__ live or every second???
|
// XXX should we call plugin's __change__ live or every second???
|
||||||
__change_timeout: undefined,
|
__change_timeout: undefined,
|
||||||
__change_requested: false,
|
__change_requested: false,
|
||||||
__change__: function(options={}){
|
__change__: function(){
|
||||||
var that = this
|
var that = this
|
||||||
|
|
||||||
// handle undo...
|
|
||||||
options.undo
|
|
||||||
&& this.setUndo(...options.undo)
|
|
||||||
|
|
||||||
// long changes...
|
|
||||||
this.__change_requested = true
|
this.__change_requested = true
|
||||||
if(this.__change_timeout){
|
if(this.__change_timeout){
|
||||||
return this }
|
return this }
|
||||||
@ -1001,7 +973,7 @@ var Outline = {
|
|||||||
// do the action...
|
// do the action...
|
||||||
if(this.__change_requested){
|
if(this.__change_requested){
|
||||||
this.sync()
|
this.sync()
|
||||||
this.runPlugins('__change__', this)
|
this.runPlugins('__change__', that)
|
||||||
this.__change_requested = false }
|
this.__change_requested = false }
|
||||||
|
|
||||||
this.__change_timeout = setTimeout(
|
this.__change_timeout = setTimeout(
|
||||||
@ -1017,8 +989,6 @@ var Outline = {
|
|||||||
collapsed: 'attr',
|
collapsed: 'attr',
|
||||||
focused: 'cls',
|
focused: 'cls',
|
||||||
},
|
},
|
||||||
// NOTE: this does not internally handle undo as it would be too
|
|
||||||
// granular...
|
|
||||||
update: function(node='focused', data){
|
update: function(node='focused', data){
|
||||||
var node = this.get(node)
|
var node = this.get(node)
|
||||||
data ??= this.data(node, false)
|
data ??= this.data(node, false)
|
||||||
@ -1084,21 +1054,23 @@ var Outline = {
|
|||||||
parent.after(cur)
|
parent.after(cur)
|
||||||
children.length > 0
|
children.length > 0
|
||||||
&& cur.lastChild.append(...children)
|
&& cur.lastChild.append(...children)
|
||||||
this.__change__({undo: [
|
this.setUndo(
|
||||||
this.path(cur),
|
this.path(cur),
|
||||||
'indent',
|
'indent',
|
||||||
['in'],
|
['in'],
|
||||||
prev ]}) }
|
prev)
|
||||||
|
this.__change__() }
|
||||||
// indent...
|
// indent...
|
||||||
} else {
|
} else {
|
||||||
var parent = siblings[siblings.indexOf(cur) - 1]
|
var parent = siblings[siblings.indexOf(cur) - 1]
|
||||||
if(parent){
|
if(parent){
|
||||||
parent.lastChild.append(cur)
|
parent.lastChild.append(cur)
|
||||||
this.__change__({undo: [
|
this.setUndo(
|
||||||
this.path(cur),
|
this.path(cur),
|
||||||
'indent',
|
'indent',
|
||||||
['out'],
|
['out'],
|
||||||
prev ]})} }
|
prev)
|
||||||
|
this.__change__()} }
|
||||||
return cur },
|
return cur },
|
||||||
shift: function(node='focused', direction){
|
shift: function(node='focused', direction){
|
||||||
if(node == 'up' || node == 'down'){
|
if(node == 'up' || node == 'down'){
|
||||||
@ -1120,12 +1092,13 @@ var Outline = {
|
|||||||
siblings[i+1].after(node) }
|
siblings[i+1].after(node) }
|
||||||
focused
|
focused
|
||||||
&& this.focus()
|
&& this.focus()
|
||||||
this.__change__({undo: [
|
this.setUndo(
|
||||||
this.path(node),
|
this.path(node),
|
||||||
'shift',
|
'shift',
|
||||||
[direction == 'up' ?
|
[direction == 'up' ?
|
||||||
'down'
|
'down'
|
||||||
: 'up'] ]})
|
: 'up'])
|
||||||
|
this.__change__()
|
||||||
return this },
|
return this },
|
||||||
// XXX make undo a bit more refined...
|
// XXX make undo a bit more refined...
|
||||||
remove: function(node='focused'){
|
remove: function(node='focused'){
|
||||||
@ -1142,19 +1115,20 @@ var Outline = {
|
|||||||
elem?.remove()
|
elem?.remove()
|
||||||
next
|
next
|
||||||
&& this.focus(next)
|
&& this.focus(next)
|
||||||
this.__change__({undo: [
|
// XXX HACK...
|
||||||
|
this.setUndo(
|
||||||
undefined,
|
undefined,
|
||||||
'load',
|
'load',
|
||||||
// XXX HACK...
|
[data])
|
||||||
[data] ]})
|
this.__change__()
|
||||||
return this },
|
return this },
|
||||||
clear: function(){
|
clear: function(){
|
||||||
var data = this.json()
|
this.setUndo(
|
||||||
this.outline.innerText = ''
|
|
||||||
this.__change__({undo: [
|
|
||||||
undefined,
|
undefined,
|
||||||
'load',
|
'load',
|
||||||
[data] ]})
|
[this.json()])
|
||||||
|
this.outline.innerText = ''
|
||||||
|
this.__change__()
|
||||||
return this },
|
return this },
|
||||||
|
|
||||||
// expand/collapse...
|
// expand/collapse...
|
||||||
@ -1341,7 +1315,7 @@ var Outline = {
|
|||||||
var attrs = this.__block_attrs__
|
var attrs = this.__block_attrs__
|
||||||
var cls_attrs = ['focused']
|
var cls_attrs = ['focused']
|
||||||
return {
|
return {
|
||||||
text: elem.querySelector('.code').value,
|
text: elem.querySelector('textarea').value,
|
||||||
...(Object.entries(attrs)
|
...(Object.entries(attrs)
|
||||||
.reduce(function(res, [attr, type]){
|
.reduce(function(res, [attr, type]){
|
||||||
if(type == 'attr'){
|
if(type == 'attr'){
|
||||||
|
|||||||
@ -48,9 +48,16 @@ var setup = function(){
|
|||||||
-
|
-
|
||||||
- ## Bugs:
|
- ## Bugs:
|
||||||
focused:: true
|
focused:: true
|
||||||
|
- BUG: crop root indent is off...
|
||||||
|
- a
|
||||||
|
- b
|
||||||
|
- c
|
||||||
|
- crop this
|
||||||
- BUG: mobile browsers behave quite chaotically ignoring parts of the styling...
|
- BUG: mobile browsers behave quite chaotically ignoring parts of the styling...
|
||||||
-
|
-
|
||||||
- ## ToDo:
|
- ## ToDo:
|
||||||
|
- undo: checkboxes and DONE??
|
||||||
|
_...this should be triggered by text change -- move current implementation to .__editedcode__()??..._
|
||||||
- copy/paste nodes/trees
|
- copy/paste nodes/trees
|
||||||
- FEATURE: read-only mode
|
- FEATURE: read-only mode
|
||||||
- auto-shift done blocks to the end of siblings... (option?)
|
- auto-shift done blocks to the end of siblings... (option?)
|
||||||
@ -104,9 +111,6 @@ var setup = function(){
|
|||||||
- empty item height is a bit off...
|
- empty item height is a bit off...
|
||||||
- search?
|
- search?
|
||||||
- _...not sure if search should be internal or external yet..._
|
- _...not sure if search should be internal or external yet..._
|
||||||
- DONE: undo: checkboxes and DONE??
|
|
||||||
collapsed:: true
|
|
||||||
_...this should be triggered by text change -- move current implementation to .__editedcode__()??..._
|
|
||||||
- DONE undo
|
- DONE undo
|
||||||
- DONE crop: make path clickable
|
- DONE crop: make path clickable
|
||||||
- DONE Q: crop: should we control crop via "crop-in"/"crop-out" instead of crop/uncrop??
|
- DONE Q: crop: should we control crop via "crop-in"/"crop-out" instead of crop/uncrop??
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user