tpmkms_4wp 8.9.1-beta.2 → 8.9.1-beta.4

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
@@ -9,6 +9,18 @@ const wp_tests = require('./wp.test.json')
9
9
  const instance = require('./wp.instance.json')
10
10
 
11
11
  /*
12
+ working on
13
+ bold the first word
14
+ bold the first paragraph
15
+ bold the first letter
16
+
17
+ after
18
+ bold the first word of every paragraph
19
+ bold the first letter of every word
20
+
21
+ after
22
+ make the words that start with t blue
23
+
12
24
  the bolded words that start with t
13
25
 
14
26
  start inserting text until I say banana
@@ -17,7 +29,9 @@ const instance = require('./wp.instance.json')
17
29
  stop inserting text
18
30
 
19
31
  make the text of the 1st to 3rd paragraphs blue
20
-
32
+
33
+ capitalize the words banana and word
34
+ capitalize banana and tree
21
35
 
22
36
  make the words that start with a bold
23
37
 
@@ -40,6 +54,8 @@ const instance = require('./wp.instance.json')
40
54
  words containing a
41
55
  every 5th word
42
56
 
57
+ the words that are capitalized
58
+
43
59
  in the first paragraph make the words that start with abc bold
44
60
  bold the first three words that start with t
45
61
  bold much and many
@@ -99,22 +115,33 @@ const changeState = ({api, isA, context, toArray, element, state}) => {
99
115
  let unit = root(context.element.marker)
100
116
  let scope
101
117
  let conditions = []
102
- if (isA(context.element, 'everything')) {
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')) {
103
122
  scope = 'all'
104
- } else if (context.element.conditions) {
105
- const condition = context.element.conditions[0]
106
- if (condition.marker == 'wordComparisonWith_wp') {
107
- // with or not with that is the question
108
- const letters = condition.letters.letters.text
109
- conditions.push({ comparison: condition.comparison, letters })
110
- } else if (condition.marker == 'wordComparison_wp') {
111
- // with or not with that is the question
112
- const letters = condition.letters.text
113
- conditions.push({ comparison: condition.comparison, letters })
114
- }
115
- } else {
123
+ } else if (context.element.quantity) {
116
124
  scope = context.element.quantity.quantity
117
125
  }
126
+
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 })
140
+ }
141
+ }
142
+ }
143
+ }
144
+
118
145
  const update = { unit, scope, conditions }
119
146
  setUpdate(isA, update, toArray(context.state))
120
147
  api.changeState(update)
@@ -123,10 +150,11 @@ const changeState = ({api, isA, context, toArray, element, state}) => {
123
150
  template = {
124
151
  configs: [
125
152
  'setidsuffix _wp',
126
- 'words are countable and statefulElements',
127
- 'characters are countable',
128
- 'paragraphs are countable and statefulElement',
153
+ 'words are countable orderable and statefulElements',
154
+ 'characters are countable orderable and statefulElements',
155
+ 'paragraphs are countable orderable and statefulElement',
129
156
  'text is a statefulElement',
157
+ 'letters means characters',
130
158
  'bold, italic, code, capitalize, lowercase and underline are styles',
131
159
  'underlined means underline',
132
160
  'capitalized means capitalize',
@@ -134,7 +162,7 @@ template = {
134
162
  'italicize means italic',
135
163
  'italicized means italic',
136
164
  // TODO have a mode where I can stay this is a definition sentence then just say style modifies and it will do it right
137
- 'capitalized, bolded, italicized and underlined are styleModifiers',
165
+ 'uppercased, lowercased, capitalized, bolded, italicized and underlined are styleModifiers',
138
166
  // 'start end and contain are wordComparisonWiths',
139
167
  // 'styles are negatable',
140
168
  "resetIdSuffix",
@@ -144,11 +172,13 @@ template = {
144
172
  "((style_wp/*) [applyStyle_wp] ([statefulElement_wp|]))",
145
173
  "((word_wp/*) [wordComparisonWith_wp] ([comparisonWith_wp|with] (a/0)? (letters)))",
146
174
  "((word_wp/*) [wordComparison_wp] (a/0)? (letters))",
147
- "((styleModifier_wp/*) [modifiedByStyle_wp] (statefulElement_wp/*))",
175
+ // this one is "the bolded/underlined/italized/... word"
176
+ "((styleModifier_wp/*) [modifiedByStyle_wp] (statefulElement_wp/* && context.determiner == undefined))",
148
177
  ],
149
178
  bridges: [
150
179
  {
151
180
  id: 'modifiedByStyle_wp',
181
+ // parents: ['verb'],
152
182
  parents: ['adjective'],
153
183
  convolution: true,
154
184
  bridge: "{ ...after[0], style: before[0], target: after[0], generate: ['style', 'target'], conditions: append(after[0].conditions, [before[0]]) }",
@@ -240,6 +270,7 @@ template = {
240
270
  },
241
271
  ],
242
272
  priorities: [
273
+ // { "context": [['underline_wp',0], ['statefulElement_wp', 1], ['thatVerb', 0]], ordered: true, choose: [2] },
243
274
  { "context": [['changeState_wp',0], ['statefulElement_wp', 0], ['list', 0]], ordered: true, choose: [0] },
244
275
  { "context": [['comparisonWith_wp',0], ['unknown', 0], ['list', 1]], ordered: true, choose: [0] },
245
276
  ],