@manuscripts/body-editor 2.7.49 → 2.7.50

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.
@@ -8,6 +8,18 @@ const nodes = [
8
8
  tag: 'p',
9
9
  node: 'paragraph',
10
10
  },
11
+ {
12
+ tag: 'ul, ol',
13
+ node: 'list',
14
+ getAttrs: (list) => {
15
+ const dom = list;
16
+ return {
17
+ listStyleType: (0, transform_1.getJatsListType)(dom.style.listStyleType ||
18
+ (dom.firstChild &&
19
+ dom.firstChild.style.listStyleType)),
20
+ };
21
+ },
22
+ },
11
23
  {
12
24
  tag: 'br.Apple-interchange-newline',
13
25
  ignore: true,
@@ -82,6 +82,17 @@ const handlePaste = (view, event, slice) => {
82
82
  dispatch(tr.setSelection(prosemirror_state_1.TextSelection.create(tr.doc, insertPos)).scrollIntoView());
83
83
  return true;
84
84
  }
85
+ if (selection instanceof prosemirror_state_1.TextSelection &&
86
+ isElement(slice) &&
87
+ selection.$anchor.parentOffset > 0 &&
88
+ selection.$head.parentOffset > 0 &&
89
+ selection.$from.node().type === transform_1.schema.nodes.paragraph) {
90
+ const { $from, $to } = selection;
91
+ const side = (!$from.parentOffset && $to.index() < $to.parent.childCount ? $from : $to).pos;
92
+ tr.replace(side, side, new prosemirror_model_1.Slice(slice.content, 0, 0));
93
+ dispatch(tr.setSelection(prosemirror_state_1.TextSelection.create(tr.doc, side + 1)).scrollIntoView());
94
+ return true;
95
+ }
85
96
  if (selection instanceof prosemirror_state_1.TextSelection &&
86
97
  selection.$anchor.parentOffset === 0 &&
87
98
  selection.$head.parentOffset === 0 &&
@@ -89,10 +100,24 @@ const handlePaste = (view, event, slice) => {
89
100
  const { $from, $to } = selection;
90
101
  const side = (!$from.parentOffset && $to.index() < $to.parent.childCount ? $from : $to)
91
102
  .pos - 1;
92
- tr.replace(side, side, slice);
103
+ if (isElement(slice)) {
104
+ tr.replace(side, side, new prosemirror_model_1.Slice(slice.content, 0, 0));
105
+ }
106
+ else {
107
+ tr.replace(side, side, slice);
108
+ }
93
109
  dispatch(tr.setSelection(prosemirror_state_1.TextSelection.create(tr.doc, side + 1)).scrollIntoView());
94
110
  return true;
95
111
  }
96
112
  return false;
97
113
  };
98
114
  exports.handlePaste = handlePaste;
115
+ const isElement = (slice) => {
116
+ const { firstChild, lastChild } = slice.content;
117
+ return ((firstChild &&
118
+ (0, transform_1.isElementNodeType)(firstChild.type) &&
119
+ firstChild.type !== transform_1.schema.nodes.paragraph) ||
120
+ (lastChild &&
121
+ (0, transform_1.isElementNodeType)(lastChild.type) &&
122
+ lastChild.type !== transform_1.schema.nodes.paragraph));
123
+ };
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MATHJAX_VERSION = exports.VERSION = void 0;
4
- exports.VERSION = '2.7.49';
4
+ exports.VERSION = '2.7.50';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -1,10 +1,22 @@
1
- import { schema } from '@manuscripts/transform';
1
+ import { schema, getJatsListType } from '@manuscripts/transform';
2
2
  import { DOMParser } from 'prosemirror-model';
3
3
  const nodes = [
4
4
  {
5
5
  tag: 'p',
6
6
  node: 'paragraph',
7
7
  },
8
+ {
9
+ tag: 'ul, ol',
10
+ node: 'list',
11
+ getAttrs: (list) => {
12
+ const dom = list;
13
+ return {
14
+ listStyleType: getJatsListType(dom.style.listStyleType ||
15
+ (dom.firstChild &&
16
+ dom.firstChild.style.listStyleType)),
17
+ };
18
+ },
19
+ },
8
20
  {
9
21
  tag: 'br.Apple-interchange-newline',
10
22
  ignore: true,
@@ -13,8 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { schema, } from '@manuscripts/transform';
17
- import { Fragment } from 'prosemirror-model';
16
+ import { isElementNodeType, schema, } from '@manuscripts/transform';
17
+ import { Fragment, Slice } from 'prosemirror-model';
18
18
  import { TextSelection } from 'prosemirror-state';
19
19
  import { findParentNode } from 'prosemirror-utils';
20
20
  const removeFirstParagraphIfEmpty = (slice) => {
@@ -77,6 +77,17 @@ export const handlePaste = (view, event, slice) => {
77
77
  dispatch(tr.setSelection(TextSelection.create(tr.doc, insertPos)).scrollIntoView());
78
78
  return true;
79
79
  }
80
+ if (selection instanceof TextSelection &&
81
+ isElement(slice) &&
82
+ selection.$anchor.parentOffset > 0 &&
83
+ selection.$head.parentOffset > 0 &&
84
+ selection.$from.node().type === schema.nodes.paragraph) {
85
+ const { $from, $to } = selection;
86
+ const side = (!$from.parentOffset && $to.index() < $to.parent.childCount ? $from : $to).pos;
87
+ tr.replace(side, side, new Slice(slice.content, 0, 0));
88
+ dispatch(tr.setSelection(TextSelection.create(tr.doc, side + 1)).scrollIntoView());
89
+ return true;
90
+ }
80
91
  if (selection instanceof TextSelection &&
81
92
  selection.$anchor.parentOffset === 0 &&
82
93
  selection.$head.parentOffset === 0 &&
@@ -84,9 +95,23 @@ export const handlePaste = (view, event, slice) => {
84
95
  const { $from, $to } = selection;
85
96
  const side = (!$from.parentOffset && $to.index() < $to.parent.childCount ? $from : $to)
86
97
  .pos - 1;
87
- tr.replace(side, side, slice);
98
+ if (isElement(slice)) {
99
+ tr.replace(side, side, new Slice(slice.content, 0, 0));
100
+ }
101
+ else {
102
+ tr.replace(side, side, slice);
103
+ }
88
104
  dispatch(tr.setSelection(TextSelection.create(tr.doc, side + 1)).scrollIntoView());
89
105
  return true;
90
106
  }
91
107
  return false;
92
108
  };
109
+ const isElement = (slice) => {
110
+ const { firstChild, lastChild } = slice.content;
111
+ return ((firstChild &&
112
+ isElementNodeType(firstChild.type) &&
113
+ firstChild.type !== schema.nodes.paragraph) ||
114
+ (lastChild &&
115
+ isElementNodeType(lastChild.type) &&
116
+ lastChild.type !== schema.nodes.paragraph));
117
+ };
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.7.49';
1
+ export const VERSION = '2.7.50';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.7.49";
1
+ export declare const VERSION = "2.7.50";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";
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": "2.7.49",
4
+ "version": "2.7.50",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -34,7 +34,7 @@
34
34
  "@manuscripts/library": "1.3.11",
35
35
  "@manuscripts/style-guide": "2.0.35",
36
36
  "@manuscripts/track-changes-plugin": "1.9.4",
37
- "@manuscripts/transform": "3.0.42",
37
+ "@manuscripts/transform": "3.0.43",
38
38
  "@popperjs/core": "^2.11.8",
39
39
  "astrocite-eutils": "^0.16.4",
40
40
  "codemirror": "^5.58.1",