@pie-lib/editable-html 11.24.0-mui-update.0 → 11.26.0-mui-update.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.
- package/CHANGELOG.md +23 -0
- package/lib/editor.js +5 -3
- package/lib/editor.js.map +1 -1
- package/lib/plugins/characters/index.js +16 -5
- package/lib/plugins/characters/index.js.map +1 -1
- package/lib/plugins/css/index.js +7 -3
- package/lib/plugins/css/index.js.map +1 -1
- package/lib/plugins/image/image-toolbar.js +4 -2
- package/lib/plugins/image/image-toolbar.js.map +1 -1
- package/lib/plugins/media/index.js +3 -2
- package/lib/plugins/media/index.js.map +1 -1
- package/lib/plugins/respArea/utils.js +4 -2
- package/lib/plugins/respArea/utils.js.map +1 -1
- package/package.json +7 -7
- package/src/editor.jsx +13 -10
- package/src/plugins/characters/index.jsx +15 -5
- package/src/plugins/css/index.jsx +7 -3
- package/src/plugins/image/image-toolbar.jsx +5 -2
- package/src/plugins/media/index.jsx +3 -2
- package/src/plugins/respArea/utils.jsx +4 -2
package/src/editor.jsx
CHANGED
|
@@ -33,8 +33,8 @@ const defaultToolbarOpts = {
|
|
|
33
33
|
|
|
34
34
|
const defaultResponseAreaProps = {
|
|
35
35
|
options: {},
|
|
36
|
-
respAreaToolbar: () => {},
|
|
37
|
-
onHandleAreaChange: () => {},
|
|
36
|
+
respAreaToolbar: () => { },
|
|
37
|
+
onHandleAreaChange: () => { },
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
const defaultLanguageCharactersProps = [];
|
|
@@ -83,6 +83,7 @@ export class Editor extends React.Component {
|
|
|
83
83
|
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
84
84
|
minHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
85
85
|
maxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
86
|
+
slateEditorExtraStyles: PropTypes.object,
|
|
86
87
|
highlightShape: PropTypes.bool,
|
|
87
88
|
disabled: PropTypes.bool,
|
|
88
89
|
spellCheck: PropTypes.bool,
|
|
@@ -147,10 +148,10 @@ export class Editor extends React.Component {
|
|
|
147
148
|
|
|
148
149
|
static defaultProps = {
|
|
149
150
|
disableUnderline: true,
|
|
150
|
-
onFocus: () => {},
|
|
151
|
-
onBlur: () => {},
|
|
152
|
-
onKeyDown: () => {},
|
|
153
|
-
runSerializationOnMarkup: () => {},
|
|
151
|
+
onFocus: () => { },
|
|
152
|
+
onBlur: () => { },
|
|
153
|
+
onKeyDown: () => { },
|
|
154
|
+
runSerializationOnMarkup: () => { },
|
|
154
155
|
mathMlOptions: {
|
|
155
156
|
mmlOutput: false,
|
|
156
157
|
mmlEditing: false,
|
|
@@ -557,7 +558,7 @@ export class Editor extends React.Component {
|
|
|
557
558
|
<div ref={(ref) => (this.elementRef = ref)}>
|
|
558
559
|
<div>Preview of Edited Html:</div>
|
|
559
560
|
{/* TODO: check if this works and we don't need to send style over to preview prompt */}
|
|
560
|
-
<StyledPreviewText>
|
|
561
|
+
<StyledPreviewText>
|
|
561
562
|
<PreviewPrompt prompt={this.state.value.document.text} />
|
|
562
563
|
</StyledPreviewText>
|
|
563
564
|
<div>Would you like to save these changes ?</div>
|
|
@@ -816,8 +817,8 @@ export class Editor extends React.Component {
|
|
|
816
817
|
const isEditedInHtmlMode = !this.state.isHtmlMode
|
|
817
818
|
? false
|
|
818
819
|
: this.state.value.document.text !== value.document.text
|
|
819
|
-
|
|
820
|
-
|
|
820
|
+
? true
|
|
821
|
+
: this.state.isEditedInHtmlMode;
|
|
821
822
|
|
|
822
823
|
if (isEditedInHtmlMode != this.state.isEditedInHtmlMode) {
|
|
823
824
|
this.handlePlugins(this.props);
|
|
@@ -961,7 +962,7 @@ export class Editor extends React.Component {
|
|
|
961
962
|
this.onChange(ch);
|
|
962
963
|
const handler = new InsertImageHandler(
|
|
963
964
|
inline,
|
|
964
|
-
() => {},
|
|
965
|
+
() => { },
|
|
965
966
|
() => this.state.value,
|
|
966
967
|
this.onChange,
|
|
967
968
|
true,
|
|
@@ -1030,6 +1031,7 @@ export class Editor extends React.Component {
|
|
|
1030
1031
|
placeholder,
|
|
1031
1032
|
pluginProps,
|
|
1032
1033
|
onKeyDown,
|
|
1034
|
+
slateEditorExtraStyles,
|
|
1033
1035
|
} = this.props;
|
|
1034
1036
|
// We don't want to send customPlugins to slate.
|
|
1035
1037
|
// Not sure if they would do any harm, but I think it's better to not send them.
|
|
@@ -1103,6 +1105,7 @@ export class Editor extends React.Component {
|
|
|
1103
1105
|
minHeight: sizeStyle.minHeight,
|
|
1104
1106
|
height: sizeStyle.height,
|
|
1105
1107
|
maxHeight: sizeStyle.maxHeight,
|
|
1108
|
+
...slateEditorExtraStyles
|
|
1106
1109
|
}}
|
|
1107
1110
|
pluginProps={otherPluginProps}
|
|
1108
1111
|
toolbarOpts={toolbarOpts}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
3
|
import debug from 'debug';
|
|
4
4
|
import get from 'lodash/get';
|
|
5
5
|
|
|
@@ -66,10 +66,16 @@ const insertDialog = ({ editorDOM, value, callback, opts }) => {
|
|
|
66
66
|
);
|
|
67
67
|
|
|
68
68
|
let popoverEl;
|
|
69
|
+
let popoverRoot;
|
|
69
70
|
|
|
70
71
|
const closePopOver = () => {
|
|
72
|
+
if (popoverRoot) {
|
|
73
|
+
popoverRoot.unmount();
|
|
74
|
+
popoverRoot = null;
|
|
75
|
+
}
|
|
71
76
|
if (popoverEl) {
|
|
72
77
|
popoverEl.remove();
|
|
78
|
+
popoverEl = null;
|
|
73
79
|
}
|
|
74
80
|
|
|
75
81
|
removePopOvers();
|
|
@@ -85,7 +91,8 @@ const insertDialog = ({ editorDOM, value, callback, opts }) => {
|
|
|
85
91
|
closePopOver();
|
|
86
92
|
|
|
87
93
|
popoverEl = document.createElement('div');
|
|
88
|
-
|
|
94
|
+
popoverRoot = createRoot(popoverEl);
|
|
95
|
+
popoverRoot.render(
|
|
89
96
|
<CustomPopper onClose={closePopOver} anchorEl={event.currentTarget}>
|
|
90
97
|
<div>{el.label}</div>
|
|
91
98
|
|
|
@@ -93,7 +100,6 @@ const insertDialog = ({ editorDOM, value, callback, opts }) => {
|
|
|
93
100
|
|
|
94
101
|
<div style={infoStyle}>{el.unicode}</div>
|
|
95
102
|
</CustomPopper>,
|
|
96
|
-
popoverEl,
|
|
97
103
|
);
|
|
98
104
|
|
|
99
105
|
document.body.appendChild(newEl);
|
|
@@ -172,7 +178,11 @@ const insertDialog = ({ editorDOM, value, callback, opts }) => {
|
|
|
172
178
|
/>
|
|
173
179
|
);
|
|
174
180
|
|
|
175
|
-
|
|
181
|
+
const dialogRoot = createRoot(newEl);
|
|
182
|
+
dialogRoot.render(el);
|
|
183
|
+
|
|
184
|
+
// Use setTimeout to ensure the element is rendered before positioning
|
|
185
|
+
setTimeout(() => {
|
|
176
186
|
const cursorItem = document.querySelector(`[data-key="${value.anchorKey}"]`);
|
|
177
187
|
|
|
178
188
|
if (cursorItem) {
|
|
@@ -216,7 +226,7 @@ const insertDialog = ({ editorDOM, value, callback, opts }) => {
|
|
|
216
226
|
|
|
217
227
|
document.body.addEventListener('click', listener);
|
|
218
228
|
}
|
|
219
|
-
});
|
|
229
|
+
}, 0);
|
|
220
230
|
};
|
|
221
231
|
|
|
222
232
|
const CharacterIcon = ({ letter }) => (
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
3
|
import List from '@mui/material/List';
|
|
4
4
|
import { Mark } from 'slate';
|
|
5
5
|
import ListItem from '@mui/material/ListItem';
|
|
@@ -110,7 +110,11 @@ const insertDialog = ({ editorDOM, value, callback, opts, textNode, parentNode }
|
|
|
110
110
|
</div>
|
|
111
111
|
);
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
const dialogRoot = createRoot(newEl);
|
|
114
|
+
dialogRoot.render(el);
|
|
115
|
+
|
|
116
|
+
// Use setTimeout to ensure the element is rendered before positioning
|
|
117
|
+
setTimeout(() => {
|
|
114
118
|
const cursorItem = document.querySelector(`[data-key="${value.anchorKey}"]`);
|
|
115
119
|
|
|
116
120
|
if (cursorItem) {
|
|
@@ -154,7 +158,7 @@ const insertDialog = ({ editorDOM, value, callback, opts, textNode, parentNode }
|
|
|
154
158
|
|
|
155
159
|
document.body.addEventListener('click', listener);
|
|
156
160
|
}
|
|
157
|
-
});
|
|
161
|
+
}, 0);
|
|
158
162
|
};
|
|
159
163
|
|
|
160
164
|
const findParentNodeInfo = (value, textNode) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import debug from 'debug';
|
|
4
|
-
import
|
|
4
|
+
import { createRoot } from 'react-dom/client';
|
|
5
5
|
import { styled } from '@mui/material/styles';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
|
|
@@ -50,6 +50,8 @@ export class ImageToolbar extends React.Component {
|
|
|
50
50
|
disableImageAlignmentButtons: PropTypes.bool,
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
+
dialogRoot = null;
|
|
54
|
+
|
|
53
55
|
onAltTextDone = (newAlt) => {
|
|
54
56
|
log('[onAltTextDone]: alt:', newAlt);
|
|
55
57
|
|
|
@@ -67,7 +69,8 @@ export class ImageToolbar extends React.Component {
|
|
|
67
69
|
|
|
68
70
|
const el = <AltDialog alt={alt} onDone={this.onAltTextDone} />;
|
|
69
71
|
|
|
70
|
-
|
|
72
|
+
this.dialogRoot = createRoot(popoverEl);
|
|
73
|
+
this.dialogRoot.render(el);
|
|
71
74
|
|
|
72
75
|
document.body.appendChild(popoverEl);
|
|
73
76
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
3
|
import { Inline } from 'slate';
|
|
4
4
|
import TheatersIcon from '@mui/icons-material/Theaters';
|
|
5
5
|
import VolumeUpIcon from '@mui/icons-material/VolumeUp';
|
|
@@ -44,7 +44,8 @@ export const insertDialog = (props) => {
|
|
|
44
44
|
/>
|
|
45
45
|
);
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
const dialogRoot = createRoot(newEl);
|
|
48
|
+
dialogRoot.render(el);
|
|
48
49
|
|
|
49
50
|
document.body.appendChild(newEl);
|
|
50
51
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
3
|
import { Inline } from 'slate';
|
|
4
4
|
import Snackbar from '@mui/material/Snackbar';
|
|
5
5
|
|
|
@@ -25,11 +25,13 @@ export const insertSnackBar = (message) => {
|
|
|
25
25
|
/>
|
|
26
26
|
);
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
const snackbarRoot = createRoot(newEl);
|
|
29
|
+
snackbarRoot.render(el);
|
|
29
30
|
|
|
30
31
|
document.body.appendChild(newEl);
|
|
31
32
|
|
|
32
33
|
setTimeout(() => {
|
|
34
|
+
snackbarRoot.unmount();
|
|
33
35
|
newEl.remove();
|
|
34
36
|
}, 2000);
|
|
35
37
|
};
|