@manuscripts/body-editor 2.6.15 → 2.6.16
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.
- package/dist/cjs/commands.js +21 -17
- package/dist/cjs/plugins/elements.js +1 -1
- package/dist/cjs/plugins/placeholder.js +3 -0
- package/dist/cjs/versions.js +1 -1
- package/dist/es/commands.js +21 -17
- package/dist/es/plugins/elements.js +2 -2
- package/dist/es/plugins/placeholder.js +4 -1
- package/dist/es/versions.js +1 -1
- package/dist/types/versions.d.ts +1 -1
- package/package.json +3 -3
package/dist/cjs/commands.js
CHANGED
|
@@ -516,32 +516,36 @@ const insertGraphicalAbstract = (state, dispatch, view) => {
|
|
|
516
516
|
};
|
|
517
517
|
exports.insertGraphicalAbstract = insertGraphicalAbstract;
|
|
518
518
|
const insertSection = (subsection = false) => (state, dispatch, view) => {
|
|
519
|
-
const
|
|
520
|
-
|
|
521
|
-
|
|
519
|
+
const nodes = transform_1.schema.nodes;
|
|
520
|
+
const $pos = state.selection.$from;
|
|
521
|
+
let pos;
|
|
522
|
+
if ((0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)($pos, nodes.bibliography_section)) {
|
|
522
523
|
return false;
|
|
523
524
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
525
|
+
else if (subsection) {
|
|
526
|
+
pos =
|
|
527
|
+
(0, exports.findPosBeforeFirstSubsection)($pos) || findPosAfterParentSection($pos);
|
|
528
|
+
if (!pos) {
|
|
529
|
+
return false;
|
|
530
|
+
}
|
|
531
|
+
pos -= 1;
|
|
530
532
|
}
|
|
531
|
-
else {
|
|
532
|
-
|
|
533
|
-
|
|
533
|
+
else if ((0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)($pos, nodes.box_element)) {
|
|
534
|
+
return false;
|
|
535
|
+
}
|
|
536
|
+
else if ((0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)($pos, nodes.body)) {
|
|
537
|
+
pos = findPosAfterParentSection($pos);
|
|
534
538
|
}
|
|
535
539
|
if (!pos) {
|
|
536
|
-
|
|
540
|
+
const body = (0, doc_1.findBody)(state.doc);
|
|
541
|
+
pos = body.pos + body.node.content.size + 1;
|
|
537
542
|
}
|
|
538
|
-
const section =
|
|
543
|
+
const section = nodes.section.createAndFill({
|
|
539
544
|
category: subsection ? 'MPSectionCategory:subsection' : '',
|
|
540
545
|
});
|
|
541
|
-
const
|
|
542
|
-
const tr = state.tr.insert(pos + diff, section);
|
|
546
|
+
const tr = state.tr.insert(pos, section);
|
|
543
547
|
if (dispatch) {
|
|
544
|
-
const selection = prosemirror_state_1.TextSelection.create(tr.doc, pos +
|
|
548
|
+
const selection = prosemirror_state_1.TextSelection.create(tr.doc, pos + 2);
|
|
545
549
|
view === null || view === void 0 ? void 0 : view.focus();
|
|
546
550
|
dispatch(tr.setSelection(selection).scrollIntoView());
|
|
547
551
|
}
|
|
@@ -26,7 +26,7 @@ exports.default = () => {
|
|
|
26
26
|
const decorations = [];
|
|
27
27
|
state.doc.descendants((node, pos, parent) => {
|
|
28
28
|
if (parent &&
|
|
29
|
-
(0, transform_1.isSectionNodeType)(parent.type) &&
|
|
29
|
+
((0, transform_1.isSectionNodeType)(parent.type) || parent.type === transform_1.schema.nodes.body) &&
|
|
30
30
|
node.type !== section) {
|
|
31
31
|
decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {}, {
|
|
32
32
|
element: true,
|
|
@@ -34,6 +34,9 @@ const getParagraphPlaceholderText = (parent) => {
|
|
|
34
34
|
if (!parent || parent.textContent.length) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
+
if (parent.type === transform_1.schema.nodes.body) {
|
|
38
|
+
return 'Paragraph';
|
|
39
|
+
}
|
|
37
40
|
if ((0, transform_1.isFootnoteNode)(parent) || (0, transform_1.isGeneralTableFootnoteNode)(parent)) {
|
|
38
41
|
return 'Type new footnote here';
|
|
39
42
|
}
|
package/dist/cjs/versions.js
CHANGED
package/dist/es/commands.js
CHANGED
|
@@ -487,32 +487,36 @@ export const insertGraphicalAbstract = (state, dispatch, view) => {
|
|
|
487
487
|
return true;
|
|
488
488
|
};
|
|
489
489
|
export const insertSection = (subsection = false) => (state, dispatch, view) => {
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
|
|
490
|
+
const nodes = schema.nodes;
|
|
491
|
+
const $pos = state.selection.$from;
|
|
492
|
+
let pos;
|
|
493
|
+
if (findParentNodeOfTypeClosestToPos($pos, nodes.bibliography_section)) {
|
|
493
494
|
return false;
|
|
494
495
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
496
|
+
else if (subsection) {
|
|
497
|
+
pos =
|
|
498
|
+
findPosBeforeFirstSubsection($pos) || findPosAfterParentSection($pos);
|
|
499
|
+
if (!pos) {
|
|
500
|
+
return false;
|
|
501
|
+
}
|
|
502
|
+
pos -= 1;
|
|
501
503
|
}
|
|
502
|
-
else {
|
|
503
|
-
|
|
504
|
-
|
|
504
|
+
else if (findParentNodeOfTypeClosestToPos($pos, nodes.box_element)) {
|
|
505
|
+
return false;
|
|
506
|
+
}
|
|
507
|
+
else if (findParentNodeOfTypeClosestToPos($pos, nodes.body)) {
|
|
508
|
+
pos = findPosAfterParentSection($pos);
|
|
505
509
|
}
|
|
506
510
|
if (!pos) {
|
|
507
|
-
|
|
511
|
+
const body = findBody(state.doc);
|
|
512
|
+
pos = body.pos + body.node.content.size + 1;
|
|
508
513
|
}
|
|
509
|
-
const section =
|
|
514
|
+
const section = nodes.section.createAndFill({
|
|
510
515
|
category: subsection ? 'MPSectionCategory:subsection' : '',
|
|
511
516
|
});
|
|
512
|
-
const
|
|
513
|
-
const tr = state.tr.insert(pos + diff, section);
|
|
517
|
+
const tr = state.tr.insert(pos, section);
|
|
514
518
|
if (dispatch) {
|
|
515
|
-
const selection = TextSelection.create(tr.doc, pos +
|
|
519
|
+
const selection = TextSelection.create(tr.doc, pos + 2);
|
|
516
520
|
view === null || view === void 0 ? void 0 : view.focus();
|
|
517
521
|
dispatch(tr.setSelection(selection).scrollIntoView());
|
|
518
522
|
}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { isSectionNodeType } from '@manuscripts/transform';
|
|
16
|
+
import { isSectionNodeType, schema } from '@manuscripts/transform';
|
|
17
17
|
import { Plugin } from 'prosemirror-state';
|
|
18
18
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
19
19
|
export default () => {
|
|
@@ -24,7 +24,7 @@ export default () => {
|
|
|
24
24
|
const decorations = [];
|
|
25
25
|
state.doc.descendants((node, pos, parent) => {
|
|
26
26
|
if (parent &&
|
|
27
|
-
isSectionNodeType(parent.type) &&
|
|
27
|
+
(isSectionNodeType(parent.type) || parent.type === schema.nodes.body) &&
|
|
28
28
|
node.type !== section) {
|
|
29
29
|
decorations.push(Decoration.node(pos, pos + node.nodeSize, {}, {
|
|
30
30
|
element: true,
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { isFootnoteNode, isGeneralTableFootnoteNode, } from '@manuscripts/transform';
|
|
16
|
+
import { isFootnoteNode, isGeneralTableFootnoteNode, schema, } from '@manuscripts/transform';
|
|
17
17
|
import { Plugin, TextSelection } from 'prosemirror-state';
|
|
18
18
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
19
19
|
const placeholderWidget = (placeholder) => (view, getPos) => {
|
|
@@ -32,6 +32,9 @@ const getParagraphPlaceholderText = (parent) => {
|
|
|
32
32
|
if (!parent || parent.textContent.length) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
+
if (parent.type === schema.nodes.body) {
|
|
36
|
+
return 'Paragraph';
|
|
37
|
+
}
|
|
35
38
|
if (isFootnoteNode(parent) || isGeneralTableFootnoteNode(parent)) {
|
|
36
39
|
return 'Type new footnote here';
|
|
37
40
|
}
|
package/dist/es/versions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '2.6.
|
|
1
|
+
export const VERSION = '2.6.16';
|
|
2
2
|
export const MATHJAX_VERSION = '3.2.2';
|
package/dist/types/versions.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "2.6.
|
|
1
|
+
export declare const VERSION = "2.6.16";
|
|
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.6.
|
|
4
|
+
"version": "2.6.16",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"@manuscripts/json-schema": "2.2.11",
|
|
34
34
|
"@manuscripts/library": "1.3.11",
|
|
35
35
|
"@manuscripts/style-guide": "2.0.23",
|
|
36
|
-
"@manuscripts/track-changes-plugin": "1.8.
|
|
37
|
-
"@manuscripts/transform": "3.0.
|
|
36
|
+
"@manuscripts/track-changes-plugin": "1.8.3",
|
|
37
|
+
"@manuscripts/transform": "3.0.19",
|
|
38
38
|
"@popperjs/core": "^2.11.8",
|
|
39
39
|
"astrocite-eutils": "^0.16.4",
|
|
40
40
|
"codemirror": "^5.58.1",
|