@manuscripts/body-editor 2.8.48 → 2.8.49
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/dist/cjs/commands.js +6 -0
- package/dist/cjs/configs/editor-views.js +2 -0
- package/dist/cjs/icons.js +2 -1
- package/dist/cjs/lib/context-menu.js +21 -0
- package/dist/cjs/lib/utils.js +7 -1
- package/dist/cjs/plugins/placeholder.js +21 -3
- package/dist/cjs/versions.js +1 -1
- package/dist/cjs/views/block_view.js +13 -6
- package/dist/cjs/views/editable_block.js +4 -8
- package/dist/cjs/views/figure_editable.js +49 -36
- package/dist/cjs/views/pullquote_element.js +33 -0
- package/dist/cjs/views/quote_image_editable.js +71 -0
- package/dist/es/commands.js +6 -0
- package/dist/es/configs/editor-views.js +2 -0
- package/dist/es/icons.js +2 -1
- package/dist/es/lib/context-menu.js +21 -0
- package/dist/es/lib/utils.js +5 -1
- package/dist/es/plugins/placeholder.js +22 -4
- package/dist/es/versions.js +1 -1
- package/dist/es/views/block_view.js +13 -6
- package/dist/es/views/editable_block.js +2 -6
- package/dist/es/views/figure_editable.js +49 -36
- package/dist/es/views/pullquote_element.js +33 -0
- package/dist/es/views/quote_image_editable.js +67 -0
- package/dist/types/icons.d.ts +1 -0
- package/dist/types/lib/utils.d.ts +3 -1
- package/dist/types/versions.d.ts +1 -1
- package/dist/types/views/block_view.d.ts +1 -0
- package/dist/types/views/blockquote_element_editable.d.ts +1 -0
- package/dist/types/views/bullet_list_editable.d.ts +1 -0
- package/dist/types/views/editable_block.d.ts +1 -0
- package/dist/types/views/equation_element_editable.d.ts +1 -0
- package/dist/types/views/figure_editable.d.ts +7 -4
- package/dist/types/views/figure_element_editable.d.ts +1 -0
- package/dist/types/views/list.d.ts +1 -0
- package/dist/types/views/ordered_list_editable.d.ts +1 -0
- package/dist/types/views/paragraph_editable.d.ts +1 -0
- package/dist/types/views/placeholder_element_editable.d.ts +1 -0
- package/dist/types/views/pullquote_element.d.ts +6 -0
- package/dist/types/views/pullquote_element_editable.d.ts +1 -0
- package/dist/types/views/quote_image_editable.d.ts +26 -0
- package/dist/types/views/section_title_editable.d.ts +1 -0
- package/dist/types/views/table_element_editable.d.ts +1 -0
- package/package.json +4 -4
- package/styles/Editor.css +105 -24
package/dist/cjs/commands.js
CHANGED
|
@@ -169,6 +169,12 @@ const createBlock = (nodeType, position, state, dispatch, attrs) => {
|
|
|
169
169
|
case transform_1.schema.nodes.embed:
|
|
170
170
|
node = createEmbedElement(attrs);
|
|
171
171
|
break;
|
|
172
|
+
case state.schema.nodes.pullquote_element:
|
|
173
|
+
node = state.schema.nodes.pullquote_element.create(attrs, [
|
|
174
|
+
state.schema.nodes.paragraph.create({}),
|
|
175
|
+
state.schema.nodes.attribution.create({}),
|
|
176
|
+
]);
|
|
177
|
+
break;
|
|
172
178
|
default:
|
|
173
179
|
node = nodeType.createAndFill(attrs);
|
|
174
180
|
}
|
|
@@ -36,6 +36,7 @@ const paragraph_editable_1 = __importDefault(require("../views/paragraph_editabl
|
|
|
36
36
|
const placeholder_1 = __importDefault(require("../views/placeholder"));
|
|
37
37
|
const placeholder_element_editable_1 = __importDefault(require("../views/placeholder_element_editable"));
|
|
38
38
|
const pullquote_element_editable_1 = __importDefault(require("../views/pullquote_element_editable"));
|
|
39
|
+
const quote_image_editable_1 = __importDefault(require("../views/quote_image_editable"));
|
|
39
40
|
const section_1 = __importDefault(require("../views/section"));
|
|
40
41
|
const section_label_1 = __importDefault(require("../views/section_label"));
|
|
41
42
|
const section_title_editable_1 = __importDefault(require("../views/section_title_editable"));
|
|
@@ -50,6 +51,7 @@ exports.default = (props, dispatch) => {
|
|
|
50
51
|
alt_titles: (0, alt_titles_section_1.default)(props),
|
|
51
52
|
bibliography_element: (0, bibliography_element_1.default)(props, dispatch),
|
|
52
53
|
blockquote_element: (0, blockquote_element_editable_1.default)(props),
|
|
54
|
+
quote_image: (0, quote_image_editable_1.default)(props, dispatch),
|
|
53
55
|
box_element: (0, box_element_1.default)(props),
|
|
54
56
|
citation: (0, citation_editable_1.default)(props, dispatch),
|
|
55
57
|
cross_reference: (0, cross_reference_editable_1.default)(props, dispatch),
|
package/dist/cjs/icons.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lockIcon = exports.scrollIcon = exports.sectionCategoryIcon = exports.editIcon = exports.deleteIcon = exports.alertIcon = exports.arrowDown = void 0;
|
|
3
|
+
exports.plusIcon = exports.lockIcon = exports.scrollIcon = exports.sectionCategoryIcon = exports.editIcon = exports.deleteIcon = exports.alertIcon = exports.arrowDown = void 0;
|
|
4
4
|
const style_guide_1 = require("@manuscripts/style-guide");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const server_1 = require("react-dom/server");
|
|
@@ -12,3 +12,4 @@ exports.editIcon = (0, server_1.renderToStaticMarkup)((0, react_1.createElement)
|
|
|
12
12
|
exports.sectionCategoryIcon = renderIcon(style_guide_1.SectionCategoryIcon);
|
|
13
13
|
exports.scrollIcon = (0, server_1.renderToStaticMarkup)((0, react_1.createElement)(style_guide_1.ScrollIcon));
|
|
14
14
|
exports.lockIcon = (0, server_1.renderToStaticMarkup)((0, react_1.createElement)(style_guide_1.LockIcon));
|
|
15
|
+
exports.plusIcon = renderIcon(style_guide_1.PlusIcon);
|
|
@@ -205,6 +205,27 @@ class ContextMenu {
|
|
|
205
205
|
}
|
|
206
206
|
}));
|
|
207
207
|
}
|
|
208
|
+
if (type === transform_1.schema.nodes.pullquote_element) {
|
|
209
|
+
const figure = (0, prosemirror_utils_1.findChildrenByType)(this.node, transform_1.schema.nodes.quote_image);
|
|
210
|
+
if (!figure.length) {
|
|
211
|
+
menu.appendChild(this.createMenuItem('Add Image', () => {
|
|
212
|
+
const tr = this.view.state.tr;
|
|
213
|
+
tr.insert(this.getPos() + 1, transform_1.schema.nodes.quote_image.create());
|
|
214
|
+
this.view.dispatch(tr);
|
|
215
|
+
popper.destroy();
|
|
216
|
+
}));
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
const found = figure[0];
|
|
220
|
+
menu.appendChild(this.createMenuItem('Remove Image', () => {
|
|
221
|
+
const tr = this.view.state.tr;
|
|
222
|
+
console.log(found);
|
|
223
|
+
tr.delete(this.getPos() + 1 + found.pos, this.getPos() + 1 + found.pos + found.node.nodeSize);
|
|
224
|
+
this.view.dispatch(tr);
|
|
225
|
+
popper.destroy();
|
|
226
|
+
}));
|
|
227
|
+
}
|
|
228
|
+
}
|
|
208
229
|
const commentTarget = this.getCommentTarget();
|
|
209
230
|
if ((0, commands_1.isCommentingAllowed)(commentTarget.type)) {
|
|
210
231
|
menu.appendChild(this.createMenuSection((section) => {
|
package/dist/cjs/lib/utils.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.getInsertPos = exports.createToggleButton = exports.isEditAllowed = exports.isBodyLocked = exports.cleanItemValues = exports.shouldRenderField = exports.createHeader = exports.isSelectionInBody = exports.isSelectionInNode = exports.isChildOfNodeTypes = exports.findParentElement = exports.findParentSection = exports.findParentNodeWithIdValue = exports.findParentNodeWithId = exports.getChildOfType = exports.getMatchingDescendant = exports.getMatchingChild = exports.iterateChildren = void 0;
|
|
18
|
+
exports.getInsertPos = exports.createToggleButton = exports.isEditAllowed = exports.isBodyLocked = exports.cleanItemValues = exports.shouldRenderField = exports.hasParent = exports.isNotNull = exports.createHeader = exports.isSelectionInBody = exports.isSelectionInNode = exports.isChildOfNodeTypes = exports.findParentElement = exports.findParentSection = exports.findParentNodeWithIdValue = exports.findParentNodeWithId = exports.getChildOfType = exports.getMatchingDescendant = exports.getMatchingChild = exports.iterateChildren = void 0;
|
|
19
19
|
const transform_1 = require("@manuscripts/transform");
|
|
20
20
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
21
21
|
const config_1 = require("../components/references/ReferenceForm/config");
|
|
@@ -102,6 +102,12 @@ const createHeader = (typeName, text) => {
|
|
|
102
102
|
return header;
|
|
103
103
|
};
|
|
104
104
|
exports.createHeader = createHeader;
|
|
105
|
+
const isNotNull = (a) => a !== null;
|
|
106
|
+
exports.isNotNull = isNotNull;
|
|
107
|
+
const hasParent = ($pos, type) => {
|
|
108
|
+
return !!(0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)($pos, type);
|
|
109
|
+
};
|
|
110
|
+
exports.hasParent = hasParent;
|
|
105
111
|
const shouldRenderField = (field, type) => {
|
|
106
112
|
var _a, _b;
|
|
107
113
|
return (_b = (_a = config_1.fieldConfigMap[type]) === null || _a === void 0 ? void 0 : _a.has(field)) !== null && _b !== void 0 ? _b : false;
|
|
@@ -30,8 +30,23 @@ const placeholderWidget = (placeholder) => (view, getPos) => {
|
|
|
30
30
|
});
|
|
31
31
|
return element;
|
|
32
32
|
};
|
|
33
|
-
const getParagraphPlaceholderText = (parent) => {
|
|
34
|
-
if (!parent
|
|
33
|
+
const getParagraphPlaceholderText = (parent, node) => {
|
|
34
|
+
if (!parent) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if ((0, transform_1.isPullquoteElement)(parent) && !node.textContent.length) {
|
|
38
|
+
let otherParagraphHasContent = false;
|
|
39
|
+
parent.descendants((child) => {
|
|
40
|
+
if (child !== node && child.type === child.type.schema.nodes.paragraph) {
|
|
41
|
+
otherParagraphHasContent = true;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
if (otherParagraphHasContent) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
return 'Insert pull quote here';
|
|
48
|
+
}
|
|
49
|
+
if (parent.textContent.length) {
|
|
35
50
|
return;
|
|
36
51
|
}
|
|
37
52
|
if (parent.type === transform_1.schema.nodes.body) {
|
|
@@ -47,8 +62,11 @@ exports.default = () => new prosemirror_state_1.Plugin({
|
|
|
47
62
|
const decorations = [];
|
|
48
63
|
state.doc.descendants((node, pos, parent) => {
|
|
49
64
|
if (!node.isAtom && node.type.isBlock && node.childCount === 0) {
|
|
65
|
+
if (node.type === node.type.schema.nodes.attribution) {
|
|
66
|
+
decorations.push(prosemirror_view_1.Decoration.widget(pos + 1, placeholderWidget('Insert reference here')));
|
|
67
|
+
}
|
|
50
68
|
if (node.type === node.type.schema.nodes.paragraph) {
|
|
51
|
-
const text = getParagraphPlaceholderText(parent);
|
|
69
|
+
const text = getParagraphPlaceholderText(parent, node);
|
|
52
70
|
if (text) {
|
|
53
71
|
decorations.push(prosemirror_view_1.Decoration.widget(pos + 1, placeholderWidget(text)));
|
|
54
72
|
}
|
package/dist/cjs/versions.js
CHANGED
|
@@ -18,14 +18,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
19
19
|
const base_node_view_1 = require("./base_node_view");
|
|
20
20
|
class BlockView extends base_node_view_1.BaseNodeView {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
this.gutter = {};
|
|
24
|
+
}
|
|
21
25
|
initialise() {
|
|
22
26
|
this.createDOM();
|
|
23
27
|
this.createGutter('block-gutter', this.gutterButtons().filter(Boolean));
|
|
24
28
|
this.createElement();
|
|
25
|
-
this.createGutter('action-gutter', this.actionGutterButtons().filter(Boolean));
|
|
26
29
|
this.updateContents();
|
|
27
30
|
}
|
|
28
31
|
updateContents() {
|
|
32
|
+
this.createGutter('action-gutter', this.actionGutterButtons().filter(Boolean));
|
|
29
33
|
super.updateContents();
|
|
30
34
|
this.updateClasses();
|
|
31
35
|
this.updatePlaceholder();
|
|
@@ -58,13 +62,16 @@ class BlockView extends base_node_view_1.BaseNodeView {
|
|
|
58
62
|
this.dom.classList.add(`block-${this.node.type.name}`);
|
|
59
63
|
}
|
|
60
64
|
createGutter(className, buttons) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
if (this.gutter[className]) {
|
|
66
|
+
this.gutter[className].remove();
|
|
67
|
+
}
|
|
68
|
+
this.gutter[className] = document.createElement('div');
|
|
69
|
+
this.gutter[className].setAttribute('contenteditable', 'false');
|
|
70
|
+
this.gutter[className].classList.add(className);
|
|
64
71
|
for (const button of buttons) {
|
|
65
|
-
gutter.appendChild(button);
|
|
72
|
+
this.gutter[className].appendChild(button);
|
|
66
73
|
}
|
|
67
|
-
this.dom.appendChild(gutter);
|
|
74
|
+
this.dom.appendChild(this.gutter[className]);
|
|
68
75
|
}
|
|
69
76
|
gutterButtons() {
|
|
70
77
|
return [];
|
|
@@ -17,12 +17,8 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.EditableBlock = void 0;
|
|
19
19
|
const transform_1 = require("@manuscripts/transform");
|
|
20
|
-
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
21
20
|
const context_menu_1 = require("../lib/context-menu");
|
|
22
|
-
const
|
|
23
|
-
const hasParent = ($pos, type) => {
|
|
24
|
-
return !!(0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)($pos, type);
|
|
25
|
-
};
|
|
21
|
+
const utils_1 = require("../lib/utils");
|
|
26
22
|
const EditableBlock = (Base) => {
|
|
27
23
|
return class extends Base {
|
|
28
24
|
constructor() {
|
|
@@ -32,7 +28,7 @@ const EditableBlock = (Base) => {
|
|
|
32
28
|
};
|
|
33
29
|
}
|
|
34
30
|
gutterButtons() {
|
|
35
|
-
return [this.createAddButton(), this.createEditButton()].filter(isNotNull);
|
|
31
|
+
return [this.createAddButton(), this.createEditButton()].filter(utils_1.isNotNull);
|
|
36
32
|
}
|
|
37
33
|
actionGutterButtons() {
|
|
38
34
|
return [];
|
|
@@ -44,10 +40,10 @@ const EditableBlock = (Base) => {
|
|
|
44
40
|
return null;
|
|
45
41
|
}
|
|
46
42
|
const $pos = this.view.state.doc.resolve(this.getPos());
|
|
47
|
-
if (hasParent($pos, transform_1.schema.nodes.keywords)) {
|
|
43
|
+
if ((0, utils_1.hasParent)($pos, transform_1.schema.nodes.keywords)) {
|
|
48
44
|
return null;
|
|
49
45
|
}
|
|
50
|
-
const after = !hasParent($pos, transform_1.schema.nodes.bibliography_section);
|
|
46
|
+
const after = !(0, utils_1.hasParent)($pos, transform_1.schema.nodes.bibliography_section);
|
|
51
47
|
const button = document.createElement('a');
|
|
52
48
|
button.classList.add('add-block', context_menu_1.contextMenuBtnClass);
|
|
53
49
|
button.classList.add(after ? 'add-block-after' : 'add-block-before');
|
|
@@ -35,6 +35,7 @@ const react_1 = require("react");
|
|
|
35
35
|
const server_1 = require("react-dom/server");
|
|
36
36
|
const FigureDropdown_1 = require("../components/views/FigureDropdown");
|
|
37
37
|
const files_1 = require("../lib/files");
|
|
38
|
+
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
38
39
|
const view_1 = require("../lib/view");
|
|
39
40
|
const creators_1 = require("./creators");
|
|
40
41
|
const figure_1 = require("./figure");
|
|
@@ -49,10 +50,10 @@ var figurePositions;
|
|
|
49
50
|
class FigureEditableView extends figure_1.FigureView {
|
|
50
51
|
constructor() {
|
|
51
52
|
super(...arguments);
|
|
52
|
-
this.
|
|
53
|
-
this.
|
|
54
|
-
this.
|
|
55
|
-
};
|
|
53
|
+
this.upload = (file) => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const result = yield this.props.fileManagement.upload(file);
|
|
55
|
+
this.setSrc(result.id);
|
|
56
|
+
});
|
|
56
57
|
this.setSrc = (src) => {
|
|
57
58
|
const { tr } = this.view.state;
|
|
58
59
|
const pos = this.getPos();
|
|
@@ -168,14 +169,17 @@ class FigureEditableView extends figure_1.FigureView {
|
|
|
168
169
|
this.props.popper.show(this.positionMenuWrapper, (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu', 'position-menu']), 'left', false);
|
|
169
170
|
};
|
|
170
171
|
}
|
|
172
|
+
initialise() {
|
|
173
|
+
this.upload = this.upload.bind(this);
|
|
174
|
+
this.createDOM();
|
|
175
|
+
this.updateContents();
|
|
176
|
+
}
|
|
171
177
|
updateContents() {
|
|
172
|
-
var _a;
|
|
173
178
|
super.updateContents();
|
|
174
|
-
const
|
|
175
|
-
const src = attrs.src;
|
|
179
|
+
const src = this.node.attrs.src;
|
|
176
180
|
const files = this.props.getFiles();
|
|
177
181
|
const file = src && files.filter((f) => f.id === src)[0];
|
|
178
|
-
this.figurePosition = attrs.type;
|
|
182
|
+
this.figurePosition = this.node.attrs.type;
|
|
179
183
|
this.container.innerHTML = '';
|
|
180
184
|
const can = this.props.getCapabilities();
|
|
181
185
|
const link = file && this.props.fileManagement.previewLink(file);
|
|
@@ -184,37 +188,13 @@ class FigureEditableView extends figure_1.FigureView {
|
|
|
184
188
|
: file
|
|
185
189
|
? this.createUnsupportedFormat(file.name)
|
|
186
190
|
: this.createPlaceholder();
|
|
187
|
-
|
|
188
|
-
let handleUpload;
|
|
189
|
-
let handleReplace;
|
|
190
|
-
let handleDetach;
|
|
191
|
-
if (src) {
|
|
192
|
-
if (file) {
|
|
193
|
-
handleDownload = () => {
|
|
194
|
-
this.props.fileManagement.download(file);
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
handleDetach = () => {
|
|
198
|
-
this.setSrc('');
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
if (can.replaceFile) {
|
|
202
|
-
handleReplace = (file) => {
|
|
203
|
-
this.setSrc(file.id);
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
if (can.uploadFile) {
|
|
207
|
-
const upload = (file) => __awaiter(this, void 0, void 0, function* () {
|
|
208
|
-
const result = yield this.props.fileManagement.upload(file);
|
|
209
|
-
this.setSrc(result.id);
|
|
210
|
-
});
|
|
211
|
-
handleUpload = (0, figure_uploader_1.figureUploader)(upload);
|
|
191
|
+
if (can.uploadFile && !(0, track_changes_utils_1.isDeleted)(this.node)) {
|
|
212
192
|
const handlePlaceholderClick = (event) => {
|
|
213
193
|
const target = event.target;
|
|
214
194
|
if (target.dataset && target.dataset.action) {
|
|
215
195
|
return;
|
|
216
196
|
}
|
|
217
|
-
const triggerUpload = (0, figure_uploader_1.figureUploader)(upload);
|
|
197
|
+
const triggerUpload = (0, figure_uploader_1.figureUploader)(this.upload);
|
|
218
198
|
triggerUpload();
|
|
219
199
|
};
|
|
220
200
|
img.addEventListener('click', handlePlaceholderClick);
|
|
@@ -244,12 +224,46 @@ class FigureEditableView extends figure_1.FigureView {
|
|
|
244
224
|
img.addEventListener('drop', (e) => __awaiter(this, void 0, void 0, function* () {
|
|
245
225
|
if (e.dataTransfer && e.dataTransfer.files.length) {
|
|
246
226
|
e.preventDefault();
|
|
247
|
-
yield upload(e.dataTransfer.files[0]);
|
|
227
|
+
yield this.upload(e.dataTransfer.files[0]);
|
|
248
228
|
}
|
|
249
229
|
}));
|
|
250
230
|
}
|
|
251
231
|
this.container.innerHTML = '';
|
|
252
232
|
this.container.appendChild(img);
|
|
233
|
+
this.addTools();
|
|
234
|
+
}
|
|
235
|
+
addTools() {
|
|
236
|
+
this.manageReactTools();
|
|
237
|
+
this.container.appendChild(this.createPositionMenuWrapper());
|
|
238
|
+
}
|
|
239
|
+
manageReactTools() {
|
|
240
|
+
var _a;
|
|
241
|
+
let handleDownload;
|
|
242
|
+
let handleUpload;
|
|
243
|
+
let handleReplace;
|
|
244
|
+
let handleDetach;
|
|
245
|
+
const src = this.node.attrs.src;
|
|
246
|
+
const files = this.props.getFiles();
|
|
247
|
+
const file = src && files.filter((f) => f.id === src)[0];
|
|
248
|
+
const can = this.props.getCapabilities();
|
|
249
|
+
if (src) {
|
|
250
|
+
if (file) {
|
|
251
|
+
handleDownload = () => {
|
|
252
|
+
this.props.fileManagement.download(file);
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
handleDetach = () => {
|
|
256
|
+
this.setSrc('');
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
if (can.replaceFile) {
|
|
260
|
+
handleReplace = (file) => {
|
|
261
|
+
this.setSrc(file.id);
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
if (can.uploadFile) {
|
|
265
|
+
handleUpload = (0, figure_uploader_1.figureUploader)(this.upload);
|
|
266
|
+
}
|
|
253
267
|
(_a = this.reactTools) === null || _a === void 0 ? void 0 : _a.remove();
|
|
254
268
|
if (this.props.dispatch && this.props.theme) {
|
|
255
269
|
const files = this.props.getFiles();
|
|
@@ -265,7 +279,6 @@ class FigureEditableView extends figure_1.FigureView {
|
|
|
265
279
|
this.reactTools = (0, ReactSubView_1.default)(this.props, FigureDropdown_1.FigureOptions, componentProps, this.node, this.getPos, this.view);
|
|
266
280
|
this.dom.insertBefore(this.reactTools, this.dom.firstChild);
|
|
267
281
|
}
|
|
268
|
-
this.container.appendChild(this.createPositionMenuWrapper());
|
|
269
282
|
}
|
|
270
283
|
}
|
|
271
284
|
exports.FigureEditableView = FigureEditableView;
|
|
@@ -19,18 +19,51 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.PullquoteElementView = void 0;
|
|
22
|
+
const style_guide_1 = require("@manuscripts/style-guide");
|
|
23
|
+
const transform_1 = require("@manuscripts/transform");
|
|
24
|
+
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
22
25
|
const block_view_1 = __importDefault(require("./block_view"));
|
|
23
26
|
const creators_1 = require("./creators");
|
|
27
|
+
const ReactSubView_1 = __importDefault(require("./ReactSubView"));
|
|
24
28
|
class PullquoteElementView extends block_view_1.default {
|
|
25
29
|
constructor() {
|
|
26
30
|
super(...arguments);
|
|
27
31
|
this.elementType = 'aside';
|
|
32
|
+
this.ignoreMutation = () => true;
|
|
33
|
+
this.stopEvent = () => true;
|
|
28
34
|
this.createElement = () => {
|
|
29
35
|
this.contentDOM = document.createElement(this.elementType);
|
|
30
36
|
this.contentDOM.className = 'block';
|
|
31
37
|
this.contentDOM.classList.add('pullquote');
|
|
32
38
|
this.dom.appendChild(this.contentDOM);
|
|
33
39
|
};
|
|
40
|
+
this.actionGutterButtons = () => {
|
|
41
|
+
const contextMenu = this.addFigureContextMenu();
|
|
42
|
+
return contextMenu ? [contextMenu] : [];
|
|
43
|
+
};
|
|
44
|
+
this.addFigureContextMenu = () => {
|
|
45
|
+
const can = this.props.getCapabilities();
|
|
46
|
+
const componentProps = {
|
|
47
|
+
actions: [],
|
|
48
|
+
};
|
|
49
|
+
if (can.editArticle) {
|
|
50
|
+
componentProps.actions.push({
|
|
51
|
+
label: 'Add Image',
|
|
52
|
+
action: () => this.handleAddFigure(),
|
|
53
|
+
icon: 'AddFigure',
|
|
54
|
+
disabled: !!(0, prosemirror_utils_1.findChildrenByType)(this.node, transform_1.schema.nodes.quote_image)
|
|
55
|
+
.length,
|
|
56
|
+
});
|
|
57
|
+
this.contextMenu = (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu']);
|
|
58
|
+
return this.contextMenu;
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
handleAddFigure() {
|
|
64
|
+
const tr = this.view.state.tr;
|
|
65
|
+
tr.insert(this.getPos() + 1, transform_1.schema.nodes.quote_image.create());
|
|
66
|
+
this.view.dispatch(tr);
|
|
34
67
|
}
|
|
35
68
|
}
|
|
36
69
|
exports.PullquoteElementView = PullquoteElementView;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 Atypon Systems LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.QuoteImageEditableView = void 0;
|
|
19
|
+
const icons_1 = require("../icons");
|
|
20
|
+
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
21
|
+
const creators_1 = require("./creators");
|
|
22
|
+
const figure_editable_1 = require("./figure_editable");
|
|
23
|
+
class QuoteImageEditableView extends figure_editable_1.FigureEditableView {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
this.createPlaceholder = () => {
|
|
27
|
+
const element = document.createElement('div');
|
|
28
|
+
element.classList.add('figure', 'placeholder');
|
|
29
|
+
const instructions = document.createElement('div');
|
|
30
|
+
instructions.classList.add('instructions');
|
|
31
|
+
instructions.innerHTML = `${icons_1.plusIcon}<div>Drag or click here to upload image</div>`;
|
|
32
|
+
element.appendChild(instructions);
|
|
33
|
+
return element;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
createDOM() {
|
|
37
|
+
this.dom = document.createElement('figure');
|
|
38
|
+
this.container = document.createElement('div');
|
|
39
|
+
this.container.className = 'pullquote-figure';
|
|
40
|
+
this.container.contentEditable = 'false';
|
|
41
|
+
this.dom.appendChild(this.container);
|
|
42
|
+
}
|
|
43
|
+
addTools() {
|
|
44
|
+
if (!this.closeButton) {
|
|
45
|
+
const closeButton = document.createElement('button');
|
|
46
|
+
closeButton.innerHTML = icons_1.plusIcon;
|
|
47
|
+
closeButton.classList.add('figure-remove-button', 'button-reset');
|
|
48
|
+
closeButton.addEventListener('click', () => {
|
|
49
|
+
if (this.node.attrs.src) {
|
|
50
|
+
this.setSrc('');
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const { tr } = this.view.state;
|
|
54
|
+
tr.delete(this.getPos(), this.getPos() + this.node.nodeSize);
|
|
55
|
+
this.view.dispatch(tr);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
this.closeButton = closeButton;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
updateContents() {
|
|
62
|
+
super.updateContents();
|
|
63
|
+
if (!(0, track_changes_utils_1.isDeleted)(this.node)) {
|
|
64
|
+
this.container.appendChild(this.closeButton);
|
|
65
|
+
}
|
|
66
|
+
(0, track_changes_utils_1.addTrackChangesAttributes)(this.node.attrs, this.dom);
|
|
67
|
+
(0, track_changes_utils_1.addTrackChangesClassNames)(this.node.attrs, this.dom);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.QuoteImageEditableView = QuoteImageEditableView;
|
|
71
|
+
exports.default = (0, creators_1.createEditableNodeView)(QuoteImageEditableView);
|
package/dist/es/commands.js
CHANGED
|
@@ -159,6 +159,12 @@ export const createBlock = (nodeType, position, state, dispatch, attrs) => {
|
|
|
159
159
|
case schema.nodes.embed:
|
|
160
160
|
node = createEmbedElement(attrs);
|
|
161
161
|
break;
|
|
162
|
+
case state.schema.nodes.pullquote_element:
|
|
163
|
+
node = state.schema.nodes.pullquote_element.create(attrs, [
|
|
164
|
+
state.schema.nodes.paragraph.create({}),
|
|
165
|
+
state.schema.nodes.attribution.create({}),
|
|
166
|
+
]);
|
|
167
|
+
break;
|
|
162
168
|
default:
|
|
163
169
|
node = nodeType.createAndFill(attrs);
|
|
164
170
|
}
|
|
@@ -31,6 +31,7 @@ import paragraph from '../views/paragraph_editable';
|
|
|
31
31
|
import placeholder from '../views/placeholder';
|
|
32
32
|
import placeholderElement from '../views/placeholder_element_editable';
|
|
33
33
|
import pullquoteElement from '../views/pullquote_element_editable';
|
|
34
|
+
import quoteImage from '../views/quote_image_editable';
|
|
34
35
|
import section from '../views/section';
|
|
35
36
|
import sectionLabel from '../views/section_label';
|
|
36
37
|
import sectionTitle from '../views/section_title_editable';
|
|
@@ -45,6 +46,7 @@ export default (props, dispatch) => {
|
|
|
45
46
|
alt_titles: alt_titles_section(props),
|
|
46
47
|
bibliography_element: bibliographyElement(props, dispatch),
|
|
47
48
|
blockquote_element: blockquoteElement(props),
|
|
49
|
+
quote_image: quoteImage(props, dispatch),
|
|
48
50
|
box_element: boxElement(props),
|
|
49
51
|
citation: citation(props, dispatch),
|
|
50
52
|
cross_reference: crossReference(props, dispatch),
|
package/dist/es/icons.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AlertIcon, ArrowDownCircleIcon, DeleteIcon, EditIcon, LockIcon, ScrollIcon, SectionCategoryIcon, } from '@manuscripts/style-guide';
|
|
1
|
+
import { AlertIcon, ArrowDownCircleIcon, DeleteIcon, EditIcon, LockIcon, PlusIcon, ScrollIcon, SectionCategoryIcon, } from '@manuscripts/style-guide';
|
|
2
2
|
import { createElement } from 'react';
|
|
3
3
|
import { renderToStaticMarkup } from 'react-dom/server';
|
|
4
4
|
const renderIcon = (c) => renderToStaticMarkup(createElement(c));
|
|
@@ -9,3 +9,4 @@ export const editIcon = renderToStaticMarkup(createElement(EditIcon));
|
|
|
9
9
|
export const sectionCategoryIcon = renderIcon(SectionCategoryIcon);
|
|
10
10
|
export const scrollIcon = renderToStaticMarkup(createElement(ScrollIcon));
|
|
11
11
|
export const lockIcon = renderToStaticMarkup(createElement(LockIcon));
|
|
12
|
+
export const plusIcon = renderIcon(PlusIcon);
|
|
@@ -201,6 +201,27 @@ export class ContextMenu {
|
|
|
201
201
|
}
|
|
202
202
|
}));
|
|
203
203
|
}
|
|
204
|
+
if (type === schema.nodes.pullquote_element) {
|
|
205
|
+
const figure = findChildrenByType(this.node, schema.nodes.quote_image);
|
|
206
|
+
if (!figure.length) {
|
|
207
|
+
menu.appendChild(this.createMenuItem('Add Image', () => {
|
|
208
|
+
const tr = this.view.state.tr;
|
|
209
|
+
tr.insert(this.getPos() + 1, schema.nodes.quote_image.create());
|
|
210
|
+
this.view.dispatch(tr);
|
|
211
|
+
popper.destroy();
|
|
212
|
+
}));
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
const found = figure[0];
|
|
216
|
+
menu.appendChild(this.createMenuItem('Remove Image', () => {
|
|
217
|
+
const tr = this.view.state.tr;
|
|
218
|
+
console.log(found);
|
|
219
|
+
tr.delete(this.getPos() + 1 + found.pos, this.getPos() + 1 + found.pos + found.node.nodeSize);
|
|
220
|
+
this.view.dispatch(tr);
|
|
221
|
+
popper.destroy();
|
|
222
|
+
}));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
204
225
|
const commentTarget = this.getCommentTarget();
|
|
205
226
|
if (isCommentingAllowed(commentTarget.type)) {
|
|
206
227
|
menu.appendChild(this.createMenuSection((section) => {
|
package/dist/es/lib/utils.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { isElementNodeType, isSectionNodeType, schema, } from '@manuscripts/transform';
|
|
17
|
-
import { findChildrenByType, findParentNode } from 'prosemirror-utils';
|
|
17
|
+
import { findChildrenByType, findParentNode, findParentNodeOfTypeClosestToPos, } from 'prosemirror-utils';
|
|
18
18
|
import { fieldConfigMap } from '../components/references/ReferenceForm/config';
|
|
19
19
|
import { arrowDown } from '../icons';
|
|
20
20
|
import { getEditorProps } from '../plugins/editor-props';
|
|
@@ -90,6 +90,10 @@ export const createHeader = (typeName, text) => {
|
|
|
90
90
|
header.textContent = text;
|
|
91
91
|
return header;
|
|
92
92
|
};
|
|
93
|
+
export const isNotNull = (a) => a !== null;
|
|
94
|
+
export const hasParent = ($pos, type) => {
|
|
95
|
+
return !!findParentNodeOfTypeClosestToPos($pos, type);
|
|
96
|
+
};
|
|
93
97
|
export const shouldRenderField = (field, type) => {
|
|
94
98
|
var _a, _b;
|
|
95
99
|
return (_b = (_a = fieldConfigMap[type]) === null || _a === void 0 ? void 0 : _a.has(field)) !== null && _b !== void 0 ? _b : false;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { isFootnoteNode, isGeneralTableFootnoteNode, schema, } from '@manuscripts/transform';
|
|
16
|
+
import { isFootnoteNode, isGeneralTableFootnoteNode, isPullquoteElement, schema, } from '@manuscripts/transform';
|
|
17
17
|
import { Plugin, TextSelection } from 'prosemirror-state';
|
|
18
18
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
19
19
|
const placeholderWidget = (placeholder) => (view, getPos) => {
|
|
@@ -28,8 +28,23 @@ const placeholderWidget = (placeholder) => (view, getPos) => {
|
|
|
28
28
|
});
|
|
29
29
|
return element;
|
|
30
30
|
};
|
|
31
|
-
const getParagraphPlaceholderText = (parent) => {
|
|
32
|
-
if (!parent
|
|
31
|
+
const getParagraphPlaceholderText = (parent, node) => {
|
|
32
|
+
if (!parent) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (isPullquoteElement(parent) && !node.textContent.length) {
|
|
36
|
+
let otherParagraphHasContent = false;
|
|
37
|
+
parent.descendants((child) => {
|
|
38
|
+
if (child !== node && child.type === child.type.schema.nodes.paragraph) {
|
|
39
|
+
otherParagraphHasContent = true;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
if (otherParagraphHasContent) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
return 'Insert pull quote here';
|
|
46
|
+
}
|
|
47
|
+
if (parent.textContent.length) {
|
|
33
48
|
return;
|
|
34
49
|
}
|
|
35
50
|
if (parent.type === schema.nodes.body) {
|
|
@@ -45,8 +60,11 @@ export default () => new Plugin({
|
|
|
45
60
|
const decorations = [];
|
|
46
61
|
state.doc.descendants((node, pos, parent) => {
|
|
47
62
|
if (!node.isAtom && node.type.isBlock && node.childCount === 0) {
|
|
63
|
+
if (node.type === node.type.schema.nodes.attribution) {
|
|
64
|
+
decorations.push(Decoration.widget(pos + 1, placeholderWidget('Insert reference here')));
|
|
65
|
+
}
|
|
48
66
|
if (node.type === node.type.schema.nodes.paragraph) {
|
|
49
|
-
const text = getParagraphPlaceholderText(parent);
|
|
67
|
+
const text = getParagraphPlaceholderText(parent, node);
|
|
50
68
|
if (text) {
|
|
51
69
|
decorations.push(Decoration.widget(pos + 1, placeholderWidget(text)));
|
|
52
70
|
}
|
package/dist/es/versions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '2.8.
|
|
1
|
+
export const VERSION = '2.8.49';
|
|
2
2
|
export const MATHJAX_VERSION = '3.2.2';
|