mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-29 10:00:08 +00:00
made system attrs safe from being overwritten from code directly...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
06f22772f5
commit
9348afd5c8
@ -203,13 +203,14 @@ var plugin = {
|
||||
var attributes = {
|
||||
__proto__: plugin,
|
||||
|
||||
// XXX should attr settings be set here or in the Outline???
|
||||
// ...this includes .__block_attrs__ and .__system_attrs__
|
||||
|
||||
//
|
||||
// Parse attrs...
|
||||
// .parseBlockAttrs(<text>[, <elem>])
|
||||
// -> [<elem>, <attrs>, <sys-attrs>]
|
||||
//
|
||||
// XXX where should we get .__block_attrs__???
|
||||
// ...editor (current), plugin, ...???
|
||||
parseBlockAttrs: function(editor, text, elem={}){
|
||||
var system = editor.__block_attrs__
|
||||
var attrs = ''
|
||||
@ -227,6 +228,9 @@ var attributes = {
|
||||
.split(/(?:[\t ]*::[\t ]*|[\t ]*\n[\t ]*)/g)
|
||||
while(match.length > 0){
|
||||
var [name, val] = match.splice(0, 2)
|
||||
// ignore non-settable attrs...
|
||||
if(editor.__system_attrs__.includes(name)){
|
||||
continue }
|
||||
elem[name] =
|
||||
val == 'true' ?
|
||||
true
|
||||
@ -234,10 +238,14 @@ var attributes = {
|
||||
false
|
||||
: val }
|
||||
return ws })
|
||||
// build the attr strings...
|
||||
// NOTE: we are not doing this in the loop above to include all
|
||||
// the attributes that are in the elem but not explicitly
|
||||
// given in code...
|
||||
for(var name in elem){
|
||||
// ignore non-settable attrs...
|
||||
if(editor.__system_attrs__.includes(name)){
|
||||
continue }
|
||||
var val = elem[name]
|
||||
if(!(name in system)){
|
||||
attrs += `\n${name}::${val}`
|
||||
@ -925,12 +933,17 @@ var JSONOutline = {
|
||||
|
||||
__code_attrs__: false,
|
||||
__view_attrs__: false,
|
||||
__system_attrs__: [
|
||||
'text',
|
||||
'children',
|
||||
],
|
||||
__block_attrs__: {
|
||||
id: 'attr',
|
||||
collapsed: 'attr',
|
||||
focused: 'cls',
|
||||
},
|
||||
|
||||
|
||||
// Plugins...
|
||||
//
|
||||
// The order of plugins can be significant in the following cases:
|
||||
|
||||
@ -275,6 +275,7 @@ var setup = function(){
|
||||
- `<editable/>` -- field marker
|
||||
- each child node will copy the template and allow editing of only fields
|
||||
- not clear how to handle template changes...
|
||||
- DONE attributes: might be a good idea to prevent setting `.text` and `.children` attrs...
|
||||
- DONE TOC: Q: should we have both manual and auto headings???
|
||||
collapsed:: true
|
||||
- IMHO: no...
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user