@windward/core 0.4.0 → 0.4.2

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.
Files changed (46) hide show
  1. package/components/Content/Blocks/BlockQuote.vue +2 -2
  2. package/components/Content/Blocks/ClickableIcons.vue +1 -1
  3. package/components/Content/Blocks/Email.vue +10 -6
  4. package/components/Content/Blocks/Feedback.vue +12 -5
  5. package/components/Content/Blocks/Image.vue +2 -2
  6. package/components/Content/Blocks/OpenResponse.vue +7 -3
  7. package/components/Content/Blocks/OpenResponseCollate.vue +1 -1
  8. package/components/Content/Blocks/ScenarioChoice.vue +2 -2
  9. package/components/Content/Blocks/UserUpload/DisplayUserFilesTable.vue +2 -0
  10. package/components/Content/Blocks/UserUpload.vue +1 -0
  11. package/components/Content/Blocks/Video.vue +2 -2
  12. package/components/Navigation/Items/AskTheExpert.vue +1 -0
  13. package/components/Settings/AccordionSettings.vue +2 -0
  14. package/components/Settings/ClickableIconsSettings.vue +5 -1
  15. package/components/Settings/EmailSettings.vue +6 -1
  16. package/components/Settings/FeedbackSettings.vue +1 -0
  17. package/components/Settings/ImageSettings.vue +7 -8
  18. package/components/Settings/MathSettings.vue +1 -1
  19. package/components/Settings/ScenarioChoiceSettings.vue +1 -0
  20. package/components/Settings/TabSettings.vue +7 -1
  21. package/components/Settings/TextEditorSettings.vue +4 -2
  22. package/components/Settings/UserUploadSettings.vue +1 -1
  23. package/components/Settings/VideoSettings.vue +2 -0
  24. package/components/utils/FillInBlank/FillInBlankInput.vue +3 -0
  25. package/components/utils/MathExpressionEditor.vue +89 -56
  26. package/components/utils/MathLiveWrapper.vue +47 -25
  27. package/components/utils/TinyMCEWrapper.vue +107 -18
  28. package/components/utils/assets/tinymce/ui/dark/skin.scss +1 -1
  29. package/components/utils/assets/tinymce/ui/light/skin.scss +1 -1
  30. package/components/utils/glossary/CourseGlossary.vue +2 -0
  31. package/config/tinymce.config.ts +19 -19
  32. package/helpers/MathHelper.ts +59 -0
  33. package/helpers/tinymce/WindwardPlugins.ts +335 -0
  34. package/i18n/en-US/components/settings/image.ts +2 -0
  35. package/i18n/en-US/components/utils/math_expression_editor.ts +4 -3
  36. package/i18n/en-US/components/utils/tiny_mce_wrapper.ts +1 -0
  37. package/i18n/es-ES/components/settings/image.ts +2 -0
  38. package/i18n/es-ES/components/utils/math_expression_editor.ts +2 -1
  39. package/i18n/es-ES/components/utils/tiny_mce_wrapper.ts +1 -0
  40. package/i18n/sv-SE/components/settings/image.ts +2 -0
  41. package/i18n/sv-SE/components/utils/math_expression_editor.ts +1 -0
  42. package/i18n/sv-SE/components/utils/tiny_mce_wrapper.ts +1 -0
  43. package/package.json +3 -2
  44. package/test/helpers/MathHelper.spec.js +14 -1
  45. package/tsconfig.json +4 -1
  46. package/helpers/tinymce/plugin.ts +0 -210
@@ -1,210 +0,0 @@
1
- import MathHelper from "../MathHelper";
2
- const WindwardPlugins = function (editor: any) {
3
- let formula: any
4
- let fillInBlank: any
5
- // ----- Events ----- //
6
- editor.ui.registry.addIcon(
7
- 'insertMath',
8
- '<svg x="0px" y="0px"width="20px" height="20px" viewBox="0 0 445.878 445.878" style="enable-background:new 0 0 445.878 445.878;">' +
9
- '<path d="M426.024,86.447H209.705l-84.911,298.911c-2.568,7.967-9.854,13.482-18.22,13.771c-0.236,0-0.464,0.006-0.688,0.006 c-8.092,0-15.41-4.924-18.436-12.478l-34.714-86.782H19.851C8.884,299.876,0,290.986,0,280.022 c0-10.965,8.893-19.854,19.851-19.854H66.18c8.109,0,15.421,4.941,18.436,12.483l19.237,48.09l72.472-260.218 c2.639-8.213,10.279-13.781,18.903-13.781h230.798c10.97,0,19.854,8.89,19.854,19.851S436.988,86.447,426.024,86.447z M436.723,353.227l-78.259-87.904l74.576-82.783c1.318-1.454,1.638-3.547,0.857-5.341c-0.804-1.791-2.577-2.946-4.54-2.946h-47.18 c-1.442,0-2.802,0.629-3.759,1.72l-50.059,58.047l-49.674-58.029c-0.939-1.103-2.317-1.738-3.771-1.738h-49.334 c-1.956,0-3.729,1.149-4.521,2.929c-0.81,1.785 0.479,3.875,0.824,5.332l73.743,82.81l-77.641,87.923 c-1.297,1.465-1.605,3.552 0.813,5.325c0.813,1.785,2.586,2.92,4.528,2.92h48.9c1.472,0,2.867-0.65,3.807-1.785l51.819-62.181 l53.05,62.229c0.951,1.11,2.328,1.743,3.782,1.743h49.97c1.962,0,3.735-1.141,4.527-2.926 C438.354,356.779,438.035,354.692,436.723,353.227z"/>' +
10
- '</svg>'
11
- )
12
- editor.addCommand('equation-window', function (data: any) {
13
- return editor.windowManager.openUrl({
14
- url: '/plugins/tinymce/math',
15
- title: 'Equation editor',
16
- buttons: [
17
- {
18
- type: 'cancel',
19
- text: 'cancel',
20
- },
21
- {
22
- type: 'custom',
23
- text: 'submit',
24
- primary: true,
25
- },
26
- ],
27
- onAction: () => {
28
- if (data.currentTarget) {
29
- editor.selection.select(data.currentTarget)
30
- }
31
- editor.selection.setContent(
32
- ` <span class='windward-math-content'>` +
33
- formula +
34
- `</span> `
35
- )
36
-
37
- editor.windowManager.close()
38
- setOnClickEquationContent(editor)
39
- },
40
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
41
- onMessage: (instance: any, message: any) => {
42
- switch (message.mceAction) {
43
- case 'equation-insert':
44
- formula = message.content
45
- break
46
- case 'math-plugin-mounted':
47
- window.postMessage({ latex: data.latex ?? '' }, '*')
48
- break
49
- }
50
- },
51
- })
52
- })
53
-
54
- editor.ui.registry.addButton('mathButton', {
55
- icon: 'insertMath',
56
- onAction: () => {
57
- editor.execCommand('equation-window', true)
58
- },
59
- })
60
- editor.ui.registry.addMenuItem('math', {
61
- text: 'Math',
62
- icon: 'insertMath',
63
- onAction: () => {
64
- editor.execCommand('equation-window', true)
65
- },
66
- })
67
- editor.on('init', function () {
68
- setOnClickEquationContent(editor)
69
- setOnClickFillInBlank(editor)
70
- })
71
-
72
- editor.on('SetContent', function () {
73
- setOnClickEquationContent(editor)
74
- setOnClickFillInBlank(editor)
75
- })
76
- editor.on('input', function () {
77
- setOnClickEquationContent(editor)
78
- setOnClickFillInBlank(editor)
79
- })
80
- function setOnClickEquationContent(editor: any) {
81
- const tinymceDoc = editor.getDoc()
82
- const mqSpan = tinymceDoc.getElementsByClassName(
83
- 'windward-math-content'
84
- )
85
-
86
- // Add onclick listener to all equation content
87
- for (const equationContent of mqSpan) {
88
- equationContent.contentEditable = 'true'
89
- if (equationContent.onclick) {
90
- continue
91
- }
92
-
93
- equationContent.ondblclick = (event: any) => {
94
- event.stopPropagation()
95
- editor.execCommand('equation-window', {
96
- latex: event.target.innerText,
97
- currentTarget: event.target,
98
- })
99
- }
100
- }
101
- }
102
-
103
- editor.addCommand('fib-window', function (data: any) {
104
- return editor.windowManager.openUrl({
105
- url: '/plugins/tinymce/FIB',
106
- title: 'Fill in the blank',
107
- buttons: [
108
- {
109
- type: 'cancel',
110
- text: 'cancel',
111
- },
112
- {
113
- type: 'custom',
114
- text: 'submit',
115
- primary: true,
116
- },
117
- ],
118
- onAction: () => {
119
- if (data.currentTarget) {
120
- editor.selection.select(data.currentTarget)
121
- }
122
- editor.selection.setContent(
123
- `<span class='windward-fill-blank' data-feedback =` +
124
- fillInBlank.feedback +
125
- ` >` +
126
- fillInBlank.answer +
127
- `</span>`
128
- )
129
-
130
- editor.windowManager.close()
131
- setOnClickFillInBlank(editor)
132
- },
133
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
134
- onMessage: (instance: any, message: any) => {
135
- switch (message.mceAction) {
136
- case 'fib-insert':
137
- fillInBlank = {
138
- answer: message.content.answer,
139
- feedback: message.content.feedback,
140
- }
141
- break
142
- case 'fib-plugin-mounted':
143
- window.parent.postMessage(
144
- { answer: data.answer, feedback: data.feedback },
145
- '*'
146
- )
147
- break
148
- }
149
- },
150
- })
151
- })
152
-
153
- editor.ui.registry.addIcon(
154
- 'insertFIB',
155
- '<svg width="20px" height="20px" viewBox="0 0 24 24"><path d="M17,7H22V17H17V19A1,1 0 0,0 18,20H20V22H17.5C16.95,22 16,21.55 16,21C16,21.55 15.05,22 14.5,22H12V20H14A1,1 0 0,0 15,19V5A1,1 0 0,0 14,4H12V2H14.5C15.05,2 16,2.45 16,3C16,2.45 16.95,2 17.5,2H20V4H18A1,1 0 0,0 17,5V7M2,7H13V9H4V15H13V17H2V7M20,15V9H17V15H20Z" /></svg>'
156
- )
157
-
158
- editor.ui.registry.addIcon(
159
- 'glossaryIcon',
160
- '<svg viewBox="0 0 24 24" width="20px" height="20px" ><path d="M3,15H1V3A2,2 0 0,1 3,1H19V3H3V15M12,23A1,1 0 0,1 11,22V19H7A2,2 0 0,1 5,17V7A2,2 0 0,1 7,5H21A2,2 0 0,1 23,7V17A2,2 0 0,1 21,19H16.9L13.2,22.71C13,22.89 12.76,23 12.5,23H12M9,9V11H19V9H9M9,13V15H17V13H9Z"></path></svg>'
161
- )
162
-
163
- /* Add a button that opens a window */
164
- editor.ui.registry.addButton('glossaryButton', {
165
- icon: 'glossaryIcon',
166
- onAction: function () {
167
- /* apply format */
168
- editor.formatter.apply('glossary')
169
- },
170
- })
171
- /* Add a button that opens a window */
172
- editor.ui.registry.addButton('fibButton', {
173
- icon: 'insertFIB',
174
- onAction: function () {
175
- /* Open window */
176
- editor.execCommand('fib-window', true)
177
- },
178
- })
179
- editor.ui.registry.addMenuItem('FIB', {
180
- text: 'FIll in the blank',
181
- icon: 'insertFIB',
182
- onAction: () => {
183
- editor.execCommand('fib-window', true)
184
- },
185
- })
186
-
187
- function setOnClickFillInBlank(editor: any) {
188
- const tinymceDoc = editor.getDoc()
189
- const mqSpan = tinymceDoc.getElementsByClassName('windward-fill-blank')
190
-
191
- // Add onclick listener to all equation content
192
- for (const fib of mqSpan) {
193
- fib.contentEditable = 'true'
194
- if (fib.onclick) {
195
- continue
196
- }
197
-
198
- fib.ondblclick = (event: any) => {
199
- event.stopPropagation()
200
- editor.execCommand('fib-window', {
201
- answer: event.target.innerText,
202
- feedback: event.target.getAttribute('data-feedback'),
203
- currentTarget: event.target,
204
- })
205
- }
206
- }
207
- }
208
- }
209
-
210
- export { WindwardPlugins }