tpmkms_4wp 8.9.0-beta.15 → 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
@@ -23,6 +23,11 @@ const instance = require('./wp.instance.json')
23
23
  make the color blue
24
24
  make the color of the first paragraph blue
25
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
26
31
  4 letter word
27
32
  4 to 6 letter word
28
33
  word with 'a' in it
@@ -70,21 +75,49 @@ let config = {
70
75
  name: 'wp',
71
76
  };
72
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
+
73
91
  template = {
74
92
  configs: [
75
93
  'setidsuffix _wp',
76
94
  'words are countable and statefulElements',
77
95
  'characters are countable',
78
96
  'paragraphs are countable',
79
- 'bold, italic, code and underlined are styles',
97
+ 'bold, italic, code and underline are styles',
98
+ 'underlined means underline',
80
99
  // 'styles are negatable',
81
100
  "resetIdSuffix",
82
101
  {
83
102
  operators: [
84
103
  // TODO write a parser for this so I can use statefulElement as the id
85
104
  "([changeState_wp|make] ([statefulElement_wp]) ([stateValue_wp|]))",
105
+ "((style_wp/*) [applyStyle_wp] ([statefulElement_wp|]))",
86
106
  ],
87
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
+ },
88
121
  {
89
122
  id: 'changeState_wp',
90
123
  parents: ['verb'],
@@ -93,17 +126,8 @@ template = {
93
126
  ['thisitthat', 'statefulElement_wp'],
94
127
  ['everything', 'statefulElement_wp'],
95
128
  ],
96
- semantic: ({api, isA, context, toArray}) => {
97
- let unit = root(context.element.marker)
98
- let scope
99
- if (isA(context.element, 'everything')) {
100
- scope = 'all'
101
- } else {
102
- scope = context.element.quantity.quantity
103
- }
104
- const update = { unit, scope }
105
- setUpdate(isA, update, toArray(context.state))
106
- api.changeState(update)
129
+ semantic: (args) => {
130
+ changeState({...args, element: args.context.element, state: args.context.state})
107
131
  }
108
132
  },
109
133
  {
@@ -138,6 +162,9 @@ template = {
138
162
  { "context": [['changeState_wp',0], ['statefulElement_wp', 0], ['list', 0]], ordered: true, choose: [0] },
139
163
  ],
140
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",
141
168
  ]
142
169
  }
143
170