@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.
Files changed (24) hide show
  1. package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/editor.js +9 -12
  2. package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/editor.js.map +1 -1
  3. package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/plugins/customPlugin/index.js +32 -11
  4. package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/plugins/customPlugin/index.js.map +1 -1
  5. package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/plugins/image/index.js +2 -4
  6. package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/plugins/image/index.js.map +1 -1
  7. package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/plugins/math/index.js +4 -4
  8. package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/plugins/math/index.js.map +1 -1
  9. package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/plugins/table/index.js +3 -5
  10. package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/plugins/table/index.js.map +1 -1
  11. package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/test-serializer.js +1 -1
  12. package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/code/editable-html/test-serializer.js.map +1 -1
  13. package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/package.json +2 -2
  14. package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/src/code/editable-html/editor.jsx +10 -13
  15. package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/src/code/editable-html/plugins/customPlugin/index.jsx +14 -11
  16. package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/src/code/editable-html/plugins/image/index.jsx +16 -12
  17. package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/src/code/editable-html/plugins/math/index.jsx +30 -18
  18. package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/src/code/editable-html/plugins/table/index.jsx +3 -4
  19. package/configure/node_modules/@pie-element/rubric/node_modules/@pie-lib/pie-toolbox/src/code/editable-html/test-serializer.js +1 -1
  20. package/module/configure.js +2 -2
  21. package/module/element.js +2 -2
  22. package/module/manifest.json +2 -2
  23. package/module/print.js +2 -2
  24. 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 { getBase64, htmlToValue, valueToHtml } from './new-serialization';
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
- default:
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: (value, onChange, getFocusedValue) => {
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
- valueToUse = change.value;
41
- onChange(change);
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
- if (editorDOM) {
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 /*, next*/) {
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('element', {
264
- type: 'image',
265
- data: {
266
- src: el.getAttribute('src'),
267
- width,
268
- height,
269
- margin: el.style.margin,
270
- justifyContent: el.style.justifyContent,
271
- alignment: el.getAttribute('alignment'),
272
- alt: el.getAttribute('alt'),
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('element', {
266
- type: 'math',
267
- data: {
268
- latex: unwrapped,
269
- wrapper: wrapType,
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('element', {
275
- type: 'mathml',
276
- data: {
277
- html: newHtml,
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('element', {
298
- type: 'math',
299
- data: {
300
- latex: unwrapped,
301
- wrapper: wrapType,
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 paragraph, ensure its children are valid.
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: 'paragraph',
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: 'paragraph', children: [] };
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(`<p>${html}</p>`);
65
+ body = this.parseHtml(`<div>${html}</div>`);
66
66
  }
67
67
 
68
68
  return this.deserializeEls(body);
@@ -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.0/module/index.js";
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.5/module/index.js";
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.0/module/index.js";
2
- import {_dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@4.11.1-next.5/module/index.js";
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) {
@@ -4,11 +4,11 @@
4
4
  "modules": [
5
5
  {
6
6
  "name": "@pie-lib/pie-toolbox-math-rendering-module",
7
- "version": "1.10.0"
7
+ "version": "1.10.3"
8
8
  },
9
9
  {
10
10
  "name": "@pie-lib/pie-toolbox-module",
11
- "version": "4.11.1-next.5"
11
+ "version": "4.11.1-next.8"
12
12
  }
13
13
  ]
14
14
  }
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.0/module/index.js";
2
- import {_dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@4.11.1-next.5/module/index.js";
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.29+1c93d0a63",
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": "1c93d0a632636b993d8caafbbb49a69dff1ffc7f",
18
+ "gitHead": "4c2350f56193abf77221d29ebec9965a29491434",
19
19
  "scripts": {
20
20
  "postpublish": "../../scripts/postpublish"
21
21
  },