@manuscripts/body-editor 3.16.2 → 3.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/lib/context-menu.js +28 -11
- package/dist/cjs/lib/popper.js +15 -1
- package/dist/cjs/lib/position-menu.js +175 -100
- 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/equation.js +2 -0
- package/dist/cjs/views/equation_editable.js +2 -0
- package/dist/cjs/views/image_element.js +7 -62
- package/dist/cjs/views/inline_equation.js +2 -0
- package/dist/cjs/views/inline_equation_editable.js +2 -0
- 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 +15 -1
- package/dist/es/lib/position-menu.js +173 -91
- 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/equation.js +2 -0
- package/dist/es/views/equation_editable.js +2 -0
- package/dist/es/views/image_element.js +7 -62
- package/dist/es/views/inline_equation.js +2 -0
- package/dist/es/views/inline_equation_editable.js +2 -0
- 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/versions.d.ts +1 -1
- package/dist/types/views/box_element.d.ts +6 -0
- 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 +1 -1
- package/src/lib/context-menu.ts +42 -21
- package/src/lib/popper.ts +18 -1
- package/src/lib/position-menu.ts +242 -137
- 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/equation.ts +5 -0
- package/src/views/equation_editable.ts +3 -0
- package/src/views/image_element.ts +12 -89
- package/src/views/inline_equation.ts +5 -0
- package/src/views/inline_equation_editable.ts +3 -0
- 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 +11 -6
|
@@ -35,8 +35,15 @@ const readonlyTypes = [
|
|
|
35
35
|
transform_1.schema.nodes.bibliography_section,
|
|
36
36
|
transform_1.schema.nodes.footnotes_section,
|
|
37
37
|
];
|
|
38
|
-
const
|
|
39
|
-
|
|
38
|
+
const getBoxElementOfSectionTitle = ($pos, node) => {
|
|
39
|
+
if ((0, transform_1.isSectionTitleNode)(node)) {
|
|
40
|
+
const parent = $pos.node($pos.depth - 1);
|
|
41
|
+
if (parent.type === transform_1.schema.nodes.box_element) {
|
|
42
|
+
return parent;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
};
|
|
40
47
|
const sectionLevel = (depth) => {
|
|
41
48
|
switch (depth) {
|
|
42
49
|
case 1:
|
|
@@ -157,18 +164,28 @@ class ContextMenu {
|
|
|
157
164
|
const menu = document.createElement('div');
|
|
158
165
|
menu.className = 'menu';
|
|
159
166
|
const $pos = this.resolvePos();
|
|
160
|
-
const
|
|
161
|
-
const type =
|
|
162
|
-
|
|
163
|
-
|
|
167
|
+
const boxParent = getBoxElementOfSectionTitle($pos, this.node);
|
|
168
|
+
const type = boxParent ? transform_1.schema.nodes.box_element : this.node.type;
|
|
169
|
+
const positionableTypes = [
|
|
170
|
+
transform_1.schema.nodes.figure_element,
|
|
171
|
+
transform_1.schema.nodes.image_element,
|
|
172
|
+
transform_1.schema.nodes.box_element,
|
|
173
|
+
transform_1.schema.nodes.pullquote_element,
|
|
174
|
+
transform_1.schema.nodes.table_element,
|
|
175
|
+
];
|
|
176
|
+
let nodeBase = this.node;
|
|
177
|
+
if (positionableTypes.includes(type)) {
|
|
164
178
|
const figure = (0, utils_1.getMatchingChild)(this.node, (node) => node.type === transform_1.schema.nodes.figure);
|
|
165
179
|
if (figure) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
menu.appendChild(submenu);
|
|
180
|
+
nodeBase = figure;
|
|
181
|
+
}
|
|
182
|
+
if (boxParent) {
|
|
183
|
+
nodeBase = boxParent;
|
|
171
184
|
}
|
|
185
|
+
const submenuOptions = position_menu_1.HorizontalPositionMenu.createPositionOptions(transform_1.schema.nodes[nodeBase.type.name], nodeBase, nodeBase.attrs.type, this.view, () => popper.destroy());
|
|
186
|
+
const submenuLabel = 'Position';
|
|
187
|
+
const submenu = this.createSubmenu(submenuLabel, submenuOptions);
|
|
188
|
+
menu.appendChild(submenu);
|
|
172
189
|
}
|
|
173
190
|
if (type === transform_1.schema.nodes.list) {
|
|
174
191
|
menu.appendChild(this.createMenuSection((section) => {
|
package/dist/cjs/lib/popper.js
CHANGED
|
@@ -22,9 +22,10 @@ class PopperManager {
|
|
|
22
22
|
constructor() {
|
|
23
23
|
this.isActive = () => !!this.activePopper;
|
|
24
24
|
}
|
|
25
|
-
show(target, contents, placement = 'bottom', showArrow = true, modifiers = [], autoFocus = true) {
|
|
25
|
+
show(target, contents, placement = 'bottom', showArrow = true, modifiers = [], autoFocus = true, onDestroy = undefined) {
|
|
26
26
|
this.destroy();
|
|
27
27
|
this.triggerElement = target;
|
|
28
|
+
this.destructionListener = onDestroy;
|
|
28
29
|
window.requestAnimationFrame(() => {
|
|
29
30
|
const container = document.createElement('div');
|
|
30
31
|
container.className = 'popper';
|
|
@@ -94,6 +95,8 @@ class PopperManager {
|
|
|
94
95
|
destroy() {
|
|
95
96
|
if (this.activePopper) {
|
|
96
97
|
this.removeContainerClass(this.activePopper.state.elements.reference);
|
|
98
|
+
this.destructionListener?.(this.activePopper);
|
|
99
|
+
this.destructionListener = undefined;
|
|
97
100
|
this.activePopper.destroy();
|
|
98
101
|
this.activePopper.state.elements.popper.remove();
|
|
99
102
|
if (this.handleDocumentClick) {
|
|
@@ -111,6 +114,17 @@ class PopperManager {
|
|
|
111
114
|
this.activePopper.update();
|
|
112
115
|
}
|
|
113
116
|
}
|
|
117
|
+
replaceContent(newContent) {
|
|
118
|
+
if (this.container && this.activePopper) {
|
|
119
|
+
const arrow = this.container.querySelector('.popper-arrow');
|
|
120
|
+
this.container.innerHTML = '';
|
|
121
|
+
if (arrow) {
|
|
122
|
+
this.container.appendChild(arrow);
|
|
123
|
+
}
|
|
124
|
+
this.container.appendChild(newContent);
|
|
125
|
+
this.activePopper.update();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
114
128
|
focusInput(container, autoFocus = true) {
|
|
115
129
|
const input = container.querySelector('input');
|
|
116
130
|
if (input) {
|
|
@@ -14,112 +14,187 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
-
};
|
|
20
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.
|
|
18
|
+
exports.HorizontalPositionMenu = exports.HorizontalPositions = void 0;
|
|
22
19
|
const style_guide_1 = require("@manuscripts/style-guide");
|
|
23
20
|
const icons_1 = require("../icons");
|
|
24
|
-
const
|
|
25
|
-
const ReactSubView_1 = __importDefault(require("../views/ReactSubView"));
|
|
21
|
+
const ReactSubView_1 = require("../views/ReactSubView");
|
|
26
22
|
const navigation_utils_1 = require("./navigation-utils");
|
|
27
23
|
const view_1 = require("./view");
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
element.setAttribute('data-alignment', 'right');
|
|
89
|
-
break;
|
|
90
|
-
default:
|
|
91
|
-
element.removeAttribute('data-alignment');
|
|
92
|
-
break;
|
|
24
|
+
var HorizontalPositions;
|
|
25
|
+
(function (HorizontalPositions) {
|
|
26
|
+
HorizontalPositions["left"] = "half-left";
|
|
27
|
+
HorizontalPositions["right"] = "half-right";
|
|
28
|
+
HorizontalPositions["default"] = "";
|
|
29
|
+
})(HorizontalPositions || (exports.HorizontalPositions = HorizontalPositions = {}));
|
|
30
|
+
class HorizontalPositionMenu {
|
|
31
|
+
constructor(parent, onChange, location, getPositionSource) {
|
|
32
|
+
this.menuOpen = false;
|
|
33
|
+
this.posMenuSelector = 'position-menu';
|
|
34
|
+
this.buttonClass = 'position-menu-button';
|
|
35
|
+
const preSource = getPositionSource?.() || parent.node;
|
|
36
|
+
if (typeof preSource.attrs.type === 'undefined') {
|
|
37
|
+
console.error("This node doesn't support horizontal alignment");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
this.getPositionSource = getPositionSource;
|
|
41
|
+
this.location = location || parent.dom;
|
|
42
|
+
this.onChange = onChange.bind(parent);
|
|
43
|
+
this.parent = parent;
|
|
44
|
+
}
|
|
45
|
+
static createPositionOptions(nodeType, node, currentPosition, view, onComplete) {
|
|
46
|
+
const createAction = (position) => () => {
|
|
47
|
+
onComplete?.();
|
|
48
|
+
(0, view_1.updateNodeAttrs)(view, nodeType, {
|
|
49
|
+
...node.attrs,
|
|
50
|
+
type: position,
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
return [
|
|
54
|
+
{
|
|
55
|
+
title: 'Left',
|
|
56
|
+
action: createAction(HorizontalPositions.left),
|
|
57
|
+
IconComponent: icons_1.imageLeftIcon,
|
|
58
|
+
iconName: 'ImageLeft',
|
|
59
|
+
selected: currentPosition === HorizontalPositions.left,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
title: 'Default',
|
|
63
|
+
action: createAction(HorizontalPositions.default),
|
|
64
|
+
IconComponent: icons_1.imageDefaultIcon,
|
|
65
|
+
iconName: 'ImageDefault',
|
|
66
|
+
selected: !currentPosition || currentPosition === HorizontalPositions.default,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
title: 'Right',
|
|
70
|
+
action: createAction(HorizontalPositions.right),
|
|
71
|
+
IconComponent: icons_1.imageRightIcon,
|
|
72
|
+
iconName: 'ImageRight',
|
|
73
|
+
selected: currentPosition === HorizontalPositions.right,
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
createPopperMenuPositionOptions(nodeType, node, currentPosition, view, onComplete) {
|
|
78
|
+
return HorizontalPositionMenu.createPositionOptions(nodeType, node, currentPosition, view, onComplete).map((option) => ({
|
|
79
|
+
label: option.title,
|
|
80
|
+
action: option.action,
|
|
81
|
+
icon: option.iconName,
|
|
82
|
+
selected: option.selected,
|
|
83
|
+
}));
|
|
93
84
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
85
|
+
createPositionMenuWrapper(currentPosition, props) {
|
|
86
|
+
const can = props.getCapabilities();
|
|
87
|
+
const positionMenuWrapper = document.createElement('div');
|
|
88
|
+
positionMenuWrapper.classList.add(this.posMenuSelector);
|
|
89
|
+
const positionMenuButton = document.createElement('div');
|
|
90
|
+
positionMenuButton.classList.add(this.buttonClass);
|
|
91
|
+
let icon;
|
|
92
|
+
switch (currentPosition) {
|
|
93
|
+
case HorizontalPositions.left:
|
|
94
|
+
icon = icons_1.imageLeftIcon;
|
|
95
|
+
break;
|
|
96
|
+
case HorizontalPositions.right:
|
|
97
|
+
icon = icons_1.imageRightIcon;
|
|
98
|
+
break;
|
|
99
|
+
default:
|
|
100
|
+
icon = icons_1.imageDefaultIcon;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
if (icon) {
|
|
104
|
+
positionMenuButton.innerHTML = icon;
|
|
105
|
+
}
|
|
106
|
+
const onClick = () => {
|
|
107
|
+
this.showPositionMenu();
|
|
108
|
+
};
|
|
109
|
+
if (can.editArticle) {
|
|
110
|
+
positionMenuButton.tabIndex = -1;
|
|
111
|
+
positionMenuButton.addEventListener('click', onClick);
|
|
112
|
+
positionMenuButton.addEventListener('keydown', (0, navigation_utils_1.handleEnterKey)(onClick));
|
|
113
|
+
}
|
|
114
|
+
if (this.positionMenuWrapper) {
|
|
115
|
+
const button = this.positionMenuWrapper.querySelector('.' + this.buttonClass);
|
|
116
|
+
if (button) {
|
|
117
|
+
this.positionMenuWrapper.removeChild(button);
|
|
118
|
+
this.positionMenuWrapper.appendChild(positionMenuButton);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
positionMenuWrapper.appendChild(positionMenuButton);
|
|
123
|
+
this.positionMenuWrapper = positionMenuWrapper;
|
|
124
|
+
this.location.prepend(this.positionMenuWrapper);
|
|
125
|
+
}
|
|
113
126
|
}
|
|
114
|
-
|
|
115
|
-
|
|
127
|
+
getHorizontalPositionOptions(current, onPick, destroy) {
|
|
128
|
+
const componentProps = {
|
|
129
|
+
actions: [
|
|
130
|
+
{
|
|
131
|
+
label: 'Left',
|
|
132
|
+
action: () => {
|
|
133
|
+
destroy();
|
|
134
|
+
this.menuOpen = false;
|
|
135
|
+
onPick(HorizontalPositions.left);
|
|
136
|
+
},
|
|
137
|
+
icon: 'ImageLeft',
|
|
138
|
+
selected: current === HorizontalPositions.left,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
label: 'Default',
|
|
142
|
+
action: () => {
|
|
143
|
+
destroy();
|
|
144
|
+
this.menuOpen = false;
|
|
145
|
+
onPick(HorizontalPositions.default);
|
|
146
|
+
},
|
|
147
|
+
icon: 'ImageDefault',
|
|
148
|
+
selected: !current,
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
label: 'Right',
|
|
152
|
+
action: () => {
|
|
153
|
+
destroy();
|
|
154
|
+
this.menuOpen = false;
|
|
155
|
+
onPick(HorizontalPositions.right);
|
|
156
|
+
},
|
|
157
|
+
icon: 'ImageRight',
|
|
158
|
+
selected: current === HorizontalPositions.right,
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
};
|
|
162
|
+
return componentProps;
|
|
163
|
+
}
|
|
164
|
+
showPositionMenu(force = false) {
|
|
165
|
+
const p = this.parent;
|
|
166
|
+
if (this.menuOpen && !force) {
|
|
167
|
+
p.props.popper.destroy();
|
|
168
|
+
this.menuOpen = false;
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const posSource = this.getPositionSource
|
|
172
|
+
? this.getPositionSource()
|
|
173
|
+
: this.parent.node;
|
|
174
|
+
const componentProps = this.getHorizontalPositionOptions(posSource?.attrs.type || HorizontalPositions.default, this.onChange, p.props.popper.destroy.bind(p.props.popper));
|
|
175
|
+
(0, ReactSubView_1.createSubViewAsync)(p.props, style_guide_1.ContextMenu, componentProps, p.node, p.getPos, p.view, ['context-menu', this.posMenuSelector]).then((content) => {
|
|
176
|
+
if (this.menuOpen && p.props.popper.isActive()) {
|
|
177
|
+
p.props.popper.replaceContent(content);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
p.props.popper.show(this.positionMenuWrapper, content, 'left', false, [], true, () => {
|
|
181
|
+
this.menuOpen = false;
|
|
182
|
+
});
|
|
183
|
+
this.menuOpen = true;
|
|
184
|
+
}
|
|
185
|
+
});
|
|
116
186
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
187
|
+
create() {
|
|
188
|
+
if (!this.parent) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const p = this.parent;
|
|
192
|
+
if (p.props.getCapabilities()?.editArticle) {
|
|
193
|
+
const posSource = this.getPositionSource
|
|
194
|
+
? this.getPositionSource()
|
|
195
|
+
: this.parent.node;
|
|
196
|
+
this.createPositionMenuWrapper(posSource?.attrs.type || HorizontalPositions.default, p.props);
|
|
197
|
+
}
|
|
121
198
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
};
|
|
125
|
-
exports.createPositionMenuWrapper = createPositionMenuWrapper;
|
|
199
|
+
}
|
|
200
|
+
exports.HorizontalPositionMenu = HorizontalPositionMenu;
|
|
@@ -25,10 +25,12 @@ exports.default = (props) => {
|
|
|
25
25
|
key: exports.detectInconsistencyKey,
|
|
26
26
|
state: {
|
|
27
27
|
init: (_, state) => (0, detect_inconsistency_utils_1.buildPluginState)(state, props, false),
|
|
28
|
-
apply: (tr, value, newState) => {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
apply: (tr, value, _, newState) => {
|
|
29
|
+
const metaValue = tr.getMeta(exports.detectInconsistencyKey);
|
|
30
|
+
const showDecorations = metaValue !== undefined ? metaValue : value.showDecorations;
|
|
31
|
+
if (!tr.docChanged && metaValue === undefined) {
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
32
34
|
return (0, detect_inconsistency_utils_1.buildPluginState)(newState, props, showDecorations);
|
|
33
35
|
},
|
|
34
36
|
},
|
package/dist/cjs/versions.js
CHANGED
|
@@ -21,6 +21,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
21
|
exports.BoxElementView = void 0;
|
|
22
22
|
const block_view_1 = __importDefault(require("./block_view"));
|
|
23
23
|
const creators_1 = require("./creators");
|
|
24
|
+
const position_menu_1 = require("../lib/position-menu");
|
|
24
25
|
class BoxElementView extends block_view_1.default {
|
|
25
26
|
constructor() {
|
|
26
27
|
super(...arguments);
|
|
@@ -29,9 +30,30 @@ class BoxElementView extends block_view_1.default {
|
|
|
29
30
|
this.contentDOM = document.createElement(this.elementType);
|
|
30
31
|
this.contentDOM.className = 'block box-element';
|
|
31
32
|
this.contentDOM.setAttribute('id', this.node.attrs.id);
|
|
32
|
-
this.
|
|
33
|
+
this.container = document.createElement('div');
|
|
34
|
+
this.container.classList.add('container');
|
|
35
|
+
this.container.appendChild(this.contentDOM);
|
|
36
|
+
this.dom.appendChild(this.container);
|
|
33
37
|
};
|
|
34
38
|
}
|
|
39
|
+
updateContents() {
|
|
40
|
+
super.updateContents();
|
|
41
|
+
this.addTools();
|
|
42
|
+
}
|
|
43
|
+
addTools() {
|
|
44
|
+
this.addPositionMenu();
|
|
45
|
+
}
|
|
46
|
+
addPositionMenu() {
|
|
47
|
+
if (!this.positionMenu) {
|
|
48
|
+
this.positionMenu = new position_menu_1.HorizontalPositionMenu(this, this.updateHorizontalPosition, this.container);
|
|
49
|
+
}
|
|
50
|
+
this.positionMenu.create();
|
|
51
|
+
}
|
|
52
|
+
updateHorizontalPosition(horizontalPosition) {
|
|
53
|
+
const tr = this.view.state.tr;
|
|
54
|
+
tr.setNodeAttribute(this.getPos(), 'type', horizontalPosition);
|
|
55
|
+
this.view.dispatch(tr);
|
|
56
|
+
}
|
|
35
57
|
}
|
|
36
58
|
exports.BoxElementView = BoxElementView;
|
|
37
59
|
exports.default = (0, creators_1.createNodeView)(BoxElementView);
|
|
@@ -27,7 +27,7 @@ class CaptionTitleView extends base_node_view_1.BaseNodeView {
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
createDOM() {
|
|
30
|
-
this.dom = document.createElement('
|
|
30
|
+
this.dom = document.createElement('div');
|
|
31
31
|
this.dom.className = 'caption-title placeholder';
|
|
32
32
|
this.contentDOM = this.dom;
|
|
33
33
|
}
|
|
@@ -19,6 +19,7 @@ exports.EquationView = void 0;
|
|
|
19
19
|
const math_1 = require("../lib/math");
|
|
20
20
|
const base_node_view_1 = require("./base_node_view");
|
|
21
21
|
const creators_1 = require("./creators");
|
|
22
|
+
const navigation_utils_1 = require("../lib/navigation-utils");
|
|
22
23
|
class EquationView extends base_node_view_1.BaseNodeView {
|
|
23
24
|
constructor() {
|
|
24
25
|
super(...arguments);
|
|
@@ -29,6 +30,7 @@ class EquationView extends base_node_view_1.BaseNodeView {
|
|
|
29
30
|
this.createDOM = () => {
|
|
30
31
|
this.dom = document.createElement('div');
|
|
31
32
|
this.dom.classList.add('equation');
|
|
33
|
+
this.dom.addEventListener('keydown', (0, navigation_utils_1.handleEnterKey)(() => this.selectNode()));
|
|
32
34
|
};
|
|
33
35
|
this.ignoreMutation = () => true;
|
|
34
36
|
}
|
|
@@ -18,8 +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.ImageElementView =
|
|
22
|
-
const style_guide_1 = require("@manuscripts/style-guide");
|
|
21
|
+
exports.ImageElementView = void 0;
|
|
23
22
|
const transform_1 = require("@manuscripts/transform");
|
|
24
23
|
const icons_1 = require("../icons");
|
|
25
24
|
const media_1 = require("../lib/media");
|
|
@@ -27,13 +26,6 @@ const navigation_utils_1 = require("../lib/navigation-utils");
|
|
|
27
26
|
const position_menu_1 = require("../lib/position-menu");
|
|
28
27
|
const block_view_1 = __importDefault(require("./block_view"));
|
|
29
28
|
const creators_1 = require("./creators");
|
|
30
|
-
const ReactSubView_1 = __importDefault(require("./ReactSubView"));
|
|
31
|
-
var figurePositions;
|
|
32
|
-
(function (figurePositions) {
|
|
33
|
-
figurePositions["left"] = "half-left";
|
|
34
|
-
figurePositions["right"] = "half-right";
|
|
35
|
-
figurePositions["default"] = "";
|
|
36
|
-
})(figurePositions || (exports.figurePositions = figurePositions = {}));
|
|
37
29
|
class ImageElementView extends block_view_1.default {
|
|
38
30
|
constructor() {
|
|
39
31
|
super(...arguments);
|
|
@@ -48,46 +40,6 @@ class ImageElementView extends block_view_1.default {
|
|
|
48
40
|
this.setExtLink({ extLink: result.id });
|
|
49
41
|
this.updateContents();
|
|
50
42
|
};
|
|
51
|
-
this.showPositionMenu = () => {
|
|
52
|
-
const firstFigure = this.getFirstFigure();
|
|
53
|
-
if (!firstFigure) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
this.props.popper.destroy();
|
|
57
|
-
const options = [
|
|
58
|
-
{
|
|
59
|
-
label: 'Left',
|
|
60
|
-
action: () => {
|
|
61
|
-
this.props.popper.destroy();
|
|
62
|
-
this.updateAllFiguresPosition(figurePositions.left);
|
|
63
|
-
},
|
|
64
|
-
icon: 'ImageLeft',
|
|
65
|
-
selected: this.figurePosition === figurePositions.left,
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
label: 'Default',
|
|
69
|
-
action: () => {
|
|
70
|
-
this.props.popper.destroy();
|
|
71
|
-
this.updateAllFiguresPosition(figurePositions.default);
|
|
72
|
-
},
|
|
73
|
-
icon: 'ImageDefault',
|
|
74
|
-
selected: !this.figurePosition,
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
label: 'Right',
|
|
78
|
-
action: () => {
|
|
79
|
-
this.props.popper.destroy();
|
|
80
|
-
this.updateAllFiguresPosition(figurePositions.right);
|
|
81
|
-
},
|
|
82
|
-
icon: 'ImageRight',
|
|
83
|
-
selected: this.figurePosition === figurePositions.right,
|
|
84
|
-
},
|
|
85
|
-
];
|
|
86
|
-
const componentProps = {
|
|
87
|
-
actions: options,
|
|
88
|
-
};
|
|
89
|
-
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);
|
|
90
|
-
};
|
|
91
43
|
this.removeExtLink = () => {
|
|
92
44
|
this.setExtLink({ extLink: '' });
|
|
93
45
|
};
|
|
@@ -133,18 +85,6 @@ class ImageElementView extends block_view_1.default {
|
|
|
133
85
|
addTools() {
|
|
134
86
|
this.addPositionMenu();
|
|
135
87
|
}
|
|
136
|
-
addPositionMenu() {
|
|
137
|
-
if (this.props.getCapabilities()?.editArticle) {
|
|
138
|
-
const existingMenu = this.container.querySelector('.position-menu');
|
|
139
|
-
if (existingMenu) {
|
|
140
|
-
existingMenu.remove();
|
|
141
|
-
}
|
|
142
|
-
const firstFigure = this.getFirstFigure();
|
|
143
|
-
this.figurePosition = firstFigure?.attrs.type || figurePositions.default;
|
|
144
|
-
this.positionMenuWrapper = (0, position_menu_1.createPositionMenuWrapper)(this.figurePosition, this.showPositionMenu, this.props);
|
|
145
|
-
this.container.prepend(this.positionMenuWrapper);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
88
|
getFirstFigure() {
|
|
149
89
|
if (this.node.type === transform_1.schema.nodes.image_element) {
|
|
150
90
|
const figureNode = this.node.firstChild;
|
|
@@ -182,6 +122,12 @@ class ImageElementView extends block_view_1.default {
|
|
|
182
122
|
}
|
|
183
123
|
return figures;
|
|
184
124
|
}
|
|
125
|
+
addPositionMenu() {
|
|
126
|
+
if (!this.positionMenu) {
|
|
127
|
+
this.positionMenu = new position_menu_1.HorizontalPositionMenu(this, this.updateAllFiguresPosition.bind(this), this.container, () => this.getFirstFigure());
|
|
128
|
+
}
|
|
129
|
+
this.positionMenu.create();
|
|
130
|
+
}
|
|
185
131
|
updateAllFiguresPosition(position) {
|
|
186
132
|
const figures = this.getAllFigures();
|
|
187
133
|
const { tr } = this.view.state;
|
|
@@ -192,7 +138,6 @@ class ImageElementView extends block_view_1.default {
|
|
|
192
138
|
});
|
|
193
139
|
});
|
|
194
140
|
this.view.dispatch(tr);
|
|
195
|
-
this.figurePosition = position;
|
|
196
141
|
}
|
|
197
142
|
createDnDPlaceholder() {
|
|
198
143
|
const can = this.props.getCapabilities();
|
|
@@ -19,6 +19,7 @@ exports.InlineEquationView = void 0;
|
|
|
19
19
|
const math_1 = require("../lib/math");
|
|
20
20
|
const base_node_view_1 = require("./base_node_view");
|
|
21
21
|
const creators_1 = require("./creators");
|
|
22
|
+
const navigation_utils_1 = require("../lib/navigation-utils");
|
|
22
23
|
class InlineEquationView extends base_node_view_1.BaseNodeView {
|
|
23
24
|
constructor() {
|
|
24
25
|
super(...arguments);
|
|
@@ -27,6 +28,7 @@ class InlineEquationView extends base_node_view_1.BaseNodeView {
|
|
|
27
28
|
initialise() {
|
|
28
29
|
this.createDOM();
|
|
29
30
|
this.updateContents();
|
|
31
|
+
this.dom.addEventListener('keydown', (0, navigation_utils_1.handleEnterKey)(() => this.selectNode()));
|
|
30
32
|
}
|
|
31
33
|
updateContents() {
|
|
32
34
|
super.updateContents();
|
|
@@ -70,6 +70,8 @@ class InlineEquationEditableView extends inline_equation_1.InlineEquationView {
|
|
|
70
70
|
Esc: () => {
|
|
71
71
|
this.props.popper.destroy();
|
|
72
72
|
this.view.focus();
|
|
73
|
+
const tabbableView = this.dom.querySelector('[tabindex="0"]');
|
|
74
|
+
tabbableView?.focus();
|
|
73
75
|
},
|
|
74
76
|
},
|
|
75
77
|
});
|