tpmkms_4wp 8.9.1-beta.4 → 8.9.1-beta.6

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