@pie-element/extended-text-entry 6.8.10 → 6.8.13

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/module/element.js DELETED
@@ -1,280 +0,0 @@
1
- import {_dll_react, _dll_prop_types, _dll_material_ui__core, _dll_material_ui__core_styles, _dll_debug, _dll_lodash, _dll_pie_lib__render_ui, _dll_react_dom} from "../../../@pie-lib/shared-module@^1.4.17/module/index.js";
2
- import {_dll_pie_lib__editable_html} from "../../../@pie-lib/editable-html-module@^1.5.4/module/index.js";
3
- import {_dll_pie_lib__math_rendering} from "../../../@pie-lib/math-rendering-module@^1.1.5/module/index.js";
4
- const React$1 = _dll_react;
5
- const PropTypes = _dll_prop_types;
6
- const {Typography: Typography} = _dll_material_ui__core;
7
- const {withStyles: withStyles} = _dll_material_ui__core_styles;
8
- const debug$1 = _dll_debug;
9
- const {debounce: debounce} = _dll_lodash;
10
- const {color: color} = _dll_pie_lib__render_ui;
11
- const {Feedback: Feedback} = _dll_pie_lib__render_ui;
12
- const {Collapsible: Collapsible} = _dll_pie_lib__render_ui;
13
- const {PreviewPrompt: PreviewPrompt} = _dll_pie_lib__render_ui;
14
- const EditableHTML = _dll_pie_lib__editable_html;
15
- const {renderMath: renderMath} = _dll_pie_lib__math_rendering;
16
- const _jsxFileName = "/home/circleci/repo/packages/extended-text-entry/src/main.jsx";
17
- const log$1 = debug$1('@pie-ui:extended-text-entry');
18
- const style = theme => ({
19
- main: {
20
- backgroundColor: color.background(),
21
- color: color.text()
22
- },
23
- prompt: {
24
- width: '100%',
25
- color: color.text(),
26
- marginBottom: theme.spacing.unit * 2,
27
- fontSize: 'inherit'
28
- }
29
- });
30
- class Main extends React$1.Component {
31
- constructor(...args) {
32
- super(...args);
33
- Main.prototype.__init.call(this);
34
- }
35
- static __initStatic() {
36
- this.propTypes = {
37
- onChange: PropTypes.func.isRequired,
38
- model: PropTypes.object,
39
- classes: PropTypes.object.isRequired,
40
- session: PropTypes.shape({
41
- value: PropTypes.string
42
- }).isRequired
43
- };
44
- }
45
- componentDidUpdate() {
46
- if (this.containerRef) {
47
- renderMath(this.containerRef);
48
- }
49
- }
50
- __init() {
51
- this.changeSession = debounce(this.props.onChange, 1500);
52
- }
53
- render() {
54
- const {model, classes, session} = this.props;
55
- const {dimensions, disabled, feedback, teacherInstructions, mathInput, animationsDisabled, playersToolbarPosition, spellCheckEnabled} = model;
56
- const {value} = session;
57
- const {width, height} = dimensions || ({});
58
- const maxHeight = '40vh';
59
- const toolbarOpts = {};
60
- log$1('[render] disabled? ', disabled);
61
- const teacherInstructionsDiv = React$1.createElement(PreviewPrompt, {
62
- defaultClassName: "teacher-instructions",
63
- prompt: teacherInstructions,
64
- __self: this,
65
- __source: {
66
- fileName: _jsxFileName,
67
- lineNumber: 54
68
- }
69
- });
70
- switch (playersToolbarPosition) {
71
- case 'top':
72
- toolbarOpts.position = 'top';
73
- break;
74
- default:
75
- toolbarOpts.position = 'bottom';
76
- break;
77
- }
78
- return React$1.createElement('div', {
79
- className: classes.main,
80
- ref: ref => {
81
- this.containerRef = ref;
82
- },
83
- __self: this,
84
- __source: {
85
- fileName: _jsxFileName,
86
- lineNumber: 66
87
- }
88
- }, teacherInstructions && React$1.createElement('div', {
89
- __self: this,
90
- __source: {
91
- fileName: _jsxFileName,
92
- lineNumber: 74
93
- }
94
- }, !animationsDisabled ? React$1.createElement(Collapsible, {
95
- labels: {
96
- hidden: 'Show Teacher Instructions',
97
- visible: 'Hide Teacher Instructions'
98
- },
99
- className: classes.collapsible,
100
- __self: this,
101
- __source: {
102
- fileName: _jsxFileName,
103
- lineNumber: 76
104
- }
105
- }, teacherInstructionsDiv) : teacherInstructionsDiv, React$1.createElement('br', {
106
- __self: this,
107
- __source: {
108
- fileName: _jsxFileName,
109
- lineNumber: 83
110
- }
111
- })), model.prompt && React$1.createElement(Typography, {
112
- component: 'span',
113
- className: classes.prompt,
114
- __self: this,
115
- __source: {
116
- fileName: _jsxFileName,
117
- lineNumber: 88
118
- }
119
- }, React$1.createElement(PreviewPrompt, {
120
- defaultClassName: "prompt",
121
- prompt: model.prompt,
122
- __self: this,
123
- __source: {
124
- fileName: _jsxFileName,
125
- lineNumber: 92
126
- }
127
- })), React$1.createElement(EditableHTML, {
128
- className: "response-area-editor",
129
- onChange: this.changeSession,
130
- markup: value || '',
131
- width: width && width.toString(),
132
- minHeight: height && height.toString(),
133
- maxHeight: maxHeight,
134
- disabled: disabled,
135
- highlightShape: true,
136
- toolbarOpts: toolbarOpts,
137
- spellCheck: spellCheckEnabled,
138
- pluginProps: {
139
- math: {
140
- disabled: !mathInput,
141
- customKeys: this.props.model.customKeys,
142
- keypadMode: this.props.model.equationEditor,
143
- controlledKeypadMode: false
144
- },
145
- video: {
146
- disabled: true
147
- },
148
- audio: {
149
- disabled: true
150
- }
151
- },
152
- __self: this,
153
- __source: {
154
- fileName: _jsxFileName,
155
- lineNumber: 95
156
- }
157
- }), feedback && React$1.createElement('div', {
158
- __self: this,
159
- __source: {
160
- fileName: _jsxFileName,
161
- lineNumber: 122
162
- }
163
- }, React$1.createElement('br', {
164
- __self: this,
165
- __source: {
166
- fileName: _jsxFileName,
167
- lineNumber: 123
168
- }
169
- }), React$1.createElement(Feedback, {
170
- correctness: "correct",
171
- feedback: feedback,
172
- __self: this,
173
- __source: {
174
- fileName: _jsxFileName,
175
- lineNumber: 124
176
- }
177
- })));
178
- }
179
- }
180
- Main.__initStatic();
181
- var Main$1 = withStyles(style)(Main);
182
- var lib = {};
183
- Object.defineProperty(lib, "__esModule", {
184
- value: true
185
- });
186
- class ModelSetEvent extends CustomEvent {
187
- constructor(component, complete, hasModel) {
188
- super(ModelSetEvent.TYPE, {
189
- bubbles: true,
190
- composed: true,
191
- detail: {
192
- complete,
193
- component,
194
- hasModel
195
- }
196
- });
197
- this.component = component;
198
- this.complete = complete;
199
- }
200
- }
201
- ModelSetEvent.TYPE = 'model-set';
202
- var ModelSetEvent_1 = lib.ModelSetEvent = ModelSetEvent;
203
- class SessionChangedEvent extends CustomEvent {
204
- constructor(component, complete) {
205
- super(SessionChangedEvent.TYPE, {
206
- bubbles: true,
207
- composed: true,
208
- detail: {
209
- complete,
210
- component
211
- }
212
- });
213
- this.component = component;
214
- this.complete = complete;
215
- }
216
- }
217
- SessionChangedEvent.TYPE = 'session-changed';
218
- var SessionChangedEvent_1 = lib.SessionChangedEvent = SessionChangedEvent;
219
- const React = _dll_react;
220
- const ReactDOM = _dll_react_dom;
221
- const debug = _dll_debug;
222
- const log = debug('@pie-ui:extended-text-entry');
223
- const domParser = typeof window !== undefined ? new DOMParser() : {
224
- parseFromString: v => v
225
- };
226
- function textContent(value) {
227
- if (typeof value !== 'string') {
228
- return undefined;
229
- }
230
- try {
231
- const document = domParser.parseFromString(value, 'text/html');
232
- const textContent = document.body.textContent;
233
- return textContent;
234
- } catch (err) {
235
- log('tried to parse as dom and failed', value);
236
- return value;
237
- }
238
- }
239
- function isComplete(value) {
240
- const tc = textContent(value);
241
- const out = tc !== undefined && tc.length > 0;
242
- return out;
243
- }
244
- class RootExtendedTextEntry extends HTMLElement {
245
- constructor() {
246
- super();
247
- this._model = null;
248
- this._session = null;
249
- }
250
- set model(m) {
251
- this._model = m;
252
- this.dispatchEvent(new ModelSetEvent_1(this.tagName.toLowerCase(), false, !!this._model));
253
- this.render();
254
- }
255
- set session(s) {
256
- this._session = s;
257
- this.render();
258
- }
259
- get session() {
260
- return this._session;
261
- }
262
- handleChange(value) {
263
- this._session.value = value;
264
- this.dispatchEvent(new SessionChangedEvent_1(this.tagName.toLowerCase(), isComplete(value)));
265
- }
266
- connectedCallback() {
267
- this.render();
268
- }
269
- render() {
270
- if (this._model && this._session) {
271
- let elem = React.createElement(Main$1, {
272
- model: this._model,
273
- session: this._session,
274
- onChange: this.handleChange.bind(this)
275
- });
276
- ReactDOM.render(elem, this);
277
- }
278
- }
279
- }
280
- export {RootExtendedTextEntry as default, isComplete, textContent};
package/module/index.html DELETED
@@ -1,21 +0,0 @@
1
-
2
- <!doctype html>
3
- <html>
4
- <head>
5
- <title>@pie-element/extended-text-entry@6.8.9</title>
6
- <script
7
- type="module"
8
- src="https://cdn.jsdelivr.net/npm/@pslb/demo-el@^1.0.0/dist/demo-el/demo-el.esm.js"></script>
9
-
10
- <link
11
- href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
12
- rel="stylesheet"
13
- />
14
- <style>
15
- html, body {
16
- font-family: 'Roboto', sans-serif;
17
- }
18
- </style>
19
- <script type="module" src="./demo.js"></script>
20
- </head>
21
- </html>
@@ -1,18 +0,0 @@
1
- {
2
- "name": "@pie-element/extended-text-entry",
3
- "version": "6.8.9",
4
- "modules": [
5
- {
6
- "name": "@pie-lib/shared-module",
7
- "version": "^1.4.17"
8
- },
9
- {
10
- "name": "@pie-lib/math-rendering-module",
11
- "version": "^1.1.5"
12
- },
13
- {
14
- "name": "@pie-lib/editable-html-module",
15
- "version": "^1.5.4"
16
- }
17
- ]
18
- }
@@ -1,76 +0,0 @@
1
- import PrintElement from './print.js';
2
-
3
- var generate = {};
4
-
5
- generate.model = (id, element) => ({
6
- id,
7
- element,
8
- customKeys: [
9
- '\\square'
10
- ],
11
- feedback: { type: 'default', default: 'this is default feedback' },
12
- prompt: 'This is the question prompt',
13
- promptEnabled: true,
14
- mathInput: true,
15
- playersToolbarPosition: 'bottom',
16
- toolbarEditorPosition: 'bottom',
17
- spellCheckEnabled: true
18
- });
19
-
20
- const { model } = generate;
21
- var config = {
22
- elements: {
23
- 'extended-text-entry': '../..'
24
- },
25
- models: [model('1', 'extended-text-entry')]
26
- };
27
-
28
- // new init - just shows off print!
29
-
30
- const init = async () => {
31
- console.log('define the element...');
32
- await Promise.all(
33
- config.models.map(async (m) => {
34
- try {
35
- const printTag = `${m.element}-print`;
36
- if (customElements.get(printTag)) {
37
- return true;
38
- } else {
39
- customElements.define(printTag, PrintElement);
40
- await customElements.whenDefined(printTag);
41
- return true;
42
- }
43
- } catch (e) {
44
- return false;
45
- }
46
- })
47
- );
48
-
49
- console.log('now apply the model...');
50
- config.models.forEach((m) => {
51
- const printTag = `${m.element}-print`;
52
- const h3s = document.createElement('h3');
53
- h3s.textContent = 'student mode';
54
- document.body.appendChild(h3s);
55
- const de = document.createElement(printTag);
56
- document.body.appendChild(de);
57
- de.options = {};
58
- de.model = m;
59
-
60
- const h3 = document.createElement('h3');
61
- h3.textContent = 'instructor mode';
62
- document.body.appendChild(h3);
63
- const instr = document.createElement(printTag);
64
- document.body.appendChild(instr);
65
- instr.options = { mode: 'instructor' };
66
- instr.model = JSON.parse(JSON.stringify(m));
67
- });
68
- };
69
-
70
- init()
71
- .then(() => {
72
- console.log('ready');
73
- })
74
- .catch((e) => {
75
- console.error(e);
76
- });
package/module/print.html DELETED
@@ -1,18 +0,0 @@
1
-
2
- <!doctype html>
3
- <html>
4
- <head>
5
- <title>@pie-element/extended-text-entry@6.8.9</title>
6
- <link
7
- href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
8
- rel="stylesheet"
9
- />
10
- <style>
11
- html, body {
12
- font-family: 'Roboto', sans-serif;
13
- }
14
- </style>
15
- <script type="module" src="./print-demo.js"></script>
16
- </head>
17
- <body></body>
18
- </html>
package/module/print.js DELETED
@@ -1,242 +0,0 @@
1
- import {_dll_react, _dll_prop_types, _dll_material_ui__core, _dll_material_ui__core_styles, _dll_debug, _dll_lodash, _dll_pie_lib__render_ui, _dll_react_dom} from "../../../@pie-lib/shared-module@^1.4.17/module/index.js";
2
- import {_dll_pie_lib__math_rendering} from "../../../@pie-lib/math-rendering-module@^1.1.5/module/index.js";
3
- import {_dll_pie_lib__editable_html} from "../../../@pie-lib/editable-html-module@^1.5.4/module/index.js";
4
- const React$1 = _dll_react;
5
- const PropTypes = _dll_prop_types;
6
- const {Typography: Typography} = _dll_material_ui__core;
7
- const {withStyles: withStyles} = _dll_material_ui__core_styles;
8
- const debug$1 = _dll_debug;
9
- const {debounce: debounce$1} = _dll_lodash;
10
- const {color: color} = _dll_pie_lib__render_ui;
11
- const {Feedback: Feedback} = _dll_pie_lib__render_ui;
12
- const {Collapsible: Collapsible} = _dll_pie_lib__render_ui;
13
- const {PreviewPrompt: PreviewPrompt} = _dll_pie_lib__render_ui;
14
- const EditableHTML = _dll_pie_lib__editable_html;
15
- const {renderMath: renderMath$1} = _dll_pie_lib__math_rendering;
16
- const _jsxFileName = "/home/circleci/repo/packages/extended-text-entry/src/main.jsx";
17
- const log$1 = debug$1('@pie-ui:extended-text-entry');
18
- const style = theme => ({
19
- main: {
20
- backgroundColor: color.background(),
21
- color: color.text()
22
- },
23
- prompt: {
24
- width: '100%',
25
- color: color.text(),
26
- marginBottom: theme.spacing.unit * 2,
27
- fontSize: 'inherit'
28
- }
29
- });
30
- class Main extends React$1.Component {
31
- constructor(...args) {
32
- super(...args);
33
- Main.prototype.__init.call(this);
34
- }
35
- static __initStatic() {
36
- this.propTypes = {
37
- onChange: PropTypes.func.isRequired,
38
- model: PropTypes.object,
39
- classes: PropTypes.object.isRequired,
40
- session: PropTypes.shape({
41
- value: PropTypes.string
42
- }).isRequired
43
- };
44
- }
45
- componentDidUpdate() {
46
- if (this.containerRef) {
47
- renderMath$1(this.containerRef);
48
- }
49
- }
50
- __init() {
51
- this.changeSession = debounce$1(this.props.onChange, 1500);
52
- }
53
- render() {
54
- const {model, classes, session} = this.props;
55
- const {dimensions, disabled, feedback, teacherInstructions, mathInput, animationsDisabled, playersToolbarPosition, spellCheckEnabled} = model;
56
- const {value} = session;
57
- const {width, height} = dimensions || ({});
58
- const maxHeight = '40vh';
59
- const toolbarOpts = {};
60
- log$1('[render] disabled? ', disabled);
61
- const teacherInstructionsDiv = React$1.createElement(PreviewPrompt, {
62
- defaultClassName: "teacher-instructions",
63
- prompt: teacherInstructions,
64
- __self: this,
65
- __source: {
66
- fileName: _jsxFileName,
67
- lineNumber: 54
68
- }
69
- });
70
- switch (playersToolbarPosition) {
71
- case 'top':
72
- toolbarOpts.position = 'top';
73
- break;
74
- default:
75
- toolbarOpts.position = 'bottom';
76
- break;
77
- }
78
- return React$1.createElement('div', {
79
- className: classes.main,
80
- ref: ref => {
81
- this.containerRef = ref;
82
- },
83
- __self: this,
84
- __source: {
85
- fileName: _jsxFileName,
86
- lineNumber: 66
87
- }
88
- }, teacherInstructions && React$1.createElement('div', {
89
- __self: this,
90
- __source: {
91
- fileName: _jsxFileName,
92
- lineNumber: 74
93
- }
94
- }, !animationsDisabled ? React$1.createElement(Collapsible, {
95
- labels: {
96
- hidden: 'Show Teacher Instructions',
97
- visible: 'Hide Teacher Instructions'
98
- },
99
- className: classes.collapsible,
100
- __self: this,
101
- __source: {
102
- fileName: _jsxFileName,
103
- lineNumber: 76
104
- }
105
- }, teacherInstructionsDiv) : teacherInstructionsDiv, React$1.createElement('br', {
106
- __self: this,
107
- __source: {
108
- fileName: _jsxFileName,
109
- lineNumber: 83
110
- }
111
- })), model.prompt && React$1.createElement(Typography, {
112
- component: 'span',
113
- className: classes.prompt,
114
- __self: this,
115
- __source: {
116
- fileName: _jsxFileName,
117
- lineNumber: 88
118
- }
119
- }, React$1.createElement(PreviewPrompt, {
120
- defaultClassName: "prompt",
121
- prompt: model.prompt,
122
- __self: this,
123
- __source: {
124
- fileName: _jsxFileName,
125
- lineNumber: 92
126
- }
127
- })), React$1.createElement(EditableHTML, {
128
- className: "response-area-editor",
129
- onChange: this.changeSession,
130
- markup: value || '',
131
- width: width && width.toString(),
132
- minHeight: height && height.toString(),
133
- maxHeight: maxHeight,
134
- disabled: disabled,
135
- highlightShape: true,
136
- toolbarOpts: toolbarOpts,
137
- spellCheck: spellCheckEnabled,
138
- pluginProps: {
139
- math: {
140
- disabled: !mathInput,
141
- customKeys: this.props.model.customKeys,
142
- keypadMode: this.props.model.equationEditor,
143
- controlledKeypadMode: false
144
- },
145
- video: {
146
- disabled: true
147
- },
148
- audio: {
149
- disabled: true
150
- }
151
- },
152
- __self: this,
153
- __source: {
154
- fileName: _jsxFileName,
155
- lineNumber: 95
156
- }
157
- }), feedback && React$1.createElement('div', {
158
- __self: this,
159
- __source: {
160
- fileName: _jsxFileName,
161
- lineNumber: 122
162
- }
163
- }, React$1.createElement('br', {
164
- __self: this,
165
- __source: {
166
- fileName: _jsxFileName,
167
- lineNumber: 123
168
- }
169
- }), React$1.createElement(Feedback, {
170
- correctness: "correct",
171
- feedback: feedback,
172
- __self: this,
173
- __source: {
174
- fileName: _jsxFileName,
175
- lineNumber: 124
176
- }
177
- })));
178
- }
179
- }
180
- Main.__initStatic();
181
- var Main$1 = withStyles(style)(Main);
182
- const React = _dll_react;
183
- const ReactDOM = _dll_react_dom;
184
- const {debounce: debounce} = _dll_lodash;
185
- const debug = _dll_debug;
186
- const {renderMath: renderMath} = _dll_pie_lib__math_rendering;
187
- const log = debug('pie-element:extended-text-entry:print');
188
- const preparePrintModel = (model, opts) => {
189
- const instr = opts.role === 'instructor';
190
- model.prompt = model.promptEnabled !== false ? model.prompt : undefined;
191
- model.teacherInstructions = instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;
192
- model.showTeacherInstructions = instr;
193
- model.mode = instr ? 'evaluate' : model.mode;
194
- const defaultDimensions = {
195
- height: 100,
196
- width: 500
197
- };
198
- model.dimensions = {
199
- ...defaultDimensions,
200
- ...model.dimensions
201
- };
202
- model.disabled = true;
203
- model.feedback = undefined;
204
- model.animationsDisabled = true;
205
- return model;
206
- };
207
- class ExtendedTextEntryPrint extends HTMLElement {
208
- constructor() {
209
- super();
210
- this._options = null;
211
- this._model = null;
212
- this._session = [];
213
- this._rerender = debounce(() => {
214
- if (this._model && this._session) {
215
- const printModel = preparePrintModel(this._model, this._options);
216
- const element = this._options && React.createElement(Main$1, {
217
- model: printModel,
218
- session: {},
219
- onChange: () => {}
220
- });
221
- ReactDOM.render(element, this, () => {
222
- log('render complete - render math');
223
- renderMath(this);
224
- });
225
- } else {
226
- log('skip');
227
- }
228
- }, 50, {
229
- leading: false,
230
- trailing: true
231
- });
232
- }
233
- set options(o) {
234
- this._options = o;
235
- }
236
- set model(s) {
237
- this._model = s;
238
- this._rerender();
239
- }
240
- connectedCallback() {}
241
- }
242
- export {ExtendedTextEntryPrint as default};