@manuscripts/body-editor 1.7.28 → 1.7.29-LEAN-3321-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/assets.js +47 -1
- package/dist/cjs/components/authors/AuthorList.js +3 -6
- package/dist/cjs/components/authors/DraggableAuthor.js +12 -24
- package/dist/cjs/components/outline/DraggableTree.js +94 -157
- package/dist/cjs/components/outline/ManuscriptOutline.js +5 -8
- package/dist/cjs/components/outline/Outline.js +27 -35
- package/dist/cjs/components/views/DeleteFootnoteDialog.js +45 -0
- package/dist/cjs/configs/editor-plugins.js +1 -1
- package/dist/cjs/index.js +1 -3
- package/dist/cjs/lib/context-menu.js +10 -4
- package/dist/cjs/lib/dnd.js +10 -0
- package/dist/cjs/plugins/footnotes/index.js +102 -1
- package/dist/es/assets.js +46 -0
- package/dist/es/components/authors/AuthorList.js +3 -6
- package/dist/es/components/authors/DraggableAuthor.js +12 -24
- package/dist/es/components/outline/DraggableTree.js +94 -158
- package/dist/es/components/outline/ManuscriptOutline.js +5 -8
- package/dist/es/components/outline/Outline.js +26 -34
- package/dist/es/components/views/DeleteFootnoteDialog.js +18 -0
- package/dist/es/configs/editor-plugins.js +1 -1
- package/dist/es/index.js +0 -1
- package/dist/es/lib/context-menu.js +10 -4
- package/dist/es/lib/dnd.js +6 -0
- package/dist/es/plugins/footnotes/index.js +101 -3
- package/dist/types/assets.d.ts +1 -0
- package/dist/types/components/outline/DraggableTree.d.ts +10 -46
- package/dist/types/components/outline/ManuscriptOutline.d.ts +4 -6
- package/dist/types/components/outline/Outline.d.ts +1 -5
- package/dist/types/components/views/DeleteFootnoteDialog.d.ts +7 -0
- package/dist/types/configs/editor-plugins.d.ts +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/lib/dnd.d.ts +3 -0
- package/dist/types/plugins/footnotes/index.d.ts +2 -1
- package/package.json +6 -6
- package/styles/Editor.css +42 -4
- package/dist/cjs/components/outline/OutlineManuscript.js +0 -34
- package/dist/es/components/outline/OutlineManuscript.js +0 -27
- package/dist/types/components/outline/OutlineManuscript.d.ts +0 -25
package/dist/cjs/assets.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.alertIcon = exports.editAttrsTrackingIcon = exports.commentIcon = exports.editIcon = void 0;
|
|
18
|
+
exports.deleteIcon = exports.alertIcon = exports.editAttrsTrackingIcon = exports.commentIcon = exports.editIcon = void 0;
|
|
19
19
|
exports.editIcon = `
|
|
20
20
|
<svg
|
|
21
21
|
width="14"
|
|
@@ -118,3 +118,49 @@ exports.alertIcon = `
|
|
|
118
118
|
/>
|
|
119
119
|
</svg>
|
|
120
120
|
`;
|
|
121
|
+
exports.deleteIcon = `
|
|
122
|
+
<svg
|
|
123
|
+
width="13"
|
|
124
|
+
height="15"
|
|
125
|
+
viewBox="0 0 13 15"
|
|
126
|
+
fill="none"
|
|
127
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
128
|
+
>
|
|
129
|
+
<path
|
|
130
|
+
fill-rule="evenodd"
|
|
131
|
+
clip-rule="evenodd"
|
|
132
|
+
d="M2.00001 3C2 3.00135 2 3.00269 2 3.00404V13.004C2 13.5563 2.44772 14.004 3 14.004H10C10.5523 14.004 11 13.5563 11 13.004V3.00404C11 3.00269 11 3.00135 11 3C11.5978 3.34581 12 3.99215 12 4.73244V13.004C12 14.1086 11.1046 15.004 10 15.004H3C1.89543 15.004 1 14.1086 1 13.004V4.73244C1 3.99215 1.4022 3.34581 2.00001 3Z"
|
|
133
|
+
fill="#C9C9C9"
|
|
134
|
+
/>
|
|
135
|
+
<path
|
|
136
|
+
fill-rule="evenodd"
|
|
137
|
+
clip-rule="evenodd"
|
|
138
|
+
d="M4.5 0C3.67157 0 3 0.671573 3 1.5V3.5C3 4.32843 3.67157 5 4.5 5H8.5C9.32843 5 10 4.32843 10 3.5V1.5C10 0.671573 9.32843 0 8.5 0H4.5ZM9 1.5C9 1.22386 8.77614 1 8.5 1H4.5C4.22386 1 4 1.22386 4 1.5C4 1.77614 4.22386 2 4.5 2H8.5C8.77614 2 9 1.77614 9 1.5Z"
|
|
139
|
+
fill="#C9C9C9"
|
|
140
|
+
/>
|
|
141
|
+
<rect
|
|
142
|
+
y="2"
|
|
143
|
+
width="13"
|
|
144
|
+
height="3"
|
|
145
|
+
rx="1.5"
|
|
146
|
+
fill="#C9C9C9"
|
|
147
|
+
/>
|
|
148
|
+
<path
|
|
149
|
+
fill-rule="evenodd"
|
|
150
|
+
clip-rule="evenodd"
|
|
151
|
+
d="M8 7.5C8 7.22386 8.22386 7 8.5 7C8.77614 7 9 7.22386 9 7.5V11.5C9 11.7761 8.77614 12 8.5 12C8.22386 12 8 11.7761 8 11.5V7.5Z"
|
|
152
|
+
fill="#C9C9C9"
|
|
153
|
+
/>
|
|
154
|
+
<path
|
|
155
|
+
fill-rule="evenodd"
|
|
156
|
+
clip-rule="evenodd"
|
|
157
|
+
d="M4 7.5C4 7.22386 4.22386 7 4.5 7C4.77614 7 5 7.22386 5 7.5V11.5C5 11.7761 4.77614 12 4.5 12C4.22386 12 4 11.7761 4 11.5V7.5Z"
|
|
158
|
+
fill="#C9C9C9"
|
|
159
|
+
/>
|
|
160
|
+
<path
|
|
161
|
+
fill-rule="evenodd"
|
|
162
|
+
clip-rule="evenodd"
|
|
163
|
+
d="M11.5 3C11.7761 3 12 3.22386 12 3.5C12 3.77614 11.7761 4 11.5 4L1.5 4C1.22386 4 1 3.77614 1 3.5C1 3.22386 1.22386 3 1.5 3L11.5 3Z"
|
|
164
|
+
fill="white"
|
|
165
|
+
/>
|
|
166
|
+
</svg>`;
|
|
@@ -19,7 +19,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.AuthorList = void 0;
|
|
22
|
-
const style_guide_1 = require("@manuscripts/style-guide");
|
|
23
22
|
const react_1 = __importDefault(require("react"));
|
|
24
23
|
const react_dnd_1 = require("react-dnd");
|
|
25
24
|
const react_dnd_html5_backend_1 = require("react-dnd-html5-backend");
|
|
@@ -31,10 +30,8 @@ const AuthorListContainer = styled_components_1.default.div `
|
|
|
31
30
|
`;
|
|
32
31
|
const AuthorList = ({ author, authors, onSelect, moveAuthor, }) => {
|
|
33
32
|
return (react_1.default.createElement(react_dnd_1.DndProvider, { backend: react_dnd_html5_backend_1.HTML5Backend },
|
|
34
|
-
react_1.default.createElement(AuthorListContainer, null,
|
|
35
|
-
react_1.default.createElement(
|
|
36
|
-
|
|
37
|
-
return (react_1.default.createElement(DraggableAuthor_1.DraggableAuthor, { key: a.id, author: a, isSelected: a.id === (author === null || author === void 0 ? void 0 : author.id), onClick: () => onSelect(a), moveAuthor: moveAuthor }));
|
|
38
|
-
}))));
|
|
33
|
+
react_1.default.createElement(AuthorListContainer, null, authors.map((a) => {
|
|
34
|
+
return (react_1.default.createElement(DraggableAuthor_1.DraggableAuthor, { key: a.id, author: a, isSelected: a.id === (author === null || author === void 0 ? void 0 : author.id), onClick: () => onSelect(a), moveAuthor: moveAuthor }));
|
|
35
|
+
}))));
|
|
39
36
|
};
|
|
40
37
|
exports.AuthorList = AuthorList;
|
|
@@ -49,6 +49,7 @@ const react_1 = __importStar(require("react"));
|
|
|
49
49
|
const react_dnd_1 = require("react-dnd");
|
|
50
50
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
51
51
|
const authors_1 = require("../../lib/authors");
|
|
52
|
+
const dnd_1 = require("../../lib/dnd");
|
|
52
53
|
const AuthorContainer = styled_components_1.default.div `
|
|
53
54
|
padding: ${(props) => props.theme.grid.unit * 2}px;
|
|
54
55
|
display: flex;
|
|
@@ -107,26 +108,12 @@ const AuthorName = styled_components_1.default.div `
|
|
|
107
108
|
const DragHandle = (0, styled_components_1.default)(VerticalEllipsis_1.default) `
|
|
108
109
|
cursor: move;
|
|
109
110
|
`;
|
|
110
|
-
const BEFORE = {
|
|
111
|
-
id: 'before',
|
|
112
|
-
diff: -0.5,
|
|
113
|
-
};
|
|
114
|
-
const AFTER = {
|
|
115
|
-
id: 'after',
|
|
116
|
-
diff: 0.5,
|
|
117
|
-
};
|
|
118
|
-
const getDropPosition = (element, monitor) => {
|
|
119
|
-
const rect = element.getBoundingClientRect();
|
|
120
|
-
const middle = (rect.bottom - rect.top) / 2;
|
|
121
|
-
const cursor = monitor.getClientOffset();
|
|
122
|
-
return cursor.y > middle + rect.top ? AFTER : BEFORE;
|
|
123
|
-
};
|
|
124
111
|
const DraggableAuthor = ({ author, isSelected, onClick, moveAuthor, }) => {
|
|
125
|
-
const [
|
|
112
|
+
const [dropSide, setDropSide] = (0, react_1.useState)();
|
|
126
113
|
const ref = (0, react_1.useRef)(null);
|
|
127
114
|
const [{ isDragging }, dragRef] = (0, react_dnd_1.useDrag)({
|
|
115
|
+
type: 'author',
|
|
128
116
|
item: {
|
|
129
|
-
type: 'author',
|
|
130
117
|
author,
|
|
131
118
|
},
|
|
132
119
|
collect: (monitor) => ({
|
|
@@ -135,29 +122,30 @@ const DraggableAuthor = ({ author, isSelected, onClick, moveAuthor, }) => {
|
|
|
135
122
|
});
|
|
136
123
|
const [{ isOver }, dropRef] = (0, react_dnd_1.useDrop)({
|
|
137
124
|
accept: 'author',
|
|
138
|
-
collect: (monitor) => ({
|
|
139
|
-
isOver: monitor.isOver(),
|
|
140
|
-
}),
|
|
141
125
|
hover: (item, monitor) => {
|
|
142
126
|
if (!ref.current) {
|
|
143
127
|
return;
|
|
144
128
|
}
|
|
145
|
-
const
|
|
146
|
-
|
|
129
|
+
const side = (0, dnd_1.getDropSide)(ref.current, monitor);
|
|
130
|
+
setDropSide(side);
|
|
147
131
|
},
|
|
148
132
|
drop: (item, monitor) => {
|
|
149
133
|
if (!ref.current) {
|
|
150
134
|
return;
|
|
151
135
|
}
|
|
152
|
-
const
|
|
136
|
+
const side = (0, dnd_1.getDropSide)(ref.current, monitor);
|
|
153
137
|
const from = item.author.priority;
|
|
154
138
|
const to = author.priority;
|
|
155
|
-
|
|
139
|
+
const diff = side === 'before' ? -0.5 : 0.5;
|
|
140
|
+
moveAuthor(from, to + diff);
|
|
156
141
|
},
|
|
142
|
+
collect: (monitor) => ({
|
|
143
|
+
isOver: monitor.isOver(),
|
|
144
|
+
}),
|
|
157
145
|
});
|
|
158
146
|
dragRef(dropRef(ref));
|
|
159
147
|
const dragClass = isDragging ? 'dragging' : '';
|
|
160
|
-
const dropClass = isOver &&
|
|
148
|
+
const dropClass = isOver && dropSide ? `drop-${dropSide}` : '';
|
|
161
149
|
const activeClass = isSelected ? 'active' : '';
|
|
162
150
|
return (react_1.default.createElement(AuthorContainer, { ref: ref, className: `${dragClass} ${dropClass} ${activeClass}`, onClick: onClick },
|
|
163
151
|
react_1.default.createElement(AvatarContainer, null,
|
|
@@ -23,13 +23,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.buildTree = void 0;
|
|
26
|
+
exports.DraggableTree = exports.buildTree = void 0;
|
|
27
27
|
const transform_1 = require("@manuscripts/transform");
|
|
28
28
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
29
|
-
const
|
|
29
|
+
const react_1 = __importStar(require("react"));
|
|
30
30
|
const react_dnd_1 = require("react-dnd");
|
|
31
|
-
const react_dom_1 = require("react-dom");
|
|
32
31
|
const context_menu_1 = require("../../lib/context-menu");
|
|
32
|
+
const dnd_1 = require("../../lib/dnd");
|
|
33
33
|
const track_changes_utils_1 = require("../../lib/track-changes-utils");
|
|
34
34
|
const node_type_icons_1 = require("../../node-type-icons");
|
|
35
35
|
const Outline_1 = require("./Outline");
|
|
@@ -56,11 +56,10 @@ const isChildrenExcluded = (nodeType) => {
|
|
|
56
56
|
const isManuscriptNode = (node) => {
|
|
57
57
|
return (node === null || node === void 0 ? void 0 : node.type) === transform_1.schema.nodes.manuscript;
|
|
58
58
|
};
|
|
59
|
-
const buildTree = ({ node, pos, index,
|
|
59
|
+
const buildTree = ({ node, pos, index, parent, }) => {
|
|
60
60
|
const items = [];
|
|
61
61
|
const startPos = pos + 1;
|
|
62
62
|
const endPos = pos + node.nodeSize;
|
|
63
|
-
const isSelected = selected ? node.attrs.id === selected.node.attrs.id : false;
|
|
64
63
|
if (!isChildrenExcluded(node.type)) {
|
|
65
64
|
node.forEach((childNode, offset, childIndex) => {
|
|
66
65
|
if (isExcluded(childNode.type)) {
|
|
@@ -73,172 +72,110 @@ const buildTree = ({ node, pos, index, selected, parent, }) => {
|
|
|
73
72
|
node: childNode,
|
|
74
73
|
pos: startPos + offset,
|
|
75
74
|
index: childIndex,
|
|
76
|
-
selected,
|
|
77
75
|
parent: node,
|
|
78
76
|
}));
|
|
79
77
|
}
|
|
80
78
|
});
|
|
81
79
|
}
|
|
82
|
-
return { node, index, items, pos, endPos, parent
|
|
80
|
+
return { node, index, items, pos, endPos, parent };
|
|
83
81
|
};
|
|
84
82
|
exports.buildTree = buildTree;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
83
|
+
const DraggableTree = ({ tree, view, depth, can, }) => {
|
|
84
|
+
const [dropSide, setDropSide] = (0, react_1.useState)();
|
|
85
|
+
const [isOpen, setOpen] = (0, react_1.useState)(depth === 0);
|
|
86
|
+
const ref = (0, react_1.useRef)(null);
|
|
87
|
+
const { node, items, parent } = tree;
|
|
88
|
+
const itemText = (node) => {
|
|
89
|
+
const text = (0, transform_1.nodeTitle)(node);
|
|
90
|
+
if (text) {
|
|
91
|
+
return text.trim();
|
|
92
|
+
}
|
|
93
|
+
const placeholder = (0, transform_1.nodeTitlePlaceholder)(node.type);
|
|
94
|
+
return react_1.default.createElement(Outline_1.OutlineItemPlaceholder, null, placeholder);
|
|
95
|
+
};
|
|
96
|
+
const toggleOpen = () => {
|
|
97
|
+
setOpen(!isOpen);
|
|
98
|
+
};
|
|
99
|
+
const [{ isDragging }, dragRef] = (0, react_dnd_1.useDrag)({
|
|
100
|
+
type: 'outline',
|
|
101
|
+
item: tree,
|
|
102
|
+
canDrag: () => {
|
|
103
|
+
return depth !== 0;
|
|
104
|
+
},
|
|
105
|
+
collect: (monitor) => ({
|
|
106
|
+
isDragging: monitor.isDragging(),
|
|
107
|
+
}),
|
|
108
|
+
});
|
|
109
|
+
const [{ isOver }, dropRef] = (0, react_dnd_1.useDrop)({
|
|
110
|
+
accept: 'outline',
|
|
111
|
+
canDrop(item, monitor) {
|
|
112
|
+
if (!ref.current) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
if (!tree.parent) {
|
|
116
|
+
return false;
|
|
108
117
|
}
|
|
109
|
-
|
|
110
|
-
return React.createElement(Outline_1.OutlineItemPlaceholder, null, placeholder);
|
|
111
|
-
};
|
|
112
|
-
this.handleContextMenu = (event) => {
|
|
113
|
-
event.preventDefault();
|
|
114
|
-
event.stopPropagation();
|
|
115
|
-
if (!this.props.editArticle) {
|
|
118
|
+
if (item.node.attrs.id === tree.node.attrs.id) {
|
|
116
119
|
return false;
|
|
117
120
|
}
|
|
118
|
-
|
|
119
|
-
if (!menu) {
|
|
121
|
+
if (item.pos <= tree.pos && item.endPos >= tree.endPos) {
|
|
120
122
|
return false;
|
|
121
123
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
const side = (0, dnd_1.getDropSide)(ref.current, monitor);
|
|
125
|
+
const index = side === 'before' ? tree.index : tree.index + 1;
|
|
126
|
+
return tree.parent.canReplace(index, index, prosemirror_model_1.Fragment.from(item.node));
|
|
127
|
+
},
|
|
128
|
+
hover(item, monitor) {
|
|
129
|
+
if (!ref.current || !monitor.canDrop()) {
|
|
130
|
+
return;
|
|
128
131
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
React.createElement(Outline_1.OutlineItemLink, { to: `#${node.attrs.id || ''}` },
|
|
155
|
-
connectDragPreview(React.createElement("span", { style: {
|
|
156
|
-
display: 'inline-flex',
|
|
157
|
-
alignItems: 'center',
|
|
158
|
-
} },
|
|
159
|
-
React.createElement(Outline_1.OutlineItemIcon, null, (0, node_type_icons_1.nodeTypeIcon)(node.type)))),
|
|
160
|
-
React.createElement(Outline_1.OutlineItemLinkText, { className: `outline-text-${node.type.name} ${isDeletedItem && 'deleted'}` }, this.itemText(node)))))),
|
|
161
|
-
items.length ? (React.createElement("div", { style: {
|
|
162
|
-
display: open || isTop ? '' : 'none',
|
|
163
|
-
} }, items.map((subtree) => (React.createElement(DraggableTree, Object.assign({}, this.props, { key: subtree.node.attrs.id, tree: subtree, view: view, depth: isTop ? depth : depth + 1 })))))) : (''),
|
|
164
|
-
React.createElement(Outline_1.OutlineDropPreview, { depth: depth, style: this.bottomPreviewStyles(mightDrop, dragPosition) }))));
|
|
132
|
+
const side = (0, dnd_1.getDropSide)(ref.current, monitor);
|
|
133
|
+
setDropSide(side);
|
|
134
|
+
},
|
|
135
|
+
drop(item, monitor) {
|
|
136
|
+
if (!ref.current || !view) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const side = (0, dnd_1.getDropSide)(ref.current, monitor);
|
|
140
|
+
const pos = side === 'before' ? tree.pos - 1 : tree.endPos - 1;
|
|
141
|
+
let sourcePos = item.pos - 1;
|
|
142
|
+
const node = item.node.type.schema.nodes[item.node.type.name].create(Object.assign(Object.assign({}, item.node.attrs), { id: '' }), item.node.content);
|
|
143
|
+
const tr = view.state.tr.insert(pos, node);
|
|
144
|
+
sourcePos = tr.mapping.map(sourcePos);
|
|
145
|
+
tr.delete(sourcePos, sourcePos + item.node.nodeSize);
|
|
146
|
+
view.dispatch(tr);
|
|
147
|
+
},
|
|
148
|
+
collect: (monitor) => ({
|
|
149
|
+
isOver: monitor.isOver({ shallow: true }),
|
|
150
|
+
}),
|
|
151
|
+
});
|
|
152
|
+
const isDeletedItem = (0, track_changes_utils_1.isDeleted)(node);
|
|
153
|
+
const isRejectedItem = (0, track_changes_utils_1.isRejectedInsert)(node);
|
|
154
|
+
const isTop = isManuscriptNode(parent);
|
|
155
|
+
if (isRejectedItem) {
|
|
156
|
+
return null;
|
|
165
157
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
tree: props.tree,
|
|
171
|
-
};
|
|
172
|
-
},
|
|
173
|
-
canDrag(props) {
|
|
174
|
-
return props.editArticle && !!props.tree.parent;
|
|
175
|
-
},
|
|
176
|
-
}, (connect, monitor) => ({
|
|
177
|
-
connectDragSource: connect.dragSource(),
|
|
178
|
-
connectDragPreview: connect.dragPreview(),
|
|
179
|
-
isDragging: monitor.isDragging(),
|
|
180
|
-
canDrag: monitor.canDrag(),
|
|
181
|
-
item: monitor.getItem(),
|
|
182
|
-
}));
|
|
183
|
-
const dropTarget = (0, react_dnd_1.DropTarget)('outline', {
|
|
184
|
-
canDrop(props, monitor) {
|
|
185
|
-
const item = monitor.getItem();
|
|
186
|
-
if (!props.tree.parent) {
|
|
187
|
-
return false;
|
|
188
|
-
}
|
|
189
|
-
if (item.tree.node.attrs.id === props.tree.node.attrs.id) {
|
|
190
|
-
return false;
|
|
191
|
-
}
|
|
192
|
-
if (item.tree.pos <= props.tree.pos &&
|
|
193
|
-
item.tree.endPos >= props.tree.endPos) {
|
|
158
|
+
const handleContextMenu = (e) => {
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
e.stopPropagation();
|
|
161
|
+
if (!(can === null || can === void 0 ? void 0 : can.editArticle)) {
|
|
194
162
|
return false;
|
|
195
163
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
},
|
|
199
|
-
hover(props, monitor, component) {
|
|
200
|
-
if (monitor.isOver({ shallow: true })) {
|
|
201
|
-
const offset = monitor.getClientOffset();
|
|
202
|
-
if (offset) {
|
|
203
|
-
const item = monitor.getItem();
|
|
204
|
-
const node = (0, react_dom_1.findDOMNode)(component);
|
|
205
|
-
const { bottom, top } = node.getBoundingClientRect();
|
|
206
|
-
const verticalMiddle = (bottom - top) / 2;
|
|
207
|
-
const verticalHover = offset.y - top;
|
|
208
|
-
item.position = verticalHover < verticalMiddle ? 'before' : 'after';
|
|
209
|
-
component.setState({
|
|
210
|
-
dragPosition: item.position,
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
},
|
|
215
|
-
drop(props, monitor) {
|
|
216
|
-
var _a;
|
|
217
|
-
if (monitor.didDrop()) {
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
if (!props.view) {
|
|
221
|
-
return;
|
|
164
|
+
if (!view) {
|
|
165
|
+
return null;
|
|
222
166
|
}
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
connectDropTarget: connect.dropTarget(),
|
|
239
|
-
isOverCurrent: monitor.isOver({ shallow: true }),
|
|
240
|
-
canDrop: monitor.canDrop(),
|
|
241
|
-
itemType: monitor.getItemType(),
|
|
242
|
-
}));
|
|
243
|
-
const DraggableTree = dragSource(dropTarget(Tree));
|
|
244
|
-
exports.default = DraggableTree;
|
|
167
|
+
const menu = new context_menu_1.ContextMenu(tree.node, view, () => tree.pos - 1);
|
|
168
|
+
menu.showEditMenu(e.currentTarget);
|
|
169
|
+
};
|
|
170
|
+
dragRef(dropRef(ref));
|
|
171
|
+
const dragClass = isDragging ? 'dragging' : '';
|
|
172
|
+
const dropClass = isOver && dropSide ? `drop-${dropSide}` : '';
|
|
173
|
+
return (react_1.default.createElement(Outline_1.Outline, { ref: ref, className: `${dragClass} ${dropClass}` },
|
|
174
|
+
!isTop && (react_1.default.createElement(Outline_1.OutlineItem, { depth: depth, onContextMenu: handleContextMenu },
|
|
175
|
+
items.length ? (react_1.default.createElement(Outline_1.OutlineItemArrow, { onClick: toggleOpen }, isOpen ? (react_1.default.createElement(Outline_1.StyledTriangleExpanded, null)) : (react_1.default.createElement(Outline_1.StyledTriangleCollapsed, null)))) : (react_1.default.createElement(Outline_1.OutlineItemNoArrow, null)),
|
|
176
|
+
react_1.default.createElement(Outline_1.OutlineItemLink, { to: `#${node.attrs.id}` },
|
|
177
|
+
react_1.default.createElement(Outline_1.OutlineItemIcon, null, (0, node_type_icons_1.nodeTypeIcon)(node.type)),
|
|
178
|
+
react_1.default.createElement(Outline_1.OutlineItemLinkText, { className: `outline-text-${node.type.name} ${isDeletedItem && 'deleted'}` }, itemText(node))))),
|
|
179
|
+
items.length ? (react_1.default.createElement("div", { className: `subtree ${isOpen ? '' : 'collapsed'}` }, items.map((subtree) => (react_1.default.createElement(exports.DraggableTree, { key: subtree.node.attrs.id, tree: subtree, view: view, depth: !tree.parent ? depth : depth + 1, can: can }))))) : null));
|
|
180
|
+
};
|
|
181
|
+
exports.DraggableTree = DraggableTree;
|
|
@@ -41,27 +41,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
41
41
|
exports.ManuscriptOutline = void 0;
|
|
42
42
|
const react_1 = __importStar(require("react"));
|
|
43
43
|
const use_debounce_1 = require("../hooks/use-debounce");
|
|
44
|
-
const DraggableTree_1 =
|
|
44
|
+
const DraggableTree_1 = require("./DraggableTree");
|
|
45
45
|
const ManuscriptOutline = (props) => {
|
|
46
|
-
var _a;
|
|
47
46
|
const [values, setValues] = (0, react_1.useState)();
|
|
48
47
|
const debouncedProps = (0, use_debounce_1.useDebounce)(props, 500);
|
|
49
48
|
(0, react_1.useEffect)(() => {
|
|
50
|
-
|
|
51
|
-
const { doc, view, selected } = debouncedProps;
|
|
49
|
+
const { doc, view } = debouncedProps;
|
|
52
50
|
if (doc) {
|
|
53
51
|
const tree = (0, DraggableTree_1.buildTree)({
|
|
54
52
|
node: doc,
|
|
55
53
|
pos: 0,
|
|
56
54
|
index: 0,
|
|
57
|
-
selected,
|
|
58
55
|
});
|
|
59
|
-
setValues({ tree, view,
|
|
56
|
+
setValues({ tree, view, can: props.can });
|
|
60
57
|
}
|
|
61
58
|
else {
|
|
62
59
|
setValues(undefined);
|
|
63
60
|
}
|
|
64
|
-
}, [debouncedProps,
|
|
65
|
-
return values ? react_1.default.createElement(DraggableTree_1.
|
|
61
|
+
}, [debouncedProps, props.can]);
|
|
62
|
+
return values ? react_1.default.createElement(DraggableTree_1.DraggableTree, Object.assign({}, values, { depth: 0 })) : null;
|
|
66
63
|
};
|
|
67
64
|
exports.ManuscriptOutline = ManuscriptOutline;
|
|
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.OutlineItemPlaceholder = exports.
|
|
21
|
+
exports.OutlineItemPlaceholder = exports.Outline = exports.OutlineItemLinkText = exports.OutlineItemLink = exports.OutlineItemNoArrow = exports.OutlineItemArrow = exports.StyledTriangleExpanded = exports.StyledTriangleCollapsed = exports.OutlineItem = exports.OutlineItemIcon = void 0;
|
|
22
22
|
const TriangleCollapsed_1 = __importDefault(require("@manuscripts/assets/react/TriangleCollapsed"));
|
|
23
23
|
const TriangleExpanded_1 = __importDefault(require("@manuscripts/assets/react/TriangleExpanded"));
|
|
24
24
|
const react_router_dom_1 = require("react-router-dom");
|
|
@@ -34,12 +34,6 @@ exports.OutlineItemIcon = styled_components_1.default.span `
|
|
|
34
34
|
`;
|
|
35
35
|
exports.OutlineItem = styled_components_1.default.div `
|
|
36
36
|
align-items: center;
|
|
37
|
-
border-bottom: 1px solid transparent;
|
|
38
|
-
border-top: 1px solid transparent;
|
|
39
|
-
background: ${(props) => props.isSelected ? props.theme.colors.background.fifth : 'transparent'};
|
|
40
|
-
border-color: ${(props) => props.isSelected
|
|
41
|
-
? props.theme.colors.border.primary
|
|
42
|
-
: props.theme.colors.background.fifth};
|
|
43
37
|
color: ${(props) => props.theme.colors.text.primary};
|
|
44
38
|
box-sizing: border-box;
|
|
45
39
|
cursor: pointer;
|
|
@@ -59,14 +53,6 @@ exports.OutlineItem = styled_components_1.default.div `
|
|
|
59
53
|
background: ${(props) => props.theme.colors.background.fifth};
|
|
60
54
|
}
|
|
61
55
|
`;
|
|
62
|
-
exports.Outline = styled_components_1.default.div `
|
|
63
|
-
font-size: ${(props) => props.theme.font.size.medium};
|
|
64
|
-
position: relative;
|
|
65
|
-
|
|
66
|
-
& .outline-text-title {
|
|
67
|
-
font-size: ${(props) => props.theme.font.size.large};
|
|
68
|
-
}
|
|
69
|
-
`;
|
|
70
56
|
exports.StyledTriangleCollapsed = (0, styled_components_1.default)(TriangleCollapsed_1.default) ``;
|
|
71
57
|
exports.StyledTriangleExpanded = (0, styled_components_1.default)(TriangleExpanded_1.default) ``;
|
|
72
58
|
exports.OutlineItemArrow = styled_components_1.default.button `
|
|
@@ -92,26 +78,6 @@ exports.OutlineItemNoArrow = styled_components_1.default.span `
|
|
|
92
78
|
width: ${(props) => props.theme.grid.unit * 5}px;
|
|
93
79
|
flex-shrink: 0;
|
|
94
80
|
`;
|
|
95
|
-
exports.OutlineDropPreview = styled_components_1.default.div `
|
|
96
|
-
width: 100%;
|
|
97
|
-
background: #65a3ff;
|
|
98
|
-
height: 1px;
|
|
99
|
-
position: absolute;
|
|
100
|
-
margin-left: ${(props) => 30 + props.depth * 20}px;
|
|
101
|
-
z-index: 2;
|
|
102
|
-
|
|
103
|
-
&:before {
|
|
104
|
-
content: '';
|
|
105
|
-
display: inline-block;
|
|
106
|
-
width: ${(props) => props.theme.grid.unit}px;
|
|
107
|
-
height: ${(props) => props.theme.grid.unit}px;
|
|
108
|
-
border: 1px solid ${(props) => props.theme.colors.brand.default}
|
|
109
|
-
border-radius: ${(props) => props.theme.grid.radius.small};
|
|
110
|
-
position: absolute;
|
|
111
|
-
top: -${(props) => props.theme.grid.unit}px;
|
|
112
|
-
left: -6px;
|
|
113
|
-
}
|
|
114
|
-
`;
|
|
115
81
|
exports.OutlineItemLink = (0, styled_components_1.default)(react_router_dom_1.Link) `
|
|
116
82
|
flex: 1;
|
|
117
83
|
display: inline-flex;
|
|
@@ -120,6 +86,8 @@ exports.OutlineItemLink = (0, styled_components_1.default)(react_router_dom_1.Li
|
|
|
120
86
|
color: inherit;
|
|
121
87
|
text-decoration: none;
|
|
122
88
|
height: 100%;
|
|
89
|
+
border-bottom: 1px solid transparent;
|
|
90
|
+
border-top: 1px solid transparent;
|
|
123
91
|
|
|
124
92
|
&:focus,
|
|
125
93
|
&:active {
|
|
@@ -137,4 +105,28 @@ exports.OutlineItemLinkText = styled_components_1.default.span `
|
|
|
137
105
|
text-decoration: line-through;
|
|
138
106
|
}
|
|
139
107
|
`;
|
|
108
|
+
exports.Outline = styled_components_1.default.div `
|
|
109
|
+
font-size: ${(props) => props.theme.font.size.medium};
|
|
110
|
+
position: relative;
|
|
111
|
+
|
|
112
|
+
& .outline-text-title {
|
|
113
|
+
font-size: ${(props) => props.theme.font.size.large};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
&.dragging {
|
|
117
|
+
opacity: 0.5;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
&.drop-before > ${exports.OutlineItem} > ${exports.OutlineItemLink} {
|
|
121
|
+
border-top-color: ${(props) => props.theme.colors.brand.dark};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
&.drop-after > ${exports.OutlineItem} > ${exports.OutlineItemLink} {
|
|
125
|
+
border-bottom-color: ${(props) => props.theme.colors.brand.dark};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
& .subtree.collapsed {
|
|
129
|
+
display: none;
|
|
130
|
+
}
|
|
131
|
+
`;
|
|
140
132
|
exports.OutlineItemPlaceholder = styled_components_1.default.span ``;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.DeleteFootnoteDialog = void 0;
|
|
27
|
+
const style_guide_1 = require("@manuscripts/style-guide");
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const DeleteFootnoteDialog = ({ footnoteType, footnoteMessage, handleDelete, }) => {
|
|
30
|
+
const [isOpen, setOpen] = (0, react_1.useState)(true);
|
|
31
|
+
return (react_1.default.createElement(style_guide_1.Dialog, { className: "delete-footnote-dialog", isOpen: isOpen, actions: {
|
|
32
|
+
primary: {
|
|
33
|
+
action: () => {
|
|
34
|
+
setOpen(false);
|
|
35
|
+
handleDelete();
|
|
36
|
+
},
|
|
37
|
+
title: 'Delete',
|
|
38
|
+
},
|
|
39
|
+
secondary: {
|
|
40
|
+
action: () => setOpen(false),
|
|
41
|
+
title: 'Cancel',
|
|
42
|
+
},
|
|
43
|
+
}, category: style_guide_1.Category.confirmation, header: `Delete ${footnoteType}`, message: `${footnoteMessage}` }));
|
|
44
|
+
};
|
|
45
|
+
exports.DeleteFootnoteDialog = DeleteFootnoteDialog;
|
|
@@ -69,7 +69,7 @@ exports.default = (props) => {
|
|
|
69
69
|
(0, prosemirror_tables_1.tableEditing)(),
|
|
70
70
|
(0, highlight_1.default)(props),
|
|
71
71
|
(0, selected_suggestion_ui_1.default)(props),
|
|
72
|
-
(0, footnotes_1.default)(),
|
|
72
|
+
(0, footnotes_1.default)(props),
|
|
73
73
|
(0, table_footnote_1.default)(),
|
|
74
74
|
];
|
|
75
75
|
if (props.collabProvider) {
|