Comparing version 8.9.0-beta.13 to 8.9.0-beta.14
@@ -26,9 +26,33 @@ const { knowledgeModule, where, Digraph } = require('./runtime').theprogrammablemind | ||
this._objects = objects | ||
this._objects.changeState = [] | ||
} | ||
changeState(value) { | ||
this._objects.changeState = value | ||
this._objects.changeState.push(value) | ||
} | ||
} | ||
const root = (id) => { | ||
return id.split('_')[0] | ||
} | ||
const setUpdate = (isA, update, states) => { | ||
let color; | ||
const styles = [] | ||
for (const state of states) { | ||
if (isA(state, 'style_wp')) { | ||
if (!update.styles) { | ||
update.styles = [] | ||
} | ||
let style = root(state.value) | ||
if (style == 'underlined') { | ||
style = 'underline' | ||
} | ||
update.styles.push(style) | ||
} else { | ||
update.color = root(state.value) | ||
} | ||
} | ||
} | ||
const api = new API() | ||
@@ -46,3 +70,3 @@ | ||
'paragraphs are countable', | ||
'bold, italic and underlined are styles', | ||
'bold, italic, code and underlined are styles', | ||
"resetIdSuffix", | ||
@@ -63,20 +87,6 @@ { | ||
semantic: ({api, isA, context, toArray}) => { | ||
const root = (id) => { | ||
return id.split('_')[0] | ||
} | ||
const unit = root(context.element.marker) | ||
const scope = context.element.quantity.quantity | ||
let color; | ||
const styles = [] | ||
const update = { unit, scope } | ||
for (const state of toArray(context.state)) { | ||
if (isA(state, 'style_wp')) { | ||
if (!update.styles) { | ||
update.styles = [] | ||
} | ||
update.styles.push(root(state.value)) | ||
} else { | ||
update.color = root(state.value) | ||
} | ||
} | ||
setUpdate(isA, update, toArray(context.state)) | ||
api.changeState(update) | ||
@@ -90,2 +100,25 @@ } | ||
], | ||
semantics: [ | ||
{ | ||
where: where(), | ||
match: ({context, isA}) => isA(context, 'style_wp') && !context.same && !context.isResponse && !context.evaluate, | ||
apply: ({context, api, isA, toArray}) => { | ||
const update = { scope: 'selection' } | ||
setUpdate(isA, update, toArray(context)) | ||
api.changeState(update) | ||
} | ||
}, | ||
{ | ||
where: where(), | ||
match: ({context, isA}) => isA(context, 'statefulElement_wp') && !context.same && !context.isResponse && !context.evaluate, | ||
apply: ({context, api, isA, toArray}) => { | ||
const unit = root(context.marker) | ||
let scope | ||
if (context.quantity) { | ||
scope = context.quantity.quantity | ||
} | ||
// TODO set default scope for "every word bold underlined etc" | ||
} | ||
}, | ||
], | ||
priorities: [ | ||
@@ -92,0 +125,0 @@ { "context": [['changeState_wp',0], ['statefulElement_wp', 0], ['list', 0]], ordered: true, choose: [0] }, |
@@ -318,6 +318,6 @@ { | ||
"argparse": "^2.0.1", | ||
"theprogrammablemind": "8.9.0-beta.13" | ||
"theprogrammablemind": "8.9.0-beta.14" | ||
}, | ||
"version": "8.9.0-beta.13", | ||
"version": "8.9.0-beta.14", | ||
"license": "UNLICENSED" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
38052342
860328
+ Addedtheprogrammablemind@8.9.0-beta.14(transitive)
- Removedtheprogrammablemind@8.9.0-beta.13(transitive)