@pie-lib/editable-html 11.18.6-esmbeta.0 → 11.19.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 +37 -0
- package/lib/block-tags.js +2 -3
- package/lib/block-tags.js.map +1 -1
- package/lib/constants.js +3 -6
- package/lib/constants.js.map +1 -1
- package/lib/editor.js +302 -450
- package/lib/editor.js.map +1 -1
- package/lib/index.js +19 -77
- package/lib/index.js.map +1 -1
- package/lib/parse-html.js +7 -7
- package/lib/parse-html.js.map +1 -1
- package/lib/plugins/characters/custom-popper.js +24 -44
- package/lib/plugins/characters/custom-popper.js.map +1 -1
- package/lib/plugins/characters/index.js +9 -60
- package/lib/plugins/characters/index.js.map +1 -1
- package/lib/plugins/characters/utils.js +3 -6
- package/lib/plugins/characters/utils.js.map +1 -1
- package/lib/plugins/css/icons/index.js +13 -25
- package/lib/plugins/css/icons/index.js.map +1 -1
- package/lib/plugins/css/index.js +22 -88
- package/lib/plugins/css/index.js.map +1 -1
- package/lib/plugins/customPlugin/index.js +10 -26
- package/lib/plugins/customPlugin/index.js.map +1 -1
- package/lib/plugins/html/icons/index.js +14 -26
- package/lib/plugins/html/icons/index.js.map +1 -1
- package/lib/plugins/html/index.js +4 -13
- package/lib/plugins/html/index.js.map +1 -1
- package/lib/plugins/image/alt-dialog.js +20 -49
- package/lib/plugins/image/alt-dialog.js.map +1 -1
- package/lib/plugins/image/component.js +119 -190
- package/lib/plugins/image/component.js.map +1 -1
- package/lib/plugins/image/image-toolbar.js +44 -86
- package/lib/plugins/image/image-toolbar.js.map +1 -1
- package/lib/plugins/image/index.js +6 -46
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/plugins/image/insert-image-handler.js +10 -31
- package/lib/plugins/image/insert-image-handler.js.map +1 -1
- package/lib/plugins/index.js +44 -106
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/list/index.js +27 -73
- package/lib/plugins/list/index.js.map +1 -1
- package/lib/plugins/math/index.js +64 -116
- package/lib/plugins/math/index.js.map +1 -1
- package/lib/plugins/media/index.js +23 -81
- package/lib/plugins/media/index.js.map +1 -1
- package/lib/plugins/media/media-dialog.js +192 -307
- package/lib/plugins/media/media-dialog.js.map +1 -1
- package/lib/plugins/media/media-toolbar.js +40 -65
- package/lib/plugins/media/media-toolbar.js.map +1 -1
- package/lib/plugins/media/media-wrapper.js +20 -49
- package/lib/plugins/media/media-wrapper.js.map +1 -1
- package/lib/plugins/rendering/index.js +5 -15
- package/lib/plugins/rendering/index.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/choice.js +175 -249
- package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/index.js +39 -29
- package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
- package/lib/plugins/respArea/explicit-constructed-response/index.js +3 -10
- package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
- package/lib/plugins/respArea/icons/index.js +22 -45
- package/lib/plugins/respArea/icons/index.js.map +1 -1
- package/lib/plugins/respArea/index.js +5 -59
- package/lib/plugins/respArea/index.js.map +1 -1
- package/lib/plugins/respArea/inline-dropdown/index.js +2 -10
- package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
- package/lib/plugins/respArea/math-templated/index.js +92 -109
- package/lib/plugins/respArea/math-templated/index.js.map +1 -1
- package/lib/plugins/respArea/utils.js +8 -40
- package/lib/plugins/respArea/utils.js.map +1 -1
- package/lib/plugins/table/CustomTablePlugin.js +24 -41
- package/lib/plugins/table/CustomTablePlugin.js.map +1 -1
- package/lib/plugins/table/icons/index.js +19 -35
- package/lib/plugins/table/icons/index.js.map +1 -1
- package/lib/plugins/table/index.js +41 -118
- package/lib/plugins/table/index.js.map +1 -1
- package/lib/plugins/table/table-toolbar.js +37 -87
- package/lib/plugins/table/table-toolbar.js.map +1 -1
- package/lib/plugins/textAlign/icons/index.js +18 -64
- package/lib/plugins/textAlign/icons/index.js.map +1 -1
- package/lib/plugins/textAlign/index.js +1 -6
- package/lib/plugins/textAlign/index.js.map +1 -1
- package/lib/plugins/toolbar/default-toolbar.js +30 -79
- package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/done-button.js +16 -34
- package/lib/plugins/toolbar/done-button.js.map +1 -1
- package/lib/plugins/toolbar/editor-and-toolbar.js +174 -201
- package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/index.js +0 -5
- package/lib/plugins/toolbar/index.js.map +1 -1
- package/lib/plugins/toolbar/toolbar-buttons.js +57 -107
- package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
- package/lib/plugins/toolbar/toolbar.js +95 -161
- package/lib/plugins/toolbar/toolbar.js.map +1 -1
- package/lib/plugins/utils.js +5 -25
- package/lib/plugins/utils.js.map +1 -1
- package/lib/serialization.js +44 -150
- package/lib/serialization.js.map +1 -1
- package/lib/shared/alert-dialog.js +23 -42
- package/lib/theme.js +1 -2
- package/lib/theme.js.map +1 -1
- package/package.json +15 -21
- package/src/__tests__/utils.js +1 -1
- package/src/editor.jsx +110 -108
- package/src/plugins/characters/custom-popper.js +20 -25
- package/src/plugins/css/icons/index.jsx +11 -13
- package/src/plugins/css/index.jsx +3 -5
- package/src/plugins/html/icons/index.jsx +12 -14
- package/src/plugins/image/alt-dialog.jsx +9 -8
- package/src/plugins/image/component.jsx +67 -87
- package/src/plugins/image/image-toolbar.jsx +26 -26
- package/src/plugins/image/index.jsx +1 -1
- package/src/plugins/index.jsx +10 -10
- package/src/plugins/math/index.jsx +1 -1
- package/src/plugins/media/index.jsx +2 -2
- package/src/plugins/media/media-dialog.js +65 -76
- package/src/plugins/media/media-toolbar.jsx +32 -33
- package/src/plugins/media/media-wrapper.jsx +10 -13
- package/src/plugins/respArea/drag-in-the-blank/choice.jsx +193 -180
- package/src/plugins/respArea/drag-in-the-blank/index.jsx +58 -22
- package/src/plugins/respArea/icons/index.jsx +16 -16
- package/src/plugins/respArea/math-templated/index.jsx +88 -89
- package/src/plugins/respArea/utils.jsx +1 -1
- package/src/plugins/table/icons/index.jsx +14 -16
- package/src/plugins/table/index.jsx +27 -19
- package/src/plugins/table/table-toolbar.jsx +17 -19
- package/src/plugins/textAlign/icons/index.jsx +3 -3
- package/src/plugins/toolbar/__tests__/default-toolbar.test.jsx +1 -1
- package/src/plugins/toolbar/__tests__/toolbar.test.jsx +1 -1
- package/src/plugins/toolbar/default-toolbar.jsx +18 -21
- package/src/plugins/toolbar/done-button.jsx +16 -22
- package/src/plugins/toolbar/editor-and-toolbar.jsx +134 -157
- package/src/plugins/toolbar/toolbar-buttons.jsx +29 -46
- package/src/plugins/toolbar/toolbar.jsx +60 -78
- package/esm/index.js +0 -111560
- package/esm/index.js.map +0 -1
- package/esm/package.json +0 -1
package/lib/plugins/css/index.js
CHANGED
|
@@ -1,66 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = CSSPlugin;
|
|
9
8
|
exports.removeDialogs = void 0;
|
|
10
|
-
|
|
11
9
|
var _react = _interopRequireDefault(require("react"));
|
|
12
|
-
|
|
13
10
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
14
|
-
|
|
15
|
-
var _List = _interopRequireDefault(require("@material-ui/core/List"));
|
|
16
|
-
|
|
11
|
+
var _List = _interopRequireDefault(require("@mui/material/List"));
|
|
17
12
|
var _slate = require("slate");
|
|
18
|
-
|
|
19
|
-
var _immutable = _interopRequireDefault(require("immutable"));
|
|
20
|
-
|
|
21
|
-
var _ListItem = _interopRequireDefault(require("@material-ui/core/ListItem"));
|
|
22
|
-
|
|
23
|
-
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
24
|
-
|
|
13
|
+
var _ListItem = _interopRequireDefault(require("@mui/material/ListItem"));
|
|
25
14
|
var _debug = _interopRequireDefault(require("debug"));
|
|
26
|
-
|
|
27
15
|
var _icons = _interopRequireDefault(require("./icons"));
|
|
28
|
-
|
|
29
16
|
var log = (0, _debug["default"])('@pie-lib:editable-html:plugins:characters');
|
|
30
|
-
|
|
31
|
-
var removeDialogs = function removeDialogs() {
|
|
17
|
+
var removeDialogs = exports.removeDialogs = function removeDialogs() {
|
|
32
18
|
var prevDialogs = document.querySelectorAll('.insert-css-dialog');
|
|
33
19
|
log('[characters:removeDialogs]');
|
|
34
20
|
prevDialogs.forEach(function (s) {
|
|
35
21
|
return s.remove();
|
|
36
22
|
});
|
|
37
23
|
};
|
|
38
|
-
|
|
39
|
-
exports.removeDialogs = removeDialogs;
|
|
40
|
-
|
|
41
24
|
var insertDialog = function insertDialog(_ref) {
|
|
42
|
-
var _parentNode$data
|
|
43
|
-
|
|
25
|
+
var _parentNode$data;
|
|
44
26
|
var editorDOM = _ref.editorDOM,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
27
|
+
value = _ref.value,
|
|
28
|
+
callback = _ref.callback,
|
|
29
|
+
opts = _ref.opts,
|
|
30
|
+
textNode = _ref.textNode,
|
|
31
|
+
parentNode = _ref.parentNode;
|
|
50
32
|
var newEl = document.createElement('div');
|
|
51
33
|
log('[characters:insertDialog]');
|
|
52
34
|
removeDialogs();
|
|
53
35
|
newEl.className = 'insert-css-dialog';
|
|
54
36
|
var popoverEl;
|
|
55
|
-
|
|
56
37
|
var closePopOver = function closePopOver() {
|
|
57
38
|
if (popoverEl) {
|
|
58
39
|
popoverEl.remove();
|
|
59
40
|
}
|
|
60
41
|
};
|
|
61
|
-
|
|
62
42
|
var firstCallMade = false;
|
|
63
|
-
|
|
64
43
|
var listener = function listener(e) {
|
|
65
44
|
// this will be triggered right after setting it because
|
|
66
45
|
// this toolbar is added on the mousedown event
|
|
@@ -68,7 +47,6 @@ var insertDialog = function insertDialog(_ref) {
|
|
|
68
47
|
if (firstCallMade) {
|
|
69
48
|
var focusIsInModals = newEl.contains(e.target) || popoverEl && popoverEl.contains(e.target);
|
|
70
49
|
var focusIsInEditor = editorDOM.contains(e.target);
|
|
71
|
-
|
|
72
50
|
if (!(focusIsInModals || focusIsInEditor)) {
|
|
73
51
|
handleClose();
|
|
74
52
|
}
|
|
@@ -76,44 +54,34 @@ var insertDialog = function insertDialog(_ref) {
|
|
|
76
54
|
firstCallMade = true;
|
|
77
55
|
}
|
|
78
56
|
};
|
|
79
|
-
|
|
80
57
|
var handleClose = function handleClose() {
|
|
81
58
|
callback(undefined, true);
|
|
82
59
|
newEl.remove();
|
|
83
60
|
closePopOver();
|
|
84
61
|
document.body.removeEventListener('click', listener);
|
|
85
62
|
};
|
|
86
|
-
|
|
87
63
|
var handleChange = function handleChange(name) {
|
|
88
64
|
callback(name, true);
|
|
89
65
|
newEl.remove();
|
|
90
66
|
closePopOver();
|
|
91
67
|
document.body.removeEventListener('click', listener);
|
|
92
68
|
};
|
|
93
|
-
|
|
94
69
|
var selectedText = textNode.text.slice(value.selection.anchorOffset, value.selection.focusOffset);
|
|
95
|
-
var parentNodeClass = parentNode === null || parentNode === void 0
|
|
96
|
-
|
|
70
|
+
var parentNodeClass = parentNode === null || parentNode === void 0 || (_parentNode$data = parentNode.data) === null || _parentNode$data === void 0 || (_parentNode$data = _parentNode$data.get('attributes')) === null || _parentNode$data === void 0 ? void 0 : _parentNode$data["class"];
|
|
97
71
|
var createHTML = function createHTML(name) {
|
|
98
72
|
var html = "<span class=\"".concat(name, "\">").concat(selectedText, "</span>");
|
|
99
|
-
|
|
100
73
|
if (parentNode) {
|
|
101
74
|
var tag;
|
|
102
|
-
|
|
103
75
|
if ((parentNode === null || parentNode === void 0 ? void 0 : parentNode.object) === 'inline') {
|
|
104
76
|
tag = 'span';
|
|
105
77
|
}
|
|
106
|
-
|
|
107
78
|
if ((parentNode === null || parentNode === void 0 ? void 0 : parentNode.object) === 'block') {
|
|
108
79
|
tag = 'div';
|
|
109
80
|
}
|
|
110
|
-
|
|
111
81
|
html = "<".concat(tag, " class=\"").concat(parentNodeClass, "\">").concat(parentNode.text.slice(0, value.selection.anchorOffset)).concat(html).concat(parentNode.text.slice(value.selection.focusOffset), "</").concat(tag, ">");
|
|
112
82
|
}
|
|
113
|
-
|
|
114
83
|
return html;
|
|
115
84
|
};
|
|
116
|
-
|
|
117
85
|
var el = /*#__PURE__*/_react["default"].createElement("div", {
|
|
118
86
|
style: {
|
|
119
87
|
background: 'white',
|
|
@@ -145,21 +113,18 @@ var insertDialog = function insertDialog(_ref) {
|
|
|
145
113
|
}
|
|
146
114
|
}));
|
|
147
115
|
})));
|
|
148
|
-
|
|
149
116
|
_reactDom["default"].render(el, newEl, function () {
|
|
150
117
|
var cursorItem = document.querySelector("[data-key=\"".concat(value.anchorKey, "\"]"));
|
|
151
|
-
|
|
152
118
|
if (cursorItem) {
|
|
153
119
|
var bodyRect = editorDOM.parentElement.parentElement.parentElement.getBoundingClientRect();
|
|
154
120
|
var boundRect = cursorItem.getBoundingClientRect();
|
|
155
|
-
editorDOM.parentElement.parentElement.parentElement.appendChild(newEl);
|
|
121
|
+
editorDOM.parentElement.parentElement.parentElement.appendChild(newEl);
|
|
156
122
|
|
|
123
|
+
// when height of toolbar exceeds screen - can happen in scrollable contexts
|
|
157
124
|
var additionalTopOffset = 0;
|
|
158
|
-
|
|
159
125
|
if (boundRect.y < newEl.offsetHeight) {
|
|
160
126
|
additionalTopOffset = newEl.offsetHeight - boundRect.y + 10;
|
|
161
127
|
}
|
|
162
|
-
|
|
163
128
|
newEl.style.maxWidth = '500px';
|
|
164
129
|
newEl.style.position = 'absolute';
|
|
165
130
|
newEl.style.top = 0;
|
|
@@ -173,39 +138,33 @@ var insertDialog = function insertDialog(_ref) {
|
|
|
173
138
|
var rightAlignedWidth = newEl.offsetWidth;
|
|
174
139
|
newEl.style.left = 'unset';
|
|
175
140
|
newEl.style.right = 'unset';
|
|
176
|
-
|
|
177
141
|
if (leftAlignedWidth >= rightAlignedWidth) {
|
|
178
142
|
newEl.style.left = leftValue;
|
|
179
143
|
} else {
|
|
180
144
|
newEl.style.right = rightValue;
|
|
181
145
|
}
|
|
182
|
-
|
|
183
146
|
document.body.addEventListener('click', listener);
|
|
184
147
|
}
|
|
185
148
|
});
|
|
186
149
|
};
|
|
187
|
-
|
|
188
150
|
var findParentNodeInfo = function findParentNodeInfo(value, textNode) {
|
|
189
151
|
var _closestInline$nodes, _closestBlock$nodes;
|
|
190
|
-
|
|
191
152
|
var closestInline = value.document.getClosestInline(value.selection.endKey);
|
|
192
153
|
var closestBlock = value.document.getClosestBlock(value.selection.endKey);
|
|
193
154
|
var nodeToUse = null;
|
|
194
|
-
|
|
195
155
|
if (closestInline !== null && closestInline !== void 0 && (_closestInline$nodes = closestInline.nodes) !== null && _closestInline$nodes !== void 0 && _closestInline$nodes.find(function (n) {
|
|
196
156
|
return n.key === textNode.key;
|
|
197
157
|
})) {
|
|
198
158
|
nodeToUse = closestInline;
|
|
199
159
|
}
|
|
200
|
-
|
|
201
160
|
if (closestBlock !== null && closestBlock !== void 0 && (_closestBlock$nodes = closestBlock.nodes) !== null && _closestBlock$nodes !== void 0 && _closestBlock$nodes.find(function (n) {
|
|
202
161
|
return n.key === textNode.key;
|
|
203
162
|
})) {
|
|
204
163
|
nodeToUse = closestBlock;
|
|
205
164
|
}
|
|
206
|
-
|
|
207
165
|
return nodeToUse;
|
|
208
166
|
};
|
|
167
|
+
|
|
209
168
|
/**
|
|
210
169
|
* Find the node that has a class attribute and return it.
|
|
211
170
|
* Keeping this in case the implementation of classes needs to be changed
|
|
@@ -213,52 +172,40 @@ var findParentNodeInfo = function findParentNodeInfo(value, textNode) {
|
|
|
213
172
|
* @param opts
|
|
214
173
|
* @returns {*}
|
|
215
174
|
*/
|
|
216
|
-
|
|
217
|
-
|
|
218
175
|
var getNodeWithClass = function getNodeWithClass(value, opts) {
|
|
219
176
|
var _blocksAtRange$, _inlinesAtRange$, _blockData$attributes, _inlineData$attribute;
|
|
220
|
-
|
|
221
177
|
var blocksAtRange = value.document.getBlocksAtRangeAsArray(value.selection);
|
|
222
178
|
var inlinesAtRange = value.document.getInlinesAtRangeAsArray(value.selection);
|
|
223
179
|
var blockData = ((_blocksAtRange$ = blocksAtRange[0]) === null || _blocksAtRange$ === void 0 ? void 0 : _blocksAtRange$.data.toJSON()) || {};
|
|
224
180
|
var inlineData = ((_inlinesAtRange$ = inlinesAtRange[0]) === null || _inlinesAtRange$ === void 0 ? void 0 : _inlinesAtRange$.data.toJSON()) || {};
|
|
225
|
-
|
|
226
181
|
if (!((_blockData$attributes = blockData.attributes) !== null && _blockData$attributes !== void 0 && _blockData$attributes["class"]) && !((_inlineData$attribute = inlineData.attributes) !== null && _inlineData$attribute !== void 0 && _inlineData$attribute["class"])) {
|
|
227
182
|
return null;
|
|
228
183
|
}
|
|
229
|
-
|
|
230
184
|
var _ref2 = blockData.attributes || {},
|
|
231
|
-
|
|
232
|
-
|
|
185
|
+
blockClass = _ref2["class"];
|
|
233
186
|
var _ref3 = inlineData.attributes || {},
|
|
234
|
-
|
|
235
|
-
|
|
187
|
+
inlineClass = _ref3["class"];
|
|
236
188
|
var inlineHasClass = opts.names.find(function (name) {
|
|
237
189
|
return inlineClass.includes(name);
|
|
238
190
|
});
|
|
239
|
-
|
|
240
191
|
if (inlineHasClass) {
|
|
241
192
|
return inlinesAtRange[0];
|
|
242
193
|
}
|
|
243
|
-
|
|
244
194
|
var blockHasClass = opts.names.find(function (name) {
|
|
245
195
|
return blockClass.includes(name);
|
|
246
196
|
});
|
|
247
|
-
|
|
248
197
|
if (blockHasClass) {
|
|
249
198
|
return blocksAtRange[0];
|
|
250
199
|
}
|
|
251
|
-
|
|
252
200
|
return null;
|
|
253
201
|
};
|
|
202
|
+
|
|
254
203
|
/**
|
|
255
204
|
* Plugin in order to be able to add a css clas that is provided through the model
|
|
256
205
|
* on a text element. Works like a mark (bold, italic etc.).
|
|
257
206
|
* @param opts
|
|
258
207
|
* @constructor
|
|
259
208
|
*/
|
|
260
|
-
|
|
261
|
-
|
|
262
209
|
function CSSPlugin(opts) {
|
|
263
210
|
var plugin = {
|
|
264
211
|
name: 'extraCSSRules',
|
|
@@ -272,15 +219,12 @@ function CSSPlugin(opts) {
|
|
|
272
219
|
var hasMark = change.value.activeMarks.find(function (entry) {
|
|
273
220
|
return entry.type === type;
|
|
274
221
|
});
|
|
275
|
-
|
|
276
222
|
if (hasMark) {
|
|
277
223
|
change.removeMark(hasMark);
|
|
278
224
|
} else {
|
|
279
225
|
var newMark = _slate.Mark.create(type);
|
|
280
|
-
|
|
281
226
|
change.addMark(newMark);
|
|
282
227
|
}
|
|
283
|
-
|
|
284
228
|
return change;
|
|
285
229
|
},
|
|
286
230
|
onClick: function onClick(value, onChange, getFocusedValue) {
|
|
@@ -289,12 +233,13 @@ function CSSPlugin(opts) {
|
|
|
289
233
|
return entry.type === type;
|
|
290
234
|
});
|
|
291
235
|
var change = value.change();
|
|
292
|
-
|
|
293
236
|
if (hasMark) {
|
|
294
237
|
change.removeMark(hasMark);
|
|
295
238
|
onChange(change);
|
|
296
239
|
return;
|
|
297
|
-
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// keeping this if implementation needs to be changed to regular blocks instead of marks
|
|
298
243
|
// let nodeWithClass = getNodeWithClass(value, opts);
|
|
299
244
|
//
|
|
300
245
|
// if (nodeWithClass) {
|
|
@@ -318,18 +263,14 @@ function CSSPlugin(opts) {
|
|
|
318
263
|
// return;
|
|
319
264
|
// }
|
|
320
265
|
|
|
321
|
-
|
|
322
266
|
var editorDOM = document.querySelector("[data-key=\"".concat(value.document.key, "\"]"));
|
|
323
267
|
var valueToUse = value;
|
|
324
|
-
|
|
325
268
|
var callback = function callback(className, focus) {
|
|
326
269
|
if (getFocusedValue) {
|
|
327
270
|
valueToUse = getFocusedValue() || valueToUse;
|
|
328
271
|
}
|
|
329
|
-
|
|
330
272
|
if (className) {
|
|
331
273
|
var _change = valueToUse.change();
|
|
332
|
-
|
|
333
274
|
var newMark = _slate.Mark.create({
|
|
334
275
|
object: 'mark',
|
|
335
276
|
type: 'css',
|
|
@@ -339,8 +280,8 @@ function CSSPlugin(opts) {
|
|
|
339
280
|
}
|
|
340
281
|
}
|
|
341
282
|
});
|
|
342
|
-
|
|
343
|
-
|
|
283
|
+
_change.addMark(newMark);
|
|
284
|
+
// keeping this if implementation needs to be changed to regular blocks instead of marks
|
|
344
285
|
// change = change.wrapInline({ type: 'span', data: { attributes: { class: className } } });
|
|
345
286
|
//
|
|
346
287
|
// // change = change.splitBlockAtRange(adaptedRange);
|
|
@@ -351,13 +292,9 @@ function CSSPlugin(opts) {
|
|
|
351
292
|
//
|
|
352
293
|
// valueToUse = change.value;
|
|
353
294
|
// log('[characters:insert]: ', value);
|
|
354
|
-
|
|
355
|
-
|
|
356
295
|
onChange(_change);
|
|
357
296
|
}
|
|
358
|
-
|
|
359
297
|
log('[characters:click]');
|
|
360
|
-
|
|
361
298
|
if (focus) {
|
|
362
299
|
setTimeout(function () {
|
|
363
300
|
if (editorDOM) {
|
|
@@ -366,9 +303,7 @@ function CSSPlugin(opts) {
|
|
|
366
303
|
}, 0);
|
|
367
304
|
}
|
|
368
305
|
};
|
|
369
|
-
|
|
370
306
|
var textNode = value.document.getTextsAtRangeAsArray(value.selection)[0];
|
|
371
|
-
|
|
372
307
|
if (textNode) {
|
|
373
308
|
var parentNode = findParentNodeInfo(value, textNode, opts);
|
|
374
309
|
insertDialog({
|
|
@@ -385,8 +320,7 @@ function CSSPlugin(opts) {
|
|
|
385
320
|
renderMark: function renderMark(props) {
|
|
386
321
|
if (props.mark.type === 'css') {
|
|
387
322
|
var _ref4 = props.mark || {},
|
|
388
|
-
|
|
389
|
-
|
|
323
|
+
data = _ref4.data;
|
|
390
324
|
var jsonData = (data === null || data === void 0 ? void 0 : data.toJSON()) || {};
|
|
391
325
|
return /*#__PURE__*/_react["default"].createElement("span", jsonData.attributes, props.children);
|
|
392
326
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugins/css/index.jsx"],"names":["log","removeDialogs","prevDialogs","document","querySelectorAll","forEach","s","remove","insertDialog","editorDOM","value","callback","opts","textNode","parentNode","newEl","createElement","className","popoverEl","closePopOver","firstCallMade","listener","e","focusIsInModals","contains","target","focusIsInEditor","handleClose","undefined","body","removeEventListener","handleChange","name","selectedText","text","slice","selection","anchorOffset","focusOffset","parentNodeClass","data","get","createHTML","html","tag","object","el","background","height","padding","overflow","display","flexFlow","names","map","i","marginRight","__html","ReactDOM","render","cursorItem","querySelector","anchorKey","bodyRect","parentElement","getBoundingClientRect","boundRect","appendChild","additionalTopOffset","y","offsetHeight","style","maxWidth","position","top","zIndex","leftValue","left","Math","abs","offsetWidth","rightValue","x","leftAlignedWidth","right","rightAlignedWidth","addEventListener","findParentNodeInfo","closestInline","getClosestInline","endKey","closestBlock","getClosestBlock","nodeToUse","nodes","find","n","key","getNodeWithClass","blocksAtRange","getBlocksAtRangeAsArray","inlinesAtRange","getInlinesAtRangeAsArray","blockData","toJSON","inlineData","attributes","blockClass","inlineClass","inlineHasClass","includes","blockHasClass","CSSPlugin","plugin","toolbar","isMark","icon","ariaLabel","type","onToggle","change","hasMark","activeMarks","entry","removeMark","newMark","Mark","create","addMark","onClick","onChange","getFocusedValue","valueToUse","focus","setTimeout","getTextsAtRangeAsArray","renderMark","props","mark","jsonData","children"],"mappings":";;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA,IAAMA,GAAG,GAAG,uBAAM,2CAAN,CAAZ;;AAEO,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,GAAM;AACjC,MAAMC,WAAW,GAAGC,QAAQ,CAACC,gBAAT,CAA0B,oBAA1B,CAApB;AAEAJ,EAAAA,GAAG,CAAC,4BAAD,CAAH;AACAE,EAAAA,WAAW,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,kBAAI7H,SAAJ,EAAe;AACbA,gBAAAA,SAAS,CAAC4H,KAAV;AACD;AACF,aAJS,EAIP,CAJO,CAAV;AAKD;AACF,SA1CD;;AA2CA,YAAMxH,QAAQ,GAAGH,KAAK,CAACP,QAAN,CAAeoI,sBAAf,CAAsC7H,KAAK,CAAC0B,SAA5C,EAAuD,CAAvD,CAAjB;;AAEA,YAAIvB,QAAJ,EAAc;AACZ,cAAMC,UAAU,GAAGyE,kBAAkB,CAAC7E,KAAD,EAAQG,QAAR,EAAkBD,IAAlB,CAArC;AAEAJ,UAAAA,YAAY,CAAC;AAAEC,YAAAA,SAAS,EAATA,SAAF;AAAaC,YAAAA,KAAK,EAAE0H,UAApB;AAAgCzH,YAAAA,QAAQ,EAARA,QAAhC;AAA0CC,YAAAA,IAAI,EAAJA,IAA1C;AAAgDC,YAAAA,QAAQ,EAARA,QAAhD;AAA0DC,YAAAA,UAAU,EAAVA;AAA1D,WAAD,CAAZ;AACD;AACF;AAhHM,KAFI;AAoHb0H,IAAAA,UApHa,sBAoHFC,KApHE,EAoHK;AAChB,UAAIA,KAAK,CAACC,IAAN,CAAWpB,IAAX,KAAoB,KAAxB,EAA+B;AAC7B,oBAAiBmB,KAAK,CAACC,IAAN,IAAc,EAA/B;AAAA,YAAQlG,IAAR,SAAQA,IAAR;;AACA,YAAMmG,QAAQ,GAAG,CAAAnG,IAAI,SAAJ,IAAAA,IAAI,WAAJ,YAAAA,IAAI,CAAEgE,MAAN,OAAkB,EAAnC;AAEA,4BAAO,wCAAUmC,QAAQ,CAACjC,UAAnB,EAAgC+B,KAAK,CAACG,QAAtC,CAAP;AACD;AACF;AA3HY,GAAf;AA8HA,SAAO3B,MAAP;AACD","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport List from '@material-ui/core/List';\nimport { Leaf, Mark } from 'slate';\nimport Immutable from 'immutable';\nimport ListItem from '@material-ui/core/ListItem';\nimport isEmpty from 'lodash/isEmpty';\nimport debug from 'debug';\nimport CssIcon from './icons';\n\nconst log = debug('@pie-lib:editable-html:plugins:characters');\n\nexport const removeDialogs = () => {\n const prevDialogs = document.querySelectorAll('.insert-css-dialog');\n\n log('[characters:removeDialogs]');\n prevDialogs.forEach((s) => s.remove());\n};\n\nconst insertDialog = ({ editorDOM, value, callback, opts, textNode, parentNode }) => {\n const newEl = document.createElement('div');\n\n log('[characters:insertDialog]');\n\n removeDialogs();\n\n newEl.className = 'insert-css-dialog';\n\n let popoverEl;\n\n const closePopOver = () => {\n if (popoverEl) {\n popoverEl.remove();\n }\n };\n\n let firstCallMade = false;\n\n const listener = (e) => {\n // this will be triggered right after setting it because\n // this toolbar is added on the mousedown event\n // so right after mouseup, the click will be triggered\n if (firstCallMade) {\n const focusIsInModals = newEl.contains(e.target) || (popoverEl && popoverEl.contains(e.target));\n const focusIsInEditor = editorDOM.contains(e.target);\n\n if (!(focusIsInModals || focusIsInEditor)) {\n handleClose();\n }\n } else {\n firstCallMade = true;\n }\n };\n\n const handleClose = () => {\n callback(undefined, true);\n newEl.remove();\n closePopOver();\n document.body.removeEventListener('click', listener);\n };\n\n const handleChange = (name) => {\n callback(name, true);\n newEl.remove();\n closePopOver();\n document.body.removeEventListener('click', listener);\n };\n\n const selectedText = textNode.text.slice(value.selection.anchorOffset, value.selection.focusOffset);\n const parentNodeClass = parentNode?.data?.get('attributes')?.class;\n const createHTML = (name) => {\n let html = `<span class=\"${name}\">${selectedText}</span>`;\n\n if (parentNode) {\n let tag;\n\n if (parentNode?.object === 'inline') {\n tag = 'span';\n }\n\n if (parentNode?.object === 'block') {\n tag = 'div';\n }\n\n html = `<${tag} class=\"${parentNodeClass}\">${parentNode.text.slice(\n 0,\n value.selection.anchorOffset,\n )}${html}${parentNode.text.slice(value.selection.focusOffset)}</${tag}>`;\n }\n\n return html;\n };\n\n const el = (\n <div\n style={{ background: 'white', height: 500, padding: 20, overflow: 'hidden', display: 'flex', flexFlow: 'column' }}\n >\n <h2>Please choose a css class</h2>\n {parentNodeClass && <div>The current parent has this class {parentNodeClass}</div>}\n <List component=\"nav\" style={{ overflow: 'scroll' }}>\n {opts.names.map((name, i) => (\n <ListItem key={`rule-${i}`} button onClick={() => handleChange(name)}>\n <div style={{ marginRight: 20 }}>{name}</div>\n <div\n dangerouslySetInnerHTML={{\n __html: createHTML(name),\n }}\n />\n </ListItem>\n ))}\n </List>\n </div>\n );\n\n ReactDOM.render(el, newEl, () => {\n const cursorItem = document.querySelector(`[data-key=\"${value.anchorKey}\"]`);\n\n if (cursorItem) {\n const bodyRect = editorDOM.parentElement.parentElement.parentElement.getBoundingClientRect();\n const boundRect = cursorItem.getBoundingClientRect();\n\n editorDOM.parentElement.parentElement.parentElement.appendChild(newEl);\n\n // when height of toolbar exceeds screen - can happen in scrollable contexts\n let additionalTopOffset = 0;\n if (boundRect.y < newEl.offsetHeight) {\n additionalTopOffset = newEl.offsetHeight - boundRect.y + 10;\n }\n\n newEl.style.maxWidth = '500px';\n newEl.style.position = 'absolute';\n newEl.style.top = 0;\n newEl.style.zIndex = 99999;\n\n const leftValue = `${boundRect.left + Math.abs(bodyRect.left) + cursorItem.offsetWidth + 10}px`;\n\n const rightValue = `${boundRect.x}px`;\n\n newEl.style.left = leftValue;\n\n const leftAlignedWidth = newEl.offsetWidth;\n\n newEl.style.left = 'unset';\n newEl.style.right = rightValue;\n\n const rightAlignedWidth = newEl.offsetWidth;\n\n newEl.style.left = 'unset';\n newEl.style.right = 'unset';\n\n if (leftAlignedWidth >= rightAlignedWidth) {\n newEl.style.left = leftValue;\n } else {\n newEl.style.right = rightValue;\n }\n\n document.body.addEventListener('click', listener);\n }\n });\n};\n\nconst findParentNodeInfo = (value, textNode) => {\n const closestInline = value.document.getClosestInline(value.selection.endKey);\n const closestBlock = value.document.getClosestBlock(value.selection.endKey);\n let nodeToUse = null;\n\n if (closestInline?.nodes?.find((n) => n.key === textNode.key)) {\n nodeToUse = closestInline;\n }\n\n if (closestBlock?.nodes?.find((n) => n.key === textNode.key)) {\n nodeToUse = closestBlock;\n }\n\n return nodeToUse;\n};\n\n/**\n * Find the node that has a class attribute and return it.\n * Keeping this in case the implementation of classes needs to be changed\n * @param value\n * @param opts\n * @returns {*}\n */\nconst getNodeWithClass = (value, opts) => {\n const blocksAtRange = value.document.getBlocksAtRangeAsArray(value.selection);\n const inlinesAtRange = value.document.getInlinesAtRangeAsArray(value.selection);\n const blockData = blocksAtRange[0]?.data.toJSON() || {};\n const inlineData = inlinesAtRange[0]?.data.toJSON() || {};\n\n if (!blockData.attributes?.class && !inlineData.attributes?.class) {\n return null;\n }\n\n const { class: blockClass } = blockData.attributes || {};\n const { class: inlineClass } = inlineData.attributes || {};\n const inlineHasClass = opts.names.find((name) => inlineClass.includes(name));\n\n if (inlineHasClass) {\n return inlinesAtRange[0];\n }\n\n const blockHasClass = opts.names.find((name) => blockClass.includes(name));\n\n if (blockHasClass) {\n return blocksAtRange[0];\n }\n\n return null;\n};\n\n/**\n * Plugin in order to be able to add a css clas that is provided through the model\n * on a text element. Works like a mark (bold, italic etc.).\n * @param opts\n * @constructor\n */\nexport default function CSSPlugin(opts) {\n const plugin = {\n name: 'extraCSSRules',\n toolbar: {\n isMark: true,\n icon: <CssIcon />,\n ariaLabel: 'CSS editor',\n type: 'css',\n onToggle: (change) => {\n const type = 'css';\n const hasMark = change.value.activeMarks.find((entry) => {\n return entry.type === type;\n });\n\n if (hasMark) {\n change.removeMark(hasMark);\n } else {\n const newMark = Mark.create(type);\n\n change.addMark(newMark);\n }\n\n return change;\n },\n onClick: (value, onChange, getFocusedValue) => {\n const type = 'css';\n const hasMark = value.activeMarks.find((entry) => {\n return entry.type === type;\n });\n\n let change = value.change();\n\n if (hasMark) {\n change.removeMark(hasMark);\n onChange(change);\n return;\n }\n\n // keeping this if implementation needs to be changed to regular blocks instead of marks\n // let nodeWithClass = getNodeWithClass(value, opts);\n //\n // if (nodeWithClass) {\n // const nodeAttributes = nodeWithClass.data.get('attributes');\n //\n // opts.names.forEach((name) => {\n // if (nodeAttributes.class.includes(name)) {\n // nodeAttributes.class = nodeAttributes.class.replace(name, '');\n // }\n // });\n //\n // // keeping only one space between classes\n // nodeAttributes.class = nodeAttributes.class.replace(/ +/g, ' ');\n //\n // nodeWithClass.data.set('attributes', nodeAttributes);\n //\n // let change = value.change();\n // change.replaceNodeByKey(nodeWithClass.key, nodeWithClass);\n //\n // onChange(change);\n // return;\n // }\n\n const editorDOM = document.querySelector(`[data-key=\"${value.document.key}\"]`);\n let valueToUse = value;\n\n const callback = (className, focus) => {\n if (getFocusedValue) {\n valueToUse = getFocusedValue() || valueToUse;\n }\n\n if (className) {\n let change = valueToUse.change();\n\n const newMark = Mark.create({\n object: 'mark',\n type: 'css',\n data: {\n attributes: {\n class: className,\n },\n },\n });\n\n change.addMark(newMark);\n // keeping this if implementation needs to be changed to regular blocks instead of marks\n // change = change.wrapInline({ type: 'span', data: { attributes: { class: className } } });\n //\n // // change = change.splitBlockAtRange(adaptedRange);\n // //\n // // const newBlock = change.value.document.getFurthestBlock(change.value.selection.endKey);\n // //\n // // change = change.setNodeByKey(newBlock.key, { data: { attributes: { class: className } } });\n //\n // valueToUse = change.value;\n // log('[characters:insert]: ', value);\n onChange(change);\n }\n\n log('[characters:click]');\n\n if (focus) {\n setTimeout(() => {\n if (editorDOM) {\n editorDOM.focus();\n }\n }, 0);\n }\n };\n const textNode = value.document.getTextsAtRangeAsArray(value.selection)[0];\n\n if (textNode) {\n const parentNode = findParentNodeInfo(value, textNode, opts);\n\n insertDialog({ editorDOM, value: valueToUse, callback, opts, textNode, parentNode });\n }\n },\n },\n renderMark(props) {\n if (props.mark.type === 'css') {\n const { data } = props.mark || {};\n const jsonData = data?.toJSON() || {};\n\n return <span {...jsonData.attributes}>{props.children}</span>;\n }\n },\n };\n\n return plugin;\n}\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_reactDom","_List","_slate","_ListItem","_debug","_icons","log","debug","removeDialogs","exports","prevDialogs","document","querySelectorAll","forEach","s","remove","insertDialog","_ref","_parentNode$data","editorDOM","value","callback","opts","textNode","parentNode","newEl","createElement","className","popoverEl","closePopOver","firstCallMade","listener","e","focusIsInModals","contains","target","focusIsInEditor","handleClose","undefined","body","removeEventListener","handleChange","name","selectedText","text","slice","selection","anchorOffset","focusOffset","parentNodeClass","data","get","createHTML","html","concat","tag","object","el","style","background","height","padding","overflow","display","flexFlow","component","names","map","i","key","button","onClick","marginRight","dangerouslySetInnerHTML","__html","ReactDOM","render","cursorItem","querySelector","anchorKey","bodyRect","parentElement","getBoundingClientRect","boundRect","appendChild","additionalTopOffset","y","offsetHeight","maxWidth","position","top","zIndex","leftValue","left","Math","abs","offsetWidth","rightValue","x","leftAlignedWidth","right","rightAlignedWidth","addEventListener","findParentNodeInfo","_closestInline$nodes","_closestBlock$nodes","closestInline","getClosestInline","endKey","closestBlock","getClosestBlock","nodeToUse","nodes","find","n","getNodeWithClass","_blocksAtRange$","_inlinesAtRange$","_blockData$attributes","_inlineData$attribute","blocksAtRange","getBlocksAtRangeAsArray","inlinesAtRange","getInlinesAtRangeAsArray","blockData","toJSON","inlineData","attributes","_ref2","blockClass","_ref3","inlineClass","inlineHasClass","includes","blockHasClass","CSSPlugin","plugin","toolbar","isMark","icon","ariaLabel","type","onToggle","change","hasMark","activeMarks","entry","removeMark","newMark","Mark","create","addMark","onChange","getFocusedValue","valueToUse","focus","setTimeout","getTextsAtRangeAsArray","renderMark","props","mark","_ref4","jsonData","children"],"sources":["../../../src/plugins/css/index.jsx"],"sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport List from '@mui/material/List';\nimport { Mark } from 'slate';\nimport ListItem from '@mui/material/ListItem';\nimport debug from 'debug';\nimport CssIcon from './icons';\n\nconst log = debug('@pie-lib:editable-html:plugins:characters');\n\nexport const removeDialogs = () => {\n const prevDialogs = document.querySelectorAll('.insert-css-dialog');\n\n log('[characters:removeDialogs]');\n prevDialogs.forEach((s) => s.remove());\n};\n\nconst insertDialog = ({ editorDOM, value, callback, opts, textNode, parentNode }) => {\n const newEl = document.createElement('div');\n\n log('[characters:insertDialog]');\n\n removeDialogs();\n\n newEl.className = 'insert-css-dialog';\n\n let popoverEl;\n\n const closePopOver = () => {\n if (popoverEl) {\n popoverEl.remove();\n }\n };\n\n let firstCallMade = false;\n\n const listener = (e) => {\n // this will be triggered right after setting it because\n // this toolbar is added on the mousedown event\n // so right after mouseup, the click will be triggered\n if (firstCallMade) {\n const focusIsInModals = newEl.contains(e.target) || (popoverEl && popoverEl.contains(e.target));\n const focusIsInEditor = editorDOM.contains(e.target);\n\n if (!(focusIsInModals || focusIsInEditor)) {\n handleClose();\n }\n } else {\n firstCallMade = true;\n }\n };\n\n const handleClose = () => {\n callback(undefined, true);\n newEl.remove();\n closePopOver();\n document.body.removeEventListener('click', listener);\n };\n\n const handleChange = (name) => {\n callback(name, true);\n newEl.remove();\n closePopOver();\n document.body.removeEventListener('click', listener);\n };\n\n const selectedText = textNode.text.slice(value.selection.anchorOffset, value.selection.focusOffset);\n const parentNodeClass = parentNode?.data?.get('attributes')?.class;\n const createHTML = (name) => {\n let html = `<span class=\"${name}\">${selectedText}</span>`;\n\n if (parentNode) {\n let tag;\n\n if (parentNode?.object === 'inline') {\n tag = 'span';\n }\n\n if (parentNode?.object === 'block') {\n tag = 'div';\n }\n\n html = `<${tag} class=\"${parentNodeClass}\">${parentNode.text.slice(\n 0,\n value.selection.anchorOffset,\n )}${html}${parentNode.text.slice(value.selection.focusOffset)}</${tag}>`;\n }\n\n return html;\n };\n\n const el = (\n <div\n style={{ background: 'white', height: 500, padding: 20, overflow: 'hidden', display: 'flex', flexFlow: 'column' }}\n >\n <h2>Please choose a css class</h2>\n {parentNodeClass && <div>The current parent has this class {parentNodeClass}</div>}\n <List component=\"nav\" style={{ overflow: 'scroll' }}>\n {opts.names.map((name, i) => (\n <ListItem key={`rule-${i}`} button onClick={() => handleChange(name)}>\n <div style={{ marginRight: 20 }}>{name}</div>\n <div\n dangerouslySetInnerHTML={{\n __html: createHTML(name),\n }}\n />\n </ListItem>\n ))}\n </List>\n </div>\n );\n\n ReactDOM.render(el, newEl, () => {\n const cursorItem = document.querySelector(`[data-key=\"${value.anchorKey}\"]`);\n\n if (cursorItem) {\n const bodyRect = editorDOM.parentElement.parentElement.parentElement.getBoundingClientRect();\n const boundRect = cursorItem.getBoundingClientRect();\n\n editorDOM.parentElement.parentElement.parentElement.appendChild(newEl);\n\n // when height of toolbar exceeds screen - can happen in scrollable contexts\n let additionalTopOffset = 0;\n if (boundRect.y < newEl.offsetHeight) {\n additionalTopOffset = newEl.offsetHeight - boundRect.y + 10;\n }\n\n newEl.style.maxWidth = '500px';\n newEl.style.position = 'absolute';\n newEl.style.top = 0;\n newEl.style.zIndex = 99999;\n\n const leftValue = `${boundRect.left + Math.abs(bodyRect.left) + cursorItem.offsetWidth + 10}px`;\n\n const rightValue = `${boundRect.x}px`;\n\n newEl.style.left = leftValue;\n\n const leftAlignedWidth = newEl.offsetWidth;\n\n newEl.style.left = 'unset';\n newEl.style.right = rightValue;\n\n const rightAlignedWidth = newEl.offsetWidth;\n\n newEl.style.left = 'unset';\n newEl.style.right = 'unset';\n\n if (leftAlignedWidth >= rightAlignedWidth) {\n newEl.style.left = leftValue;\n } else {\n newEl.style.right = rightValue;\n }\n\n document.body.addEventListener('click', listener);\n }\n });\n};\n\nconst findParentNodeInfo = (value, textNode) => {\n const closestInline = value.document.getClosestInline(value.selection.endKey);\n const closestBlock = value.document.getClosestBlock(value.selection.endKey);\n let nodeToUse = null;\n\n if (closestInline?.nodes?.find((n) => n.key === textNode.key)) {\n nodeToUse = closestInline;\n }\n\n if (closestBlock?.nodes?.find((n) => n.key === textNode.key)) {\n nodeToUse = closestBlock;\n }\n\n return nodeToUse;\n};\n\n/**\n * Find the node that has a class attribute and return it.\n * Keeping this in case the implementation of classes needs to be changed\n * @param value\n * @param opts\n * @returns {*}\n */\nconst getNodeWithClass = (value, opts) => {\n const blocksAtRange = value.document.getBlocksAtRangeAsArray(value.selection);\n const inlinesAtRange = value.document.getInlinesAtRangeAsArray(value.selection);\n const blockData = blocksAtRange[0]?.data.toJSON() || {};\n const inlineData = inlinesAtRange[0]?.data.toJSON() || {};\n\n if (!blockData.attributes?.class && !inlineData.attributes?.class) {\n return null;\n }\n\n const { class: blockClass } = blockData.attributes || {};\n const { class: inlineClass } = inlineData.attributes || {};\n const inlineHasClass = opts.names.find((name) => inlineClass.includes(name));\n\n if (inlineHasClass) {\n return inlinesAtRange[0];\n }\n\n const blockHasClass = opts.names.find((name) => blockClass.includes(name));\n\n if (blockHasClass) {\n return blocksAtRange[0];\n }\n\n return null;\n};\n\n/**\n * Plugin in order to be able to add a css clas that is provided through the model\n * on a text element. Works like a mark (bold, italic etc.).\n * @param opts\n * @constructor\n */\nexport default function CSSPlugin(opts) {\n const plugin = {\n name: 'extraCSSRules',\n toolbar: {\n isMark: true,\n icon: <CssIcon />,\n ariaLabel: 'CSS editor',\n type: 'css',\n onToggle: (change) => {\n const type = 'css';\n const hasMark = change.value.activeMarks.find((entry) => {\n return entry.type === type;\n });\n\n if (hasMark) {\n change.removeMark(hasMark);\n } else {\n const newMark = Mark.create(type);\n\n change.addMark(newMark);\n }\n\n return change;\n },\n onClick: (value, onChange, getFocusedValue) => {\n const type = 'css';\n const hasMark = value.activeMarks.find((entry) => {\n return entry.type === type;\n });\n\n let change = value.change();\n\n if (hasMark) {\n change.removeMark(hasMark);\n onChange(change);\n return;\n }\n\n // keeping this if implementation needs to be changed to regular blocks instead of marks\n // let nodeWithClass = getNodeWithClass(value, opts);\n //\n // if (nodeWithClass) {\n // const nodeAttributes = nodeWithClass.data.get('attributes');\n //\n // opts.names.forEach((name) => {\n // if (nodeAttributes.class.includes(name)) {\n // nodeAttributes.class = nodeAttributes.class.replace(name, '');\n // }\n // });\n //\n // // keeping only one space between classes\n // nodeAttributes.class = nodeAttributes.class.replace(/ +/g, ' ');\n //\n // nodeWithClass.data.set('attributes', nodeAttributes);\n //\n // let change = value.change();\n // change.replaceNodeByKey(nodeWithClass.key, nodeWithClass);\n //\n // onChange(change);\n // return;\n // }\n\n const editorDOM = document.querySelector(`[data-key=\"${value.document.key}\"]`);\n let valueToUse = value;\n\n const callback = (className, focus) => {\n if (getFocusedValue) {\n valueToUse = getFocusedValue() || valueToUse;\n }\n\n if (className) {\n let change = valueToUse.change();\n\n const newMark = Mark.create({\n object: 'mark',\n type: 'css',\n data: {\n attributes: {\n class: className,\n },\n },\n });\n\n change.addMark(newMark);\n // keeping this if implementation needs to be changed to regular blocks instead of marks\n // change = change.wrapInline({ type: 'span', data: { attributes: { class: className } } });\n //\n // // change = change.splitBlockAtRange(adaptedRange);\n // //\n // // const newBlock = change.value.document.getFurthestBlock(change.value.selection.endKey);\n // //\n // // change = change.setNodeByKey(newBlock.key, { data: { attributes: { class: className } } });\n //\n // valueToUse = change.value;\n // log('[characters:insert]: ', value);\n onChange(change);\n }\n\n log('[characters:click]');\n\n if (focus) {\n setTimeout(() => {\n if (editorDOM) {\n editorDOM.focus();\n }\n }, 0);\n }\n };\n const textNode = value.document.getTextsAtRangeAsArray(value.selection)[0];\n\n if (textNode) {\n const parentNode = findParentNodeInfo(value, textNode, opts);\n\n insertDialog({ editorDOM, value: valueToUse, callback, opts, textNode, parentNode });\n }\n },\n },\n renderMark(props) {\n if (props.mark.type === 'css') {\n const { data } = props.mark || {};\n const jsonData = data?.toJSON() || {};\n\n return <span {...jsonData.attributes}>{props.children}</span>;\n }\n },\n };\n\n return plugin;\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,MAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,MAAA,GAAAP,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,WAAVA,UAAUA,CAACC,KAAK,EAAE;MAChB,IAAIA,KAAK,CAACC,IAAI,CAACnB,IAAI,KAAK,KAAK,EAAE;QAC7B,IAAAoB,KAAA,GAAiBF,KAAK,CAACC,IAAI,IAAI,CAAC,CAAC;UAAzB9G,IAAI,GAAA+G,KAAA,CAAJ/G,IAAI;QACZ,IAAMgH,QAAQ,GAAG,CAAAhH,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAE2E,MAAM,CAAC,CAAC,KAAI,CAAC,CAAC;QAErC,oBAAOhI,MAAA,YAAA6B,aAAA,SAAUwI,QAAQ,CAACnC,UAAU,EAAGgC,KAAK,CAACI,QAAe,CAAC;MAC/D;IACF;EACF,CAAC;EAED,OAAO3B,MAAM;AACf","ignoreList":[]}
|
|
@@ -1,37 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.ICON_TYPE = exports.CONTENT_TYPE = void 0;
|
|
9
8
|
exports["default"] = CustomPlugin;
|
|
10
|
-
|
|
11
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
-
|
|
13
10
|
var _react = _interopRequireDefault(require("react"));
|
|
14
|
-
|
|
15
11
|
var _serialization = require("../../serialization");
|
|
16
|
-
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
20
|
-
|
|
12
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
21
14
|
// We're possibly going to have to support content types, so starting it as an enum
|
|
22
|
-
var CONTENT_TYPE = {
|
|
15
|
+
var CONTENT_TYPE = exports.CONTENT_TYPE = {
|
|
23
16
|
FRAGMENT: 'FRAGMENT'
|
|
24
|
-
};
|
|
17
|
+
};
|
|
25
18
|
|
|
26
|
-
|
|
27
|
-
var ICON_TYPE = {
|
|
19
|
+
// We're possibly going to have to support multiple icon types, so starting it as an enum
|
|
20
|
+
var ICON_TYPE = exports.ICON_TYPE = {
|
|
28
21
|
SVG: 'SVG'
|
|
29
22
|
};
|
|
30
|
-
exports.ICON_TYPE = ICON_TYPE;
|
|
31
|
-
|
|
32
23
|
var getIcon = function getIcon(customPluginProps) {
|
|
33
24
|
var svg = customPluginProps.icon;
|
|
34
|
-
|
|
35
25
|
switch (customPluginProps.iconType) {
|
|
36
26
|
case ICON_TYPE.SVG:
|
|
37
27
|
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
@@ -43,24 +33,20 @@ var getIcon = function getIcon(customPluginProps) {
|
|
|
43
33
|
__html: svg
|
|
44
34
|
}
|
|
45
35
|
});
|
|
46
|
-
|
|
47
36
|
default:
|
|
48
37
|
return /*#__PURE__*/_react["default"].createElement("span", null, customPluginProps.iconAlt);
|
|
49
38
|
}
|
|
50
39
|
};
|
|
51
|
-
|
|
52
40
|
function CustomPlugin(type, customPluginProps) {
|
|
53
41
|
var toolbar = {
|
|
54
42
|
icon: getIcon(customPluginProps),
|
|
55
43
|
onClick: function onClick(value, onChange, getFocusedValue) {
|
|
56
44
|
var editorDOM = document.querySelector("[data-key=\"".concat(value.document.key, "\"]"));
|
|
57
45
|
var valueToUse = value;
|
|
58
|
-
|
|
59
46
|
var callback = function callback(_ref, focus) {
|
|
60
47
|
var customContent = _ref.customContent,
|
|
61
|
-
|
|
48
|
+
contentType = _ref.contentType;
|
|
62
49
|
valueToUse = getFocusedValue();
|
|
63
|
-
|
|
64
50
|
switch (contentType) {
|
|
65
51
|
case CONTENT_TYPE.FRAGMENT:
|
|
66
52
|
default:
|
|
@@ -72,15 +58,14 @@ function CustomPlugin(type, customPluginProps) {
|
|
|
72
58
|
break;
|
|
73
59
|
}
|
|
74
60
|
}
|
|
75
|
-
|
|
76
61
|
if (focus) {
|
|
77
62
|
if (editorDOM) {
|
|
78
63
|
editorDOM.focus();
|
|
79
64
|
}
|
|
80
65
|
}
|
|
81
|
-
};
|
|
82
|
-
|
|
66
|
+
};
|
|
83
67
|
|
|
68
|
+
// NOTE: the emitted event (custom event named by client) will be suffixed with "PIE-"
|
|
84
69
|
window.dispatchEvent(new CustomEvent("PIE-".concat(customPluginProps.event), {
|
|
85
70
|
detail: _objectSpread(_objectSpread({}, customPluginProps), {}, {
|
|
86
71
|
callback: callback
|
|
@@ -100,8 +85,7 @@ function CustomPlugin(type, customPluginProps) {
|
|
|
100
85
|
var data = node.data;
|
|
101
86
|
var jsonData = data.toJSON();
|
|
102
87
|
var customContent = jsonData.customContent,
|
|
103
|
-
|
|
104
|
-
|
|
88
|
+
contentType = jsonData.contentType;
|
|
105
89
|
switch (contentType) {
|
|
106
90
|
case CONTENT_TYPE.FRAGMENT:
|
|
107
91
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_serialization","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","CONTENT_TYPE","exports","FRAGMENT","ICON_TYPE","SVG","getIcon","customPluginProps","svg","icon","iconType","createElement","style","width","height","dangerouslySetInnerHTML","__html","iconAlt","CustomPlugin","type","toolbar","onClick","value","onChange","getFocusedValue","editorDOM","document","querySelector","concat","key","valueToUse","callback","_ref","focus","customContent","contentType","contentValue","htmlToValue","change","insertFragment","window","dispatchEvent","CustomEvent","event","detail","supports","node","object","name","renderNode","props","data","jsonData","toJSON"],"sources":["../../../src/plugins/customPlugin/index.jsx"],"sourcesContent":["import React from 'react';\nimport { htmlToValue } from '../../serialization';\n\n// We're possibly going to have to support content types, so starting it as an enum\nexport const CONTENT_TYPE = {\n FRAGMENT: 'FRAGMENT',\n};\n\n// We're possibly going to have to support multiple icon types, so starting it as an enum\nexport const ICON_TYPE = {\n SVG: 'SVG',\n};\n\nconst getIcon = (customPluginProps) => {\n const svg = customPluginProps.icon;\n\n switch (customPluginProps.iconType) {\n case ICON_TYPE.SVG:\n return <span style={{ width: 28, height: 28 }} dangerouslySetInnerHTML={{ __html: svg }} />;\n default:\n return <span>{customPluginProps.iconAlt}</span>;\n }\n};\n\nexport default function CustomPlugin(type, customPluginProps) {\n const toolbar = {\n icon: getIcon(customPluginProps),\n onClick: (value, onChange, getFocusedValue) => {\n const editorDOM = document.querySelector(`[data-key=\"${value.document.key}\"]`);\n let valueToUse = value;\n const callback = ({ customContent, contentType }, focus) => {\n valueToUse = getFocusedValue();\n\n switch (contentType) {\n case CONTENT_TYPE.FRAGMENT:\n default: {\n const contentValue = htmlToValue(customContent);\n const change = valueToUse.change().insertFragment(contentValue.document);\n\n valueToUse = change.value;\n onChange(change);\n\n break;\n }\n }\n\n if (focus) {\n if (editorDOM) {\n editorDOM.focus();\n }\n }\n };\n\n // NOTE: the emitted event (custom event named by client) will be suffixed with \"PIE-\"\n window.dispatchEvent(\n new CustomEvent(`PIE-${customPluginProps.event}`, {\n detail: {\n ...customPluginProps,\n callback,\n },\n }),\n );\n },\n supports: (node) => node.object === 'inline' && node.type === type,\n };\n\n return {\n name: type,\n toolbar,\n renderNode(props) {\n if (props.node.type === type) {\n const { node } = props;\n const { data } = node;\n const jsonData = data.toJSON();\n const { customContent, contentType } = jsonData;\n\n switch (contentType) {\n case CONTENT_TYPE.FRAGMENT:\n default:\n return customContent;\n }\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAAkD,SAAAE,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,QAAAe,gBAAA,aAAAhB,CAAA,EAAAC,CAAA,EAAAC,CAAA,CAAAD,CAAA,SAAAE,MAAA,CAAAc,yBAAA,GAAAd,MAAA,CAAAe,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GAAKL,IAAI,CAAbK,IAAI;QACZ,IAAMC,QAAQ,GAAGD,IAAI,CAACE,MAAM,CAAC,CAAC;QAC9B,IAAQnB,aAAa,GAAkBkB,QAAQ,CAAvClB,aAAa;UAAEC,WAAW,GAAKiB,QAAQ,CAAxBjB,WAAW;QAElC,QAAQA,WAAW;UACjB,KAAKlC,YAAY,CAACE,QAAQ;UAC1B;YACE,OAAO+B,aAAa;QACxB;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -1,38 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
var styles = function styles(theme) {
|
|
9
|
+
var _styles = require("@mui/material/styles");
|
|
10
|
+
var StyledHtmlIcon = (0, _styles.styled)('div')(function (_ref) {
|
|
11
|
+
var theme = _ref.theme;
|
|
15
12
|
return {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
whiteSpace: 'nowrap'
|
|
23
|
-
}
|
|
13
|
+
fontFamily: 'Cerebri Sans, Arial, sans-serif',
|
|
14
|
+
fontSize: theme.typography.fontSize,
|
|
15
|
+
fontWeight: 'bold',
|
|
16
|
+
lineHeight: '14px',
|
|
17
|
+
position: 'relative',
|
|
18
|
+
whiteSpace: 'nowrap'
|
|
24
19
|
};
|
|
20
|
+
});
|
|
21
|
+
var HtmlModeIcon = function HtmlModeIcon(_ref2) {
|
|
22
|
+
var isHtmlMode = _ref2.isHtmlMode;
|
|
23
|
+
return /*#__PURE__*/_react["default"].createElement(StyledHtmlIcon, null, isHtmlMode ? 'Exit <HTML> mode' : '<HTML>');
|
|
25
24
|
};
|
|
26
|
-
|
|
27
|
-
var HtmlModeIcon = function HtmlModeIcon(_ref) {
|
|
28
|
-
var classes = _ref.classes,
|
|
29
|
-
isHtmlMode = _ref.isHtmlMode;
|
|
30
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
31
|
-
className: classes.icon
|
|
32
|
-
}, isHtmlMode ? 'Exit <HTML> mode' : '<HTML>');
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
var _default = (0, _styles.withStyles)(styles)(HtmlModeIcon);
|
|
36
|
-
|
|
37
|
-
exports["default"] = _default;
|
|
25
|
+
var _default = exports["default"] = HtmlModeIcon;
|
|
38
26
|
//# sourceMappingURL=index.js.map
|