@pie-lib/editable-html 11.1.1 → 11.3.0-beta.0

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 (194) hide show
  1. package/CHANGELOG.md +8 -4
  2. package/NEXT.CHANGELOG.json +1 -0
  3. package/lib/__tests__/editor.test.js +470 -0
  4. package/lib/__tests__/serialization.test.js +246 -0
  5. package/lib/__tests__/utils.js +106 -0
  6. package/lib/block-tags.js +25 -0
  7. package/lib/constants.js +16 -0
  8. package/lib/editor.js +349 -88
  9. package/lib/index.js +26 -10
  10. package/lib/parse-html.js +1 -1
  11. package/lib/plugins/characters/custom-popper.js +1 -1
  12. package/lib/plugins/characters/index.js +9 -4
  13. package/lib/plugins/characters/utils.js +13 -13
  14. package/lib/plugins/css/icons/index.js +37 -0
  15. package/lib/plugins/css/index.js +397 -0
  16. package/lib/plugins/customPlugin/index.js +114 -0
  17. package/lib/plugins/html/icons/index.js +1 -1
  18. package/lib/plugins/html/index.js +12 -8
  19. package/lib/plugins/image/__tests__/component.test.js +51 -0
  20. package/lib/plugins/image/__tests__/image-toolbar-logic.test.js +56 -0
  21. package/lib/plugins/image/__tests__/image-toolbar.test.js +26 -0
  22. package/lib/plugins/image/__tests__/index.test.js +98 -0
  23. package/lib/plugins/image/__tests__/insert-image-handler.test.js +125 -0
  24. package/lib/plugins/image/__tests__/mock-change.js +25 -0
  25. package/lib/plugins/image/alt-dialog.js +1 -1
  26. package/lib/plugins/image/component.js +1 -1
  27. package/lib/plugins/image/image-toolbar.js +1 -1
  28. package/lib/plugins/image/index.js +3 -2
  29. package/lib/plugins/image/insert-image-handler.js +14 -5
  30. package/lib/plugins/index.js +271 -12
  31. package/lib/plugins/list/__tests__/index.test.js +79 -0
  32. package/lib/plugins/list/index.js +131 -1
  33. package/lib/plugins/math/__tests__/index.test.js +300 -0
  34. package/lib/plugins/math/index.js +92 -57
  35. package/lib/plugins/media/__tests__/index.test.js +71 -0
  36. package/lib/plugins/media/index.js +6 -3
  37. package/lib/plugins/media/media-dialog.js +99 -58
  38. package/lib/plugins/media/media-toolbar.js +1 -1
  39. package/lib/plugins/media/media-wrapper.js +1 -1
  40. package/lib/plugins/rendering/index.js +46 -0
  41. package/lib/plugins/respArea/drag-in-the-blank/choice.js +6 -3
  42. package/lib/plugins/respArea/drag-in-the-blank/index.js +1 -1
  43. package/lib/plugins/respArea/explicit-constructed-response/index.js +12 -10
  44. package/lib/plugins/respArea/icons/index.js +1 -1
  45. package/lib/plugins/respArea/index.js +70 -22
  46. package/lib/plugins/respArea/inline-dropdown/index.js +11 -6
  47. package/lib/plugins/respArea/math-templated/index.js +130 -0
  48. package/lib/plugins/respArea/utils.js +17 -2
  49. package/lib/plugins/table/CustomTablePlugin.js +133 -0
  50. package/lib/plugins/table/__tests__/index.test.js +442 -0
  51. package/lib/plugins/table/__tests__/table-toolbar.test.js +54 -0
  52. package/lib/plugins/table/icons/index.js +1 -1
  53. package/lib/plugins/table/index.js +44 -60
  54. package/lib/plugins/table/table-toolbar.js +34 -5
  55. package/lib/plugins/textAlign/icons/index.js +226 -0
  56. package/lib/plugins/textAlign/index.js +34 -0
  57. package/lib/plugins/toolbar/__tests__/default-toolbar.test.js +128 -0
  58. package/lib/plugins/toolbar/__tests__/editor-and-toolbar.test.js +51 -0
  59. package/lib/plugins/toolbar/__tests__/toolbar-buttons.test.js +54 -0
  60. package/lib/plugins/toolbar/__tests__/toolbar.test.js +120 -0
  61. package/lib/plugins/toolbar/default-toolbar.js +83 -28
  62. package/lib/plugins/toolbar/done-button.js +6 -3
  63. package/lib/plugins/toolbar/editor-and-toolbar.js +19 -20
  64. package/lib/plugins/toolbar/index.js +1 -1
  65. package/lib/plugins/toolbar/toolbar-buttons.js +45 -12
  66. package/lib/plugins/toolbar/toolbar.js +36 -12
  67. package/lib/plugins/utils.js +1 -1
  68. package/lib/serialization.js +234 -45
  69. package/lib/theme.js +1 -1
  70. package/package.json +6 -6
  71. package/src/__tests__/editor.test.jsx +363 -0
  72. package/src/__tests__/serialization.test.js +291 -0
  73. package/src/__tests__/utils.js +36 -0
  74. package/src/block-tags.js +17 -0
  75. package/src/constants.js +7 -0
  76. package/src/editor.jsx +303 -49
  77. package/src/index.jsx +19 -10
  78. package/src/plugins/characters/index.jsx +11 -3
  79. package/src/plugins/characters/utils.js +12 -12
  80. package/src/plugins/css/icons/index.jsx +17 -0
  81. package/src/plugins/css/index.jsx +346 -0
  82. package/src/plugins/customPlugin/index.jsx +85 -0
  83. package/src/plugins/html/index.jsx +9 -6
  84. package/src/plugins/image/__tests__/__snapshots__/component.test.jsx.snap +51 -0
  85. package/src/plugins/image/__tests__/__snapshots__/image-toolbar-logic.test.jsx.snap +27 -0
  86. package/src/plugins/image/__tests__/__snapshots__/image-toolbar.test.jsx.snap +44 -0
  87. package/src/plugins/image/__tests__/component.test.jsx +41 -0
  88. package/src/plugins/image/__tests__/image-toolbar-logic.test.jsx +42 -0
  89. package/src/plugins/image/__tests__/image-toolbar.test.jsx +11 -0
  90. package/src/plugins/image/__tests__/index.test.js +95 -0
  91. package/src/plugins/image/__tests__/insert-image-handler.test.js +113 -0
  92. package/src/plugins/image/__tests__/mock-change.js +15 -0
  93. package/src/plugins/image/index.jsx +2 -1
  94. package/src/plugins/image/insert-image-handler.js +13 -6
  95. package/src/plugins/index.jsx +248 -5
  96. package/src/plugins/list/__tests__/index.test.js +54 -0
  97. package/src/plugins/list/index.jsx +130 -0
  98. package/src/plugins/math/__tests__/__snapshots__/index.test.jsx.snap +48 -0
  99. package/src/plugins/math/__tests__/index.test.jsx +245 -0
  100. package/src/plugins/math/index.jsx +87 -56
  101. package/src/plugins/media/__tests__/index.test.js +75 -0
  102. package/src/plugins/media/index.jsx +3 -2
  103. package/src/plugins/media/media-dialog.js +106 -57
  104. package/src/plugins/rendering/index.js +31 -0
  105. package/src/plugins/respArea/drag-in-the-blank/choice.jsx +4 -1
  106. package/src/plugins/respArea/explicit-constructed-response/index.jsx +10 -8
  107. package/src/plugins/respArea/index.jsx +53 -7
  108. package/src/plugins/respArea/inline-dropdown/index.jsx +13 -6
  109. package/src/plugins/respArea/math-templated/index.jsx +104 -0
  110. package/src/plugins/respArea/utils.jsx +11 -0
  111. package/src/plugins/table/CustomTablePlugin.js +113 -0
  112. package/src/plugins/table/__tests__/__snapshots__/table-toolbar.test.jsx.snap +44 -0
  113. package/src/plugins/table/__tests__/index.test.jsx +401 -0
  114. package/src/plugins/table/__tests__/table-toolbar.test.jsx +42 -0
  115. package/src/plugins/table/index.jsx +46 -59
  116. package/src/plugins/table/table-toolbar.jsx +39 -2
  117. package/src/plugins/textAlign/icons/index.jsx +139 -0
  118. package/src/plugins/textAlign/index.jsx +23 -0
  119. package/src/plugins/toolbar/__tests__/__snapshots__/default-toolbar.test.jsx.snap +923 -0
  120. package/src/plugins/toolbar/__tests__/__snapshots__/editor-and-toolbar.test.jsx.snap +20 -0
  121. package/src/plugins/toolbar/__tests__/__snapshots__/toolbar-buttons.test.jsx.snap +36 -0
  122. package/src/plugins/toolbar/__tests__/__snapshots__/toolbar.test.jsx.snap +46 -0
  123. package/src/plugins/toolbar/__tests__/default-toolbar.test.jsx +94 -0
  124. package/src/plugins/toolbar/__tests__/editor-and-toolbar.test.jsx +37 -0
  125. package/src/plugins/toolbar/__tests__/toolbar-buttons.test.jsx +51 -0
  126. package/src/plugins/toolbar/__tests__/toolbar.test.jsx +106 -0
  127. package/src/plugins/toolbar/default-toolbar.jsx +80 -20
  128. package/src/plugins/toolbar/done-button.jsx +3 -1
  129. package/src/plugins/toolbar/editor-and-toolbar.jsx +18 -13
  130. package/src/plugins/toolbar/toolbar-buttons.jsx +52 -11
  131. package/src/plugins/toolbar/toolbar.jsx +31 -8
  132. package/src/serialization.jsx +213 -38
  133. package/README.md +0 -45
  134. package/deploy.sh +0 -16
  135. package/lib/editor.js.map +0 -1
  136. package/lib/index.js.map +0 -1
  137. package/lib/parse-html.js.map +0 -1
  138. package/lib/plugins/characters/custom-popper.js.map +0 -1
  139. package/lib/plugins/characters/index.js.map +0 -1
  140. package/lib/plugins/characters/utils.js.map +0 -1
  141. package/lib/plugins/html/icons/index.js.map +0 -1
  142. package/lib/plugins/html/index.js.map +0 -1
  143. package/lib/plugins/image/alt-dialog.js.map +0 -1
  144. package/lib/plugins/image/component.js.map +0 -1
  145. package/lib/plugins/image/image-toolbar.js.map +0 -1
  146. package/lib/plugins/image/index.js.map +0 -1
  147. package/lib/plugins/image/insert-image-handler.js.map +0 -1
  148. package/lib/plugins/index.js.map +0 -1
  149. package/lib/plugins/list/index.js.map +0 -1
  150. package/lib/plugins/math/index.js.map +0 -1
  151. package/lib/plugins/media/index.js.map +0 -1
  152. package/lib/plugins/media/media-dialog.js.map +0 -1
  153. package/lib/plugins/media/media-toolbar.js.map +0 -1
  154. package/lib/plugins/media/media-wrapper.js.map +0 -1
  155. package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +0 -1
  156. package/lib/plugins/respArea/drag-in-the-blank/index.js.map +0 -1
  157. package/lib/plugins/respArea/explicit-constructed-response/index.js.map +0 -1
  158. package/lib/plugins/respArea/icons/index.js.map +0 -1
  159. package/lib/plugins/respArea/index.js.map +0 -1
  160. package/lib/plugins/respArea/inline-dropdown/index.js.map +0 -1
  161. package/lib/plugins/respArea/utils.js.map +0 -1
  162. package/lib/plugins/table/icons/index.js.map +0 -1
  163. package/lib/plugins/table/index.js.map +0 -1
  164. package/lib/plugins/table/table-toolbar.js.map +0 -1
  165. package/lib/plugins/toolbar/default-toolbar.js.map +0 -1
  166. package/lib/plugins/toolbar/done-button.js.map +0 -1
  167. package/lib/plugins/toolbar/editor-and-toolbar.js.map +0 -1
  168. package/lib/plugins/toolbar/index.js.map +0 -1
  169. package/lib/plugins/toolbar/toolbar-buttons.js.map +0 -1
  170. package/lib/plugins/toolbar/toolbar.js.map +0 -1
  171. package/lib/plugins/utils.js.map +0 -1
  172. package/lib/serialization.js.map +0 -1
  173. package/lib/theme.js.map +0 -1
  174. package/playground/image/data.js +0 -59
  175. package/playground/image/index.html +0 -22
  176. package/playground/image/index.jsx +0 -81
  177. package/playground/index.html +0 -25
  178. package/playground/mathquill/index.html +0 -22
  179. package/playground/mathquill/index.jsx +0 -155
  180. package/playground/package.json +0 -15
  181. package/playground/prod-test/index.html +0 -22
  182. package/playground/prod-test/index.jsx +0 -28
  183. package/playground/schema-override/data.js +0 -29
  184. package/playground/schema-override/image-plugin.jsx +0 -41
  185. package/playground/schema-override/index.html +0 -21
  186. package/playground/schema-override/index.jsx +0 -97
  187. package/playground/serialization/data.js +0 -29
  188. package/playground/serialization/image-plugin.jsx +0 -41
  189. package/playground/serialization/index.html +0 -22
  190. package/playground/serialization/index.jsx +0 -12
  191. package/playground/static.json +0 -3
  192. package/playground/table-examples.html +0 -70
  193. package/playground/webpack.config.js +0 -42
  194. package/static.json +0 -1
@@ -1,97 +0,0 @@
1
- import React from 'react';
2
- import ReactDOM from 'react-dom';
3
- import { Value, Schema } from 'slate';
4
- import data from './data';
5
- import { Editor } from 'slate-react';
6
- import ImgPlugin from './image-plugin';
7
-
8
- const schema = {
9
- document: {
10
- nodes: [
11
- {
12
- match: [{ type: 'paragraph' }, { type: 'image' }],
13
- },
14
- ],
15
- },
16
- blocks: {
17
- paragraph: {
18
- nodes: [
19
- {
20
- match: [{ type: 'image' }, { object: 'text' }],
21
- },
22
- ],
23
- },
24
- },
25
- inlines: {
26
- image: {
27
- isVoid: true,
28
- },
29
- },
30
- };
31
-
32
- // const raw = new Schema();
33
-
34
- // raw.rules.push({
35
- // match: {
36
- // object: 'block',
37
- // first: { object: 'block' }
38
- // },
39
- // nodes: [
40
- // {
41
- // match: { object: 'block' }
42
- // }
43
- // ],
44
- // normalize: error => {
45
- // console.log('override the defaults! where we force only blocks');
46
- // }
47
- // });
48
-
49
- // raw.rules.push({
50
- // match: {
51
- // object: 'block',
52
- // first: [{ object: 'inline' }, { object: 'text' }]
53
- // },
54
- // nodes: [
55
- // {
56
- // match: [{ object: 'inline' }, { object: 'text' }]
57
- // }
58
- // ],
59
- // normalize: error => {
60
- // console.log('override the defaults! where we force only inline/text');
61
- // }
62
- // });
63
-
64
- // const s = Schema.fromJSON(schema);
65
- // const v = Value.fromJSON(data, { normalize: false });
66
- // const error = s.validateNode(v.document.nodes.get(0));
67
- // const rawError = raw.validateNode(v.document.nodes.get(0));
68
- // console.log('error: ', error, 'rawError', rawError);
69
-
70
- class App extends React.Component {
71
- constructor(props) {
72
- super(props);
73
- this.state = {
74
- value: Value.fromJSON(data, { normalize: false }),
75
- };
76
-
77
- this.plugins = [ImgPlugin()];
78
- }
79
-
80
- render() {
81
- return (
82
- <Editor
83
- value={this.state.value}
84
- plugins={this.plugins}
85
- schema={schema}
86
- renderNode={this.renderNode}
87
- onChange={(change) => this.setState({ value: change.value })}
88
- />
89
- );
90
- }
91
- }
92
-
93
- document.addEventListener('DOMContentLoaded', () => {
94
- const el = React.createElement(App, {});
95
-
96
- ReactDOM.render(el, document.querySelector('#app'));
97
- });
@@ -1,29 +0,0 @@
1
- module.exports = {
2
- document: {
3
- nodes: [
4
- {
5
- object: 'block',
6
- type: 'paragraph',
7
- nodes: [
8
- {
9
- object: 'inline',
10
- type: 'image',
11
- isVoid: true,
12
- data: {
13
- src:
14
- 'https://img.washingtonpost.com/wp-apps/imrs.php?src=https://img.washingtonpost.com/news/speaking-of-science/wp-content/uploads/sites/36/2015/10/as12-49-7278-1024x1024.jpg&w=1484',
15
- },
16
- },
17
- {
18
- object: 'text',
19
- leaves: [
20
- {
21
- text: 'hi',
22
- },
23
- ],
24
- },
25
- ],
26
- },
27
- ],
28
- },
29
- };
@@ -1,41 +0,0 @@
1
- import React from 'react';
2
- import { Block, Range } from 'slate';
3
-
4
- class Img extends React.Component {
5
- render() {
6
- const { data } = this.props.node;
7
- const src = data.get('src');
8
-
9
- return <img src={src} width={100} />;
10
- }
11
- }
12
-
13
- const ImgPlugin = () => {
14
- return {
15
- renderNode: (props) => {
16
- if (props.node.type === 'image') {
17
- return <Img {...props} />;
18
- }
19
- },
20
- onKeyDown(event, change, editor) {
21
- const { startKey } = change.value.selection;
22
- const n = change.value.document.getDescendant(startKey);
23
- const p = change.value.document.getParent(n.key);
24
-
25
- if (p.type === 'image') {
26
- const block = Block.fromJSON({ type: 'div' });
27
- const range = Range.fromJSON({
28
- anchorKey: block.key,
29
- anchorOffset: 0,
30
- focusKey: block.key,
31
- focusOffset: 0,
32
- isFocused: true,
33
- isBackward: false,
34
- });
35
- change.insertBlockAtRange(change.value.selection, block).select(range);
36
- }
37
- },
38
- };
39
- };
40
-
41
- export default ImgPlugin;
@@ -1,22 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
5
- <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
6
- <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom-server.browser.production.min.js"></script>
7
- <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet" />
8
- <style>
9
- body,
10
- span,
11
- div,
12
- p {
13
- font-family: 'Roboto', sans-serif;
14
- }
15
- </style>
16
- <script src="bundle.js" type="text/javascript"></script>
17
- </head>
18
-
19
- <body>
20
- <div id="app"></div>
21
- </body>
22
- </html>
@@ -1,12 +0,0 @@
1
- import { htmlToValue } from '../../src/serialization';
2
-
3
- const html = `<div>
4
- <p>
5
- foo
6
- <img src="img.jpg"/>
7
- bar
8
- </p>
9
- </div>`;
10
- const v = htmlToValue(html);
11
-
12
- console.log('v: ', JSON.stringify(v.toJSON(), null, ' '));
@@ -1,3 +0,0 @@
1
- {
2
- "root": "."
3
- }
@@ -1,70 +0,0 @@
1
- <table class="tblmargin" border="2">
2
- <tbody>
3
- <tr>
4
- <th class="tabpadding" colspan="2">Selena's Input/Output Table</th>
5
- </tr>
6
- <tr>
7
- <th class="tabpadding">
8
- time in minutes since beginning of train ride ( <span class="mf-mc-pml-pie">$x$</span>)
9
- </th>
10
- <th class="tabpadding">
11
- distance in miles between Selena's and her grandmother's house ( <span class="mf-mc-pml-pie">$y$</span>)
12
- </th>
13
- </tr>
14
- <tr>
15
- <td class="numbersCenter">5</td>
16
- <td class="numbersCenter">24</td>
17
- </tr>
18
- <tr>
19
- <td class="numbersCenter">10</td>
20
- <td class="numbersCenter">21</td>
21
- </tr>
22
- <tr>
23
- <td class="numbersCenter">15</td>
24
- <td class="numbersCenter">18</td>
25
- </tr>
26
- <tr>
27
- <td class="numbersCenter">20</td>
28
- <td class="numbersCenter">15</td>
29
- </tr>
30
- </tbody>
31
- </table>
32
-
33
- <table class="tblmargin" border="2">
34
- <tr>
35
- <td class="numbersCenter">5</td>
36
- <td class="numbersCenter">24</td>
37
- </tr>
38
- <tr>
39
- <td class="numbersCenter">10</td>
40
- <td class="numbersCenter">21</td>
41
- </tr>
42
- <tr>
43
- <td class="numbersCenter">15</td>
44
- <td class="numbersCenter">18</td>
45
- </tr>
46
- <tr>
47
- <td class="numbersCenter">20</td>
48
- <td class="numbersCenter">15</td>
49
- </tr>
50
- </table>
51
-
52
- <table border="1">
53
- <tr>
54
- <td>hi</td>
55
- </tr>
56
- </table>
57
-
58
- <table>
59
- <tr>
60
- <td>foo</td>
61
- </tr>
62
- </table>
63
-
64
- <table>
65
- <tbody>
66
- <tr>
67
- <td>foo</td>
68
- </tr>
69
- </tbody>
70
- </table>
@@ -1,42 +0,0 @@
1
- // const DashboardPlugin = require('webpack-dashboard/plugin');
2
-
3
- module.exports = {
4
- mode: 'development',
5
- devtool: 'eval-source-map',
6
- context: __dirname,
7
- entry: {
8
- image: './image/index.jsx',
9
- 'schema-override': './schema-override/index.jsx',
10
- 'prod-test': './prod-test/index.jsx',
11
- mathquill: './mathquill/index.jsx',
12
- serialization: './serialization/index.jsx',
13
- },
14
- output: {
15
- filename: '[name]/bundle.js',
16
- path: __dirname,
17
- },
18
- module: {
19
- rules: [
20
- {
21
- test: /\.css$/,
22
- loader: 'url-loader',
23
- },
24
- {
25
- test: /\.jsx$/,
26
- loader: 'babel-loader',
27
- options: {
28
- babelrc: false,
29
- presets: ['react', 'env', 'stage-0'],
30
- },
31
- },
32
- ],
33
- },
34
- resolve: {
35
- extensions: ['.js', '.jsx'],
36
- },
37
- externals: {
38
- react: 'React',
39
- 'react-dom': 'ReactDOM',
40
- 'react-dom/server': 'ReactDOMServer',
41
- },
42
- };
package/static.json DELETED
@@ -1 +0,0 @@
1
-