@pie-element/complex-rubric 2.10.2-next.29 → 2.10.2-next.31
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/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/editor.js +16 -18
- package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/editor.js.map +1 -1
- package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/plugins/customPlugin/index.js +32 -11
- package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/plugins/customPlugin/index.js.map +1 -1
- package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/plugins/image/index.js +2 -4
- package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/plugins/image/index.js.map +1 -1
- package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/plugins/math/index.js +4 -4
- package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/plugins/math/index.js.map +1 -1
- package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/plugins/table/index.js +2 -21
- package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/plugins/table/index.js.map +1 -1
- package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/test-serializer.js +1 -1
- package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/test-serializer.js.map +1 -1
- package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/package.json +2 -2
- package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/src/code/editable-html/editor.jsx +15 -19
- package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/src/code/editable-html/plugins/customPlugin/index.jsx +14 -11
- package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/src/code/editable-html/plugins/image/index.jsx +16 -12
- package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/src/code/editable-html/plugins/math/index.jsx +30 -18
- package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/src/code/editable-html/plugins/table/index.jsx +2 -11
- package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/src/code/editable-html/test-serializer.js +1 -1
- package/module/configure.js +2 -2
- package/module/element.js +2 -2
- package/module/manifest.json +2 -2
- package/module/print.js +2 -2
- package/package.json +2 -2
|
@@ -12,13 +12,10 @@ import { withStyles } from '@material-ui/core/styles';
|
|
|
12
12
|
import classNames from 'classnames';
|
|
13
13
|
import { color } from '../render-ui';
|
|
14
14
|
// import Plain from 'slate-plain-serializer';
|
|
15
|
-
import AlertDialog from '../config-ui/alert-dialog';
|
|
16
15
|
import { PreviewPrompt } from '../render-ui';
|
|
17
16
|
|
|
18
|
-
import {
|
|
19
|
-
import InsertImageHandler from './plugins/image/insert-image-handler';
|
|
17
|
+
import { htmlToValue, valueToHtml } from './new-serialization';
|
|
20
18
|
|
|
21
|
-
import isHotkey from 'is-hotkey';
|
|
22
19
|
import { ReactEditor, useSlateStatic, Editable, useFocused, useSlate, Slate } from 'slate-react';
|
|
23
20
|
import { Node as SlateNode, Path, Editor, Transforms, createEditor, Element as SlateElement } from 'slate';
|
|
24
21
|
|
|
@@ -62,7 +59,7 @@ const initialValue = [
|
|
|
62
59
|
|
|
63
60
|
const SlateEditor = (editorProps) => {
|
|
64
61
|
const mounted = useRef(false);
|
|
65
|
-
const { autoFocus, value, plugins, actionsRef, onEditingDone } = editorProps;
|
|
62
|
+
const { autoFocus, value, plugins, actionsRef, onEditingDone, placeholder, renderPlaceholder } = editorProps;
|
|
66
63
|
const renderElement = useCallback((props) => <Element {...props} plugins={plugins} />, []);
|
|
67
64
|
const renderLeaf = useCallback((props) => <Leaf {...props} />, []);
|
|
68
65
|
const editor = useMemo(() => withPlugins(createEditor(), plugins), []);
|
|
@@ -183,9 +180,10 @@ const SlateEditor = (editorProps) => {
|
|
|
183
180
|
}}
|
|
184
181
|
>
|
|
185
182
|
<Editable
|
|
183
|
+
placeholder={placeholder}
|
|
184
|
+
renderPlaceholder={renderPlaceholder}
|
|
186
185
|
renderElement={renderElement}
|
|
187
186
|
renderLeaf={renderLeaf}
|
|
188
|
-
placeholder="Enter some rich text…"
|
|
189
187
|
spellCheck
|
|
190
188
|
onKeyDown={onKeyDown}
|
|
191
189
|
onFocus={onFocus}
|
|
@@ -306,18 +304,18 @@ const Element = (props) => {
|
|
|
306
304
|
{children}
|
|
307
305
|
</ol>
|
|
308
306
|
);
|
|
309
|
-
|
|
307
|
+
case 'div':
|
|
310
308
|
return (
|
|
311
|
-
<div
|
|
312
|
-
style={{
|
|
313
|
-
...style,
|
|
314
|
-
margin: 0,
|
|
315
|
-
}}
|
|
316
|
-
{...attributes}
|
|
317
|
-
>
|
|
309
|
+
<div style={style} {...attributes}>
|
|
318
310
|
{children}
|
|
319
311
|
</div>
|
|
320
312
|
);
|
|
313
|
+
default:
|
|
314
|
+
return (
|
|
315
|
+
<p style={style} {...attributes}>
|
|
316
|
+
{children}
|
|
317
|
+
</p>
|
|
318
|
+
);
|
|
321
319
|
}
|
|
322
320
|
};
|
|
323
321
|
|
|
@@ -1126,10 +1124,7 @@ export class EditorComponent extends React.Component {
|
|
|
1126
1124
|
};
|
|
1127
1125
|
|
|
1128
1126
|
renderPlaceholder = (props) => {
|
|
1129
|
-
|
|
1130
|
-
const { document } = editor.value;
|
|
1131
|
-
|
|
1132
|
-
if (!editor.props.placeholder || document.text !== '' || document.nodes.size !== 1) {
|
|
1127
|
+
if (!props.children) {
|
|
1133
1128
|
return false;
|
|
1134
1129
|
}
|
|
1135
1130
|
|
|
@@ -1146,7 +1141,7 @@ export class EditorComponent extends React.Component {
|
|
|
1146
1141
|
userSelect: 'none',
|
|
1147
1142
|
}}
|
|
1148
1143
|
>
|
|
1149
|
-
{
|
|
1144
|
+
{props.children}
|
|
1150
1145
|
</span>
|
|
1151
1146
|
);
|
|
1152
1147
|
};
|
|
@@ -1274,6 +1269,7 @@ const styles = {
|
|
|
1274
1269
|
borderCollapse: 'collapse',
|
|
1275
1270
|
color: color.text(),
|
|
1276
1271
|
backgroundColor: color.background(),
|
|
1272
|
+
whiteSpace: 'pre-wrap',
|
|
1277
1273
|
},
|
|
1278
1274
|
'& table:not([border="1"]) tr': {
|
|
1279
1275
|
borderTop: '1px solid #dfe2e5',
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { htmlToValue } from '../../new-serialization';
|
|
3
|
+
import {ReactEditor} from "slate-react";
|
|
4
|
+
import {Editor, Text, Transforms} from "slate";
|
|
3
5
|
|
|
4
6
|
// We're possibly going to have to support content types, so starting it as an enum
|
|
5
7
|
export const CONTENT_TYPE = {
|
|
@@ -25,29 +27,30 @@ const getIcon = (customPluginProps) => {
|
|
|
25
27
|
export default function CustomPlugin(type, customPluginProps) {
|
|
26
28
|
const toolbar = {
|
|
27
29
|
icon: getIcon(customPluginProps),
|
|
28
|
-
onClick: (
|
|
29
|
-
const editorDOM = document.querySelector(`[data-key="${value.document.key}"]`);
|
|
30
|
-
let valueToUse = value;
|
|
30
|
+
onClick: (editor) => {
|
|
31
31
|
const callback = ({ customContent, contentType }, focus) => {
|
|
32
|
-
valueToUse = getFocusedValue();
|
|
33
|
-
|
|
34
32
|
switch (contentType) {
|
|
35
33
|
case CONTENT_TYPE.FRAGMENT:
|
|
36
34
|
default: {
|
|
37
35
|
const contentValue = htmlToValue(customContent);
|
|
38
|
-
const change = valueToUse.change().insertFragment(contentValue.document);
|
|
39
36
|
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
const [nodeAtSelection, nodePath] = Editor.node(editor, editor.selection);
|
|
38
|
+
|
|
39
|
+
if (Text.isText(nodeAtSelection)) {
|
|
40
|
+
const block = { type: 'paragraph', children: [] };
|
|
41
|
+
|
|
42
|
+
Transforms.wrapNodes(editor, block, { at: nodePath });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
editor.insertNode(contentValue);
|
|
46
|
+
Transforms.move(editor, { distance: 1, unit: 'offset' });
|
|
42
47
|
|
|
43
48
|
break;
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
if (focus) {
|
|
48
|
-
|
|
49
|
-
editorDOM.focus();
|
|
50
|
-
}
|
|
53
|
+
ReactEditor.focus(editor);
|
|
51
54
|
}
|
|
52
55
|
};
|
|
53
56
|
|
|
@@ -251,7 +251,7 @@ export default function ImagePlugin(opts) {
|
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
export const serialization = {
|
|
254
|
-
deserialize(el
|
|
254
|
+
deserialize(el , next) {
|
|
255
255
|
const name = el.tagName.toLowerCase();
|
|
256
256
|
if (name !== 'img') return;
|
|
257
257
|
|
|
@@ -260,18 +260,22 @@ export const serialization = {
|
|
|
260
260
|
const width = parseInt(style.width.replace('px', ''), 10) || null;
|
|
261
261
|
const height = parseInt(style.height.replace('px', ''), 10) || null;
|
|
262
262
|
|
|
263
|
-
const out = jsx(
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
263
|
+
const out = jsx(
|
|
264
|
+
'element',
|
|
265
|
+
{
|
|
266
|
+
type: 'image',
|
|
267
|
+
data: {
|
|
268
|
+
src: el.getAttribute('src'),
|
|
269
|
+
width,
|
|
270
|
+
height,
|
|
271
|
+
margin: el.style.margin,
|
|
272
|
+
justifyContent: el.style.justifyContent,
|
|
273
|
+
alignment: el.getAttribute('alignment'),
|
|
274
|
+
alt: el.getAttribute('alt'),
|
|
275
|
+
},
|
|
273
276
|
},
|
|
274
|
-
|
|
277
|
+
next(Array.from(el.children)),
|
|
278
|
+
);
|
|
275
279
|
log('return object: ', out);
|
|
276
280
|
return out;
|
|
277
281
|
},
|
|
@@ -243,7 +243,7 @@ function fixLatexExpression(latexInput) {
|
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
export const serialization = {
|
|
246
|
-
deserialize(el) {
|
|
246
|
+
deserialize(el, next) {
|
|
247
247
|
const tagName = getTagName(el);
|
|
248
248
|
log('[deserialize] name: ', tagName);
|
|
249
249
|
|
|
@@ -262,21 +262,29 @@ export const serialization = {
|
|
|
262
262
|
const correctedLatex = fixLatexExpression(latex);
|
|
263
263
|
const { unwrapped, wrapType } = unWrapMath(correctedLatex);
|
|
264
264
|
|
|
265
|
-
return jsx(
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
265
|
+
return jsx(
|
|
266
|
+
'element',
|
|
267
|
+
{
|
|
268
|
+
type: 'math',
|
|
269
|
+
data: {
|
|
270
|
+
latex: unwrapped,
|
|
271
|
+
wrapper: wrapType,
|
|
272
|
+
},
|
|
270
273
|
},
|
|
271
|
-
|
|
274
|
+
next(Array.from(el.children)),
|
|
275
|
+
);
|
|
272
276
|
}
|
|
273
277
|
|
|
274
|
-
return jsx(
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
+
return jsx(
|
|
279
|
+
'element',
|
|
280
|
+
{
|
|
281
|
+
type: 'mathml',
|
|
282
|
+
data: {
|
|
283
|
+
html: newHtml,
|
|
284
|
+
},
|
|
278
285
|
},
|
|
279
|
-
|
|
286
|
+
next(Array.from(el.children)),
|
|
287
|
+
);
|
|
280
288
|
}
|
|
281
289
|
|
|
282
290
|
if (el.nodeType === TEXT_NODE) {
|
|
@@ -294,13 +302,17 @@ export const serialization = {
|
|
|
294
302
|
const { unwrapped, wrapType } = unWrapMath(latex);
|
|
295
303
|
log('[deserialize]: noBrackets: ', unwrapped, wrapType);
|
|
296
304
|
|
|
297
|
-
return jsx(
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
305
|
+
return jsx(
|
|
306
|
+
'element',
|
|
307
|
+
{
|
|
308
|
+
type: 'math',
|
|
309
|
+
data: {
|
|
310
|
+
latex: unwrapped,
|
|
311
|
+
wrapper: wrapType,
|
|
312
|
+
},
|
|
302
313
|
},
|
|
303
|
-
|
|
314
|
+
next(Array.from(el.children)),
|
|
315
|
+
);
|
|
304
316
|
}
|
|
305
317
|
},
|
|
306
318
|
serialize(object) {
|
|
@@ -12,7 +12,6 @@ import { object as toStyleObject } from 'to-style';
|
|
|
12
12
|
import get from 'lodash/get';
|
|
13
13
|
import omit from 'lodash/omit';
|
|
14
14
|
import reduce from 'lodash/reduce';
|
|
15
|
-
import { LIST_TYPES } from "../list";
|
|
16
15
|
|
|
17
16
|
const log = debug('@pie-lib:editable-html:plugins:table');
|
|
18
17
|
|
|
@@ -138,10 +137,10 @@ export default (opts, toolbarPlugins /* : {toolbar: {}}[] */) => {
|
|
|
138
137
|
const [tableNode, tablePath] = entry;
|
|
139
138
|
const tableParent = SlateNode.get(editor, tablePath.slice(0, -1));
|
|
140
139
|
|
|
141
|
-
// If the element is a
|
|
140
|
+
// If the element is a table, ensure its children are valid.
|
|
142
141
|
if (SlateElement.isElement(tableNode) && tableNode.type === 'table') {
|
|
143
142
|
const emptyBlock = {
|
|
144
|
-
type: '
|
|
143
|
+
type: 'div',
|
|
145
144
|
children: [{ text: '' }],
|
|
146
145
|
};
|
|
147
146
|
const tableIndex = tablePath.slice(-1)[0];
|
|
@@ -251,14 +250,6 @@ export default (opts, toolbarPlugins /* : {toolbar: {}}[] */) => {
|
|
|
251
250
|
},
|
|
252
251
|
});
|
|
253
252
|
|
|
254
|
-
const [nodeAtSelection, nodePath] = Editor.node(editor, editor.selection);
|
|
255
|
-
|
|
256
|
-
if (Text.isText(nodeAtSelection)) {
|
|
257
|
-
const block = { type: 'paragraph', children: [] };
|
|
258
|
-
|
|
259
|
-
Transforms.wrapNodes(editor, block, { at: nodePath });
|
|
260
|
-
}
|
|
261
|
-
|
|
262
253
|
editor.insertNode(newTable);
|
|
263
254
|
moveToBeginningOfTable(editor, newTable);
|
|
264
255
|
},
|
|
@@ -62,7 +62,7 @@ class Html {
|
|
|
62
62
|
!Object.keys(BLOCK_TAGS).includes(body.firstChild.tagName.toLowerCase()) ||
|
|
63
63
|
Object.keys(MARK_TAGS).includes(body.firstChild.tagName.toLowerCase())
|
|
64
64
|
) {
|
|
65
|
-
body = this.parseHtml(`<
|
|
65
|
+
body = this.parseHtml(`<div>${html}</div>`);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
return this.deserializeEls(body);
|
package/module/configure.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_debug, _dll_lodash, _dll_react_dom_server, _dll_pie_framework__mathquill} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.10.
|
|
1
|
+
import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_debug, _dll_lodash, _dll_react_dom_server, _dll_pie_framework__mathquill} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.10.4/module/index.js";
|
|
2
2
|
import RubricConfigure from '@pie-element/rubric/configure/lib';
|
|
3
|
-
import {_dll_pie_lib__pie_toolbox_editable_html, _dll_pie_lib__pie_toolbox_render_ui, _dll_pie_lib__pie_toolbox_config_ui} from "../../../@pie-lib/pie-toolbox-module@4.11.1-next.
|
|
3
|
+
import {_dll_pie_lib__pie_toolbox_editable_html, _dll_pie_lib__pie_toolbox_render_ui, _dll_pie_lib__pie_toolbox_config_ui} from "../../../@pie-lib/pie-toolbox-module@4.11.1-next.10/module/index.js";
|
|
4
4
|
function _mergeNamespaces(n, m) {
|
|
5
5
|
m.forEach(function (e) {
|
|
6
6
|
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
package/module/element.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {_dll_react, _dll_prop_types, _dll_react_dom, _dll_classnames, _dll_debug, _dll_lodash, _dll_react_dom_server, _dll_pie_framework__mathquill} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.10.
|
|
2
|
-
import {_dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@4.11.1-next.
|
|
1
|
+
import {_dll_react, _dll_prop_types, _dll_react_dom, _dll_classnames, _dll_debug, _dll_lodash, _dll_react_dom_server, _dll_pie_framework__mathquill} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.10.4/module/index.js";
|
|
2
|
+
import {_dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@4.11.1-next.10/module/index.js";
|
|
3
3
|
function _mergeNamespaces(n, m) {
|
|
4
4
|
m.forEach(function (e) {
|
|
5
5
|
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
package/module/manifest.json
CHANGED
package/module/print.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {_dll_react, _dll_prop_types, _dll_react_dom, _dll_classnames, _dll_debug, _dll_lodash, _dll_react_dom_server, _dll_pie_framework__mathquill} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.10.
|
|
2
|
-
import {_dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@4.11.1-next.
|
|
1
|
+
import {_dll_react, _dll_prop_types, _dll_react_dom, _dll_classnames, _dll_debug, _dll_lodash, _dll_react_dom_server, _dll_pie_framework__mathquill} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.10.4/module/index.js";
|
|
2
|
+
import {_dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@4.11.1-next.10/module/index.js";
|
|
3
3
|
function _mergeNamespaces(n, m) {
|
|
4
4
|
m.forEach(function (e) {
|
|
5
5
|
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/complex-rubric",
|
|
3
3
|
"repository": "pie-framework/pie-elements",
|
|
4
|
-
"version": "2.10.2-next.
|
|
4
|
+
"version": "2.10.2-next.31+1a4733b88",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"lodash": "^4.17.11",
|
|
16
16
|
"prop-types": "^15.7.2"
|
|
17
17
|
},
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "1a4733b888439b260c1af1dc75083aa956a7c14a",
|
|
19
19
|
"scripts": {
|
|
20
20
|
"postpublish": "../../scripts/postpublish"
|
|
21
21
|
},
|