@manuscripts/body-editor 1.7.28 → 1.7.29
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/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/index.js +1 -3
- package/dist/cjs/lib/dnd.js +10 -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/index.js +0 -1
- package/dist/es/lib/dnd.js +6 -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/index.d.ts +0 -1
- package/dist/types/lib/dnd.d.ts +3 -0
- package/package.json +4 -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
|
@@ -20,6 +20,7 @@ import React, { useRef, useState } from 'react';
|
|
|
20
20
|
import { useDrag, useDrop } from 'react-dnd';
|
|
21
21
|
import styled from 'styled-components';
|
|
22
22
|
import { authorLabel } from '../../lib/authors';
|
|
23
|
+
import { getDropSide } from '../../lib/dnd';
|
|
23
24
|
const AuthorContainer = styled.div `
|
|
24
25
|
padding: ${(props) => props.theme.grid.unit * 2}px;
|
|
25
26
|
display: flex;
|
|
@@ -78,26 +79,12 @@ const AuthorName = styled.div `
|
|
|
78
79
|
const DragHandle = styled(VerticalEllipsis) `
|
|
79
80
|
cursor: move;
|
|
80
81
|
`;
|
|
81
|
-
const BEFORE = {
|
|
82
|
-
id: 'before',
|
|
83
|
-
diff: -0.5,
|
|
84
|
-
};
|
|
85
|
-
const AFTER = {
|
|
86
|
-
id: 'after',
|
|
87
|
-
diff: 0.5,
|
|
88
|
-
};
|
|
89
|
-
const getDropPosition = (element, monitor) => {
|
|
90
|
-
const rect = element.getBoundingClientRect();
|
|
91
|
-
const middle = (rect.bottom - rect.top) / 2;
|
|
92
|
-
const cursor = monitor.getClientOffset();
|
|
93
|
-
return cursor.y > middle + rect.top ? AFTER : BEFORE;
|
|
94
|
-
};
|
|
95
82
|
export const DraggableAuthor = ({ author, isSelected, onClick, moveAuthor, }) => {
|
|
96
|
-
const [
|
|
83
|
+
const [dropSide, setDropSide] = useState();
|
|
97
84
|
const ref = useRef(null);
|
|
98
85
|
const [{ isDragging }, dragRef] = useDrag({
|
|
86
|
+
type: 'author',
|
|
99
87
|
item: {
|
|
100
|
-
type: 'author',
|
|
101
88
|
author,
|
|
102
89
|
},
|
|
103
90
|
collect: (monitor) => ({
|
|
@@ -106,29 +93,30 @@ export const DraggableAuthor = ({ author, isSelected, onClick, moveAuthor, }) =>
|
|
|
106
93
|
});
|
|
107
94
|
const [{ isOver }, dropRef] = useDrop({
|
|
108
95
|
accept: 'author',
|
|
109
|
-
collect: (monitor) => ({
|
|
110
|
-
isOver: monitor.isOver(),
|
|
111
|
-
}),
|
|
112
96
|
hover: (item, monitor) => {
|
|
113
97
|
if (!ref.current) {
|
|
114
98
|
return;
|
|
115
99
|
}
|
|
116
|
-
const
|
|
117
|
-
|
|
100
|
+
const side = getDropSide(ref.current, monitor);
|
|
101
|
+
setDropSide(side);
|
|
118
102
|
},
|
|
119
103
|
drop: (item, monitor) => {
|
|
120
104
|
if (!ref.current) {
|
|
121
105
|
return;
|
|
122
106
|
}
|
|
123
|
-
const
|
|
107
|
+
const side = getDropSide(ref.current, monitor);
|
|
124
108
|
const from = item.author.priority;
|
|
125
109
|
const to = author.priority;
|
|
126
|
-
|
|
110
|
+
const diff = side === 'before' ? -0.5 : 0.5;
|
|
111
|
+
moveAuthor(from, to + diff);
|
|
127
112
|
},
|
|
113
|
+
collect: (monitor) => ({
|
|
114
|
+
isOver: monitor.isOver(),
|
|
115
|
+
}),
|
|
128
116
|
});
|
|
129
117
|
dragRef(dropRef(ref));
|
|
130
118
|
const dragClass = isDragging ? 'dragging' : '';
|
|
131
|
-
const dropClass = isOver &&
|
|
119
|
+
const dropClass = isOver && dropSide ? `drop-${dropSide}` : '';
|
|
132
120
|
const activeClass = isSelected ? 'active' : '';
|
|
133
121
|
return (React.createElement(AuthorContainer, { ref: ref, className: `${dragClass} ${dropClass} ${activeClass}`, onClick: onClick },
|
|
134
122
|
React.createElement(AvatarContainer, null,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { isElementNodeType, nodeTitle, nodeTitlePlaceholder, schema, } from '@manuscripts/transform';
|
|
2
2
|
import { Fragment } from 'prosemirror-model';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { findDOMNode } from 'react-dom';
|
|
3
|
+
import React, { useRef, useState } from 'react';
|
|
4
|
+
import { useDrag, useDrop } from 'react-dnd';
|
|
6
5
|
import { ContextMenu } from '../../lib/context-menu';
|
|
6
|
+
import { getDropSide } from '../../lib/dnd';
|
|
7
7
|
import { isDeleted, isRejectedInsert } from '../../lib/track-changes-utils';
|
|
8
8
|
import { nodeTypeIcon } from '../../node-type-icons';
|
|
9
|
-
import { Outline,
|
|
9
|
+
import { Outline, OutlineItem, OutlineItemArrow, OutlineItemIcon, OutlineItemLink, OutlineItemLinkText, OutlineItemNoArrow, OutlineItemPlaceholder, StyledTriangleCollapsed, StyledTriangleExpanded, } from './Outline';
|
|
10
10
|
const excludedTypes = [
|
|
11
11
|
schema.nodes.table,
|
|
12
12
|
schema.nodes.figure,
|
|
@@ -30,11 +30,10 @@ const isChildrenExcluded = (nodeType) => {
|
|
|
30
30
|
const isManuscriptNode = (node) => {
|
|
31
31
|
return (node === null || node === void 0 ? void 0 : node.type) === schema.nodes.manuscript;
|
|
32
32
|
};
|
|
33
|
-
export const buildTree = ({ node, pos, index,
|
|
33
|
+
export const buildTree = ({ node, pos, index, parent, }) => {
|
|
34
34
|
const items = [];
|
|
35
35
|
const startPos = pos + 1;
|
|
36
36
|
const endPos = pos + node.nodeSize;
|
|
37
|
-
const isSelected = selected ? node.attrs.id === selected.node.attrs.id : false;
|
|
38
37
|
if (!isChildrenExcluded(node.type)) {
|
|
39
38
|
node.forEach((childNode, offset, childIndex) => {
|
|
40
39
|
if (isExcluded(childNode.type)) {
|
|
@@ -47,171 +46,108 @@ export const buildTree = ({ node, pos, index, selected, parent, }) => {
|
|
|
47
46
|
node: childNode,
|
|
48
47
|
pos: startPos + offset,
|
|
49
48
|
index: childIndex,
|
|
50
|
-
selected,
|
|
51
49
|
parent: node,
|
|
52
50
|
}));
|
|
53
51
|
}
|
|
54
52
|
});
|
|
55
53
|
}
|
|
56
|
-
return { node, index, items, pos, endPos, parent
|
|
54
|
+
return { node, index, items, pos, endPos, parent };
|
|
57
55
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
56
|
+
export const DraggableTree = ({ tree, view, depth, can, }) => {
|
|
57
|
+
const [dropSide, setDropSide] = useState();
|
|
58
|
+
const [isOpen, setOpen] = useState(depth === 0);
|
|
59
|
+
const ref = useRef(null);
|
|
60
|
+
const { node, items, parent } = tree;
|
|
61
|
+
const itemText = (node) => {
|
|
62
|
+
const text = nodeTitle(node);
|
|
63
|
+
if (text) {
|
|
64
|
+
return text.trim();
|
|
65
|
+
}
|
|
66
|
+
const placeholder = nodeTitlePlaceholder(node.type);
|
|
67
|
+
return React.createElement(OutlineItemPlaceholder, null, placeholder);
|
|
68
|
+
};
|
|
69
|
+
const toggleOpen = () => {
|
|
70
|
+
setOpen(!isOpen);
|
|
71
|
+
};
|
|
72
|
+
const [{ isDragging }, dragRef] = useDrag({
|
|
73
|
+
type: 'outline',
|
|
74
|
+
item: tree,
|
|
75
|
+
canDrag: () => {
|
|
76
|
+
return depth !== 0;
|
|
77
|
+
},
|
|
78
|
+
collect: (monitor) => ({
|
|
79
|
+
isDragging: monitor.isDragging(),
|
|
80
|
+
}),
|
|
81
|
+
});
|
|
82
|
+
const [{ isOver }, dropRef] = useDrop({
|
|
83
|
+
accept: 'outline',
|
|
84
|
+
canDrop(item, monitor) {
|
|
85
|
+
if (!ref.current) {
|
|
86
|
+
return false;
|
|
81
87
|
}
|
|
82
|
-
|
|
83
|
-
return React.createElement(OutlineItemPlaceholder, null, placeholder);
|
|
84
|
-
};
|
|
85
|
-
this.handleContextMenu = (event) => {
|
|
86
|
-
event.preventDefault();
|
|
87
|
-
event.stopPropagation();
|
|
88
|
-
if (!this.props.editArticle) {
|
|
88
|
+
if (!tree.parent) {
|
|
89
89
|
return false;
|
|
90
90
|
}
|
|
91
|
-
|
|
92
|
-
if (!menu) {
|
|
91
|
+
if (item.node.attrs.id === tree.node.attrs.id) {
|
|
93
92
|
return false;
|
|
94
93
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
this.createMenu = () => {
|
|
98
|
-
const { tree, view } = this.props;
|
|
99
|
-
if (!view) {
|
|
100
|
-
return null;
|
|
94
|
+
if (item.pos <= tree.pos && item.endPos >= tree.endPos) {
|
|
95
|
+
return false;
|
|
101
96
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
display: open || isTop ? '' : 'none',
|
|
136
|
-
} }, items.map((subtree) => (React.createElement(DraggableTree, Object.assign({}, this.props, { key: subtree.node.attrs.id, tree: subtree, view: view, depth: isTop ? depth : depth + 1 })))))) : (''),
|
|
137
|
-
React.createElement(OutlineDropPreview, { depth: depth, style: this.bottomPreviewStyles(mightDrop, dragPosition) }))));
|
|
97
|
+
const side = getDropSide(ref.current, monitor);
|
|
98
|
+
const index = side === 'before' ? tree.index : tree.index + 1;
|
|
99
|
+
return tree.parent.canReplace(index, index, Fragment.from(item.node));
|
|
100
|
+
},
|
|
101
|
+
hover(item, monitor) {
|
|
102
|
+
if (!ref.current || !monitor.canDrop()) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const side = getDropSide(ref.current, monitor);
|
|
106
|
+
setDropSide(side);
|
|
107
|
+
},
|
|
108
|
+
drop(item, monitor) {
|
|
109
|
+
if (!ref.current || !view) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const side = getDropSide(ref.current, monitor);
|
|
113
|
+
const pos = side === 'before' ? tree.pos - 1 : tree.endPos - 1;
|
|
114
|
+
let sourcePos = item.pos - 1;
|
|
115
|
+
const node = item.node.type.schema.nodes[item.node.type.name].create(Object.assign(Object.assign({}, item.node.attrs), { id: '' }), item.node.content);
|
|
116
|
+
const tr = view.state.tr.insert(pos, node);
|
|
117
|
+
sourcePos = tr.mapping.map(sourcePos);
|
|
118
|
+
tr.delete(sourcePos, sourcePos + item.node.nodeSize);
|
|
119
|
+
view.dispatch(tr);
|
|
120
|
+
},
|
|
121
|
+
collect: (monitor) => ({
|
|
122
|
+
isOver: monitor.isOver({ shallow: true }),
|
|
123
|
+
}),
|
|
124
|
+
});
|
|
125
|
+
const isDeletedItem = isDeleted(node);
|
|
126
|
+
const isRejectedItem = isRejectedInsert(node);
|
|
127
|
+
const isTop = isManuscriptNode(parent);
|
|
128
|
+
if (isRejectedItem) {
|
|
129
|
+
return null;
|
|
138
130
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
tree: props.tree,
|
|
144
|
-
};
|
|
145
|
-
},
|
|
146
|
-
canDrag(props) {
|
|
147
|
-
return props.editArticle && !!props.tree.parent;
|
|
148
|
-
},
|
|
149
|
-
}, (connect, monitor) => ({
|
|
150
|
-
connectDragSource: connect.dragSource(),
|
|
151
|
-
connectDragPreview: connect.dragPreview(),
|
|
152
|
-
isDragging: monitor.isDragging(),
|
|
153
|
-
canDrag: monitor.canDrag(),
|
|
154
|
-
item: monitor.getItem(),
|
|
155
|
-
}));
|
|
156
|
-
const dropTarget = DropTarget('outline', {
|
|
157
|
-
canDrop(props, monitor) {
|
|
158
|
-
const item = monitor.getItem();
|
|
159
|
-
if (!props.tree.parent) {
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
|
-
if (item.tree.node.attrs.id === props.tree.node.attrs.id) {
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
if (item.tree.pos <= props.tree.pos &&
|
|
166
|
-
item.tree.endPos >= props.tree.endPos) {
|
|
131
|
+
const handleContextMenu = (e) => {
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
e.stopPropagation();
|
|
134
|
+
if (!(can === null || can === void 0 ? void 0 : can.editArticle)) {
|
|
167
135
|
return false;
|
|
168
136
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
},
|
|
172
|
-
hover(props, monitor, component) {
|
|
173
|
-
if (monitor.isOver({ shallow: true })) {
|
|
174
|
-
const offset = monitor.getClientOffset();
|
|
175
|
-
if (offset) {
|
|
176
|
-
const item = monitor.getItem();
|
|
177
|
-
const node = findDOMNode(component);
|
|
178
|
-
const { bottom, top } = node.getBoundingClientRect();
|
|
179
|
-
const verticalMiddle = (bottom - top) / 2;
|
|
180
|
-
const verticalHover = offset.y - top;
|
|
181
|
-
item.position = verticalHover < verticalMiddle ? 'before' : 'after';
|
|
182
|
-
component.setState({
|
|
183
|
-
dragPosition: item.position,
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
drop(props, monitor) {
|
|
189
|
-
var _a;
|
|
190
|
-
if (monitor.didDrop()) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
if (!props.view) {
|
|
194
|
-
return;
|
|
137
|
+
if (!view) {
|
|
138
|
+
return null;
|
|
195
139
|
}
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}, (connect, monitor) => ({
|
|
211
|
-
connectDropTarget: connect.dropTarget(),
|
|
212
|
-
isOverCurrent: monitor.isOver({ shallow: true }),
|
|
213
|
-
canDrop: monitor.canDrop(),
|
|
214
|
-
itemType: monitor.getItemType(),
|
|
215
|
-
}));
|
|
216
|
-
const DraggableTree = dragSource(dropTarget(Tree));
|
|
217
|
-
export default DraggableTree;
|
|
140
|
+
const menu = new ContextMenu(tree.node, view, () => tree.pos - 1);
|
|
141
|
+
menu.showEditMenu(e.currentTarget);
|
|
142
|
+
};
|
|
143
|
+
dragRef(dropRef(ref));
|
|
144
|
+
const dragClass = isDragging ? 'dragging' : '';
|
|
145
|
+
const dropClass = isOver && dropSide ? `drop-${dropSide}` : '';
|
|
146
|
+
return (React.createElement(Outline, { ref: ref, className: `${dragClass} ${dropClass}` },
|
|
147
|
+
!isTop && (React.createElement(OutlineItem, { depth: depth, onContextMenu: handleContextMenu },
|
|
148
|
+
items.length ? (React.createElement(OutlineItemArrow, { onClick: toggleOpen }, isOpen ? (React.createElement(StyledTriangleExpanded, null)) : (React.createElement(StyledTriangleCollapsed, null)))) : (React.createElement(OutlineItemNoArrow, null)),
|
|
149
|
+
React.createElement(OutlineItemLink, { to: `#${node.attrs.id}` },
|
|
150
|
+
React.createElement(OutlineItemIcon, null, nodeTypeIcon(node.type)),
|
|
151
|
+
React.createElement(OutlineItemLinkText, { className: `outline-text-${node.type.name} ${isDeletedItem && 'deleted'}` }, itemText(node))))),
|
|
152
|
+
items.length ? (React.createElement("div", { className: `subtree ${isOpen ? '' : 'collapsed'}` }, items.map((subtree) => (React.createElement(DraggableTree, { key: subtree.node.attrs.id, tree: subtree, view: view, depth: !tree.parent ? depth : depth + 1, can: can }))))) : null));
|
|
153
|
+
};
|
|
@@ -15,26 +15,23 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import React, { useEffect, useState } from 'react';
|
|
17
17
|
import { useDebounce } from '../hooks/use-debounce';
|
|
18
|
-
import
|
|
18
|
+
import { buildTree, DraggableTree } from './DraggableTree';
|
|
19
19
|
export const ManuscriptOutline = (props) => {
|
|
20
|
-
var _a;
|
|
21
20
|
const [values, setValues] = useState();
|
|
22
21
|
const debouncedProps = useDebounce(props, 500);
|
|
23
22
|
useEffect(() => {
|
|
24
|
-
|
|
25
|
-
const { doc, view, selected } = debouncedProps;
|
|
23
|
+
const { doc, view } = debouncedProps;
|
|
26
24
|
if (doc) {
|
|
27
25
|
const tree = buildTree({
|
|
28
26
|
node: doc,
|
|
29
27
|
pos: 0,
|
|
30
28
|
index: 0,
|
|
31
|
-
selected,
|
|
32
29
|
});
|
|
33
|
-
setValues({ tree, view,
|
|
30
|
+
setValues({ tree, view, can: props.can });
|
|
34
31
|
}
|
|
35
32
|
else {
|
|
36
33
|
setValues(undefined);
|
|
37
34
|
}
|
|
38
|
-
}, [debouncedProps,
|
|
39
|
-
return values ? React.createElement(DraggableTree, Object.assign({}, values)) : null;
|
|
35
|
+
}, [debouncedProps, props.can]);
|
|
36
|
+
return values ? React.createElement(DraggableTree, Object.assign({}, values, { depth: 0 })) : null;
|
|
40
37
|
};
|
|
@@ -28,12 +28,6 @@ export const OutlineItemIcon = styled.span `
|
|
|
28
28
|
`;
|
|
29
29
|
export const OutlineItem = styled.div `
|
|
30
30
|
align-items: center;
|
|
31
|
-
border-bottom: 1px solid transparent;
|
|
32
|
-
border-top: 1px solid transparent;
|
|
33
|
-
background: ${(props) => props.isSelected ? props.theme.colors.background.fifth : 'transparent'};
|
|
34
|
-
border-color: ${(props) => props.isSelected
|
|
35
|
-
? props.theme.colors.border.primary
|
|
36
|
-
: props.theme.colors.background.fifth};
|
|
37
31
|
color: ${(props) => props.theme.colors.text.primary};
|
|
38
32
|
box-sizing: border-box;
|
|
39
33
|
cursor: pointer;
|
|
@@ -53,14 +47,6 @@ export const OutlineItem = styled.div `
|
|
|
53
47
|
background: ${(props) => props.theme.colors.background.fifth};
|
|
54
48
|
}
|
|
55
49
|
`;
|
|
56
|
-
export const Outline = styled.div `
|
|
57
|
-
font-size: ${(props) => props.theme.font.size.medium};
|
|
58
|
-
position: relative;
|
|
59
|
-
|
|
60
|
-
& .outline-text-title {
|
|
61
|
-
font-size: ${(props) => props.theme.font.size.large};
|
|
62
|
-
}
|
|
63
|
-
`;
|
|
64
50
|
export const StyledTriangleCollapsed = styled(TriangleCollapsed) ``;
|
|
65
51
|
export const StyledTriangleExpanded = styled(TriangleExpanded) ``;
|
|
66
52
|
export const OutlineItemArrow = styled.button `
|
|
@@ -86,26 +72,6 @@ export const OutlineItemNoArrow = styled.span `
|
|
|
86
72
|
width: ${(props) => props.theme.grid.unit * 5}px;
|
|
87
73
|
flex-shrink: 0;
|
|
88
74
|
`;
|
|
89
|
-
export const OutlineDropPreview = styled.div `
|
|
90
|
-
width: 100%;
|
|
91
|
-
background: #65a3ff;
|
|
92
|
-
height: 1px;
|
|
93
|
-
position: absolute;
|
|
94
|
-
margin-left: ${(props) => 30 + props.depth * 20}px;
|
|
95
|
-
z-index: 2;
|
|
96
|
-
|
|
97
|
-
&:before {
|
|
98
|
-
content: '';
|
|
99
|
-
display: inline-block;
|
|
100
|
-
width: ${(props) => props.theme.grid.unit}px;
|
|
101
|
-
height: ${(props) => props.theme.grid.unit}px;
|
|
102
|
-
border: 1px solid ${(props) => props.theme.colors.brand.default}
|
|
103
|
-
border-radius: ${(props) => props.theme.grid.radius.small};
|
|
104
|
-
position: absolute;
|
|
105
|
-
top: -${(props) => props.theme.grid.unit}px;
|
|
106
|
-
left: -6px;
|
|
107
|
-
}
|
|
108
|
-
`;
|
|
109
75
|
export const OutlineItemLink = styled(Link) `
|
|
110
76
|
flex: 1;
|
|
111
77
|
display: inline-flex;
|
|
@@ -114,6 +80,8 @@ export const OutlineItemLink = styled(Link) `
|
|
|
114
80
|
color: inherit;
|
|
115
81
|
text-decoration: none;
|
|
116
82
|
height: 100%;
|
|
83
|
+
border-bottom: 1px solid transparent;
|
|
84
|
+
border-top: 1px solid transparent;
|
|
117
85
|
|
|
118
86
|
&:focus,
|
|
119
87
|
&:active {
|
|
@@ -131,4 +99,28 @@ export const OutlineItemLinkText = styled.span `
|
|
|
131
99
|
text-decoration: line-through;
|
|
132
100
|
}
|
|
133
101
|
`;
|
|
102
|
+
export const Outline = styled.div `
|
|
103
|
+
font-size: ${(props) => props.theme.font.size.medium};
|
|
104
|
+
position: relative;
|
|
105
|
+
|
|
106
|
+
& .outline-text-title {
|
|
107
|
+
font-size: ${(props) => props.theme.font.size.large};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
&.dragging {
|
|
111
|
+
opacity: 0.5;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&.drop-before > ${OutlineItem} > ${OutlineItemLink} {
|
|
115
|
+
border-top-color: ${(props) => props.theme.colors.brand.dark};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
&.drop-after > ${OutlineItem} > ${OutlineItemLink} {
|
|
119
|
+
border-bottom-color: ${(props) => props.theme.colors.brand.dark};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
& .subtree.collapsed {
|
|
123
|
+
display: none;
|
|
124
|
+
}
|
|
125
|
+
`;
|
|
134
126
|
export const OutlineItemPlaceholder = styled.span ``;
|
package/dist/es/index.js
CHANGED
|
@@ -17,7 +17,6 @@ export * from './citation-sources';
|
|
|
17
17
|
export * from './commands';
|
|
18
18
|
export { ManuscriptOutline } from './components/outline/ManuscriptOutline';
|
|
19
19
|
export { OutlineItemIcon } from './components/outline/Outline';
|
|
20
|
-
export { OutlineManuscript } from './components/outline/OutlineManuscript';
|
|
21
20
|
export { LevelSelector } from './components/toolbar/LevelSelector';
|
|
22
21
|
export * from './menus';
|
|
23
22
|
export { CollabProvider } from './classes/collabProvider';
|
|
@@ -1,63 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
export type DropSide = 'before' | 'after' | null;
|
|
5
|
-
interface DragSourceProps {
|
|
6
|
-
tree: TreeItem;
|
|
7
|
-
position: DropSide;
|
|
8
|
-
}
|
|
9
|
-
interface ConnectedDragSourceProps {
|
|
10
|
-
connectDragSource: ConnectDragSource;
|
|
11
|
-
connectDragPreview: ConnectDragPreview;
|
|
12
|
-
isDragging: boolean;
|
|
13
|
-
canDrag: boolean;
|
|
14
|
-
item: DragSourceProps;
|
|
15
|
-
}
|
|
16
|
-
interface ConnectedDropTargetProps {
|
|
17
|
-
connectDropTarget: ConnectDropTarget;
|
|
18
|
-
isOverCurrent: boolean;
|
|
19
|
-
canDrop: boolean;
|
|
20
|
-
itemType: string | symbol | null;
|
|
21
|
-
}
|
|
22
|
-
type ConnectedProps = ConnectedDragSourceProps & ConnectedDropTargetProps;
|
|
1
|
+
import { Capabilities } from '@manuscripts/style-guide';
|
|
2
|
+
import { ManuscriptEditorView, ManuscriptNode } from '@manuscripts/transform';
|
|
3
|
+
import React from 'react';
|
|
23
4
|
export interface TreeItem {
|
|
24
5
|
index: number;
|
|
25
|
-
isSelected: boolean;
|
|
26
6
|
items: TreeItem[];
|
|
27
7
|
node: ManuscriptNode;
|
|
28
8
|
pos: number;
|
|
29
9
|
endPos: number;
|
|
30
10
|
parent?: ManuscriptNode;
|
|
31
11
|
}
|
|
32
|
-
interface Props {
|
|
33
|
-
depth?: number;
|
|
34
|
-
tree: TreeItem;
|
|
35
|
-
view?: ManuscriptEditorView;
|
|
36
|
-
editArticle: boolean;
|
|
37
|
-
}
|
|
38
|
-
interface State {
|
|
39
|
-
open: boolean;
|
|
40
|
-
dragPosition: DropSide;
|
|
41
|
-
}
|
|
42
12
|
interface TreeBuilderOptions {
|
|
43
13
|
node: ManuscriptNode;
|
|
44
14
|
pos: number;
|
|
45
15
|
index: number;
|
|
46
|
-
selected: Selected | null;
|
|
47
16
|
parent?: ManuscriptNode;
|
|
48
17
|
}
|
|
49
18
|
type TreeBuilder = (options: TreeBuilderOptions) => TreeItem;
|
|
50
19
|
export declare const buildTree: TreeBuilder;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
private topPreviewStyles;
|
|
57
|
-
private toggle;
|
|
58
|
-
private itemText;
|
|
59
|
-
private handleContextMenu;
|
|
60
|
-
private createMenu;
|
|
20
|
+
export interface DraggableTreeProps {
|
|
21
|
+
depth: number;
|
|
22
|
+
tree: TreeItem;
|
|
23
|
+
view?: ManuscriptEditorView;
|
|
24
|
+
can?: Capabilities;
|
|
61
25
|
}
|
|
62
|
-
declare const DraggableTree:
|
|
63
|
-
export
|
|
26
|
+
export declare const DraggableTree: React.FC<DraggableTreeProps>;
|
|
27
|
+
export {};
|
|
@@ -15,14 +15,12 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { Manuscript } from '@manuscripts/json-schema';
|
|
17
17
|
import { Capabilities } from '@manuscripts/style-guide';
|
|
18
|
-
import { ManuscriptEditorView, ManuscriptNode
|
|
18
|
+
import { ManuscriptEditorView, ManuscriptNode } from '@manuscripts/transform';
|
|
19
19
|
import React from 'react';
|
|
20
|
-
interface
|
|
20
|
+
export interface ManuscriptOutlineProps {
|
|
21
21
|
manuscript: Manuscript;
|
|
22
|
-
selected: Selected | null;
|
|
23
22
|
doc: ManuscriptNode | null;
|
|
24
|
-
|
|
23
|
+
can?: Capabilities;
|
|
25
24
|
view?: ManuscriptEditorView;
|
|
26
25
|
}
|
|
27
|
-
export declare const ManuscriptOutline: React.
|
|
28
|
-
export {};
|
|
26
|
+
export declare const ManuscriptOutline: React.FC<ManuscriptOutlineProps>;
|
|
@@ -17,17 +17,13 @@
|
|
|
17
17
|
import { Link } from 'react-router-dom';
|
|
18
18
|
export declare const OutlineItemIcon: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
19
19
|
export declare const OutlineItem: import("styled-components").StyledComponent<"div", any, {
|
|
20
|
-
isSelected: boolean;
|
|
21
20
|
depth: number;
|
|
22
21
|
}, never>;
|
|
23
|
-
export declare const Outline: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
24
22
|
export declare const StyledTriangleCollapsed: import("styled-components").StyledComponent<import("react").SFC<import("react").SVGAttributes<SVGElement>>, any, {}, never>;
|
|
25
23
|
export declare const StyledTriangleExpanded: import("styled-components").StyledComponent<import("react").SFC<import("react").SVGAttributes<SVGElement>>, any, {}, never>;
|
|
26
24
|
export declare const OutlineItemArrow: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
27
25
|
export declare const OutlineItemNoArrow: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
28
|
-
export declare const OutlineDropPreview: import("styled-components").StyledComponent<"div", any, {
|
|
29
|
-
depth: number;
|
|
30
|
-
}, never>;
|
|
31
26
|
export declare const OutlineItemLink: import("styled-components").StyledComponent<typeof Link, any, {}, never>;
|
|
32
27
|
export declare const OutlineItemLinkText: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
28
|
+
export declare const Outline: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
33
29
|
export declare const OutlineItemPlaceholder: import("styled-components").StyledComponent<"span", any, {}, never>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -17,7 +17,6 @@ export * from './citation-sources';
|
|
|
17
17
|
export * from './commands';
|
|
18
18
|
export { ManuscriptOutline } from './components/outline/ManuscriptOutline';
|
|
19
19
|
export { OutlineItemIcon } from './components/outline/Outline';
|
|
20
|
-
export { OutlineManuscript } from './components/outline/OutlineManuscript';
|
|
21
20
|
export { LevelSelector } from './components/toolbar/LevelSelector';
|
|
22
21
|
export * from './menus';
|
|
23
22
|
export { ChangeReceiver } from './types';
|