ekms 8.9.0-beta.14 → 8.9.0-beta.16

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
@@ -18,6 +18,21 @@ const instance = require('./wp.instance.json')
18
18
 
19
19
 
20
20
  make every word bold and underlines and blue -> weirdly "bold underlined and blue" works
21
+
22
+ make the font ...
23
+ make the color blue
24
+ make the color of the first paragraph blue
25
+
26
+ words that start with a
27
+ make all the bold text uppercase
28
+ underline all the bold text
29
+ underline all the text
30
+ underline everything
31
+ 4 letter word
32
+ 4 to 6 letter word
33
+ word with 'a' in it
34
+ words containing a
35
+ every 5th word
21
36
  */
22
37
 
23
38
  class API {
@@ -60,33 +75,59 @@ let config = {
60
75
  name: 'wp',
61
76
  };
62
77
 
78
+ const changeState = ({api, isA, context, toArray, element, state}) => {
79
+ let unit = root(context.element.marker)
80
+ let scope
81
+ if (isA(context.element, 'everything')) {
82
+ scope = 'all'
83
+ } else {
84
+ scope = context.element.quantity.quantity
85
+ }
86
+ const update = { unit, scope }
87
+ setUpdate(isA, update, toArray(context.state))
88
+ api.changeState(update)
89
+ }
90
+
63
91
  template = {
64
92
  configs: [
65
93
  'setidsuffix _wp',
66
94
  'words are countable and statefulElements',
67
95
  'characters are countable',
68
96
  'paragraphs are countable',
69
- 'bold, italic, code and underlined are styles',
97
+ 'bold, italic, code and underline are styles',
98
+ 'underlined means underline',
99
+ // 'styles are negatable',
70
100
  "resetIdSuffix",
71
101
  {
72
102
  operators: [
73
103
  // TODO write a parser for this so I can use statefulElement as the id
74
104
  "([changeState_wp|make] ([statefulElement_wp]) ([stateValue_wp|]))",
105
+ "((style_wp/*) [applyStyle_wp] ([statefulElement_wp|]))",
75
106
  ],
76
107
  bridges: [
108
+ {
109
+ id: 'applyStyle_wp',
110
+ parents: ['verb'],
111
+ convolution: true,
112
+ bridge: "{ ...next(operator), element: after[0], state: before[0], operator: operator, generate: ['state', 'element'] }",
113
+ localHierarchy: [
114
+ ['thisitthat', 'statefulElement_wp'],
115
+ ['everything', 'statefulElement_wp'],
116
+ ],
117
+ semantic: (args) => {
118
+ changeState({...args, element: args.context.element, state: args.context.state})
119
+ }
120
+ },
77
121
  {
78
122
  id: 'changeState_wp',
79
123
  parents: ['verb'],
80
124
  bridge: "{ ...next(operator), element: after[0], state: after[1], operator: operator, generate: ['operator', 'element', 'state'] }",
81
125
  localHierarchy: [
82
- ['thisitthat', 'statefulElement'],
126
+ ['thisitthat', 'statefulElement_wp'],
127
+ ['everything', 'statefulElement_wp'],
83
128
  ],
84
- semantic: ({api, isA, context, toArray}) => {
85
- const unit = root(context.element.marker)
86
- const scope = context.element.quantity.quantity
87
- const update = { unit, scope }
88
- setUpdate(isA, update, toArray(context.state))
89
- api.changeState(update)
129
+ semantic: (args) => {
130
+ changeState({...args, element: args.context.element, state: args.context.state})
90
131
  }
91
132
  },
92
133
  {
@@ -121,6 +162,9 @@ template = {
121
162
  { "context": [['changeState_wp',0], ['statefulElement_wp', 0], ['list', 0]], ordered: true, choose: [0] },
122
163
  ],
123
164
  },
165
+ // "([changeState_wp|make] ([statefulElement_wp]) ([stateValue_wp|]))",
166
+ // "((style_wp/*) [applyStyle_wp] ([statefulElement_wp|]))",
167
+ // "x statefulElement_wp y means y changeState_wp x",
124
168
  ]
125
169
  }
126
170