ekms 8.9.0-beta.10 → 8.9.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/common/wp.js CHANGED
@@ -16,6 +16,8 @@ const instance = require('./wp.instance.json')
16
16
 
17
17
  make the text of the 1st to 3rd paragraphs blue
18
18
 
19
+
20
+ make every word bold and underlines and blue -> weirdly "bold underlined and blue" works
19
21
  */
20
22
 
21
23
  class API {
@@ -23,8 +25,8 @@ class API {
23
25
  this._objects = objects
24
26
  }
25
27
 
26
- changeColor({ unit, scope, color }) {
27
- this._objects.changeColor = { unit, scope, color }
28
+ changeState(value) {
29
+ this._objects.changeState = value
28
30
  }
29
31
  }
30
32
 
@@ -32,40 +34,58 @@ const api = new API()
32
34
 
33
35
  let config = {
34
36
  name: 'wp',
35
- operators: [
36
- // TODO write a parser for this so I can use statefulElement as the id
37
- "([changeState|make] ([statefulelement]) ([stateValue|]))",
38
- ],
39
- bridges: [
40
- {
41
- id: 'changeState',
42
- parents: ['verb'],
43
- bridge: "{ ...next(operator), element: after[0], state: after[1], operator: operator, generate: ['operator', 'element', 'state'] }",
44
- semantic: ({api, context}) => {
45
- const unit = context.element.marker
46
- const scope = context.element.quantity.quantity
47
- const color = context.state.value.split('_')[0]
48
- api.changeColor({ unit, scope, color })
49
- }
50
- },
51
- {
52
- id: 'statefulelement',
53
- },
54
- {
55
- id: 'stateValue',
56
- children: ['color_colors'],
57
- },
58
- ],
59
- semantics: [
60
- ]
61
37
  };
62
38
 
63
39
  template = {
64
40
  configs: [
41
+ 'setidsuffix _wp',
65
42
  'words are countable and statefulElements',
66
43
  'characters are countable',
67
44
  'paragraphs are countable',
68
- ],
45
+ 'bold, italic and underlined are styles',
46
+ "resetIdSuffix",
47
+ {
48
+ operators: [
49
+ // TODO write a parser for this so I can use statefulElement as the id
50
+ "([changeState_wp|make] ([statefulElement_wp]) ([stateValue_wp|]))",
51
+ ],
52
+ bridges: [
53
+ {
54
+ id: 'changeState_wp',
55
+ parents: ['verb'],
56
+ bridge: "{ ...next(operator), element: after[0], state: after[1], operator: operator, generate: ['operator', 'element', 'state'] }",
57
+ localHierarchy: [
58
+ ['thisitthat', 'statefulElement'],
59
+ ],
60
+ semantic: ({api, isA, context, toArray}) => {
61
+ const unit = context.element.marker
62
+ const scope = context.element.quantity.quantity
63
+ let color;
64
+ const styles = []
65
+ const update = { unit, scope }
66
+ for (const state of toArray(context.state)) {
67
+ if (isA(state, 'style_wp')) {
68
+ if (!update.styles) {
69
+ update.styles = []
70
+ }
71
+ update.styles.push(state.value.split('_')[0])
72
+ } else {
73
+ update.color = state.value.split('_')[0]
74
+ }
75
+ }
76
+ api.changeState(update)
77
+ }
78
+ },
79
+ {
80
+ id: 'stateValue_wp',
81
+ children: ['color_colors', 'style_wp'],
82
+ },
83
+ ],
84
+ priorities: [
85
+ { "context": [['changeState_wp',0], ['statefulElement_wp', 0], ['list', 0]], ordered: true, choose: [0] },
86
+ ],
87
+ },
88
+ ]
69
89
  }
70
90
 
71
91
  knowledgeModule({
@@ -83,7 +103,7 @@ knowledgeModule({
83
103
  ...defaultContextCheck(),
84
104
  ],
85
105
  objects: [
86
- 'changeColor',
106
+ 'changeState',
87
107
  { km: 'ui' },
88
108
  ],
89
109
  },