@manuscripts/body-editor 1.11.2 → 1.11.4-LEAN-3519.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.
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clipboardParser = void 0;
4
+ const transform_1 = require("@manuscripts/transform");
5
+ const prosemirror_model_1 = require("prosemirror-model");
6
+ const nodes = [
7
+ {
8
+ tag: 'p',
9
+ node: 'paragraph',
10
+ },
11
+ {
12
+ tag: 'br.Apple-interchange-newline',
13
+ ignore: true,
14
+ },
15
+ ];
16
+ exports.clipboardParser = new prosemirror_model_1.DOMParser(transform_1.schema, [
17
+ ...nodes,
18
+ ...prosemirror_model_1.DOMParser.fromSchema(transform_1.schema).rules,
19
+ ]);
@@ -129,9 +129,12 @@ exports.createBlock = createBlock;
129
129
  const insertGeneralFootnote = (tableNode, position, view, tableElementFooter) => {
130
130
  var _a;
131
131
  const { state, dispatch } = view;
132
- const generalNote = state.schema.nodes.paragraph.create({
132
+ const paragraph = state.schema.nodes.paragraph.create({
133
133
  placeholder: 'Add general note here',
134
134
  });
135
+ const generalNote = state.schema.nodes.general_table_footnote.create({}, [
136
+ paragraph,
137
+ ]);
135
138
  const tableColGroup = (0, prosemirror_utils_1.findChildrenByType)(tableNode, transform_1.schema.nodes.table_colgroup)[0];
136
139
  const tr = state.tr;
137
140
  const pos = (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length)
@@ -23,6 +23,7 @@ require("prosemirror-view/style/prosemirror.css");
23
23
  const transform_1 = require("@manuscripts/transform");
24
24
  const prosemirror_state_1 = require("prosemirror-state");
25
25
  const prosemirror_view_1 = require("prosemirror-view");
26
+ const clipboard_1 = require("../clipboard");
26
27
  const paste_1 = require("../lib/paste");
27
28
  const editor_plugins_1 = __importDefault(require("./editor-plugins"));
28
29
  const editor_views_1 = __importDefault(require("./editor-views"));
@@ -46,6 +47,7 @@ const createEditorView = (props, root, state, dispatch) => {
46
47
  nodeViews: (0, editor_views_1.default)(props, dispatch),
47
48
  attributes: props.attributes,
48
49
  transformPasted: paste_1.transformPasted,
50
+ clipboardParser: clipboard_1.clipboardParser,
49
51
  });
50
52
  const tr = view.state.tr.setMeta('INIT', true);
51
53
  const nextState = view.state.apply(tr);
@@ -27,6 +27,7 @@ const footnotes_utils_1 = require("../plugins/footnotes/footnotes-utils");
27
27
  const ReactSubView_1 = __importDefault(require("../views/ReactSubView"));
28
28
  const popper_1 = require("./popper");
29
29
  const track_changes_utils_1 = require("./track-changes-utils");
30
+ const utils_1 = require("./utils");
30
31
  const popper = new popper_1.PopperManager();
31
32
  const listTypes = [transform_1.schema.nodes.ordered_list, transform_1.schema.nodes.bullet_list];
32
33
  const readonlyTypes = [transform_1.schema.nodes.keywords, transform_1.schema.nodes.bibliography_element];
@@ -143,7 +144,7 @@ class ContextMenu {
143
144
  this.addPopperEventListeners();
144
145
  };
145
146
  this.showEditMenu = (target) => {
146
- var _a, _b;
147
+ var _a;
147
148
  const menu = document.createElement('div');
148
149
  menu.className = 'menu';
149
150
  const $pos = this.resolvePos();
@@ -179,9 +180,9 @@ class ContextMenu {
179
180
  const tableElementFooter = (0, prosemirror_utils_1.findChildrenByType)(this.node, transform_1.schema.nodes.table_element_footer);
180
181
  let isDeletedOrRejected = false;
181
182
  const hasGeneralNote = tableElementFooter.length &&
182
- ((_a = tableElementFooter[0].node.firstChild) === null || _a === void 0 ? void 0 : _a.type) === transform_1.schema.nodes.paragraph;
183
+ (0, utils_1.getChildOfType)(tableElementFooter[0].node, transform_1.schema.nodes.general_table_footnote, true);
183
184
  if (hasGeneralNote) {
184
- const generalFootnote = (_b = tableElementFooter[0]) === null || _b === void 0 ? void 0 : _b.node.firstChild;
185
+ const generalFootnote = (_a = tableElementFooter[0]) === null || _a === void 0 ? void 0 : _a.node.firstChild;
185
186
  if (generalFootnote) {
186
187
  isDeletedOrRejected =
187
188
  (0, track_changes_utils_1.isDeleted)(generalFootnote) || (0, track_changes_utils_1.isRejectedInsert)(generalFootnote);
@@ -82,7 +82,7 @@ const deleteFootnoteWidget = (node, props, id, tableElement) => (view, getPos) =
82
82
  }
83
83
  else {
84
84
  node.content.forEach((item) => {
85
- if (item.type === transform_1.schema.nodes.paragraph && pos) {
85
+ if (item.type === transform_1.schema.nodes.general_table_footnote && pos) {
86
86
  tr.delete(pos - 1, pos + item.nodeSize + 1);
87
87
  }
88
88
  });
@@ -0,0 +1,16 @@
1
+ import { schema } from '@manuscripts/transform';
2
+ import { DOMParser } from 'prosemirror-model';
3
+ const nodes = [
4
+ {
5
+ tag: 'p',
6
+ node: 'paragraph',
7
+ },
8
+ {
9
+ tag: 'br.Apple-interchange-newline',
10
+ ignore: true,
11
+ },
12
+ ];
13
+ export const clipboardParser = new DOMParser(schema, [
14
+ ...nodes,
15
+ ...DOMParser.fromSchema(schema).rules,
16
+ ]);
@@ -120,9 +120,12 @@ export const createBlock = (nodeType, position, state, dispatch) => {
120
120
  export const insertGeneralFootnote = (tableNode, position, view, tableElementFooter) => {
121
121
  var _a;
122
122
  const { state, dispatch } = view;
123
- const generalNote = state.schema.nodes.paragraph.create({
123
+ const paragraph = state.schema.nodes.paragraph.create({
124
124
  placeholder: 'Add general note here',
125
125
  });
126
+ const generalNote = state.schema.nodes.general_table_footnote.create({}, [
127
+ paragraph,
128
+ ]);
126
129
  const tableColGroup = findChildrenByType(tableNode, schema.nodes.table_colgroup)[0];
127
130
  const tr = state.tr;
128
131
  const pos = (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length)
@@ -17,6 +17,7 @@ import 'prosemirror-view/style/prosemirror.css';
17
17
  import { schema } from '@manuscripts/transform';
18
18
  import { EditorState } from 'prosemirror-state';
19
19
  import { EditorView } from 'prosemirror-view';
20
+ import { clipboardParser } from '../clipboard';
20
21
  import { transformPasted } from '../lib/paste';
21
22
  import plugins from './editor-plugins';
22
23
  import views from './editor-views';
@@ -39,6 +40,7 @@ export const createEditorView = (props, root, state, dispatch) => {
39
40
  nodeViews: views(props, dispatch),
40
41
  attributes: props.attributes,
41
42
  transformPasted,
43
+ clipboardParser,
42
44
  });
43
45
  const tr = view.state.tr.setMeta('INIT', true);
44
46
  const nextState = view.state.apply(tr);
@@ -21,6 +21,7 @@ import { buildTableFootnoteLabels } from '../plugins/footnotes/footnotes-utils';
21
21
  import ReactSubView from '../views/ReactSubView';
22
22
  import { PopperManager } from './popper';
23
23
  import { isDeleted, isRejectedInsert } from './track-changes-utils';
24
+ import { getChildOfType } from './utils';
24
25
  const popper = new PopperManager();
25
26
  const listTypes = [schema.nodes.ordered_list, schema.nodes.bullet_list];
26
27
  const readonlyTypes = [schema.nodes.keywords, schema.nodes.bibliography_element];
@@ -136,7 +137,7 @@ export class ContextMenu {
136
137
  this.addPopperEventListeners();
137
138
  };
138
139
  this.showEditMenu = (target) => {
139
- var _a, _b;
140
+ var _a;
140
141
  const menu = document.createElement('div');
141
142
  menu.className = 'menu';
142
143
  const $pos = this.resolvePos();
@@ -172,9 +173,9 @@ export class ContextMenu {
172
173
  const tableElementFooter = findChildrenByType(this.node, schema.nodes.table_element_footer);
173
174
  let isDeletedOrRejected = false;
174
175
  const hasGeneralNote = tableElementFooter.length &&
175
- ((_a = tableElementFooter[0].node.firstChild) === null || _a === void 0 ? void 0 : _a.type) === schema.nodes.paragraph;
176
+ getChildOfType(tableElementFooter[0].node, schema.nodes.general_table_footnote, true);
176
177
  if (hasGeneralNote) {
177
- const generalFootnote = (_b = tableElementFooter[0]) === null || _b === void 0 ? void 0 : _b.node.firstChild;
178
+ const generalFootnote = (_a = tableElementFooter[0]) === null || _a === void 0 ? void 0 : _a.node.firstChild;
178
179
  if (generalFootnote) {
179
180
  isDeletedOrRejected =
180
181
  isDeleted(generalFootnote) || isRejectedInsert(generalFootnote);
@@ -75,7 +75,7 @@ const deleteFootnoteWidget = (node, props, id, tableElement) => (view, getPos) =
75
75
  }
76
76
  else {
77
77
  node.content.forEach((item) => {
78
- if (item.type === schema.nodes.paragraph && pos) {
78
+ if (item.type === schema.nodes.general_table_footnote && pos) {
79
79
  tr.delete(pos - 1, pos + item.nodeSize + 1);
80
80
  }
81
81
  });
@@ -0,0 +1,2 @@
1
+ import { DOMParser } from 'prosemirror-model';
2
+ export declare const clipboardParser: DOMParser;
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.11.2",
4
+ "version": "1.11.4-LEAN-3519.0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -30,9 +30,9 @@
30
30
  "@iarna/word-count": "^1.1.2",
31
31
  "@manuscripts/json-schema": "2.2.8",
32
32
  "@manuscripts/library": "1.3.7",
33
- "@manuscripts/style-guide": "1.12.12",
33
+ "@manuscripts/style-guide": "1.12.13-LEAN-3519.0",
34
34
  "@manuscripts/track-changes-plugin": "1.7.12",
35
- "@manuscripts/transform": "2.3.6",
35
+ "@manuscripts/transform": "2.3.7-LEAN-3519.1",
36
36
  "astrocite-eutils": "^0.16.4",
37
37
  "mathjax-full": "^3.2.2",
38
38
  "codemirror": "^5.58.1",
package/styles/Editor.css CHANGED
@@ -971,7 +971,8 @@
971
971
  fill: #353535;
972
972
  }
973
973
  .ProseMirror .table-footnotes-element > div,
974
- .ProseMirror .block-footnotes_element > .block > div
974
+ .ProseMirror .block-footnotes_element > .block > div,
975
+ .ProseMirror .general-table-footnote
975
976
  {
976
977
  position: relative;
977
978
  }
@@ -995,37 +996,27 @@
995
996
  margin-top: 0px;
996
997
  }
997
998
 
998
- .ProseMirror .footnote-selected, .table-footer > div:has(> p.footnote-selected) > p {
999
- background-color: #f2fbfc;
1000
- padding: 4px;
1001
- }
1002
999
  .table-footer > div {
1003
1000
  position: relative;
1004
1001
  }
1005
1002
 
1006
- .table-footer > div > p {
1007
- padding-bottom: 10px;
1003
+ .general-table-footnote > p {
1004
+ padding-bottom: 8px;
1005
+ }
1006
+
1007
+ .general-table-footnote:has(> p.footnote-selected) > p:last-child {
1008
+ padding-bottom: 0;
1008
1009
  }
1009
1010
 
1010
1011
  .ProseMirror .table-footnotes-element .footnote-selected,
1011
- .ProseMirror .block-footnotes_element .footnote-selected
1012
+ .ProseMirror .block-footnotes_element .footnote-selected,
1013
+ .ProseMirror .general-table-footnote:has(> p.footnote-selected)
1012
1014
  {
1015
+ background-color: #f2fbfc;
1016
+ padding: 4px;
1013
1017
  border: 1px solid #bce7f6;
1014
1018
  }
1015
- .table-footer > div:has(> p.footnote-selected) > p {
1016
- border-left: 1px solid #bce7f6;
1017
- border-right: 1px solid #bce7f6;
1018
- }
1019
- .table-footer > div:has(> p.footnote-selected) > p:first-child {
1020
- border-top: 1px solid #bce7f6;
1021
- position: relative;
1022
- }
1023
- .table-footer > div:has(> p.footnote-selected) > p:last-of-type {
1024
- border-bottom: 1px solid #bce7f6;
1025
- }
1026
- .table-footer > div:has(> p.footnote-selected) > p:last-child {
1027
- border-bottom: 1px solid #bce7f6;
1028
- }
1019
+
1029
1020
  .ProseMirror .footnote-label {
1030
1021
  vertical-align: super;
1031
1022
  font-size: 75%;