tpmkms_4wp 8.9.1-beta.5 → 8.9.1-beta.7

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,13 +16,22 @@ const instance = require('./wp.instance.json')
16
16
 
17
17
  after
18
18
  bold the first word of every paragraph
19
+ bold the first word of the second and third paragraph
20
+ bold the first word of the second paragraph and third paragraph
19
21
  bold the first letter of every word
22
+ bold the first letter of every word that starts with t
23
+ bold the first letter of the words that start with t in the third paragraph
24
+ bold the paragraph that contains words that start with t
20
25
 
21
26
  after
22
27
  make the words that start with t blue
23
28
 
24
29
  the bolded words that start with t
25
30
 
31
+ replace better with worse
32
+
33
+ change underlines to bolds
34
+
26
35
  start inserting text until I say banana
27
36
  ...
28
37
  or
@@ -112,37 +121,53 @@ let config = {
112
121
  };
113
122
 
114
123
  const changeState = ({api, isA, context, toArray, element, state}) => {
115
- let unit = root(context.element.marker)
116
124
  let scope
117
- let conditions = []
118
-
119
- if (context.element.ordinal) {
120
- conditions.push({ ordinals: toArray(context.element.ordinal).map((context) => context.value)})
121
- } else if (isA(context.element, 'everything')) {
122
- scope = 'all'
123
- } else if (context.element.quantity) {
124
- scope = context.element.quantity.quantity
125
- }
126
125
 
127
- if (context.element.conditions) {
128
- for (const condition of context.element.conditions) {
129
- if (condition.marker == 'wordComparisonWith_wp') {
130
- // with or not with that is the question
131
- const letters = condition.letters.letters.text
132
- conditions.push({ comparison: condition.comparison, letters })
133
- } else if (condition.marker == 'wordComparison_wp') {
134
- // with or not with that is the question
135
- const letters = condition.letters.text
136
- conditions.push({ comparison: condition.comparison, letters })
137
- } else if (isA(condition, 'styleModifier_wp')) {
138
- for (const style of toArray(condition)) {
139
- conditions.push({ hasStyle: style.marker })
126
+ const getElement = (selector, update) => {
127
+ const unit = root(selector.marker)
128
+ let conditions = []
129
+ let scope;
130
+ const condition = []
131
+ if (selector.ordinal) {
132
+ conditions.push({ ordinals: toArray(selector.ordinal).map((context) => context.value)})
133
+ } else if (isA(selector, 'everything')) {
134
+ scope = 'all'
135
+ } else if (selector.quantity) {
136
+ scope = selector.quantity.quantity
137
+ } if (selector.distributer) {
138
+ scope = selector.distributer.value
139
+ }
140
+
141
+ if (selector.conditions) {
142
+ for (const condition of selector.conditions) {
143
+ if (condition.marker == 'wordComparisonWith_wp') {
144
+ // with or not with that is the question
145
+ const letters = condition.letters.letters.text
146
+ conditions.push({ comparison: condition.comparison, letters })
147
+ } else if (condition.marker == 'wordComparison_wp') {
148
+ // with or not with that is the question
149
+ const letters = condition.letters.text
150
+ conditions.push({ comparison: condition.comparison, letters })
151
+ } else if (isA(condition, 'styleModifier_wp')) {
152
+ for (const style of toArray(condition)) {
153
+ conditions.push({ hasStyle: style.marker })
154
+ }
140
155
  }
141
156
  }
142
157
  }
158
+
159
+ if (selector.context) {
160
+ for (const context of toArray(selector.context)) {
161
+ getElement(context, update)
162
+ }
163
+ }
164
+
165
+ update.selectors.push({ unit, scope, conditions })
143
166
  }
144
167
 
145
- const update = { unit, scope, conditions }
168
+ const update = { selectors: [] }
169
+ getElement(context.element, update)
170
+
146
171
  setUpdate(isA, update, toArray(context.state))
147
172
  api.changeState(update)
148
173
  }
@@ -150,9 +175,9 @@ const changeState = ({api, isA, context, toArray, element, state}) => {
150
175
  template = {
151
176
  configs: [
152
177
  'setidsuffix _wp',
153
- 'words are countable orderable and statefulElements',
154
- 'characters are countable orderable and statefulElements',
155
- 'paragraphs are countable orderable and statefulElement',
178
+ 'words are countable distributable orderable textContainers and statefulElements',
179
+ 'characters are countable distributable orderable and statefulElements',
180
+ 'paragraphs are countable distributable orderable textContainers and statefulElement',
156
181
  'text is a statefulElement',
157
182
  'letters means characters',
158
183
  'bold, italic, code, capitalize, lowercase and underline are styles',
@@ -174,8 +199,15 @@ template = {
174
199
  "((word_wp/*) [wordComparison_wp] (a/0)? (letters))",
175
200
  // this one is "the bolded/underlined/italized/... word"
176
201
  "((styleModifier_wp/*) [modifiedByStyle_wp] (statefulElement_wp/* && context.determiner == undefined))",
202
+ // the first letter of each paragraph
203
+ "((statefulElement_wp/*) <statefulElementInContext_wp|of> (statefulElement_wp/*))",
177
204
  ],
178
205
  bridges: [
206
+ {
207
+ id: 'statefulElementInContext_wp',
208
+ parents: ['preposition'],
209
+ bridge: "{ ...before[0], context: append(before[0].context, [after[0]]), generate: [before[0], operator, after[0]] }",
210
+ },
179
211
  {
180
212
  id: 'modifiedByStyle_wp',
181
213
  // parents: ['verb'],
@@ -270,7 +302,7 @@ template = {
270
302
  },
271
303
  ],
272
304
  priorities: [
273
- // { "context": [['underline_wp',0], ['statefulElement_wp', 1], ['thatVerb', 0]], ordered: true, choose: [2] },
305
+ { "context": [['changeState_wp',0], ['every', 0], ['word_wp', 1], ['list', 1]], ordered: true, choose: [1] },
274
306
  { "context": [['changeState_wp',0], ['statefulElement_wp', 0], ['list', 0]], ordered: true, choose: [0] },
275
307
  { "context": [['comparisonWith_wp',0], ['unknown', 0], ['list', 1]], ordered: true, choose: [0] },
276
308
  ],
@@ -293,7 +325,7 @@ knowledgeModule({
293
325
  contents: wp_tests,
294
326
  checks: {
295
327
  context: [
296
- ...defaultContextCheck(),
328
+ ...defaultContextCheck(['distributer', 'subject', 'element', 'letters', 'target', 'conditions' ]),
297
329
  ],
298
330
  objects: [
299
331
  'changeState',