@manuscripts/body-editor 3.5.11 → 3.5.12

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.
@@ -38,6 +38,7 @@ const doi_1 = __importDefault(require("../plugins/doi"));
38
38
  const editor_props_1 = __importDefault(require("../plugins/editor-props"));
39
39
  const elements_1 = __importDefault(require("../plugins/elements"));
40
40
  const footnotes_1 = __importDefault(require("../plugins/footnotes"));
41
+ const link_1 = __importDefault(require("../plugins/link"));
41
42
  const lock_body_1 = __importDefault(require("../plugins/lock-body"));
42
43
  const move_node_1 = __importDefault(require("../plugins/move-node"));
43
44
  const objects_1 = __importDefault(require("../plugins/objects"));
@@ -91,6 +92,7 @@ exports.default = (props) => {
91
92
  (0, accessibility_element_1.default)(),
92
93
  (0, prevent_empty_1.default)(),
93
94
  (0, move_node_1.default)(),
95
+ (0, link_1.default)(),
94
96
  ];
95
97
  if (props.collabProvider) {
96
98
  allPlugins.push((0, prosemirror_collab_1.collab)({ version: props.collabProvider.currentVersion }));
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
4
+ const transform_1 = require("@manuscripts/transform");
5
+ const prosemirror_state_1 = require("prosemirror-state");
6
+ exports.default = () => new prosemirror_state_1.Plugin({
7
+ appendTransaction(transactions, oldState, newState) {
8
+ if (!transactions.some((tr) => oldState.selection instanceof prosemirror_state_1.NodeSelection &&
9
+ oldState.selection.node.type === transform_1.schema.nodes.link &&
10
+ (tr.getMeta(track_changes_plugin_1.TrackChangesAction.setChangeStatuses)?.status ===
11
+ track_changes_plugin_1.CHANGE_STATUS.accepted ||
12
+ (tr.getMeta('pointer') && tr.selectionSet)))) {
13
+ return null;
14
+ }
15
+ const { $from: { pos }, node, } = oldState.selection;
16
+ if (!node.content.size || !node.attrs.href) {
17
+ const tr = newState.tr.setMeta('clear-empty-link', true);
18
+ tr.delete(pos, pos + node.nodeSize);
19
+ return (0, track_changes_plugin_1.skipTracking)(tr.insert(pos, node.content));
20
+ }
21
+ return null;
22
+ },
23
+ });
@@ -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.5.11';
4
+ exports.VERSION = '3.5.12';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -49,10 +49,6 @@ class LinkEditableView extends link_1.LinkView {
49
49
  this.closeForm();
50
50
  };
51
51
  this.deselectNode = () => {
52
- const attrs = this.node.attrs;
53
- if (!this.node.content.size || !attrs.href) {
54
- this.removeLink();
55
- }
56
52
  this.closeForm();
57
53
  };
58
54
  this.showForm = () => {
@@ -33,6 +33,7 @@ import doi from '../plugins/doi';
33
33
  import editorProps from '../plugins/editor-props';
34
34
  import elements from '../plugins/elements';
35
35
  import footnotes from '../plugins/footnotes';
36
+ import link from '../plugins/link';
36
37
  import lock_body from '../plugins/lock-body';
37
38
  import move_node from '../plugins/move-node';
38
39
  import objects from '../plugins/objects';
@@ -86,6 +87,7 @@ export default (props) => {
86
87
  accessibility_element(),
87
88
  prevent_empty(),
88
89
  move_node(),
90
+ link(),
89
91
  ];
90
92
  if (props.collabProvider) {
91
93
  allPlugins.push(collab({ version: props.collabProvider.currentVersion }));
@@ -0,0 +1,21 @@
1
+ import { CHANGE_STATUS, skipTracking, TrackChangesAction, } from '@manuscripts/track-changes-plugin';
2
+ import { schema } from '@manuscripts/transform';
3
+ import { NodeSelection, Plugin } from 'prosemirror-state';
4
+ export default () => new Plugin({
5
+ appendTransaction(transactions, oldState, newState) {
6
+ if (!transactions.some((tr) => oldState.selection instanceof NodeSelection &&
7
+ oldState.selection.node.type === schema.nodes.link &&
8
+ (tr.getMeta(TrackChangesAction.setChangeStatuses)?.status ===
9
+ CHANGE_STATUS.accepted ||
10
+ (tr.getMeta('pointer') && tr.selectionSet)))) {
11
+ return null;
12
+ }
13
+ const { $from: { pos }, node, } = oldState.selection;
14
+ if (!node.content.size || !node.attrs.href) {
15
+ const tr = newState.tr.setMeta('clear-empty-link', true);
16
+ tr.delete(pos, pos + node.nodeSize);
17
+ return skipTracking(tr.insert(pos, node.content));
18
+ }
19
+ return null;
20
+ },
21
+ });
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.5.11';
1
+ export const VERSION = '3.5.12';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -43,10 +43,6 @@ export class LinkEditableView extends LinkView {
43
43
  this.closeForm();
44
44
  };
45
45
  this.deselectNode = () => {
46
- const attrs = this.node.attrs;
47
- if (!this.node.content.size || !attrs.href) {
48
- this.removeLink();
49
- }
50
46
  this.closeForm();
51
47
  };
52
48
  this.showForm = () => {
@@ -0,0 +1,3 @@
1
+ import { Plugin } from 'prosemirror-state';
2
+ declare const _default: () => Plugin<any>;
3
+ export default _default;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.5.11";
1
+ export declare const VERSION = "3.5.12";
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.5.11",
4
+ "version": "3.5.12",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -1863,3 +1863,7 @@ th:hover > .table-context-menu-button,
1863
1863
  .block-attachments:has(.attachment-item:empty), .block-attachments.empty-node {
1864
1864
  display: none !important;
1865
1865
  }
1866
+
1867
+ .ProseMirror a.link:empty::before {
1868
+ content: "\00a0";
1869
+ }