@manuscripts/body-editor 1.9.7 → 1.9.10-LEAN-3508.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.
@@ -176,6 +176,6 @@ const DraggableTree = ({ tree, view, depth, can, }) => {
176
176
  react_1.default.createElement(Outline_1.OutlineItemLink, { to: `#${node.attrs.id}` },
177
177
  react_1.default.createElement(Outline_1.OutlineItemIcon, null, (0, node_type_icons_1.nodeTypeIcon)(node.type)),
178
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));
179
+ items.length ? (react_1.default.createElement("div", { className: `subtree ${isOpen ? '' : 'collapsed'}` }, items.map((subtree, index) => (react_1.default.createElement(exports.DraggableTree, { key: subtree.node.attrs.id || 'subtree-' + index, tree: subtree, view: view, depth: !tree.parent ? depth : depth + 1, can: can }))))) : null));
180
180
  };
181
181
  exports.DraggableTree = DraggableTree;
@@ -18,17 +18,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.skipCommandTracking = void 0;
19
19
  const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
20
20
  const transform_1 = require("@manuscripts/transform");
21
+ const prosemirror_commands_1 = require("prosemirror-commands");
22
+ const prosemirror_inputrules_1 = require("prosemirror-inputrules");
21
23
  const prosemirror_schema_list_1 = require("prosemirror-schema-list");
24
+ const prosemirror_utils_1 = require("prosemirror-utils");
22
25
  const skipCommandTracking = (command) => (state, dispatch) => {
23
- command(state, (tr) => {
26
+ return command(state, (tr) => {
24
27
  if (dispatch) {
25
28
  (0, track_changes_plugin_1.skipTracking)(tr);
26
29
  dispatch(tr);
27
30
  }
28
31
  });
29
- return true;
30
32
  };
31
33
  exports.skipCommandTracking = skipCommandTracking;
34
+ const listItemBackward = (state, dispatch) => {
35
+ const { selection } = state;
36
+ const isListItem = (0, prosemirror_utils_1.findParentNodeOfType)(transform_1.schema.nodes.list_item)(selection);
37
+ if (isListItem) {
38
+ return (0, prosemirror_commands_1.joinBackward)(state, dispatch);
39
+ }
40
+ return false;
41
+ };
32
42
  const liftToOuterList = (itemType) => {
33
43
  return function (state, dispatch) {
34
44
  const { $from, $to } = state.selection;
@@ -55,5 +65,6 @@ const listKeymap = {
55
65
  'Mod-Alt-k': (0, exports.skipCommandTracking)((0, prosemirror_schema_list_1.wrapInList)(transform_1.schema.nodes.bullet_list)),
56
66
  'Shift-Tab': (0, exports.skipCommandTracking)(liftToOuterList(transform_1.schema.nodes.list_item)),
57
67
  Tab: (0, exports.skipCommandTracking)((0, prosemirror_schema_list_1.sinkListItem)(transform_1.schema.nodes.list_item)),
68
+ Backspace: (0, exports.skipCommandTracking)((0, prosemirror_commands_1.chainCommands)(prosemirror_inputrules_1.undoInputRule, listItemBackward, prosemirror_commands_1.deleteSelection)),
58
69
  };
59
70
  exports.default = listKeymap;
@@ -118,7 +118,7 @@ class CitationEditableView extends citation_1.CitationView {
118
118
  };
119
119
  this.editor = (0, ReactSubView_1.default)(this.props, CitationViewer_1.CitationViewer, componentProps, this.node, this.getPos, this.view, 'citation-editor');
120
120
  }
121
- this.props.popper.show(this.dom, this.editor, 'right');
121
+ this.props.popper.show(this.dom, this.editor, 'auto');
122
122
  };
123
123
  this.handleEdit = () => {
124
124
  this.showPopper();
@@ -149,5 +149,5 @@ export const DraggableTree = ({ tree, view, depth, can, }) => {
149
149
  React.createElement(OutlineItemLink, { to: `#${node.attrs.id}` },
150
150
  React.createElement(OutlineItemIcon, null, nodeTypeIcon(node.type)),
151
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));
152
+ items.length ? (React.createElement("div", { className: `subtree ${isOpen ? '' : 'collapsed'}` }, items.map((subtree, index) => (React.createElement(DraggableTree, { key: subtree.node.attrs.id || 'subtree-' + index, tree: subtree, view: view, depth: !tree.parent ? depth : depth + 1, can: can }))))) : null));
153
153
  };
@@ -15,15 +15,25 @@
15
15
  */
16
16
  import { skipTracking } from '@manuscripts/track-changes-plugin';
17
17
  import { schema } from '@manuscripts/transform';
18
+ import { chainCommands, deleteSelection, joinBackward, } from 'prosemirror-commands';
19
+ import { undoInputRule } from 'prosemirror-inputrules';
18
20
  import { liftListItem, sinkListItem, splitListItem, wrapInList, } from 'prosemirror-schema-list';
21
+ import { findParentNodeOfType } from 'prosemirror-utils';
19
22
  export const skipCommandTracking = (command) => (state, dispatch) => {
20
- command(state, (tr) => {
23
+ return command(state, (tr) => {
21
24
  if (dispatch) {
22
25
  skipTracking(tr);
23
26
  dispatch(tr);
24
27
  }
25
28
  });
26
- return true;
29
+ };
30
+ const listItemBackward = (state, dispatch) => {
31
+ const { selection } = state;
32
+ const isListItem = findParentNodeOfType(schema.nodes.list_item)(selection);
33
+ if (isListItem) {
34
+ return joinBackward(state, dispatch);
35
+ }
36
+ return false;
27
37
  };
28
38
  const liftToOuterList = (itemType) => {
29
39
  return function (state, dispatch) {
@@ -51,5 +61,6 @@ const listKeymap = {
51
61
  'Mod-Alt-k': skipCommandTracking(wrapInList(schema.nodes.bullet_list)),
52
62
  'Shift-Tab': skipCommandTracking(liftToOuterList(schema.nodes.list_item)),
53
63
  Tab: skipCommandTracking(sinkListItem(schema.nodes.list_item)),
64
+ Backspace: skipCommandTracking(chainCommands(undoInputRule, listItemBackward, deleteSelection)),
54
65
  };
55
66
  export default listKeymap;
@@ -112,7 +112,7 @@ export class CitationEditableView extends CitationView {
112
112
  };
113
113
  this.editor = ReactSubView(this.props, CitationViewer, componentProps, this.node, this.getPos, this.view, 'citation-editor');
114
114
  }
115
- this.props.popper.show(this.dom, this.editor, 'right');
115
+ this.props.popper.show(this.dom, this.editor, 'auto');
116
116
  };
117
117
  this.handleEdit = () => {
118
118
  this.showPopper();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/body-editor",
3
3
  "description": "Prosemirror components for editing and viewing manuscripts",
4
- "version": "1.9.7",
4
+ "version": "1.9.10-LEAN-3508.0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -111,4 +111,4 @@
111
111
  "@types/react": "^17.0.2",
112
112
  "prosemirror-tables": "^1.3.5"
113
113
  }
114
- }
114
+ }
package/styles/popper.css CHANGED
@@ -188,6 +188,7 @@
188
188
  }
189
189
 
190
190
  .popper .link-editor {
191
+ position: relative;
191
192
  background: #fff;
192
193
  border-radius: 8px;
193
194
  border: 1px solid #e2e2e2;
@@ -195,7 +196,10 @@
195
196
  height: auto;
196
197
  }
197
198
 
198
- .popper .citation-editor,
199
+ .popper .citation-editor {
200
+ position: relative;
201
+ width: 600px;
202
+ }
199
203
  .popper .table-footnote-editor {
200
204
  width: 600px;
201
205
  }