@pie-lib/editable-html 9.5.13 → 10.0.0-beta.1

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 (144) hide show
  1. package/CHANGELOG.md +0 -302
  2. package/lib/components.js +116 -0
  3. package/lib/components.js.map +1 -0
  4. package/lib/editor.js +418 -103
  5. package/lib/editor.js.map +1 -1
  6. package/lib/index.js +101 -155
  7. package/lib/index.js.map +1 -1
  8. package/lib/new-serialization.js +320 -0
  9. package/lib/new-serialization.js.map +1 -0
  10. package/lib/old-serialization.js +330 -0
  11. package/lib/parse-html.js +1 -1
  12. package/lib/parse-html.js.map +1 -1
  13. package/lib/plugins/characters/custom-popper.js +1 -1
  14. package/lib/plugins/characters/custom-popper.js.map +1 -1
  15. package/lib/plugins/characters/index.js +21 -19
  16. package/lib/plugins/characters/index.js.map +1 -1
  17. package/lib/plugins/characters/utils.js +1 -1
  18. package/lib/plugins/characters/utils.js.map +1 -1
  19. package/lib/plugins/hotKeys/index.js +67 -0
  20. package/lib/plugins/hotKeys/index.js.map +1 -0
  21. package/lib/plugins/image/alt-dialog.js +1 -6
  22. package/lib/plugins/image/alt-dialog.js.map +1 -1
  23. package/lib/plugins/image/component.js +70 -53
  24. package/lib/plugins/image/component.js.map +1 -1
  25. package/lib/plugins/image/image-toolbar.js +7 -9
  26. package/lib/plugins/image/image-toolbar.js.map +1 -1
  27. package/lib/plugins/image/index.js +83 -27
  28. package/lib/plugins/image/index.js.map +1 -1
  29. package/lib/plugins/image/insert-image-handler.js +72 -33
  30. package/lib/plugins/image/insert-image-handler.js.map +1 -1
  31. package/lib/plugins/index.js +23 -41
  32. package/lib/plugins/index.js.map +1 -1
  33. package/lib/plugins/list/index.js +64 -100
  34. package/lib/plugins/list/index.js.map +1 -1
  35. package/lib/plugins/math/index.js +86 -60
  36. package/lib/plugins/math/index.js.map +1 -1
  37. package/lib/plugins/media/index.js +202 -132
  38. package/lib/plugins/media/index.js.map +1 -1
  39. package/lib/plugins/media/media-dialog.js +17 -16
  40. package/lib/plugins/media/media-dialog.js.map +1 -1
  41. package/lib/plugins/media/media-toolbar.js +3 -3
  42. package/lib/plugins/media/media-toolbar.js.map +1 -1
  43. package/lib/plugins/media/media-wrapper.js +21 -58
  44. package/lib/plugins/media/media-wrapper.js.map +1 -1
  45. package/lib/plugins/respArea/drag-in-the-blank/choice.js +3 -3
  46. package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
  47. package/lib/plugins/respArea/drag-in-the-blank/index.js +3 -2
  48. package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
  49. package/lib/plugins/respArea/explicit-constructed-response/index.js +3 -2
  50. package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
  51. package/lib/plugins/respArea/icons/index.js +13 -15
  52. package/lib/plugins/respArea/icons/index.js.map +1 -1
  53. package/lib/plugins/respArea/index.js +87 -53
  54. package/lib/plugins/respArea/index.js.map +1 -1
  55. package/lib/plugins/respArea/inline-dropdown/index.js +4 -3
  56. package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
  57. package/lib/plugins/respArea/utils.js +17 -20
  58. package/lib/plugins/respArea/utils.js.map +1 -1
  59. package/lib/plugins/table/icons/index.js +1 -1
  60. package/lib/plugins/table/icons/index.js.map +1 -1
  61. package/lib/plugins/table/index.js +381 -212
  62. package/lib/plugins/table/index.js.map +1 -1
  63. package/lib/plugins/table/table-toolbar.js +5 -6
  64. package/lib/plugins/table/table-toolbar.js.map +1 -1
  65. package/lib/plugins/toolbar/default-toolbar.js +55 -11
  66. package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
  67. package/lib/plugins/toolbar/done-button.js +1 -1
  68. package/lib/plugins/toolbar/done-button.js.map +1 -1
  69. package/lib/plugins/toolbar/editor-and-toolbar.js +186 -232
  70. package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
  71. package/lib/plugins/toolbar/index.js +1 -2
  72. package/lib/plugins/toolbar/index.js.map +1 -1
  73. package/lib/plugins/toolbar/toolbar-buttons.js +1 -1
  74. package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
  75. package/lib/plugins/toolbar/toolbar.js +253 -239
  76. package/lib/plugins/toolbar/toolbar.js.map +1 -1
  77. package/lib/plugins/utils.js +27 -2
  78. package/lib/plugins/utils.js.map +1 -1
  79. package/lib/serialization.js +1 -1
  80. package/lib/serialization.js.map +1 -1
  81. package/lib/slate-editor.js +302 -0
  82. package/lib/test-serializer.js +189 -0
  83. package/lib/test-serializer.js.map +1 -0
  84. package/lib/theme.js +1 -1
  85. package/lib/theme.js.map +1 -1
  86. package/package.json +18 -14
  87. package/playground/image/data.js +20 -20
  88. package/playground/image/index.html +22 -20
  89. package/playground/image/index.jsx +12 -10
  90. package/playground/index.html +25 -23
  91. package/playground/mathquill/index.html +23 -20
  92. package/playground/mathquill/index.jsx +18 -22
  93. package/playground/prod-test/index.html +24 -20
  94. package/playground/prod-test/index.jsx +5 -3
  95. package/playground/schema-override/data.js +10 -10
  96. package/playground/schema-override/image-plugin.jsx +3 -4
  97. package/playground/schema-override/index.html +21 -19
  98. package/playground/schema-override/index.jsx +13 -14
  99. package/playground/serialization/data.js +10 -10
  100. package/playground/serialization/image-plugin.jsx +3 -4
  101. package/playground/serialization/index.html +22 -20
  102. package/playground/table-examples.html +5 -8
  103. package/playground/webpack.config.js +10 -10
  104. package/src/components.js +135 -0
  105. package/src/editor.jsx +478 -141
  106. package/src/index.jsx +71 -95
  107. package/src/new-serialization.jsx +291 -0
  108. package/src/parse-html.js +1 -1
  109. package/src/plugins/characters/custom-popper.js +7 -7
  110. package/src/plugins/characters/index.jsx +33 -34
  111. package/src/plugins/characters/utils.js +81 -81
  112. package/src/plugins/hotKeys/index.js +54 -0
  113. package/src/plugins/image/alt-dialog.jsx +4 -5
  114. package/src/plugins/image/component.jsx +106 -89
  115. package/src/plugins/image/image-toolbar.jsx +27 -19
  116. package/src/plugins/image/index.jsx +75 -43
  117. package/src/plugins/image/insert-image-handler.js +62 -27
  118. package/src/plugins/index.jsx +23 -41
  119. package/src/plugins/list/index.jsx +70 -95
  120. package/src/plugins/math/index.jsx +102 -82
  121. package/src/plugins/media/index.jsx +159 -124
  122. package/src/plugins/media/media-dialog.js +98 -71
  123. package/src/plugins/media/media-toolbar.jsx +8 -8
  124. package/src/plugins/media/media-wrapper.jsx +29 -30
  125. package/src/plugins/respArea/drag-in-the-blank/choice.jsx +21 -19
  126. package/src/plugins/respArea/drag-in-the-blank/index.jsx +14 -11
  127. package/src/plugins/respArea/explicit-constructed-response/index.jsx +7 -6
  128. package/src/plugins/respArea/icons/index.jsx +11 -14
  129. package/src/plugins/respArea/index.jsx +92 -52
  130. package/src/plugins/respArea/inline-dropdown/index.jsx +9 -8
  131. package/src/plugins/respArea/utils.jsx +26 -35
  132. package/src/plugins/table/icons/index.jsx +17 -11
  133. package/src/plugins/table/index.jsx +288 -231
  134. package/src/plugins/table/table-toolbar.jsx +15 -11
  135. package/src/plugins/toolbar/default-toolbar.jsx +65 -19
  136. package/src/plugins/toolbar/done-button.jsx +4 -4
  137. package/src/plugins/toolbar/editor-and-toolbar.jsx +150 -145
  138. package/src/plugins/toolbar/index.jsx +2 -3
  139. package/src/plugins/toolbar/toolbar-buttons.jsx +11 -11
  140. package/src/plugins/toolbar/toolbar.jsx +244 -221
  141. package/src/plugins/utils.js +21 -4
  142. package/src/serialization.jsx +32 -32
  143. package/src/test-serializer.js +139 -0
  144. package/src/test-serializer.js.rej +20 -0
@@ -11,19 +11,19 @@ module.exports = {
11
11
  isVoid: true,
12
12
  data: {
13
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
- },
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
16
  },
17
17
  {
18
18
  object: 'text',
19
19
  leaves: [
20
20
  {
21
- text: 'hi',
22
- },
23
- ],
24
- },
25
- ],
26
- },
27
- ],
28
- },
21
+ text: 'hi'
22
+ }
23
+ ]
24
+ }
25
+ ]
26
+ }
27
+ ]
28
+ }
29
29
  };
@@ -5,14 +5,13 @@ class Img extends React.Component {
5
5
  render() {
6
6
  const { data } = this.props.node;
7
7
  const src = data.get('src');
8
-
9
8
  return <img src={src} width={100} />;
10
9
  }
11
10
  }
12
11
 
13
12
  const ImgPlugin = () => {
14
13
  return {
15
- renderNode: (props) => {
14
+ renderNode: props => {
16
15
  if (props.node.type === 'image') {
17
16
  return <Img {...props} />;
18
17
  }
@@ -30,11 +29,11 @@ const ImgPlugin = () => {
30
29
  focusKey: block.key,
31
30
  focusOffset: 0,
32
31
  isFocused: true,
33
- isBackward: false,
32
+ isBackward: false
34
33
  });
35
34
  change.insertBlockAtRange(change.value.selection, block).select(range);
36
35
  }
37
- },
36
+ }
38
37
  };
39
38
  };
40
39
 
@@ -1,22 +1,24 @@
1
- <!DOCTYPE html>
1
+ <!doctype html>
2
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
3
 
19
- <body>
20
- <div id="app"></div>
21
- </body>
22
- </html>
4
+ <head>
5
+ <script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
6
+ <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
7
+ <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom-server.browser.production.min.js"></script>
8
+ <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
9
+ <style>
10
+ body,
11
+ span,
12
+ div,
13
+ p {
14
+ font-family: 'Roboto', sans-serif;
15
+ }
16
+ </style>
17
+ <script src="bundle.js" type="text/javascript"></script>
18
+ </head>
19
+
20
+ <body>
21
+ <div id="app"></div>
22
+ </body>
23
+
24
+ </html>
@@ -4,12 +4,10 @@
4
4
  <th class="tabpadding" colspan="2">Selena's Input/Output Table</th>
5
5
  </tr>
6
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>
7
+ <th class="tabpadding">time in minutes since beginning of train ride (
8
+ <span class="mf-mc-pml-pie">$x$</span>)</th>
9
+ <th class="tabpadding">distance in miles between Selena's and her grandmother's house (
10
+ <span class="mf-mc-pml-pie">$y$</span>)</th>
13
11
  </tr>
14
12
  <tr>
15
13
  <td class="numbersCenter">5</td>
@@ -60,11 +58,10 @@
60
58
  <td>foo</td>
61
59
  </tr>
62
60
  </table>
63
-
64
61
  <table>
65
62
  <tbody>
66
63
  <tr>
67
64
  <td>foo</td>
68
65
  </tr>
69
66
  </tbody>
70
- </table>
67
+ </table>
@@ -9,34 +9,34 @@ module.exports = {
9
9
  'schema-override': './schema-override/index.jsx',
10
10
  'prod-test': './prod-test/index.jsx',
11
11
  mathquill: './mathquill/index.jsx',
12
- serialization: './serialization/index.jsx',
12
+ serialization: './serialization/index.jsx'
13
13
  },
14
14
  output: {
15
15
  filename: '[name]/bundle.js',
16
- path: __dirname,
16
+ path: __dirname
17
17
  },
18
18
  module: {
19
19
  rules: [
20
20
  {
21
21
  test: /\.css$/,
22
- loader: 'url-loader',
22
+ loader: 'url-loader'
23
23
  },
24
24
  {
25
25
  test: /\.jsx$/,
26
26
  loader: 'babel-loader',
27
27
  options: {
28
28
  babelrc: false,
29
- presets: ['react', 'env', 'stage-0'],
30
- },
31
- },
32
- ],
29
+ presets: ['react', 'env', 'stage-0']
30
+ }
31
+ }
32
+ ]
33
33
  },
34
34
  resolve: {
35
- extensions: ['.js', '.jsx'],
35
+ extensions: ['.js', '.jsx']
36
36
  },
37
37
  externals: {
38
38
  react: 'React',
39
39
  'react-dom': 'ReactDOM',
40
- 'react-dom/server': 'ReactDOMServer',
41
- },
40
+ 'react-dom/server': 'ReactDOMServer'
41
+ }
42
42
  };
@@ -0,0 +1,135 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom';
3
+ import { cx, css } from '@emotion/css';
4
+
5
+ export const Button = React.forwardRef(({ className, active, reversed, ...props }, ref) => (
6
+ <span
7
+ {...props}
8
+ ref={ref}
9
+ className={cx(
10
+ className,
11
+ css`
12
+ cursor: pointer;
13
+
14
+ color: ${reversed ? (active ? 'white' : '#aaa') : active ? 'black' : '#ccc'};
15
+ `
16
+ )}
17
+ />
18
+ ));
19
+
20
+ export const EditorValue = React.forwardRef(({ className, value, ...props }, ref) => {
21
+ const textLines = value.document.nodes
22
+ .map(node => node.text)
23
+ .toArray()
24
+ .join('\n');
25
+ return (
26
+ <div
27
+ ref={ref}
28
+ {...props}
29
+ className={cx(
30
+ className,
31
+ css`
32
+ margin: 30px -20px 0;
33
+ `
34
+ )}
35
+ >
36
+ <div
37
+ className={css`
38
+ font-size: 14px;
39
+ padding: 5px 20px;
40
+ color: #404040;
41
+ border-top: 2px solid #eeeeee;
42
+ background: #f8f8f8;
43
+ `}
44
+ >
45
+ Slates value as text
46
+ </div>
47
+ <div
48
+ className={css`
49
+ color: #404040;
50
+ font: 12px monospace;
51
+ white-space: pre-wrap;
52
+ padding: 10px 20px;
53
+
54
+ div {
55
+ margin: 0 0 0.5em;
56
+ }
57
+ `}
58
+ >
59
+ {textLines}
60
+ </div>
61
+ </div>
62
+ );
63
+ });
64
+
65
+ export const Icon = React.forwardRef(({ className, ...props }, ref) => (
66
+ <span
67
+ {...props}
68
+ ref={ref}
69
+ className={cx(
70
+ 'material-icons',
71
+ className,
72
+ css`
73
+ font-size: 18px;
74
+ vertical-align: text-bottom;
75
+ `
76
+ )}
77
+ />
78
+ ));
79
+
80
+ export const Instruction = React.forwardRef(({ className, ...props }, ref) => (
81
+ <div
82
+ {...props}
83
+ ref={ref}
84
+ className={cx(
85
+ className,
86
+ css`
87
+ white-space: pre-wrap;
88
+ margin: 0 -20px 10px;
89
+ padding: 10px 20px;
90
+ font-size: 14px;
91
+ background: #f8f8e8;
92
+ `
93
+ )}
94
+ />
95
+ ));
96
+
97
+ export const Menu = React.forwardRef(({ className, ...props }, ref) => (
98
+ <div
99
+ {...props}
100
+ ref={ref}
101
+ className={cx(
102
+ className,
103
+ css`
104
+ & > * {
105
+ display: inline-block;
106
+ }
107
+
108
+ & > * + * {
109
+ margin-left: 15px;
110
+ }
111
+ `
112
+ )}
113
+ />
114
+ ));
115
+
116
+ export const Portal = ({ children }) => {
117
+ return typeof document === 'object' ? ReactDOM.createPortal(children, document.body) : null;
118
+ };
119
+
120
+ export const Toolbar = React.forwardRef(({ className, ...props }, ref) => (
121
+ <Menu
122
+ {...props}
123
+ ref={ref}
124
+ className={cx(
125
+ className,
126
+ css`
127
+ position: relative;
128
+ padding: 1px 18px 17px;
129
+ margin: 0 -20px;
130
+ border-bottom: 2px solid #eee;
131
+ margin-bottom: 20px;
132
+ `
133
+ )}
134
+ />
135
+ ));