@windward/core 0.9.0 → 0.9.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/CHANGELOG.md +3 -0
- package/components/Settings/TextEditorSettings.vue +17 -15
- package/components/utils/TinyMCEWrapper.vue +1 -1
- package/components/utils/glossary/CourseGlossary.vue +5 -3
- package/components/utils/glossary/GlossaryToolTip.vue +2 -1
- package/helpers/GlossaryHelper.ts +38 -18
- package/package.json +1 -1
- package/test/helpers/GlossaryHelper.spec.js +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
<v-btn
|
|
9
9
|
elevation="0"
|
|
10
10
|
v-bind="attrs"
|
|
11
|
-
v-on="on"
|
|
12
11
|
text
|
|
13
12
|
:disabled="render"
|
|
13
|
+
v-on="on"
|
|
14
14
|
>
|
|
15
15
|
<v-icon>mdi-comment-text-multiple</v-icon>
|
|
16
16
|
{{
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
<v-btn
|
|
35
35
|
elevation="0"
|
|
36
36
|
v-bind="attrs"
|
|
37
|
-
v-on="on"
|
|
38
37
|
text
|
|
39
38
|
:disabled="render"
|
|
39
|
+
v-on="on"
|
|
40
40
|
>
|
|
41
41
|
<v-icon> mdi-text-long</v-icon>
|
|
42
42
|
{{
|
|
@@ -55,14 +55,14 @@
|
|
|
55
55
|
>
|
|
56
56
|
</v-tooltip>
|
|
57
57
|
|
|
58
|
-
<v-tooltip
|
|
58
|
+
<v-tooltip v-if="settingSelector.includes(1)" top>
|
|
59
59
|
<template #activator="{ on, attrs }">
|
|
60
60
|
<v-btn
|
|
61
61
|
v-bind="attrs"
|
|
62
|
-
v-on="on"
|
|
63
62
|
elevation="0"
|
|
64
63
|
text
|
|
65
64
|
:disabled="render"
|
|
65
|
+
v-on="on"
|
|
66
66
|
@click="
|
|
67
67
|
block.metadata.config.expand =
|
|
68
68
|
!block.metadata.config.expand
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
</v-card>
|
|
95
95
|
<div v-show="settingSelector.includes(0)" class="pt-4">
|
|
96
96
|
<br />
|
|
97
|
-
<v-card
|
|
97
|
+
<v-card v-if="verifiedTerms.length > 0" elevation="0" outlined>
|
|
98
98
|
<v-card-title outlined class="text-capitalize">
|
|
99
99
|
{{
|
|
100
100
|
$t(
|
|
@@ -113,11 +113,11 @@
|
|
|
113
113
|
:disabled="render"
|
|
114
114
|
@click:close="editTerm(verified)"
|
|
115
115
|
>
|
|
116
|
-
|
|
116
|
+
<TextViewer v-model="verified.term"></TextViewer>
|
|
117
117
|
</v-chip>
|
|
118
118
|
</v-card-text>
|
|
119
119
|
</v-card>
|
|
120
|
-
<v-card
|
|
120
|
+
<v-card v-if="unVerifiedTerms.length > 0" elevation="0" outlined>
|
|
121
121
|
<v-card-title outlined class="text-capitalize">
|
|
122
122
|
{{
|
|
123
123
|
$t(
|
|
@@ -136,16 +136,16 @@
|
|
|
136
136
|
:disabled="render"
|
|
137
137
|
@click:close="addGlossaryTerm(unVerified)"
|
|
138
138
|
>
|
|
139
|
-
|
|
139
|
+
<TextViewer v-model="unVerified.term"></TextViewer>
|
|
140
140
|
</v-chip>
|
|
141
141
|
</v-card-text>
|
|
142
142
|
</v-card>
|
|
143
143
|
<v-card
|
|
144
|
-
elevation="0"
|
|
145
|
-
outlined
|
|
146
144
|
v-if="
|
|
147
145
|
verifiedTerms.length === 0 && unVerifiedTerms.length === 0
|
|
148
146
|
"
|
|
147
|
+
elevation="0"
|
|
148
|
+
outlined
|
|
149
149
|
><v-card-text class="text-capitalize font-weight-bold">
|
|
150
150
|
{{
|
|
151
151
|
$t(
|
|
@@ -164,9 +164,9 @@
|
|
|
164
164
|
allow-read
|
|
165
165
|
></TextEditor>
|
|
166
166
|
<v-skeleton-loader
|
|
167
|
+
v-show="settingSelector.includes(1) && block.metadata.config.expand"
|
|
167
168
|
v-bind="attrs"
|
|
168
169
|
type=" table-row-divider, list-item, divider, list-item, divider, image,image"
|
|
169
|
-
v-show="settingSelector.includes(1) && block.metadata.config.expand"
|
|
170
170
|
></v-skeleton-loader>
|
|
171
171
|
<DialogBox
|
|
172
172
|
v-model="dialog"
|
|
@@ -196,20 +196,22 @@
|
|
|
196
196
|
|
|
197
197
|
<script>
|
|
198
198
|
import { mapGetters, mapMutations } from 'vuex'
|
|
199
|
-
import DialogBox from '~/components/Core/DialogBox.vue'
|
|
200
199
|
import GlossaryHelper from '../../helpers/GlossaryHelper'
|
|
200
|
+
import CourseGlossaryForm from '../utils/glossary/CourseGlossaryForm.vue'
|
|
201
|
+
import DialogBox from '~/components/Core/DialogBox.vue'
|
|
201
202
|
import Course from '~/models/Course'
|
|
202
203
|
import BaseContentSettings from '~/components/Content/Settings/BaseContentSettings.js'
|
|
203
204
|
import TextEditor from '~/components/Text/TextEditor'
|
|
204
|
-
import
|
|
205
|
+
import TextViewer from '~/components/Text/TextViewer.vue'
|
|
205
206
|
export default {
|
|
206
207
|
name: 'TextEditorSettings',
|
|
207
|
-
extends: BaseContentSettings,
|
|
208
208
|
components: {
|
|
209
209
|
DialogBox,
|
|
210
210
|
TextEditor,
|
|
211
211
|
CourseGlossaryForm,
|
|
212
|
+
TextViewer,
|
|
212
213
|
},
|
|
214
|
+
extends: BaseContentSettings,
|
|
213
215
|
data() {
|
|
214
216
|
return {
|
|
215
217
|
dialog: false,
|
|
@@ -255,7 +257,7 @@ export default {
|
|
|
255
257
|
},
|
|
256
258
|
methods: {
|
|
257
259
|
async save() {
|
|
258
|
-
|
|
260
|
+
const currentGlossary = _.cloneDeep(this.glossary)
|
|
259
261
|
let currentItemIndex = -1
|
|
260
262
|
currentGlossary.filter((item, index) => {
|
|
261
263
|
if (item.term === this.selectedTerm.term) {
|
|
@@ -158,15 +158,17 @@
|
|
|
158
158
|
<script>
|
|
159
159
|
import { mapGetters, mapMutations } from 'vuex'
|
|
160
160
|
import _ from 'lodash'
|
|
161
|
+
import { encode } from 'he'
|
|
162
|
+
import CourseGlossaryForm from './CourseGlossaryForm'
|
|
161
163
|
import DialogBox from '~/components/Core/DialogBox.vue'
|
|
162
164
|
import Crypto from '~/helpers/Crypto'
|
|
163
165
|
import Course from '~/models/Course'
|
|
164
166
|
import SpeedDial from '~/components/Core/SpeedDial.vue'
|
|
167
|
+
import TextViewer from '~/components/Text/TextViewer.vue'
|
|
165
168
|
|
|
166
|
-
import CourseGlossaryForm from './CourseGlossaryForm'
|
|
167
169
|
export default {
|
|
168
170
|
name: 'CourseGlossary',
|
|
169
|
-
components: { DialogBox, CourseGlossaryForm, SpeedDial },
|
|
171
|
+
components: { DialogBox, CourseGlossaryForm, SpeedDial, TextViewer },
|
|
170
172
|
layout: 'course',
|
|
171
173
|
middleware: ['auth'],
|
|
172
174
|
props: {},
|
|
@@ -278,7 +280,7 @@ export default {
|
|
|
278
280
|
const updatedCourse = await course.save()
|
|
279
281
|
this.$store.commit('course/set', updatedCourse)
|
|
280
282
|
this.$toast.success(this.$t('shared.forms.saved'))
|
|
281
|
-
//force update on datatable
|
|
283
|
+
// force update on datatable
|
|
282
284
|
this.tableKey = Crypto.id()
|
|
283
285
|
},
|
|
284
286
|
saveNew() {
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import GlossaryTerm from '../helpers/GlossaryTerm'
|
|
2
1
|
import * as _ from 'lodash'
|
|
2
|
+
import { decode } from 'he'
|
|
3
|
+
import GlossaryTerm from '../helpers/GlossaryTerm'
|
|
3
4
|
|
|
4
5
|
export default class GlossaryHelper {
|
|
5
6
|
private static glossaryRegex =
|
|
6
7
|
/<span.*?.class="glossary-word".*?>(.*?)<\/span>/g
|
|
8
|
+
|
|
7
9
|
public static makeToolTip(term: GlossaryTerm, text: String): string {
|
|
8
|
-
|
|
10
|
+
const word = _.isString(term.term)
|
|
9
11
|
? '<template v-slot:term>' + text + '</template>'
|
|
10
12
|
: ''
|
|
11
|
-
|
|
13
|
+
const definition = _.isString(term.definition)
|
|
12
14
|
? '<template v-slot:definition>' + term.definition + '</template>'
|
|
13
15
|
: ''
|
|
14
|
-
|
|
16
|
+
const alternate_forms = _.isString(term.alternate_forms)
|
|
15
17
|
? '<template v-slot:alternate_forms>' +
|
|
16
18
|
term.alternate_forms +
|
|
17
19
|
'</template>'
|
|
18
20
|
: ''
|
|
19
|
-
|
|
21
|
+
const related_terms = _.isString(term.related_term)
|
|
20
22
|
? '<template v-slot:related_terms>' +
|
|
21
23
|
term.related_term +
|
|
22
24
|
'</template>'
|
|
@@ -30,6 +32,7 @@ export default class GlossaryHelper {
|
|
|
30
32
|
'</plugin-core-glossary-tool-tip>'
|
|
31
33
|
)
|
|
32
34
|
}
|
|
35
|
+
|
|
33
36
|
public static containsGlossaryTerms(content: string): boolean {
|
|
34
37
|
const regex = new RegExp(this.glossaryRegex)
|
|
35
38
|
|
|
@@ -50,7 +53,7 @@ export default class GlossaryHelper {
|
|
|
50
53
|
if (match.index === regex.lastIndex) {
|
|
51
54
|
regex.lastIndex++
|
|
52
55
|
}
|
|
53
|
-
|
|
56
|
+
match[1] = decode(match[1])
|
|
54
57
|
// The result can be accessed through the `m`-variable.
|
|
55
58
|
currentGlossary.forEach((term: any) => {
|
|
56
59
|
let addTerm = true
|
|
@@ -64,12 +67,15 @@ export default class GlossaryHelper {
|
|
|
64
67
|
})
|
|
65
68
|
|
|
66
69
|
if (
|
|
67
|
-
(
|
|
70
|
+
(_.trim(_.toLower(match[1])) ===
|
|
68
71
|
_.trim(_.toLower(term.term)) ||
|
|
69
|
-
term.alternate_forms &&
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
(term.alternate_forms &&
|
|
73
|
+
_.some(
|
|
74
|
+
term.alternate_forms,
|
|
75
|
+
(alt) =>
|
|
76
|
+
_.trim(_.toLower(alt)) ===
|
|
77
|
+
_.trim(_.toLower(match[1]))
|
|
78
|
+
))) &&
|
|
73
79
|
addTerm
|
|
74
80
|
) {
|
|
75
81
|
verifiedTerms.push(new GlossaryTerm(term))
|
|
@@ -98,13 +104,20 @@ export default class GlossaryHelper {
|
|
|
98
104
|
regex.lastIndex++
|
|
99
105
|
}
|
|
100
106
|
|
|
107
|
+
match[1] = decode(match[1])
|
|
101
108
|
let inGlossary = []
|
|
102
109
|
|
|
103
110
|
inGlossary = glossary.filter((item: any) => {
|
|
104
111
|
if (
|
|
105
|
-
_.trim(_.toLower(item.term)) ===
|
|
106
|
-
|
|
107
|
-
item.alternate_forms &&
|
|
112
|
+
_.trim(_.toLower(item.term)) ===
|
|
113
|
+
_.trim(_.toLower(match[1])) ||
|
|
114
|
+
(item.alternate_forms &&
|
|
115
|
+
_.some(
|
|
116
|
+
item.alternate_forms,
|
|
117
|
+
(alt) =>
|
|
118
|
+
_.trim(_.toLower(alt)) ===
|
|
119
|
+
_.trim(_.toLower(match[1]))
|
|
120
|
+
))
|
|
108
121
|
) {
|
|
109
122
|
return item
|
|
110
123
|
}
|
|
@@ -131,6 +144,7 @@ export default class GlossaryHelper {
|
|
|
131
144
|
|
|
132
145
|
return unVerifiedTerms
|
|
133
146
|
}
|
|
147
|
+
|
|
134
148
|
public static renderGlossaryWordsHtml(content: string, glossary: any) {
|
|
135
149
|
const regex: any = new RegExp(this.glossaryRegex)
|
|
136
150
|
const currentGlossary: any = glossary
|
|
@@ -143,13 +157,19 @@ export default class GlossaryHelper {
|
|
|
143
157
|
regex.lastIndex++
|
|
144
158
|
}
|
|
145
159
|
|
|
160
|
+
match[1] = decode(match[1])
|
|
146
161
|
// The result can be accessed through the `m`-variable.
|
|
147
162
|
currentGlossary.forEach((term: any) => {
|
|
148
163
|
if (
|
|
149
|
-
_.trim(_.toLower(match[1])) ===
|
|
150
|
-
|
|
151
|
-
(
|
|
152
|
-
_.some(
|
|
164
|
+
_.trim(_.toLower(match[1])) ===
|
|
165
|
+
_.trim(_.toLower(term.term)) ||
|
|
166
|
+
(term.alternate_forms &&
|
|
167
|
+
_.some(
|
|
168
|
+
term.alternate_forms,
|
|
169
|
+
(alt) =>
|
|
170
|
+
_.trim(_.toLower(alt)) ===
|
|
171
|
+
_.trim(_.toLower(match[1]))
|
|
172
|
+
))
|
|
153
173
|
) {
|
|
154
174
|
content = content.replace(
|
|
155
175
|
match[0],
|
package/package.json
CHANGED
|
@@ -20,6 +20,8 @@ const glossaryWord4 =
|
|
|
20
20
|
'<span class="glossary-word" aria-label="Glossary Term">architect</span>'
|
|
21
21
|
const glossaryWord5 =
|
|
22
22
|
'<span class="glossary-word" aria-label="Glossary Term">universe</span>'
|
|
23
|
+
const accentedGlossaryTerm =
|
|
24
|
+
'<span class="glossary-word" aria-label="Glossary Term">valores periféricos</span>'
|
|
23
25
|
const glossaryWordSpaceBefore =
|
|
24
26
|
'<span class="glossary-word" aria-label="Glossary Term"> Crisis change</span>'
|
|
25
27
|
const glossaryWordSpaceAfter =
|
|
@@ -54,6 +56,13 @@ const glossary = [
|
|
|
54
56
|
alternate_forms: ['crisis', 'change'],
|
|
55
57
|
related_term: null,
|
|
56
58
|
},
|
|
59
|
+
{
|
|
60
|
+
term: 'valores periféricos',
|
|
61
|
+
definition:
|
|
62
|
+
'Valores que son importantes pero no esenciales para una organización.',
|
|
63
|
+
tags: 'valores periféricos',
|
|
64
|
+
alternate_forms: [],
|
|
65
|
+
},
|
|
57
66
|
]
|
|
58
67
|
const glossaryRender =
|
|
59
68
|
'<p>Voluptas est quis ut <strong>consequatur.</strong> ' +
|
|
@@ -147,6 +156,14 @@ describe('GlossaryHelper ', () => {
|
|
|
147
156
|
)
|
|
148
157
|
).toEqual([term])
|
|
149
158
|
})
|
|
159
|
+
test('can retrieve verified glossary terms from accented words encoded to htmlentitites', () => {
|
|
160
|
+
expect(
|
|
161
|
+
GlossaryHelper.getContentVerifiedGlossaryTerms(
|
|
162
|
+
accentedGlossaryTerm + contentHtml,
|
|
163
|
+
glossary
|
|
164
|
+
)
|
|
165
|
+
).toEqual([new GlossaryTerm(glossary[4])])
|
|
166
|
+
})
|
|
150
167
|
test('can retrieve un-verified glossary terms', () => {
|
|
151
168
|
expect(
|
|
152
169
|
GlossaryHelper.getContentUnVerifiedGlossaryTerms(
|