@manuscripts/body-editor 3.13.8 → 3.13.10

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.
@@ -963,7 +963,7 @@ const insertTransGraphicalAbstract = (category, insertAfterPos) => (state, dispa
963
963
  lang,
964
964
  category: category.id,
965
965
  }, [
966
- transform_1.schema.nodes.section_title.create({}, transform_1.schema.text(category.titles[0])),
966
+ transform_1.schema.nodes.section_title.create(),
967
967
  createAndFillFigureElement(state),
968
968
  ]);
969
969
  const tr = state.tr.insert(pos, node);
@@ -128,11 +128,33 @@ const handlePaste = (view, event, slice) => {
128
128
  tr.setMeta('uiEvent', 'paste');
129
129
  tr.setMeta('paste', true);
130
130
  const clipboardData = event.clipboardData;
131
- const text = clipboardData?.getData('text/plain');
132
- if (text && (0, url_1.allowedHref)(text)) {
133
- const link = transform_1.schema.nodes.link.create({ href: text }, transform_1.schema.text(text));
134
- dispatch(tr.insert(selection.from, prosemirror_model_1.Fragment.from(link)).scrollIntoView());
135
- return true;
131
+ const text = clipboardData?.getData('text/plain')?.trim();
132
+ let href = text && (0, url_1.allowedHref)(text) ? text : null;
133
+ if (!href) {
134
+ const html = clipboardData?.getData('text/html');
135
+ const fromHtml = html
136
+ ? new DOMParser()
137
+ .parseFromString(html, 'text/html')
138
+ .querySelector('a[href]')
139
+ ?.getAttribute('href')
140
+ ?.trim()
141
+ : null;
142
+ if (fromHtml && (0, url_1.allowedHref)(fromHtml)) {
143
+ href = fromHtml;
144
+ }
145
+ }
146
+ if (href && selection instanceof prosemirror_state_1.TextSelection) {
147
+ const $from = selection.$from;
148
+ const canInsertLink = $from.parent.canReplaceWith($from.index(), $from.index(), transform_1.schema.nodes.link);
149
+ if (canInsertLink) {
150
+ const link = transform_1.schema.nodes.link.create({ href }, transform_1.schema.text(text || href));
151
+ dispatch(tr.insert(selection.from, prosemirror_model_1.Fragment.from(link)).scrollIntoView());
152
+ return true;
153
+ }
154
+ if (text) {
155
+ dispatch(tr.insertText(text, selection.from, selection.to).scrollIntoView());
156
+ return true;
157
+ }
136
158
  }
137
159
  const parent = (0, prosemirror_utils_1.findParentNode)((node) => node.type === transform_1.schema.nodes.section || node.type === transform_1.schema.nodes.body)(selection);
138
160
  if ((slice.content.firstChild?.type === transform_1.schema.nodes.section ||
@@ -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 = '3.13.8';
4
+ exports.VERSION = '3.13.10';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -32,7 +32,6 @@ class SectionTitleView extends block_view_1.default {
32
32
  transform_1.schema.nodes.bibliography_section,
33
33
  transform_1.schema.nodes.footnotes_section,
34
34
  transform_1.schema.nodes.graphical_abstract_section,
35
- transform_1.schema.nodes.trans_graphical_abstract,
36
35
  transform_1.schema.nodes.supplements,
37
36
  ];
38
37
  this.createElement = () => {
@@ -920,7 +920,7 @@ export const insertTransGraphicalAbstract = (category, insertAfterPos) => (state
920
920
  lang,
921
921
  category: category.id,
922
922
  }, [
923
- schema.nodes.section_title.create({}, schema.text(category.titles[0])),
923
+ schema.nodes.section_title.create(),
924
924
  createAndFillFigureElement(state),
925
925
  ]);
926
926
  const tr = state.tr.insert(pos, node);
@@ -123,11 +123,33 @@ export const handlePaste = (view, event, slice) => {
123
123
  tr.setMeta('uiEvent', 'paste');
124
124
  tr.setMeta('paste', true);
125
125
  const clipboardData = event.clipboardData;
126
- const text = clipboardData?.getData('text/plain');
127
- if (text && allowedHref(text)) {
128
- const link = schema.nodes.link.create({ href: text }, schema.text(text));
129
- dispatch(tr.insert(selection.from, Fragment.from(link)).scrollIntoView());
130
- return true;
126
+ const text = clipboardData?.getData('text/plain')?.trim();
127
+ let href = text && allowedHref(text) ? text : null;
128
+ if (!href) {
129
+ const html = clipboardData?.getData('text/html');
130
+ const fromHtml = html
131
+ ? new DOMParser()
132
+ .parseFromString(html, 'text/html')
133
+ .querySelector('a[href]')
134
+ ?.getAttribute('href')
135
+ ?.trim()
136
+ : null;
137
+ if (fromHtml && allowedHref(fromHtml)) {
138
+ href = fromHtml;
139
+ }
140
+ }
141
+ if (href && selection instanceof TextSelection) {
142
+ const $from = selection.$from;
143
+ const canInsertLink = $from.parent.canReplaceWith($from.index(), $from.index(), schema.nodes.link);
144
+ if (canInsertLink) {
145
+ const link = schema.nodes.link.create({ href }, schema.text(text || href));
146
+ dispatch(tr.insert(selection.from, Fragment.from(link)).scrollIntoView());
147
+ return true;
148
+ }
149
+ if (text) {
150
+ dispatch(tr.insertText(text, selection.from, selection.to).scrollIntoView());
151
+ return true;
152
+ }
131
153
  }
132
154
  const parent = findParentNode((node) => node.type === schema.nodes.section || node.type === schema.nodes.body)(selection);
133
155
  if ((slice.content.firstChild?.type === schema.nodes.section ||
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.13.8';
1
+ export const VERSION = '3.13.10';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -26,7 +26,6 @@ export class SectionTitleView extends BlockView {
26
26
  schema.nodes.bibliography_section,
27
27
  schema.nodes.footnotes_section,
28
28
  schema.nodes.graphical_abstract_section,
29
- schema.nodes.trans_graphical_abstract,
30
29
  schema.nodes.supplements,
31
30
  ];
32
31
  this.createElement = () => {
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.13.8";
1
+ export declare const VERSION = "3.13.10";
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": "3.13.8",
4
+ "version": "3.13.10",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
package/src/commands.ts CHANGED
@@ -1456,7 +1456,7 @@ export const insertTransGraphicalAbstract =
1456
1456
  category: category.id,
1457
1457
  },
1458
1458
  [
1459
- schema.nodes.section_title.create({}, schema.text(category.titles[0])),
1459
+ schema.nodes.section_title.create(),
1460
1460
  createAndFillFigureElement(state),
1461
1461
  ]
1462
1462
  ) as TransGraphicalAbstractNode
package/src/lib/paste.ts CHANGED
@@ -185,12 +185,40 @@ export const handlePaste = (
185
185
  tr.setMeta('paste', true)
186
186
 
187
187
  const clipboardData = event.clipboardData
188
+ const text = clipboardData?.getData('text/plain')?.trim()
189
+ let href = text && allowedHref(text) ? text : null
190
+ if (!href) {
191
+ const html = clipboardData?.getData('text/html')
192
+ const fromHtml = html
193
+ ? new DOMParser()
194
+ .parseFromString(html, 'text/html')
195
+ .querySelector('a[href]')
196
+ ?.getAttribute('href')
197
+ ?.trim()
198
+ : null
199
+ if (fromHtml && allowedHref(fromHtml)) {
200
+ href = fromHtml
201
+ }
202
+ }
188
203
 
189
- const text = clipboardData?.getData('text/plain')
190
- if (text && allowedHref(text)) {
191
- const link = schema.nodes.link.create({ href: text }, schema.text(text))
192
- dispatch(tr.insert(selection.from, Fragment.from(link)).scrollIntoView())
193
- return true
204
+ if (href && selection instanceof TextSelection) {
205
+ const $from = selection.$from
206
+ const canInsertLink = $from.parent.canReplaceWith(
207
+ $from.index(),
208
+ $from.index(),
209
+ schema.nodes.link
210
+ )
211
+ if (canInsertLink) {
212
+ const link = schema.nodes.link.create({ href }, schema.text(text || href))
213
+ dispatch(tr.insert(selection.from, Fragment.from(link)).scrollIntoView())
214
+ return true
215
+ }
216
+ if (text) {
217
+ dispatch(
218
+ tr.insertText(text, selection.from, selection.to).scrollIntoView()
219
+ )
220
+ return true
221
+ }
194
222
  }
195
223
 
196
224
  // TODO:: all the cases below should be removed when figuring out issue of open slice sides from track-changes plugin
package/src/versions.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  //THIS FILE WAS GENERATED BY versions.mjs
2
- export const VERSION = '3.13.8';
2
+ export const VERSION = '3.13.10';
3
3
  export const MATHJAX_VERSION = '3.2.2';
@@ -29,7 +29,6 @@ export class SectionTitleView extends BlockView<SectionTitleNode> {
29
29
  schema.nodes.bibliography_section,
30
30
  schema.nodes.footnotes_section,
31
31
  schema.nodes.graphical_abstract_section,
32
- schema.nodes.trans_graphical_abstract,
33
32
  schema.nodes.supplements,
34
33
  ]
35
34