@oat-sa/tao-core-ui 1.63.0 → 1.63.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/dist/figure/FigureStateActive.js +23 -5
- package/dist/mediaEditor/plugins/mediaAlignment/helper.js +49 -2
- package/dist/mediaEditor/plugins/mediaAlignment/mediaAlignmentComponent.js +0 -1
- package/package.json +1 -1
- package/scss/inc/_feedback.scss +4 -0
- package/src/css/basic.css +4 -0
- package/src/css/basic.css.map +1 -1
- package/src/figure/FigureStateActive.js +15 -5
- package/src/mediaEditor/plugins/mediaAlignment/helper.js +48 -0
|
@@ -97,12 +97,14 @@ const formCallbacks = ({ widget, formElement, mediaEditor, togglePlaceholder })
|
|
|
97
97
|
const initForm = ({ widget, formElement, formTpl, mediaEditor, togglePlaceholder }) => {
|
|
98
98
|
const imageElem = getImageElement(widget);
|
|
99
99
|
const figcaptionElem = getCaptionElement(widget);
|
|
100
|
+
const showFigure = widget.element.attr('showFigure');
|
|
100
101
|
widget.$form.html(
|
|
101
102
|
formTpl({
|
|
102
103
|
baseUrl: widget.options.baseUrl || '',
|
|
103
104
|
src: imageElem.attr('src'),
|
|
104
105
|
alt: imageElem.attr('alt'),
|
|
105
|
-
figcaption: figcaptionElem ? figcaptionElem.body() : ''
|
|
106
|
+
figcaption: figcaptionElem ? figcaptionElem.body() : '',
|
|
107
|
+
showFigure: showFigure
|
|
106
108
|
})
|
|
107
109
|
);
|
|
108
110
|
|
|
@@ -125,7 +127,15 @@ const initForm = ({ widget, formElement, formTpl, mediaEditor, togglePlaceholder
|
|
|
125
127
|
);
|
|
126
128
|
};
|
|
127
129
|
|
|
128
|
-
|
|
130
|
+
/**
|
|
131
|
+
* @param {Object} stateFactory
|
|
132
|
+
* @param {Object} ActiveState
|
|
133
|
+
* @param {Object} formTpl
|
|
134
|
+
* @param {Object} formElement
|
|
135
|
+
* @param {Object} inlineHelper
|
|
136
|
+
* @returns
|
|
137
|
+
*/
|
|
138
|
+
export default function ({ stateFactory, ActiveState, formTpl, formElement, inlineHelper }) {
|
|
129
139
|
/**
|
|
130
140
|
* media Editor instance if has been initialized
|
|
131
141
|
* @type {null}
|
|
@@ -134,7 +144,7 @@ export default function (stateFactory, ActiveState, formTpl, formElement, inline
|
|
|
134
144
|
let textareaObserver = null;
|
|
135
145
|
let texareaHTMLElem = null;
|
|
136
146
|
|
|
137
|
-
const
|
|
147
|
+
const FigureStateActive = stateFactory.extend(
|
|
138
148
|
ActiveState,
|
|
139
149
|
function () {
|
|
140
150
|
this.initForm();
|
|
@@ -148,7 +158,7 @@ export default function (stateFactory, ActiveState, formTpl, formElement, inline
|
|
|
148
158
|
}
|
|
149
159
|
);
|
|
150
160
|
|
|
151
|
-
|
|
161
|
+
FigureStateActive.prototype.initForm = function () {
|
|
152
162
|
initForm({
|
|
153
163
|
widget: this.widget,
|
|
154
164
|
formElement,
|
|
@@ -170,5 +180,5 @@ export default function (stateFactory, ActiveState, formTpl, formElement, inline
|
|
|
170
180
|
}
|
|
171
181
|
};
|
|
172
182
|
|
|
173
|
-
return
|
|
183
|
+
return FigureStateActive;
|
|
174
184
|
}
|
|
@@ -15,10 +15,34 @@
|
|
|
15
15
|
*
|
|
16
16
|
* Copyright (c) 2021-2022 (original work) Open Assessment Technologies SA;
|
|
17
17
|
*/
|
|
18
|
+
import _ from 'lodash';
|
|
18
19
|
|
|
19
20
|
export const FLOAT_LEFT_CLASS = 'wrap-left';
|
|
20
21
|
export const FLOAT_RIGHT_CLASS = 'wrap-right';
|
|
21
22
|
|
|
23
|
+
const searchRecurse = (parentElement, serial) => {
|
|
24
|
+
if (!parentElement) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
if (parentElement.serial === serial) {
|
|
28
|
+
return parentElement;
|
|
29
|
+
}
|
|
30
|
+
let found = null;
|
|
31
|
+
_.some(parentElement['elements'], childElement => {
|
|
32
|
+
if (childElement.serial === serial) {
|
|
33
|
+
found = parentElement;
|
|
34
|
+
} else if (childElement['elements']) {
|
|
35
|
+
found = searchRecurse(childElement, serial);
|
|
36
|
+
} else if (childElement['prompt']) {
|
|
37
|
+
found = searchRecurse(childElement.prompt.bdy, serial);
|
|
38
|
+
}
|
|
39
|
+
if (found) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return found;
|
|
44
|
+
};
|
|
45
|
+
|
|
22
46
|
export const positionFloat = function positionFloat(widget, position) {
|
|
23
47
|
if (!position) {
|
|
24
48
|
return;
|
|
@@ -43,12 +67,36 @@ export const positionFloat = function positionFloat(widget, position) {
|
|
|
43
67
|
// Update DOM
|
|
44
68
|
widget.$container.addClass(className);
|
|
45
69
|
// Update model
|
|
70
|
+
const prevClassName = widget.element.attr('class') || '';
|
|
46
71
|
if (className) {
|
|
47
72
|
widget.element.attr('class', className);
|
|
48
73
|
} else {
|
|
49
74
|
widget.element.removeAttr('class');
|
|
50
75
|
}
|
|
51
76
|
|
|
77
|
+
if (prevClassName !== className) {
|
|
78
|
+
// Re-build Figure widget to toggle between inline/block
|
|
79
|
+
const parent = searchRecurse(widget.element.bdy.rootElement.bdy, widget.serial);
|
|
80
|
+
// avoid changes on Figure in a prompt
|
|
81
|
+
if (parent.contentModel && parent.contentModel === 'inlineStatic') {
|
|
82
|
+
_.defer(() => {
|
|
83
|
+
widget.element.data('widget').refresh();
|
|
84
|
+
});
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
widget.element.data('widget').changeState('sleep');
|
|
88
|
+
_.defer(() => {
|
|
89
|
+
if (parent && parent.data('widget')) {
|
|
90
|
+
parent.data('widget').changeState('active');
|
|
91
|
+
_.defer(() => {
|
|
92
|
+
parent.data('widget').changeState('sleep');
|
|
93
|
+
_.defer(() => {
|
|
94
|
+
widget.element.data('widget').changeState('active');
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
52
100
|
widget.$original.trigger('contentChange.qti-widget');
|
|
53
101
|
};
|
|
54
102
|
|