ekms 8.9.0-beta.15 → 8.9.0-beta.17

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
@@ -56,6 +61,8 @@ const setUpdate = (isA, update, states) => {
56
61
  let style = root(state.value)
57
62
  if (style == 'underlined') {
58
63
  style = 'underline'
64
+ } else if (style == 'italicize') {
65
+ style = 'italic'
59
66
  }
60
67
  update.styles.push(style)
61
68
  } else {
@@ -70,21 +77,50 @@ let config = {
70
77
  name: 'wp',
71
78
  };
72
79
 
80
+ const changeState = ({api, isA, context, toArray, element, state}) => {
81
+ let unit = root(context.element.marker)
82
+ let scope
83
+ if (isA(context.element, 'everything')) {
84
+ scope = 'all'
85
+ } else {
86
+ scope = context.element.quantity.quantity
87
+ }
88
+ const update = { unit, scope }
89
+ setUpdate(isA, update, toArray(context.state))
90
+ api.changeState(update)
91
+ }
92
+
73
93
  template = {
74
94
  configs: [
75
95
  'setidsuffix _wp',
76
96
  'words are countable and statefulElements',
77
97
  'characters are countable',
78
98
  'paragraphs are countable',
79
- 'bold, italic, code and underlined are styles',
99
+ 'bold, italic, code and underline are styles',
100
+ 'underlined means underline',
101
+ 'italicize means italic',
80
102
  // 'styles are negatable',
81
103
  "resetIdSuffix",
82
104
  {
83
105
  operators: [
84
106
  // TODO write a parser for this so I can use statefulElement as the id
85
107
  "([changeState_wp|make] ([statefulElement_wp]) ([stateValue_wp|]))",
108
+ "((style_wp/*) [applyStyle_wp] ([statefulElement_wp|]))",
86
109
  ],
87
110
  bridges: [
111
+ {
112
+ id: 'applyStyle_wp',
113
+ parents: ['verb'],
114
+ convolution: true,
115
+ bridge: "{ ...next(operator), element: after[0], state: before[0], operator: operator, generate: ['state', 'element'] }",
116
+ localHierarchy: [
117
+ ['thisitthat', 'statefulElement_wp'],
118
+ ['everything', 'statefulElement_wp'],
119
+ ],
120
+ semantic: (args) => {
121
+ changeState({...args, element: args.context.element, state: args.context.state})
122
+ }
123
+ },
88
124
  {
89
125
  id: 'changeState_wp',
90
126
  parents: ['verb'],
@@ -93,17 +129,8 @@ template = {
93
129
  ['thisitthat', 'statefulElement_wp'],
94
130
  ['everything', 'statefulElement_wp'],
95
131
  ],
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)
132
+ semantic: (args) => {
133
+ changeState({...args, element: args.context.element, state: args.context.state})
107
134
  }
108
135
  },
109
136
  {
@@ -138,6 +165,9 @@ template = {
138
165
  { "context": [['changeState_wp',0], ['statefulElement_wp', 0], ['list', 0]], ordered: true, choose: [0] },
139
166
  ],
140
167
  },
168
+ // "([changeState_wp|make] ([statefulElement_wp]) ([stateValue_wp|]))",
169
+ // "((style_wp/*) [applyStyle_wp] ([statefulElement_wp|]))",
170
+ // "x statefulElement_wp y means y changeState_wp x",
141
171
  ]
142
172
  }
143
173