@manuscripts/body-editor 3.16.3 → 3.17.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/lib/context-menu.js +28 -11
- package/dist/cjs/lib/popper.js +18 -3
- package/dist/cjs/lib/position-menu.js +175 -100
- package/dist/cjs/lib/view.js +10 -1
- package/dist/cjs/plugins/detect-inconsistency/index.js +6 -4
- package/dist/cjs/plugins/persist.js +3 -0
- package/dist/cjs/versions.js +1 -1
- package/dist/cjs/views/box_element.js +23 -1
- package/dist/cjs/views/caption_title.js +1 -1
- package/dist/cjs/views/footnote.js +43 -18
- package/dist/cjs/views/general_table_footnote.js +31 -21
- package/dist/cjs/views/image_element.js +7 -62
- package/dist/cjs/views/pullquote_element.js +23 -1
- package/dist/cjs/views/table_element.js +23 -1
- package/dist/es/lib/context-menu.js +29 -12
- package/dist/es/lib/popper.js +18 -3
- package/dist/es/lib/position-menu.js +173 -91
- package/dist/es/lib/view.js +8 -0
- package/dist/es/plugins/detect-inconsistency/index.js +6 -4
- package/dist/es/plugins/persist.js +3 -0
- package/dist/es/versions.js +1 -1
- package/dist/es/views/box_element.js +23 -1
- package/dist/es/views/caption_title.js +1 -1
- package/dist/es/views/footnote.js +43 -18
- package/dist/es/views/general_table_footnote.js +31 -21
- package/dist/es/views/image_element.js +7 -62
- package/dist/es/views/pullquote_element.js +23 -1
- package/dist/es/views/table_element.js +23 -1
- package/dist/types/lib/popper.d.ts +4 -2
- package/dist/types/lib/position-menu.d.ts +36 -11
- package/dist/types/lib/view.d.ts +3 -1
- package/dist/types/versions.d.ts +1 -1
- package/dist/types/views/box_element.d.ts +6 -0
- package/dist/types/views/footnote.d.ts +5 -2
- package/dist/types/views/general_table_footnote.d.ts +2 -2
- package/dist/types/views/image_element.d.ts +2 -9
- package/dist/types/views/pullquote_element.d.ts +6 -0
- package/dist/types/views/table_element.d.ts +6 -0
- package/package.json +2 -2
- package/src/lib/context-menu.ts +42 -21
- package/src/lib/popper.ts +23 -4
- package/src/lib/position-menu.ts +243 -137
- package/src/lib/view.ts +17 -0
- package/src/plugins/detect-inconsistency/index.ts +6 -4
- package/src/plugins/persist.ts +3 -0
- package/src/versions.ts +1 -1
- package/src/views/box_element.ts +34 -1
- package/src/views/caption_title.ts +1 -1
- package/src/views/footnote.ts +69 -33
- package/src/views/general_table_footnote.ts +43 -20
- package/src/views/image_element.ts +12 -89
- package/src/views/pullquote_element.ts +33 -1
- package/src/views/table_element.ts +34 -1
- package/styles/AdvancedEditor.css +5 -8
- package/styles/Editor.css +9 -5
package/dist/es/lib/view.js
CHANGED
|
@@ -100,3 +100,11 @@ export const saveBibliographyItem = (view, attrs) => {
|
|
|
100
100
|
}
|
|
101
101
|
insertBibliographyItems(view, attrs);
|
|
102
102
|
};
|
|
103
|
+
export const isSelectionInsideNode = (view, node, pos) => {
|
|
104
|
+
const { from, to, empty } = view.state.selection;
|
|
105
|
+
const end = pos + node.nodeSize;
|
|
106
|
+
if (empty) {
|
|
107
|
+
return from > pos && from < end;
|
|
108
|
+
}
|
|
109
|
+
return from >= pos && to <= end;
|
|
110
|
+
};
|
|
@@ -22,10 +22,12 @@ export default (props) => {
|
|
|
22
22
|
key: detectInconsistencyKey,
|
|
23
23
|
state: {
|
|
24
24
|
init: (_, state) => buildPluginState(state, props, false),
|
|
25
|
-
apply: (tr, value, newState) => {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
apply: (tr, value, _, newState) => {
|
|
26
|
+
const metaValue = tr.getMeta(detectInconsistencyKey);
|
|
27
|
+
const showDecorations = metaValue !== undefined ? metaValue : value.showDecorations;
|
|
28
|
+
if (!tr.docChanged && metaValue === undefined) {
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
29
31
|
return buildPluginState(newState, props, showDecorations);
|
|
30
32
|
},
|
|
31
33
|
},
|
package/dist/es/versions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '3.
|
|
1
|
+
export const VERSION = '3.17.1';
|
|
2
2
|
export const MATHJAX_VERSION = '3.2.2';
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import BlockView from './block_view';
|
|
17
17
|
import { createNodeView } from './creators';
|
|
18
|
+
import { HorizontalPositionMenu } from '../lib/position-menu';
|
|
18
19
|
export class BoxElementView extends BlockView {
|
|
19
20
|
constructor() {
|
|
20
21
|
super(...arguments);
|
|
@@ -23,8 +24,29 @@ export class BoxElementView extends BlockView {
|
|
|
23
24
|
this.contentDOM = document.createElement(this.elementType);
|
|
24
25
|
this.contentDOM.className = 'block box-element';
|
|
25
26
|
this.contentDOM.setAttribute('id', this.node.attrs.id);
|
|
26
|
-
this.
|
|
27
|
+
this.container = document.createElement('div');
|
|
28
|
+
this.container.classList.add('container');
|
|
29
|
+
this.container.appendChild(this.contentDOM);
|
|
30
|
+
this.dom.appendChild(this.container);
|
|
27
31
|
};
|
|
28
32
|
}
|
|
33
|
+
updateContents() {
|
|
34
|
+
super.updateContents();
|
|
35
|
+
this.addTools();
|
|
36
|
+
}
|
|
37
|
+
addTools() {
|
|
38
|
+
this.addPositionMenu();
|
|
39
|
+
}
|
|
40
|
+
addPositionMenu() {
|
|
41
|
+
if (!this.positionMenu) {
|
|
42
|
+
this.positionMenu = new HorizontalPositionMenu(this, this.updateHorizontalPosition, this.container);
|
|
43
|
+
}
|
|
44
|
+
this.positionMenu.create();
|
|
45
|
+
}
|
|
46
|
+
updateHorizontalPosition(horizontalPosition) {
|
|
47
|
+
const tr = this.view.state.tr;
|
|
48
|
+
tr.setNodeAttribute(this.getPos(), 'type', horizontalPosition);
|
|
49
|
+
this.view.dispatch(tr);
|
|
50
|
+
}
|
|
29
51
|
}
|
|
30
52
|
export default createNodeView(BoxElementView);
|
|
@@ -24,7 +24,7 @@ export class CaptionTitleView extends BaseNodeView {
|
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
createDOM() {
|
|
27
|
-
this.dom = document.createElement('
|
|
27
|
+
this.dom = document.createElement('div');
|
|
28
28
|
this.dom.className = 'caption-title placeholder';
|
|
29
29
|
this.contentDOM = this.dom;
|
|
30
30
|
}
|
|
@@ -17,6 +17,7 @@ import { ContextMenu } from '@manuscripts/style-guide';
|
|
|
17
17
|
import { isDeleted, isPendingInsert } from '@manuscripts/track-changes-plugin';
|
|
18
18
|
import { schema } from '@manuscripts/transform';
|
|
19
19
|
import isEqual from 'lodash/isEqual';
|
|
20
|
+
import xor from 'lodash/xor';
|
|
20
21
|
import { NodeSelection } from 'prosemirror-state';
|
|
21
22
|
import { findParentNodeOfTypeClosestToPos } from 'prosemirror-utils';
|
|
22
23
|
import { DeleteFootnoteDialog, } from '../components/views/DeleteFootnoteDialog';
|
|
@@ -26,25 +27,31 @@ import { BaseNodeView } from './base_node_view';
|
|
|
26
27
|
import { createNodeView } from './creators';
|
|
27
28
|
import ReactSubView from './ReactSubView';
|
|
28
29
|
import { handleEnterKey } from '../lib/navigation-utils';
|
|
30
|
+
import { isSelectionInsideNode } from '../lib/view';
|
|
29
31
|
export class FootnoteView extends BaseNodeView {
|
|
30
32
|
constructor() {
|
|
31
33
|
super(...arguments);
|
|
34
|
+
this.isMenuShown = false;
|
|
35
|
+
this.previousActionsLabels = [];
|
|
32
36
|
this.initialise = () => {
|
|
33
37
|
this.dom = document.createElement('div');
|
|
34
38
|
this.dom.classList.add('footnote');
|
|
35
39
|
this.dom.tabIndex = 0;
|
|
36
40
|
this.contentDOM = document.createElement('div');
|
|
37
41
|
this.contentDOM.classList.add('footnote-text');
|
|
38
|
-
this.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const element = event.target;
|
|
44
|
-
const item = element.closest('.footnote');
|
|
45
|
-
if (item) {
|
|
46
|
-
this.showContextMenu(item, fromKeyboard);
|
|
42
|
+
if (!this.view.editable) {
|
|
43
|
+
const actions = this.getContextMenuActions();
|
|
44
|
+
if (actions.length > 0) {
|
|
45
|
+
this.dom.addEventListener('mousedown', () => this.showContextMenu(actions, true));
|
|
46
|
+
}
|
|
47
47
|
}
|
|
48
|
+
this.dom.addEventListener('keydown', handleEnterKey(() => {
|
|
49
|
+
const actions = this.getContextMenuActions();
|
|
50
|
+
if (actions.length > 0) {
|
|
51
|
+
this.showContextMenu(actions, true);
|
|
52
|
+
}
|
|
53
|
+
}));
|
|
54
|
+
this.updateContents();
|
|
48
55
|
};
|
|
49
56
|
this.handleMarkerClick = (e) => {
|
|
50
57
|
e?.preventDefault();
|
|
@@ -128,35 +135,53 @@ export class FootnoteView extends BaseNodeView {
|
|
|
128
135
|
this.dom.innerHTML = '';
|
|
129
136
|
this.dom.appendChild(marker);
|
|
130
137
|
this.contentDOM && this.dom.appendChild(this.contentDOM);
|
|
138
|
+
const selectionInsideNode = isSelectionInsideNode(this.view, this.node, this.getPos());
|
|
139
|
+
const actions = this.getContextMenuActions();
|
|
140
|
+
const hasActions = actions.length > 0;
|
|
141
|
+
const currentLabels = actions.map(({ label }) => label);
|
|
142
|
+
const changedLabels = xor(currentLabels, this.previousActionsLabels);
|
|
143
|
+
if (selectionInsideNode &&
|
|
144
|
+
hasActions &&
|
|
145
|
+
(!this.isMenuShown || changedLabels.length > 0)) {
|
|
146
|
+
this.showContextMenu(actions, false);
|
|
147
|
+
this.previousActionsLabels = actions.map(({ label }) => label);
|
|
148
|
+
}
|
|
149
|
+
else if ((!hasActions || !selectionInsideNode) && this.isMenuShown) {
|
|
150
|
+
this.props.popper.destroy();
|
|
151
|
+
this.isMenuShown = false;
|
|
152
|
+
this.previousActionsLabels = [];
|
|
153
|
+
}
|
|
131
154
|
}
|
|
132
155
|
getFootnoteState() {
|
|
133
156
|
const id = this.node.attrs.id;
|
|
134
157
|
const fn = getFootnotesElementState(this.view.state, id);
|
|
135
158
|
return { id, fn };
|
|
136
159
|
}
|
|
137
|
-
showContextMenu(
|
|
160
|
+
showContextMenu(actions, autoFocus) {
|
|
161
|
+
this.isMenuShown = true;
|
|
138
162
|
this.props.popper.destroy();
|
|
163
|
+
this.contextMenu = ReactSubView(this.props, ContextMenu, { actions }, this.node, this.getPos, this.view, ['context-menu', 'footnote-context-menu']);
|
|
164
|
+
this.props.popper.show(this.dom, this.contextMenu, 'right-start', true, [], autoFocus, false);
|
|
165
|
+
}
|
|
166
|
+
getContextMenuActions() {
|
|
139
167
|
const can = this.props.getCapabilities();
|
|
140
168
|
const { id, fn } = this.getFootnoteState();
|
|
141
|
-
const
|
|
142
|
-
actions: [],
|
|
143
|
-
};
|
|
169
|
+
const actions = [];
|
|
144
170
|
if (!fn?.unusedFootnoteIDs.has(id)) {
|
|
145
|
-
|
|
146
|
-
label: 'Go to footnote
|
|
171
|
+
actions.push({
|
|
172
|
+
label: 'Go to footnote Reference',
|
|
147
173
|
action: () => this.handleMarkerClick(),
|
|
148
174
|
icon: 'Scroll',
|
|
149
175
|
});
|
|
150
176
|
}
|
|
151
177
|
if (can.editArticle && !isDeleted(this.node)) {
|
|
152
|
-
|
|
178
|
+
actions.push({
|
|
153
179
|
label: 'Delete',
|
|
154
180
|
action: () => this.handleDeleteClick(),
|
|
155
181
|
icon: 'Delete',
|
|
156
182
|
});
|
|
157
183
|
}
|
|
158
|
-
|
|
159
|
-
this.props.popper.show(element, this.contextMenu, 'right-start', true, [], autoFocus);
|
|
184
|
+
return actions;
|
|
160
185
|
}
|
|
161
186
|
}
|
|
162
187
|
const getEffectiveChildCount = (node) => {
|
|
@@ -21,27 +21,27 @@ import { BaseNodeView } from './base_node_view';
|
|
|
21
21
|
import { createNodeView } from './creators';
|
|
22
22
|
import ReactSubView from './ReactSubView';
|
|
23
23
|
import { isDeleted, isPendingInsert } from '@manuscripts/track-changes-plugin';
|
|
24
|
+
import { handleEnterKey } from '../lib/navigation-utils';
|
|
25
|
+
import { isSelectionInsideNode } from '../lib/view';
|
|
24
26
|
export class GeneralTableFootnoteView extends BaseNodeView {
|
|
25
27
|
constructor() {
|
|
26
28
|
super(...arguments);
|
|
29
|
+
this.isMenuShown = false;
|
|
27
30
|
this.initialise = () => {
|
|
28
31
|
this.dom = document.createElement('div');
|
|
29
32
|
this.dom.classList.add('footnote', 'general-table-footnote');
|
|
30
|
-
this.dom.
|
|
33
|
+
this.dom.tabIndex = 0;
|
|
34
|
+
this.dom.addEventListener('keydown', handleEnterKey(() => {
|
|
35
|
+
const can = this.props.getCapabilities();
|
|
36
|
+
const canShowMenu = can.editArticle && !isDeleted(this.node);
|
|
37
|
+
if (canShowMenu) {
|
|
38
|
+
this.showContextMenu(true);
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
31
41
|
this.contentDOM = document.createElement('div');
|
|
32
42
|
this.contentDOM.classList.add('footnote-text');
|
|
33
43
|
this.updateContents();
|
|
34
44
|
};
|
|
35
|
-
this.handleClick = (e) => {
|
|
36
|
-
const element = e.target;
|
|
37
|
-
const can = this.props.getCapabilities();
|
|
38
|
-
if (can.editArticle) {
|
|
39
|
-
const item = element.closest('.general-table-footnote');
|
|
40
|
-
if (item) {
|
|
41
|
-
this.showContextMenu(item);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
45
|
this.handleDeleteClick = () => {
|
|
46
46
|
const componentProps = {
|
|
47
47
|
header: 'Delete table general note',
|
|
@@ -74,21 +74,31 @@ export class GeneralTableFootnoteView extends BaseNodeView {
|
|
|
74
74
|
super.updateContents();
|
|
75
75
|
this.dom.innerHTML = '';
|
|
76
76
|
this.contentDOM && this.dom.appendChild(this.contentDOM);
|
|
77
|
+
const selectionInsideNode = isSelectionInsideNode(this.view, this.node, this.getPos());
|
|
78
|
+
const can = this.props.getCapabilities();
|
|
79
|
+
const canShowMenu = can.editArticle && !isDeleted(this.node);
|
|
80
|
+
if (canShowMenu && selectionInsideNode && !this.isMenuShown) {
|
|
81
|
+
this.showContextMenu(false);
|
|
82
|
+
}
|
|
83
|
+
else if ((!canShowMenu || !selectionInsideNode) && this.isMenuShown) {
|
|
84
|
+
this.props.popper.destroy();
|
|
85
|
+
this.isMenuShown = false;
|
|
86
|
+
}
|
|
77
87
|
}
|
|
78
|
-
showContextMenu(
|
|
88
|
+
showContextMenu(autoFocus = false) {
|
|
89
|
+
this.isMenuShown = true;
|
|
79
90
|
this.props.popper.destroy();
|
|
80
91
|
const componentProps = {
|
|
81
|
-
actions: [
|
|
92
|
+
actions: [
|
|
93
|
+
{
|
|
94
|
+
label: 'Delete',
|
|
95
|
+
action: () => this.handleDeleteClick(),
|
|
96
|
+
icon: 'Delete',
|
|
97
|
+
},
|
|
98
|
+
],
|
|
82
99
|
};
|
|
83
|
-
if (!isDeleted(this.node)) {
|
|
84
|
-
componentProps.actions.push({
|
|
85
|
-
label: 'Delete',
|
|
86
|
-
action: () => this.handleDeleteClick(),
|
|
87
|
-
icon: 'Delete',
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
100
|
this.contextMenu = ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu', 'footnote-context-menu']);
|
|
91
|
-
this.props.popper.show(
|
|
101
|
+
this.props.popper.show(this.dom, this.contextMenu, 'right-start', false, [], autoFocus, false);
|
|
92
102
|
}
|
|
93
103
|
}
|
|
94
104
|
export default createNodeView(GeneralTableFootnoteView);
|
|
@@ -13,21 +13,13 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ContextMenu } from '@manuscripts/style-guide';
|
|
17
16
|
import { schema } from '@manuscripts/transform';
|
|
18
17
|
import { deleteIcon, linkIcon } from '../icons';
|
|
19
18
|
import { addInteractionHandlers, createMediaPlaceholder, MediaType, } from '../lib/media';
|
|
20
19
|
import { handleEnterKey } from '../lib/navigation-utils';
|
|
21
|
-
import {
|
|
20
|
+
import { HorizontalPositionMenu } from '../lib/position-menu';
|
|
22
21
|
import BlockView from './block_view';
|
|
23
22
|
import { createNodeView } from './creators';
|
|
24
|
-
import ReactSubView from './ReactSubView';
|
|
25
|
-
export var figurePositions;
|
|
26
|
-
(function (figurePositions) {
|
|
27
|
-
figurePositions["left"] = "half-left";
|
|
28
|
-
figurePositions["right"] = "half-right";
|
|
29
|
-
figurePositions["default"] = "";
|
|
30
|
-
})(figurePositions || (figurePositions = {}));
|
|
31
23
|
export class ImageElementView extends BlockView {
|
|
32
24
|
constructor() {
|
|
33
25
|
super(...arguments);
|
|
@@ -42,46 +34,6 @@ export class ImageElementView extends BlockView {
|
|
|
42
34
|
this.setExtLink({ extLink: result.id });
|
|
43
35
|
this.updateContents();
|
|
44
36
|
};
|
|
45
|
-
this.showPositionMenu = () => {
|
|
46
|
-
const firstFigure = this.getFirstFigure();
|
|
47
|
-
if (!firstFigure) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
this.props.popper.destroy();
|
|
51
|
-
const options = [
|
|
52
|
-
{
|
|
53
|
-
label: 'Left',
|
|
54
|
-
action: () => {
|
|
55
|
-
this.props.popper.destroy();
|
|
56
|
-
this.updateAllFiguresPosition(figurePositions.left);
|
|
57
|
-
},
|
|
58
|
-
icon: 'ImageLeft',
|
|
59
|
-
selected: this.figurePosition === figurePositions.left,
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
label: 'Default',
|
|
63
|
-
action: () => {
|
|
64
|
-
this.props.popper.destroy();
|
|
65
|
-
this.updateAllFiguresPosition(figurePositions.default);
|
|
66
|
-
},
|
|
67
|
-
icon: 'ImageDefault',
|
|
68
|
-
selected: !this.figurePosition,
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
label: 'Right',
|
|
72
|
-
action: () => {
|
|
73
|
-
this.props.popper.destroy();
|
|
74
|
-
this.updateAllFiguresPosition(figurePositions.right);
|
|
75
|
-
},
|
|
76
|
-
icon: 'ImageRight',
|
|
77
|
-
selected: this.figurePosition === figurePositions.right,
|
|
78
|
-
},
|
|
79
|
-
];
|
|
80
|
-
const componentProps = {
|
|
81
|
-
actions: options,
|
|
82
|
-
};
|
|
83
|
-
this.props.popper.show(this.positionMenuWrapper, ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu', 'position-menu']), 'left', false);
|
|
84
|
-
};
|
|
85
37
|
this.removeExtLink = () => {
|
|
86
38
|
this.setExtLink({ extLink: '' });
|
|
87
39
|
};
|
|
@@ -127,18 +79,6 @@ export class ImageElementView extends BlockView {
|
|
|
127
79
|
addTools() {
|
|
128
80
|
this.addPositionMenu();
|
|
129
81
|
}
|
|
130
|
-
addPositionMenu() {
|
|
131
|
-
if (this.props.getCapabilities()?.editArticle) {
|
|
132
|
-
const existingMenu = this.container.querySelector('.position-menu');
|
|
133
|
-
if (existingMenu) {
|
|
134
|
-
existingMenu.remove();
|
|
135
|
-
}
|
|
136
|
-
const firstFigure = this.getFirstFigure();
|
|
137
|
-
this.figurePosition = firstFigure?.attrs.type || figurePositions.default;
|
|
138
|
-
this.positionMenuWrapper = createPositionMenuWrapper(this.figurePosition, this.showPositionMenu, this.props);
|
|
139
|
-
this.container.prepend(this.positionMenuWrapper);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
82
|
getFirstFigure() {
|
|
143
83
|
if (this.node.type === schema.nodes.image_element) {
|
|
144
84
|
const figureNode = this.node.firstChild;
|
|
@@ -176,6 +116,12 @@ export class ImageElementView extends BlockView {
|
|
|
176
116
|
}
|
|
177
117
|
return figures;
|
|
178
118
|
}
|
|
119
|
+
addPositionMenu() {
|
|
120
|
+
if (!this.positionMenu) {
|
|
121
|
+
this.positionMenu = new HorizontalPositionMenu(this, this.updateAllFiguresPosition.bind(this), this.container, () => this.getFirstFigure());
|
|
122
|
+
}
|
|
123
|
+
this.positionMenu.create();
|
|
124
|
+
}
|
|
179
125
|
updateAllFiguresPosition(position) {
|
|
180
126
|
const figures = this.getAllFigures();
|
|
181
127
|
const { tr } = this.view.state;
|
|
@@ -186,7 +132,6 @@ export class ImageElementView extends BlockView {
|
|
|
186
132
|
});
|
|
187
133
|
});
|
|
188
134
|
this.view.dispatch(tr);
|
|
189
|
-
this.figurePosition = position;
|
|
190
135
|
}
|
|
191
136
|
createDnDPlaceholder() {
|
|
192
137
|
const can = this.props.getCapabilities();
|
|
@@ -21,6 +21,7 @@ import { setCommentSelection } from '../plugins/comments';
|
|
|
21
21
|
import BlockView from './block_view';
|
|
22
22
|
import { createNodeOrElementView } from './creators';
|
|
23
23
|
import ReactSubView from './ReactSubView';
|
|
24
|
+
import { HorizontalPositionMenu } from '../lib/position-menu';
|
|
24
25
|
export class PullquoteElementView extends BlockView {
|
|
25
26
|
constructor() {
|
|
26
27
|
super(...arguments);
|
|
@@ -43,7 +44,10 @@ export class PullquoteElementView extends BlockView {
|
|
|
43
44
|
this.contentDOM = document.createElement(this.elementType);
|
|
44
45
|
this.contentDOM.className = 'block';
|
|
45
46
|
this.contentDOM.classList.add('pullquote');
|
|
46
|
-
this.
|
|
47
|
+
this.container = document.createElement('div');
|
|
48
|
+
this.container.classList.add('container');
|
|
49
|
+
this.container.appendChild(this.contentDOM);
|
|
50
|
+
this.dom.appendChild(this.container);
|
|
47
51
|
this.dom.addEventListener('click', this.handleClick);
|
|
48
52
|
};
|
|
49
53
|
this.actionGutterButtons = () => {
|
|
@@ -78,5 +82,23 @@ export class PullquoteElementView extends BlockView {
|
|
|
78
82
|
tr.insert(this.getPos() + 1, schema.nodes.quote_image.create());
|
|
79
83
|
this.view.dispatch(tr);
|
|
80
84
|
}
|
|
85
|
+
updateContents() {
|
|
86
|
+
super.updateContents();
|
|
87
|
+
this.addTools();
|
|
88
|
+
}
|
|
89
|
+
addTools() {
|
|
90
|
+
this.addPositionMenu();
|
|
91
|
+
}
|
|
92
|
+
addPositionMenu() {
|
|
93
|
+
if (!this.positionMenu) {
|
|
94
|
+
this.positionMenu = new HorizontalPositionMenu(this, this.updateHorizontalPosition, this.container);
|
|
95
|
+
}
|
|
96
|
+
this.positionMenu.create();
|
|
97
|
+
}
|
|
98
|
+
updateHorizontalPosition(horizontalPosition) {
|
|
99
|
+
const tr = this.view.state.tr;
|
|
100
|
+
tr.setNodeAttribute(this.getPos(), 'type', horizontalPosition);
|
|
101
|
+
this.view.dispatch(tr);
|
|
102
|
+
}
|
|
81
103
|
}
|
|
82
104
|
export default createNodeOrElementView(PullquoteElementView, 'aside');
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import BlockView from './block_view';
|
|
17
17
|
import { createNodeView } from './creators';
|
|
18
|
+
import { HorizontalPositionMenu } from '../lib/position-menu';
|
|
18
19
|
export class TableElementView extends BlockView {
|
|
19
20
|
constructor() {
|
|
20
21
|
super(...arguments);
|
|
@@ -23,8 +24,29 @@ export class TableElementView extends BlockView {
|
|
|
23
24
|
this.contentDOM = document.createElement('figure');
|
|
24
25
|
this.contentDOM.classList.add('block');
|
|
25
26
|
this.contentDOM.setAttribute('id', this.node.attrs.id);
|
|
26
|
-
this.
|
|
27
|
+
this.container = document.createElement('div');
|
|
28
|
+
this.container.classList.add('container');
|
|
29
|
+
this.container.appendChild(this.contentDOM);
|
|
30
|
+
this.dom.appendChild(this.container);
|
|
27
31
|
};
|
|
28
32
|
}
|
|
33
|
+
updateContents() {
|
|
34
|
+
super.updateContents();
|
|
35
|
+
this.addTools();
|
|
36
|
+
}
|
|
37
|
+
addTools() {
|
|
38
|
+
this.addPositionMenu();
|
|
39
|
+
}
|
|
40
|
+
addPositionMenu() {
|
|
41
|
+
if (!this.positionMenu) {
|
|
42
|
+
this.positionMenu = new HorizontalPositionMenu(this, this.updateHorizontalPosition, this.container);
|
|
43
|
+
}
|
|
44
|
+
this.positionMenu.create();
|
|
45
|
+
}
|
|
46
|
+
updateHorizontalPosition(horizontalPosition) {
|
|
47
|
+
const tr = this.view.state.tr;
|
|
48
|
+
tr.setNodeAttribute(this.getPos(), 'type', horizontalPosition);
|
|
49
|
+
this.view.dispatch(tr);
|
|
50
|
+
}
|
|
29
51
|
}
|
|
30
52
|
export default createNodeView(TableElementView);
|
|
@@ -13,16 +13,18 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Placement, StrictModifiers } from '@popperjs/core';
|
|
16
|
+
import { Instance, Placement, StrictModifiers } from '@popperjs/core';
|
|
17
17
|
export declare class PopperManager {
|
|
18
18
|
private activePopper?;
|
|
19
19
|
private handleDocumentClick?;
|
|
20
20
|
private triggerElement?;
|
|
21
21
|
private container?;
|
|
22
|
-
|
|
22
|
+
private destructionListener?;
|
|
23
|
+
show(target: Element, contents: HTMLElement, placement?: Placement, showArrow?: boolean, modifiers?: Array<Partial<StrictModifiers>>, autoFocus?: boolean, autoCloseOnOutsideClick?: boolean, onDestroy?: ((i: Instance) => void) | undefined): void;
|
|
23
24
|
destroy(): void;
|
|
24
25
|
getContainer(): HTMLElement | undefined;
|
|
25
26
|
update(): void;
|
|
27
|
+
replaceContent(newContent: HTMLElement): void;
|
|
26
28
|
isActive: () => boolean;
|
|
27
29
|
private focusInput;
|
|
28
30
|
private addContainerClass;
|
|
@@ -15,20 +15,45 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { ManuscriptEditorView, ManuscriptNode, ManuscriptNodeType } from '@manuscripts/transform';
|
|
17
17
|
import { EditorProps } from '../configs/ManuscriptsEditor';
|
|
18
|
+
import BlockView from '../views/block_view';
|
|
19
|
+
export declare enum HorizontalPositions {
|
|
20
|
+
left = "half-left",
|
|
21
|
+
right = "half-right",
|
|
22
|
+
default = ""
|
|
23
|
+
}
|
|
18
24
|
export interface PopperMenuPositionOption {
|
|
19
25
|
label: string;
|
|
20
26
|
action: () => void;
|
|
21
27
|
icon: string;
|
|
22
28
|
selected: boolean;
|
|
23
29
|
}
|
|
24
|
-
export declare
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
export declare class HorizontalPositionMenu {
|
|
31
|
+
private parent;
|
|
32
|
+
menuOpen: boolean;
|
|
33
|
+
posMenuSelector: string;
|
|
34
|
+
onChange: (newPos: HorizontalPositions) => void;
|
|
35
|
+
positionMenuWrapper: HTMLDivElement;
|
|
36
|
+
location: HTMLElement;
|
|
37
|
+
getPositionSource?: () => ManuscriptNode | null;
|
|
38
|
+
constructor(parent: BlockView<ManuscriptNode>, onChange: (newPos: HorizontalPositions) => void, location?: HTMLElement, getPositionSource?: () => ManuscriptNode | null);
|
|
39
|
+
static createPositionOptions<T extends ManuscriptNode>(nodeType: ManuscriptNodeType, node: T, currentPosition: string, view: ManuscriptEditorView, onComplete?: () => void): {
|
|
40
|
+
title: string;
|
|
41
|
+
action: () => void;
|
|
42
|
+
IconComponent: string;
|
|
43
|
+
iconName: string;
|
|
44
|
+
selected: boolean;
|
|
45
|
+
}[];
|
|
46
|
+
createPopperMenuPositionOptions<T extends ManuscriptNode>(nodeType: ManuscriptNodeType, node: T, currentPosition: string, view: ManuscriptEditorView, onComplete?: () => void): PopperMenuPositionOption[];
|
|
47
|
+
buttonClass: string;
|
|
48
|
+
createPositionMenuWrapper(currentPosition: string, props: EditorProps): void;
|
|
49
|
+
getHorizontalPositionOptions(current: string, onPick: (newPos: HorizontalPositions) => void, destroy: () => void): {
|
|
50
|
+
actions: {
|
|
51
|
+
label: string;
|
|
52
|
+
action: () => void;
|
|
53
|
+
icon: string;
|
|
54
|
+
selected: boolean;
|
|
55
|
+
}[];
|
|
56
|
+
};
|
|
57
|
+
showPositionMenu(force?: boolean): void;
|
|
58
|
+
create(): void;
|
|
59
|
+
}
|
package/dist/types/lib/view.d.ts
CHANGED
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { BibliographyItemAttrs, ManuscriptEditorView, ManuscriptNodeType } from '@manuscripts/transform';
|
|
16
|
+
import { BibliographyItemAttrs, ManuscriptEditorView, ManuscriptNode, ManuscriptNodeType } from '@manuscripts/transform';
|
|
17
17
|
import { Attrs } from 'prosemirror-model';
|
|
18
18
|
import * as utils from 'prosemirror-utils';
|
|
19
|
+
import { EditorView } from 'prosemirror-view';
|
|
19
20
|
export declare const findChildByID: (view: ManuscriptEditorView, id: string) => utils.NodeWithPos | undefined;
|
|
20
21
|
export declare const findChildByType: (view: ManuscriptEditorView, type: ManuscriptNodeType) => utils.NodeWithPos | undefined;
|
|
21
22
|
export declare const findChildrenByType: (view: ManuscriptEditorView, type: ManuscriptNodeType) => utils.NodeWithPos[];
|
|
@@ -24,3 +25,4 @@ export declare const updateNodeAttrs: (view: ManuscriptEditorView, type: Manuscr
|
|
|
24
25
|
export declare const deleteNode: (view: ManuscriptEditorView, id: string) => void;
|
|
25
26
|
export declare const insertBibliographyItems: (view: ManuscriptEditorView, items: BibliographyItemAttrs[]) => void;
|
|
26
27
|
export declare const saveBibliographyItem: (view: ManuscriptEditorView, attrs: BibliographyItemAttrs[]) => void;
|
|
28
|
+
export declare const isSelectionInsideNode: (view: EditorView, node: ManuscriptNode, pos: number) => boolean;
|
package/dist/types/versions.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "3.
|
|
1
|
+
export declare const VERSION = "3.17.1";
|
|
2
2
|
export declare const MATHJAX_VERSION = "3.2.2";
|
|
@@ -17,7 +17,13 @@ import { BoxElementNode } from '@manuscripts/transform';
|
|
|
17
17
|
import BlockView from './block_view';
|
|
18
18
|
export declare class BoxElementView extends BlockView<BoxElementNode> {
|
|
19
19
|
elementType: string;
|
|
20
|
+
container: HTMLDivElement;
|
|
20
21
|
createElement: () => void;
|
|
22
|
+
updateContents(): void;
|
|
23
|
+
protected addTools(): void;
|
|
24
|
+
private positionMenu;
|
|
25
|
+
protected addPositionMenu(): void;
|
|
26
|
+
private updateHorizontalPosition;
|
|
21
27
|
}
|
|
22
28
|
declare const _default: (props: import("../configs/ManuscriptsEditor").EditorProps, dispatch?: import("..").Dispatch) => import("../types").NodeViewCreator<BoxElementView>;
|
|
23
29
|
export default _default;
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { ContextMenuProps } from '@manuscripts/style-guide';
|
|
16
17
|
import { FootnoteNode } from '@manuscripts/transform';
|
|
17
18
|
import { Transaction } from 'prosemirror-state';
|
|
18
19
|
import { Trackable } from '../types';
|
|
@@ -20,14 +21,16 @@ import { BaseNodeView } from './base_node_view';
|
|
|
20
21
|
export declare class FootnoteView extends BaseNodeView<Trackable<FootnoteNode>> {
|
|
21
22
|
dialog: HTMLElement;
|
|
22
23
|
contextMenu: HTMLDivElement;
|
|
24
|
+
isMenuShown: boolean;
|
|
25
|
+
previousActionsLabels: string[];
|
|
23
26
|
initialise: () => void;
|
|
24
27
|
updateContents(): void;
|
|
25
28
|
getFootnoteState(): {
|
|
26
29
|
id: string;
|
|
27
30
|
fn: import("../plugins/footnotes").FootnotesElementState | undefined;
|
|
28
31
|
};
|
|
29
|
-
showContextMenu(
|
|
30
|
-
|
|
32
|
+
showContextMenu(actions: ContextMenuProps['actions'], autoFocus: boolean): void;
|
|
33
|
+
getContextMenuActions(): import("@manuscripts/style-guide").Actions[];
|
|
31
34
|
handleMarkerClick: (e?: Event) => void;
|
|
32
35
|
handleDeleteClick: (e?: Event) => void;
|
|
33
36
|
handleDelete: () => void;
|
|
@@ -19,10 +19,10 @@ import { BaseNodeView } from './base_node_view';
|
|
|
19
19
|
export declare class GeneralTableFootnoteView extends BaseNodeView<Trackable<GeneralTableFootnoteNode>> {
|
|
20
20
|
dialog: HTMLElement;
|
|
21
21
|
contextMenu: HTMLDivElement;
|
|
22
|
+
isMenuShown: boolean;
|
|
22
23
|
initialise: () => void;
|
|
23
24
|
updateContents(): void;
|
|
24
|
-
|
|
25
|
-
showContextMenu(element: HTMLElement): void;
|
|
25
|
+
showContextMenu(autoFocus?: boolean): void;
|
|
26
26
|
handleDeleteClick: () => void;
|
|
27
27
|
handleDelete: () => void;
|
|
28
28
|
}
|