@windward/core 0.0.1
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/.editorconfig +13 -0
- package/.eslintrc.js +11 -0
- package/.prettierrc +4 -0
- package/README.md +86 -0
- package/babel.config.js +1 -0
- package/components/Content/Blocks/Accordion.vue +133 -0
- package/components/Content/Blocks/ClickableIcons.vue +98 -0
- package/components/Content/Blocks/Feedback.vue +323 -0
- package/components/Content/Blocks/FeedbackTemplates/FeedbackQuestionLikert.vue +95 -0
- package/components/Content/Blocks/FeedbackTemplates/FeedbackQuestionOpenResponse.vue +45 -0
- package/components/Content/Blocks/FeedbackTemplates/FeedbackQuestionTrueFalse.vue +55 -0
- package/components/Content/Blocks/Image.vue +116 -0
- package/components/Content/Blocks/Math.vue +87 -0
- package/components/Content/Blocks/Tab.vue +89 -0
- package/components/Content/Blocks/Table.vue +68 -0
- package/components/Content/Blocks/UserUpload/DisplayUserFilesTable.vue +157 -0
- package/components/Content/Blocks/UserUpload/ManageDataTableUserFiles.vue +68 -0
- package/components/Content/Blocks/UserUpload.vue +240 -0
- package/components/Content/Blocks/Video.vue +245 -0
- package/components/Navigation/Items/CourseGlossaryToolNav.vue +39 -0
- package/components/Navigation/Items/GlossaryNav.vue +32 -0
- package/components/Navigation/Items/UserUploadNav.vue +35 -0
- package/components/Settings/AccordionSettings.vue +153 -0
- package/components/Settings/ClickableIconsSettings.vue +189 -0
- package/components/Settings/FeedbackSettings.vue +92 -0
- package/components/Settings/ImageSettings.vue +124 -0
- package/components/Settings/MathSettings.vue +81 -0
- package/components/Settings/TabSettings.vue +139 -0
- package/components/Settings/TextEditorSettings.vue +249 -0
- package/components/Settings/UserUploadSettings.vue +151 -0
- package/components/Settings/VideoSettings.vue +699 -0
- package/components/utils/ContentViewer.vue +69 -0
- package/components/utils/MathExpressionEditor.vue +294 -0
- package/components/utils/MathLiveWrapper.vue +86 -0
- package/components/utils/TinyMCEWrapper.vue +103 -0
- package/components/utils/glossary/CourseGlossary.vue +284 -0
- package/components/utils/glossary/CourseGlossaryForm.vue +106 -0
- package/components/utils/glossary/GlossaryToolTip.vue +87 -0
- package/config/tinymce.config.js +136 -0
- package/helpers/GlossaryHelper.ts +137 -0
- package/helpers/GlossaryTerm.ts +31 -0
- package/helpers/MathHelper.ts +236 -0
- package/helpers/tinymce/plugin.ts +83 -0
- package/i18n/en-US/components/content/blocks/feedback.ts +28 -0
- package/i18n/en-US/components/content/blocks/image.ts +5 -0
- package/i18n/en-US/components/content/blocks/index.ts +15 -0
- package/i18n/en-US/components/content/blocks/tab.ts +4 -0
- package/i18n/en-US/components/content/blocks/table.ts +4 -0
- package/i18n/en-US/components/content/blocks/user_upload.ts +12 -0
- package/i18n/en-US/components/content/blocks/video.ts +53 -0
- package/i18n/en-US/components/content/index.ts +5 -0
- package/i18n/en-US/components/index.ts +12 -0
- package/i18n/en-US/components/navigation/image.ts +4 -0
- package/i18n/en-US/components/navigation/index.ts +7 -0
- package/i18n/en-US/components/navigation/user_upload.ts +3 -0
- package/i18n/en-US/components/settings/clickable_icon.ts +9 -0
- package/i18n/en-US/components/settings/image.ts +1 -0
- package/i18n/en-US/components/settings/index.ts +13 -0
- package/i18n/en-US/components/settings/text_editor.ts +7 -0
- package/i18n/en-US/components/settings/user_upload.ts +11 -0
- package/i18n/en-US/components/settings/video.ts +13 -0
- package/i18n/en-US/components/utils/index.ts +5 -0
- package/i18n/en-US/components/utils/tiny_mce_wrapper.ts +7 -0
- package/i18n/en-US/index.ts +16 -0
- package/i18n/en-US/modules/index.ts +5 -0
- package/i18n/en-US/pages/glossary.ts +7 -0
- package/i18n/en-US/pages/index.ts +7 -0
- package/i18n/en-US/pages/user_upload.ts +3 -0
- package/i18n/en-US/shared/content_blocks.ts +20 -0
- package/i18n/en-US/shared/index.ts +11 -0
- package/i18n/en-US/shared/menu.ts +3 -0
- package/i18n/en-US/shared/permission.ts +15 -0
- package/i18n/en-US/shared/settings.ts +15 -0
- package/index.js +15 -0
- package/jest.config.js +15 -0
- package/models/SurveyResult.ts +8 -0
- package/models/SurveyTemplate.ts +8 -0
- package/models/UserFileAsset.ts +12 -0
- package/package.json +48 -0
- package/pages/glossary.vue +31 -0
- package/pages/userUpload.vue +204 -0
- package/plugin.js +299 -0
- package/test/Components/Content/Blocks/Accordion.spec.js +21 -0
- package/test/Components/Content/Blocks/ClickableIcons.spec.js +21 -0
- package/test/Components/Content/Blocks/Feedback.spec.js +31 -0
- package/test/Components/Content/Blocks/FeedbackTemplates/FeedbackQuestionLikert.spec.js +23 -0
- package/test/Components/Content/Blocks/FeedbackTemplates/FeedbackQuestionOpenResponse.spec.js +23 -0
- package/test/Components/Content/Blocks/FeedbackTemplates/FeedbackQuestionTrueFalse.spec.js +23 -0
- package/test/Components/Content/Blocks/Image.spec.js +34 -0
- package/test/Components/Content/Blocks/Math.spec.js +34 -0
- package/test/Components/Content/Blocks/Tab.spec.js +20 -0
- package/test/Components/Content/Blocks/Table.spec.js +21 -0
- package/test/Components/Content/Blocks/UserUpload.spec.js +25 -0
- package/test/Components/Content/Blocks/Video.spec.js +112 -0
- package/test/Components/Settings/AccordionSettings.spec.js +45 -0
- package/test/Components/Settings/ClickableIconsSettings.spec.js +20 -0
- package/test/Components/Settings/FeedbackSettings.spec.js +20 -0
- package/test/Components/Settings/ImageSettings.spec.js +20 -0
- package/test/Components/Settings/MathSettings.spec.js +20 -0
- package/test/Components/Settings/TabSettings.spec.js +45 -0
- package/test/Components/Settings/UserUploadSettings.spec.js +20 -0
- package/test/__mocks__/componentsMock.js +83 -0
- package/test/__mocks__/contentBlockMock.js +119 -0
- package/test/__mocks__/contentSettingsMock.js +54 -0
- package/test/__mocks__/fileMock.js +1 -0
- package/test/__mocks__/helpersMock.js +53 -0
- package/test/__mocks__/modelMock.js +82 -0
- package/test/__mocks__/styleMock.js +1 -0
- package/test/helpers/GlossaryHelper.spec.js +227 -0
- package/test/helpers/MathHelper.spec.js +128 -0
- package/test/mocks.js +140 -0
- package/tsconfig.json +15 -0
- package/utils/index.js +18 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component
|
|
3
|
+
:class="textViewer ? 'text-viewer' : ''"
|
|
4
|
+
:is="convertedContent"
|
|
5
|
+
></component>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
import MathHelper from '../../helpers/MathHelper'
|
|
10
|
+
import GlossaryHelper from '../../helpers/GlossaryHelper'
|
|
11
|
+
import { mapGetters } from 'vuex'
|
|
12
|
+
import Vue from 'vue'
|
|
13
|
+
export default {
|
|
14
|
+
name: 'ContentViewer',
|
|
15
|
+
props: {
|
|
16
|
+
value: { type: String, required: false, default: '' },
|
|
17
|
+
textViewer: { type: Boolean, required: false, default: false },
|
|
18
|
+
},
|
|
19
|
+
data() {
|
|
20
|
+
return {
|
|
21
|
+
content: '',
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
beforeMount() {},
|
|
25
|
+
computed: {
|
|
26
|
+
...mapGetters({
|
|
27
|
+
course: 'course/get',
|
|
28
|
+
}),
|
|
29
|
+
convertedContent() {
|
|
30
|
+
let content = ''
|
|
31
|
+
if (this.value) {
|
|
32
|
+
if (
|
|
33
|
+
GlossaryHelper.containsGlossaryTerms(this.value) &&
|
|
34
|
+
_.isObject(this.course.metadata) &&
|
|
35
|
+
_.isArray(this.course.metadata.glossary)
|
|
36
|
+
) {
|
|
37
|
+
content = GlossaryHelper.renderGlossaryWordsHtml(
|
|
38
|
+
MathHelper.convertMathContentToHtml(this.value),
|
|
39
|
+
this.course.metadata.glossary
|
|
40
|
+
)
|
|
41
|
+
} else {
|
|
42
|
+
content = MathHelper.convertMathContentToHtml(this.value)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return Vue.compile('<div>' + content + '</div>')
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<style>
|
|
52
|
+
.text-viewer {
|
|
53
|
+
min-height: 100px;
|
|
54
|
+
}
|
|
55
|
+
.text-viewer table tr td {
|
|
56
|
+
padding: 10px !important;
|
|
57
|
+
}
|
|
58
|
+
@media (max-width: 600px) {
|
|
59
|
+
.text-viewer {
|
|
60
|
+
overflow-x: auto !important;
|
|
61
|
+
display: flex !important;
|
|
62
|
+
flex-wrap: wrap !important;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
img {
|
|
66
|
+
height: 100% !important;
|
|
67
|
+
width: 100% !important;
|
|
68
|
+
}
|
|
69
|
+
</style>
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<v-card flat class="py-12">
|
|
4
|
+
<label>Add Math Below</label>
|
|
5
|
+
<math-live-wrapper
|
|
6
|
+
ref="mathfield"
|
|
7
|
+
v-model="formula"
|
|
8
|
+
:options="options"
|
|
9
|
+
:value="value"
|
|
10
|
+
@change="submit"
|
|
11
|
+
></math-live-wrapper>
|
|
12
|
+
</v-card>
|
|
13
|
+
<v-card>
|
|
14
|
+
<v-card-text>
|
|
15
|
+
<v-tabs
|
|
16
|
+
v-model="tab"
|
|
17
|
+
align-with-title
|
|
18
|
+
next-icon="mdi-arrow-right-bold-box-outline"
|
|
19
|
+
prev-icon="mdi-arrow-left-bold-box-outline"
|
|
20
|
+
show-arrows
|
|
21
|
+
>
|
|
22
|
+
<v-tabs-slider color="primary"></v-tabs-slider>
|
|
23
|
+
<v-tab>
|
|
24
|
+
{{ $t('shared.accessibility.accessibility') }}</v-tab
|
|
25
|
+
>
|
|
26
|
+
<v-tab
|
|
27
|
+
v-for="(keyboard, index) in config.buttons.groups"
|
|
28
|
+
:key="index"
|
|
29
|
+
>
|
|
30
|
+
{{ $tc(keyboard.name, keyboard.buttons.length) }}
|
|
31
|
+
</v-tab>
|
|
32
|
+
</v-tabs>
|
|
33
|
+
|
|
34
|
+
<v-tabs-items v-model="tab">
|
|
35
|
+
<v-tab-item>
|
|
36
|
+
<v-card-text>
|
|
37
|
+
<v-container>
|
|
38
|
+
<v-row align="center">
|
|
39
|
+
<v-checkbox
|
|
40
|
+
v-model="spokenTextChanged"
|
|
41
|
+
hide-details
|
|
42
|
+
class="shrink mr-2 mt-0"
|
|
43
|
+
></v-checkbox>
|
|
44
|
+
<v-textarea
|
|
45
|
+
v-model="spokenText"
|
|
46
|
+
:disabled="!spokenTextChanged"
|
|
47
|
+
:label="
|
|
48
|
+
$t(
|
|
49
|
+
'shared.accessibility.set_aria_label_text'
|
|
50
|
+
)
|
|
51
|
+
"
|
|
52
|
+
class="col-md-12"
|
|
53
|
+
@input="submit"
|
|
54
|
+
></v-textarea>
|
|
55
|
+
</v-row>
|
|
56
|
+
</v-container>
|
|
57
|
+
|
|
58
|
+
<br />
|
|
59
|
+
<v-btn
|
|
60
|
+
primary
|
|
61
|
+
color="success"
|
|
62
|
+
@click="setSRText"
|
|
63
|
+
:class="shrinkClass"
|
|
64
|
+
>{{ $t('shared.accessibility.default_text') }}
|
|
65
|
+
</v-btn>
|
|
66
|
+
<v-btn
|
|
67
|
+
:disabled="spokenTextChanged"
|
|
68
|
+
color="primary"
|
|
69
|
+
:class="shrinkClass"
|
|
70
|
+
@click="readSRText"
|
|
71
|
+
>{{
|
|
72
|
+
$t(
|
|
73
|
+
'shared.accessibility.read_default_aria_label_text'
|
|
74
|
+
)
|
|
75
|
+
}}</v-btn
|
|
76
|
+
>
|
|
77
|
+
</v-card-text>
|
|
78
|
+
</v-tab-item>
|
|
79
|
+
<v-tab-item
|
|
80
|
+
v-for="(keyboard, index) in config.buttons.groups"
|
|
81
|
+
:key="index"
|
|
82
|
+
>
|
|
83
|
+
<v-card flat>
|
|
84
|
+
<v-card-text>
|
|
85
|
+
<v-container>
|
|
86
|
+
<v-btn-toggle mandatory>
|
|
87
|
+
<button
|
|
88
|
+
v-for="(
|
|
89
|
+
button, buttonIndex
|
|
90
|
+
) in keyboard.buttons"
|
|
91
|
+
:key="buttonIndex"
|
|
92
|
+
class="btn"
|
|
93
|
+
@click="insert(button)"
|
|
94
|
+
>
|
|
95
|
+
<div
|
|
96
|
+
v-html="
|
|
97
|
+
convertLatexToMarkup(
|
|
98
|
+
button.text
|
|
99
|
+
)
|
|
100
|
+
"
|
|
101
|
+
></div>
|
|
102
|
+
</button>
|
|
103
|
+
</v-btn-toggle>
|
|
104
|
+
</v-container>
|
|
105
|
+
</v-card-text>
|
|
106
|
+
</v-card>
|
|
107
|
+
</v-tab-item>
|
|
108
|
+
</v-tabs-items>
|
|
109
|
+
</v-card-text>
|
|
110
|
+
</v-card>
|
|
111
|
+
</div>
|
|
112
|
+
</template>
|
|
113
|
+
|
|
114
|
+
<script>
|
|
115
|
+
import MathHelper from '../../helpers/MathHelper'
|
|
116
|
+
import MathLiveWrapper from './MathLiveWrapper'
|
|
117
|
+
import tinymceConfig from '../../config/tinymce.config'
|
|
118
|
+
export default {
|
|
119
|
+
components: { MathLiveWrapper },
|
|
120
|
+
layout: 'plugin',
|
|
121
|
+
props: {
|
|
122
|
+
mode: { type: String, required: false, default: 'plugin' },
|
|
123
|
+
value: { type: String, required: false, default: null },
|
|
124
|
+
shrinkFont: { type: Boolean, required: false, default: null },
|
|
125
|
+
},
|
|
126
|
+
data() {
|
|
127
|
+
return {
|
|
128
|
+
formula: '',
|
|
129
|
+
keystroke: '',
|
|
130
|
+
spokenText: '',
|
|
131
|
+
spokenTextChanged: false,
|
|
132
|
+
options: {
|
|
133
|
+
smartFence: true,
|
|
134
|
+
smartMode: true,
|
|
135
|
+
virtualKeyboardMode: 'manual',
|
|
136
|
+
keypressSound: 'none',
|
|
137
|
+
plonkSound: 'none',
|
|
138
|
+
readOnly: false,
|
|
139
|
+
},
|
|
140
|
+
tab: null,
|
|
141
|
+
toggle_exclusive: true,
|
|
142
|
+
panel: [],
|
|
143
|
+
shrinkClass: '',
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
computed: {
|
|
147
|
+
config() {
|
|
148
|
+
const plugin = tinymceConfig.plugins.filter((item) => {
|
|
149
|
+
return item.name === 'math'
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
return plugin[0]
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
beforeMount() {
|
|
156
|
+
if (this.mode === 'standalone') {
|
|
157
|
+
this.initStandaloneMode()
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
mounted() {
|
|
161
|
+
if (this.shrinkFont === true) {
|
|
162
|
+
this.shrinkClass = 'adjustFont'
|
|
163
|
+
}
|
|
164
|
+
if (this.mode === 'plugin') {
|
|
165
|
+
window.parent.postMessage(
|
|
166
|
+
{
|
|
167
|
+
mceAction: 'math-plugin-mounted',
|
|
168
|
+
status: true,
|
|
169
|
+
},
|
|
170
|
+
'*'
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
this.$refs.mathfield.focus()
|
|
174
|
+
},
|
|
175
|
+
created() {
|
|
176
|
+
if (this.mode === 'plugin') {
|
|
177
|
+
window.parent.addEventListener('message', (event) => {
|
|
178
|
+
if (event.data.latex) this.initPluginMode(event.data.latex)
|
|
179
|
+
})
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
methods: {
|
|
183
|
+
initStandaloneMode() {
|
|
184
|
+
if (this.value && MathHelper.containsLatex(this.value)) {
|
|
185
|
+
this.formula = MathHelper.parseLatexString(this.value)
|
|
186
|
+
} else if (
|
|
187
|
+
this.value &&
|
|
188
|
+
MathHelper.containSREnhancedLatex(this.value)
|
|
189
|
+
) {
|
|
190
|
+
const formulaObject = MathHelper.parseSREnhancedLatexString(
|
|
191
|
+
this.value
|
|
192
|
+
)
|
|
193
|
+
this.formula = formulaObject.latex
|
|
194
|
+
this.spokenText = formulaObject.sr_text
|
|
195
|
+
this.spokenTextChanged = true
|
|
196
|
+
} else if (this.value) {
|
|
197
|
+
this.formula = this.value
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
initPluginMode(value) {
|
|
201
|
+
if (value && MathHelper.containsLatex(value)) {
|
|
202
|
+
this.formula = MathHelper.parseLatexString(value)
|
|
203
|
+
} else if (value && MathHelper.containSREnhancedLatex(value)) {
|
|
204
|
+
const formulaObject =
|
|
205
|
+
MathHelper.parseSREnhancedLatexString(value)
|
|
206
|
+
this.formula = formulaObject.latex
|
|
207
|
+
this.spokenText = formulaObject.sr_text
|
|
208
|
+
this.spokenTextChanged = true
|
|
209
|
+
}
|
|
210
|
+
this.$refs.mathfield.setValue(this.formula)
|
|
211
|
+
},
|
|
212
|
+
convertLatexToSpeakableText(latex) {
|
|
213
|
+
return MathHelper.Mathlive.convertLatexToSpeakableText(latex)
|
|
214
|
+
},
|
|
215
|
+
convertLatexToMarkup(latex) {
|
|
216
|
+
return MathHelper.Mathlive.convertLatexToMarkup(latex)
|
|
217
|
+
},
|
|
218
|
+
submit() {
|
|
219
|
+
let latex = '$$' + this.formula + '$$'
|
|
220
|
+
if (this.spokenTextChanged) {
|
|
221
|
+
latex =
|
|
222
|
+
'**' +
|
|
223
|
+
JSON.stringify({
|
|
224
|
+
latex: this.formula,
|
|
225
|
+
sr_text: this.spokenText,
|
|
226
|
+
}) +
|
|
227
|
+
'**'
|
|
228
|
+
}
|
|
229
|
+
if (this.mode === 'plugin') {
|
|
230
|
+
window.parent.postMessage(
|
|
231
|
+
{
|
|
232
|
+
mceAction: 'equation-insert',
|
|
233
|
+
content: latex,
|
|
234
|
+
},
|
|
235
|
+
'*'
|
|
236
|
+
)
|
|
237
|
+
} else {
|
|
238
|
+
this.$emit('input', latex)
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
getBtnCode(button) {
|
|
242
|
+
if (button.cmd) {
|
|
243
|
+
return button.latex
|
|
244
|
+
}
|
|
245
|
+
return button.text
|
|
246
|
+
},
|
|
247
|
+
insert(latex) {
|
|
248
|
+
this.$refs.mathfield.insert(this.getBtnCode(latex), {
|
|
249
|
+
selectionMode: 'placeholder',
|
|
250
|
+
})
|
|
251
|
+
},
|
|
252
|
+
|
|
253
|
+
setSRText() {
|
|
254
|
+
this.spokenTextChanged = false
|
|
255
|
+
this.spokenText = this.convertLatexToSpeakableText(this.formula)
|
|
256
|
+
},
|
|
257
|
+
readSRText() {
|
|
258
|
+
this.$refs.mathfield.executeCommand('speak')
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
}
|
|
262
|
+
</script>
|
|
263
|
+
|
|
264
|
+
<style scoped>
|
|
265
|
+
/* stylelint-disable-next-line selector-type-no-unknown */
|
|
266
|
+
math-field {
|
|
267
|
+
min-height: 150px;
|
|
268
|
+
outline: 2px solid #64b5f6;
|
|
269
|
+
border-radius: 4px;
|
|
270
|
+
}
|
|
271
|
+
/* stylelint-disable-next-line selector-type-no-unknown */
|
|
272
|
+
math-field:focus-within {
|
|
273
|
+
outline: 4px solid #52d70b;
|
|
274
|
+
border-radius: 4px;
|
|
275
|
+
background: rgba(251, 187, 182, 0.1);
|
|
276
|
+
}
|
|
277
|
+
.btn {
|
|
278
|
+
cursor: pointer;
|
|
279
|
+
margin: 0 5px 5px 0;
|
|
280
|
+
border: 1px solid #595959;
|
|
281
|
+
background: white;
|
|
282
|
+
border-radius: 5px;
|
|
283
|
+
padding: 5px 10px;
|
|
284
|
+
min-height: 40px;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.btn:hover {
|
|
288
|
+
background: #595959;
|
|
289
|
+
color: white;
|
|
290
|
+
}
|
|
291
|
+
.adjustFont {
|
|
292
|
+
font-size: 12px !important;
|
|
293
|
+
}
|
|
294
|
+
</style>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<math-field :id="id"><slot></slot></math-field>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
import * as mathlive from 'mathlive'
|
|
7
|
+
import 'mathlive/dist/mathlive-fonts.css'
|
|
8
|
+
import 'mathlive/dist/mathlive-static.css'
|
|
9
|
+
export default {
|
|
10
|
+
props: {
|
|
11
|
+
id: { type: String, default: '' },
|
|
12
|
+
value: { type: String, default: '' },
|
|
13
|
+
options: { type: Object, default: () => ({}) },
|
|
14
|
+
},
|
|
15
|
+
data() {
|
|
16
|
+
return {
|
|
17
|
+
version: mathlive.version.mathlive,
|
|
18
|
+
key: 1,
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
watch: {
|
|
22
|
+
options: {
|
|
23
|
+
deep: true,
|
|
24
|
+
handler(newValue) {
|
|
25
|
+
this.$el.setOptions(newValue)
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
mounted() {
|
|
30
|
+
this.$nextTick(() => {
|
|
31
|
+
this.$el.setOptions({
|
|
32
|
+
...this.options,
|
|
33
|
+
macros: {
|
|
34
|
+
...this.$el.getOptions('macros'),
|
|
35
|
+
smallfrac: '{}^{#1}\\!\\!/\\!{}_{#2}',
|
|
36
|
+
},
|
|
37
|
+
onContentDidChange: () => {
|
|
38
|
+
this.$emit('input', this.$el.getValue())
|
|
39
|
+
this.$emit('change')
|
|
40
|
+
},
|
|
41
|
+
onFocus: () => {
|
|
42
|
+
this.$emit('focus')
|
|
43
|
+
},
|
|
44
|
+
onBlur: () => {
|
|
45
|
+
this.$emit('blur')
|
|
46
|
+
},
|
|
47
|
+
onUndoStateDidChange: (t, e) => {
|
|
48
|
+
this.$emit('undo-state-did-change', e)
|
|
49
|
+
},
|
|
50
|
+
onReadAloudStatus: (t, e) => {
|
|
51
|
+
this.$emit('read-aloud-status-change', e)
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
if (this.value !== '') {
|
|
56
|
+
this.$el.setValue(this.value)
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
methods: {
|
|
60
|
+
executeCommand(command) {
|
|
61
|
+
this.$el.executeCommand(command)
|
|
62
|
+
},
|
|
63
|
+
hasFocus() {
|
|
64
|
+
return this.$el.hasFocus()
|
|
65
|
+
},
|
|
66
|
+
focus() {
|
|
67
|
+
this.$el.focus()
|
|
68
|
+
},
|
|
69
|
+
blur() {
|
|
70
|
+
this.$el.blur()
|
|
71
|
+
},
|
|
72
|
+
getValue(t) {
|
|
73
|
+
return this.$el.getValue(t)
|
|
74
|
+
},
|
|
75
|
+
insert(content, options) {
|
|
76
|
+
this.$el.insert(content, options)
|
|
77
|
+
},
|
|
78
|
+
select() {
|
|
79
|
+
this.$el.select()
|
|
80
|
+
},
|
|
81
|
+
setValue(value) {
|
|
82
|
+
this.$el.setValue(value)
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
</script>
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<editor
|
|
3
|
+
v-model="text"
|
|
4
|
+
initial-value=""
|
|
5
|
+
:api-key="api_key"
|
|
6
|
+
:init="config"
|
|
7
|
+
tag-name="div"
|
|
8
|
+
model-events="change keydown blur focus paste input"
|
|
9
|
+
@input="change"
|
|
10
|
+
>
|
|
11
|
+
</editor>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
import Editor from '@tinymce/tinymce-vue'
|
|
16
|
+
import { MathEditorPlugin } from '../../helpers/tinymce/plugin'
|
|
17
|
+
export default {
|
|
18
|
+
name: 'ContentEditorRichText',
|
|
19
|
+
components: {
|
|
20
|
+
editor: Editor,
|
|
21
|
+
},
|
|
22
|
+
props: {
|
|
23
|
+
value: { type: String, required: true, default: '' },
|
|
24
|
+
api_key: { type: String, required: true, default: '' },
|
|
25
|
+
},
|
|
26
|
+
beforeMount() {
|
|
27
|
+
this.text = this.value
|
|
28
|
+
},
|
|
29
|
+
data() {
|
|
30
|
+
return {
|
|
31
|
+
render: true,
|
|
32
|
+
text: '',
|
|
33
|
+
config: {
|
|
34
|
+
height: 500,
|
|
35
|
+
menubar: true,
|
|
36
|
+
plugins: [
|
|
37
|
+
'advlist autolink lists link image charmap',
|
|
38
|
+
'searchreplace visualblocks code fullscreen',
|
|
39
|
+
'print preview anchor insertdatetime media',
|
|
40
|
+
'paste code help wordcount table MathEditor ',
|
|
41
|
+
],
|
|
42
|
+
toolbar:
|
|
43
|
+
'undo redo | formatselect | bold italic | alignleft aligncenter alignright | bullist numlist outdent indent | MathEditor | help',
|
|
44
|
+
setup() {
|
|
45
|
+
// Here we can add plugin
|
|
46
|
+
window.tinymce.PluginManager.add(
|
|
47
|
+
'MathEditor',
|
|
48
|
+
MathEditorPlugin
|
|
49
|
+
)
|
|
50
|
+
},
|
|
51
|
+
formats: {
|
|
52
|
+
glossary: {
|
|
53
|
+
inline: 'span',
|
|
54
|
+
attributes: {
|
|
55
|
+
'aria-label': this.$t(
|
|
56
|
+
'windward.core.components.utils.tiny_mce_wrapper.term'
|
|
57
|
+
),
|
|
58
|
+
},
|
|
59
|
+
classes: 'glossary-word',
|
|
60
|
+
},
|
|
61
|
+
removeformat: [
|
|
62
|
+
// Configures `clear formatting` to remove the class glossary-word from spans and if the element then becomes empty it's left intact
|
|
63
|
+
{
|
|
64
|
+
selector: 'span',
|
|
65
|
+
classes: 'glossary-word',
|
|
66
|
+
remove: 'all',
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
style_formats: [
|
|
71
|
+
{
|
|
72
|
+
title: this.$t(
|
|
73
|
+
'windward.core.components.utils.tiny_mce_wrapper.term'
|
|
74
|
+
),
|
|
75
|
+
format: 'glossary',
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
style_formats_merge: true,
|
|
79
|
+
placeholder: this.$t(
|
|
80
|
+
'windward.core.shared.content_blocks.grouping.placeholder'
|
|
81
|
+
),
|
|
82
|
+
//required as it will be displayed as inline style in tinymce renderer
|
|
83
|
+
content_style:
|
|
84
|
+
'.glossary-word {\n' +
|
|
85
|
+
' display: inline-block;\n' +
|
|
86
|
+
' border-radius: 12px;\n' +
|
|
87
|
+
' padding: 0px 7px;\n' +
|
|
88
|
+
' background-color: #ffd269;\n ' +
|
|
89
|
+
' font-weight: bold;\n' +
|
|
90
|
+
' color: #1a1d1e;' +
|
|
91
|
+
'}',
|
|
92
|
+
importcss_append: true,
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
updated() {},
|
|
97
|
+
methods: {
|
|
98
|
+
change() {
|
|
99
|
+
this.$emit('input', this.text)
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
}
|
|
103
|
+
</script>
|