@pie-element/complex-rubric 2.10.2-next.29 → 2.10.2-next.30
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 +9 -12
- 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 +3 -5
- 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 +10 -13
- 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 +3 -4
- 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
|
|
|
@@ -185,7 +182,6 @@ const SlateEditor = (editorProps) => {
|
|
|
185
182
|
<Editable
|
|
186
183
|
renderElement={renderElement}
|
|
187
184
|
renderLeaf={renderLeaf}
|
|
188
|
-
placeholder="Enter some rich text…"
|
|
189
185
|
spellCheck
|
|
190
186
|
onKeyDown={onKeyDown}
|
|
191
187
|
onFocus={onFocus}
|
|
@@ -306,18 +302,18 @@ const Element = (props) => {
|
|
|
306
302
|
{children}
|
|
307
303
|
</ol>
|
|
308
304
|
);
|
|
309
|
-
|
|
305
|
+
case 'div':
|
|
310
306
|
return (
|
|
311
|
-
<div
|
|
312
|
-
style={{
|
|
313
|
-
...style,
|
|
314
|
-
margin: 0,
|
|
315
|
-
}}
|
|
316
|
-
{...attributes}
|
|
317
|
-
>
|
|
307
|
+
<div style={style} {...attributes}>
|
|
318
308
|
{children}
|
|
319
309
|
</div>
|
|
320
310
|
);
|
|
311
|
+
default:
|
|
312
|
+
return (
|
|
313
|
+
<p style={style} {...attributes}>
|
|
314
|
+
{children}
|
|
315
|
+
</p>
|
|
316
|
+
);
|
|
321
317
|
}
|
|
322
318
|
};
|
|
323
319
|
|
|
@@ -1274,6 +1270,7 @@ const styles = {
|
|
|
1274
1270
|
borderCollapse: 'collapse',
|
|
1275
1271
|
color: color.text(),
|
|
1276
1272
|
backgroundColor: color.background(),
|
|
1273
|
+
whiteSpace: 'pre-wrap',
|
|
1277
1274
|
},
|
|
1278
1275
|
'& table:not([border="1"]) tr': {
|
|
1279
1276
|
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];
|
|
@@ -254,7 +253,7 @@ export default (opts, toolbarPlugins /* : {toolbar: {}}[] */) => {
|
|
|
254
253
|
const [nodeAtSelection, nodePath] = Editor.node(editor, editor.selection);
|
|
255
254
|
|
|
256
255
|
if (Text.isText(nodeAtSelection)) {
|
|
257
|
-
const block = { type: '
|
|
256
|
+
const block = { type: 'div', children: [] };
|
|
258
257
|
|
|
259
258
|
Transforms.wrapNodes(editor, block, { at: nodePath });
|
|
260
259
|
}
|
|
@@ -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.3/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.8/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.3/module/index.js";
|
|
2
|
+
import {_dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@4.11.1-next.8/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.3/module/index.js";
|
|
2
|
+
import {_dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@4.11.1-next.8/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.30+4c2350f56",
|
|
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": "4c2350f56193abf77221d29ebec9965a29491434",
|
|
19
19
|
"scripts": {
|
|
20
20
|
"postpublish": "../../scripts/postpublish"
|
|
21
21
|
},
|