@manuscripts/body-editor 2.0.35 → 2.0.36-LEAN-3883.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.
- package/dist/cjs/commands.js +14 -12
- package/dist/cjs/keys/misc.js +1 -0
- package/dist/cjs/lib/section-titles.js +28 -0
- package/dist/cjs/plugins/section_title/autocompletion.js +37 -0
- package/dist/cjs/plugins/{section_title.js → section_title/index.js} +18 -1
- package/dist/cjs/versions.js +1 -1
- package/dist/es/commands.js +11 -10
- package/dist/es/keys/misc.js +3 -2
- package/dist/es/lib/section-titles.js +25 -0
- package/dist/es/plugins/section_title/autocompletion.js +32 -0
- package/dist/es/plugins/{section_title.js → section_title/index.js} +18 -1
- package/dist/es/versions.js +1 -1
- package/dist/types/commands.d.ts +1 -0
- package/dist/types/lib/section-titles.d.ts +17 -0
- package/dist/types/plugins/section_title/autocompletion.d.ts +4 -0
- package/dist/types/versions.d.ts +1 -1
- package/package.json +2 -2
- package/styles/AdvancedEditor.css +62 -43
- /package/dist/types/plugins/{section_title.d.ts → section_title/index.d.ts} +0 -0
package/dist/cjs/commands.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.mergeCellsWithSpace = exports.addColumns = exports.addRows = exports.insertTableFootnote = exports.addInlineComment = exports.addNodeComment = exports.createAndFillTableElement = exports.selectAllIsolating = exports.ignoreAtomBlockNodeForward = exports.isAtEndOfTextBlock = exports.ignoreMetaNodeBackspaceCommand = exports.ignoreAtomBlockNodeBackward = exports.isTextSelection = exports.isAtStartOfTextBlock = exports.insertTOCSection = exports.insertBibliographySection = exports.insertList = exports.insertKeywords = exports.insertContributors = exports.insertAbstract = exports.insertBackMatterSection = exports.insertSection = exports.insertGraphicalAbstract = exports.insertInlineFootnote = exports.insertFootnote = exports.createFootnote = exports.insertInlineEquation = exports.insertCrossReference = exports.insertInlineCitation = exports.insertLink = exports.insertSectionLabel = exports.findPosBeforeFirstSubsection = exports.insertBreak = exports.deleteBlock = exports.insertBlock = exports.insertSupplement = exports.insertFigure = exports.insertGeneralFootnote = exports.createBlock = exports.createSelection = exports.canInsert = exports.blockActive = exports.isNodeSelection = exports.markActive = void 0;
|
|
18
|
+
exports.autoComplete = exports.mergeCellsWithSpace = exports.addColumns = exports.addRows = exports.insertTableFootnote = exports.addInlineComment = exports.addNodeComment = exports.createAndFillTableElement = exports.selectAllIsolating = exports.ignoreAtomBlockNodeForward = exports.isAtEndOfTextBlock = exports.ignoreMetaNodeBackspaceCommand = exports.ignoreAtomBlockNodeBackward = exports.isTextSelection = exports.isAtStartOfTextBlock = exports.insertTOCSection = exports.insertBibliographySection = exports.insertList = exports.insertKeywords = exports.insertContributors = exports.insertAbstract = exports.insertBackMatterSection = exports.insertSection = exports.insertGraphicalAbstract = exports.insertInlineFootnote = exports.insertFootnote = exports.createFootnote = exports.insertInlineEquation = exports.insertCrossReference = exports.insertInlineCitation = exports.insertLink = exports.insertSectionLabel = exports.findPosBeforeFirstSubsection = exports.insertBreak = exports.deleteBlock = exports.insertBlock = exports.insertSupplement = exports.insertFigure = exports.insertGeneralFootnote = exports.createBlock = exports.createSelection = exports.canInsert = exports.blockActive = exports.isNodeSelection = exports.markActive = void 0;
|
|
19
19
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
20
|
const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
|
|
21
21
|
const transform_1 = require("@manuscripts/transform");
|
|
@@ -28,12 +28,14 @@ const prosemirror_utils_1 = require("prosemirror-utils");
|
|
|
28
28
|
const comments_1 = require("./lib/comments");
|
|
29
29
|
const doc_1 = require("./lib/doc");
|
|
30
30
|
const helpers_1 = require("./lib/helpers");
|
|
31
|
+
const section_titles_1 = require("./lib/section-titles");
|
|
31
32
|
const track_changes_utils_1 = require("./lib/track-changes-utils");
|
|
32
33
|
const utils_1 = require("./lib/utils");
|
|
33
34
|
const comments_2 = require("./plugins/comments");
|
|
34
35
|
const editor_props_1 = require("./plugins/editor-props");
|
|
35
36
|
const footnotes_1 = require("./plugins/footnotes");
|
|
36
37
|
const footnotes_utils_1 = require("./plugins/footnotes/footnotes-utils");
|
|
38
|
+
const autocompletion_1 = require("./plugins/section_title/autocompletion");
|
|
37
39
|
const markActive = (type) => (state) => {
|
|
38
40
|
const { from, $from, to, empty } = state.selection;
|
|
39
41
|
return empty
|
|
@@ -472,16 +474,6 @@ const insertSection = (subsection = false) => (state, dispatch, view) => {
|
|
|
472
474
|
return true;
|
|
473
475
|
};
|
|
474
476
|
exports.insertSection = insertSection;
|
|
475
|
-
const sectionTitles = new Map([
|
|
476
|
-
['MPSectionCategory:acknowledgement', 'Acknowledgments'],
|
|
477
|
-
['MPSectionCategory:availability', 'Availability'],
|
|
478
|
-
['MPSectionCategory:competing-interests', 'COI Statement'],
|
|
479
|
-
['MPSectionCategory:con', 'Contributed-by information'],
|
|
480
|
-
['MPSectionCategory:ethics-statement', 'Ethics Statement'],
|
|
481
|
-
['MPSectionCategory:financial-disclosure', 'Financial Disclosure'],
|
|
482
|
-
['MPSectionCategory:supplementary-material', 'Supplementary Material'],
|
|
483
|
-
['MPSectionCategory:supported-by', 'Supported By'],
|
|
484
|
-
]);
|
|
485
477
|
const insertBackMatterSection = (category) => (state, dispatch, view) => {
|
|
486
478
|
const backmatter = (0, doc_1.findBackmatter)(state.doc);
|
|
487
479
|
const sections = (0, prosemirror_utils_1.findChildrenByType)(backmatter.node, transform_1.schema.nodes.section);
|
|
@@ -499,7 +491,7 @@ const insertBackMatterSection = (category) => (state, dispatch, view) => {
|
|
|
499
491
|
const node = transform_1.schema.nodes.section.createAndFill({
|
|
500
492
|
category,
|
|
501
493
|
}, [
|
|
502
|
-
transform_1.schema.nodes.section_title.create({}, transform_1.schema.text(sectionTitles.get(category) || '')),
|
|
494
|
+
transform_1.schema.nodes.section_title.create({}, transform_1.schema.text(section_titles_1.sectionTitles.get(category) || '')),
|
|
503
495
|
]);
|
|
504
496
|
const tr = state.tr.insert(pos, node);
|
|
505
497
|
if (dispatch) {
|
|
@@ -1126,3 +1118,13 @@ function mergeCellsWithSpace(state, dispatch) {
|
|
|
1126
1118
|
return true;
|
|
1127
1119
|
}
|
|
1128
1120
|
exports.mergeCellsWithSpace = mergeCellsWithSpace;
|
|
1121
|
+
const autoComplete = (state, dispatch) => {
|
|
1122
|
+
const autocompleteText = (0, autocompletion_1.checkForCompletion)(state);
|
|
1123
|
+
if (autocompleteText) {
|
|
1124
|
+
const tr = state.tr.insertText(autocompleteText, state.selection.from);
|
|
1125
|
+
dispatch && dispatch(tr);
|
|
1126
|
+
return true;
|
|
1127
|
+
}
|
|
1128
|
+
return false;
|
|
1129
|
+
};
|
|
1130
|
+
exports.autoComplete = autoComplete;
|
package/dist/cjs/keys/misc.js
CHANGED
|
@@ -39,6 +39,7 @@ const customKeymap = {
|
|
|
39
39
|
'Mod-Alt-=': (0, prosemirror_commands_1.toggleMark)(transform_1.schema.marks.superscript),
|
|
40
40
|
'Mod-Alt--': (0, prosemirror_commands_1.toggleMark)(transform_1.schema.marks.subscript),
|
|
41
41
|
'Ctrl->': (0, prosemirror_commands_1.wrapIn)(transform_1.schema.nodes.blockquote),
|
|
42
|
+
Enter: (0, prosemirror_commands_1.chainCommands)(commands_1.autoComplete, prosemirror_commands_1.newlineInCode, prosemirror_commands_1.createParagraphNear, prosemirror_commands_1.liftEmptyBlock, prosemirror_commands_1.splitBlock),
|
|
42
43
|
'Shift-Mod-Enter': (0, commands_1.insertSection)(true),
|
|
43
44
|
'Mod-Enter': (0, prosemirror_commands_1.chainCommands)(prosemirror_commands_1.exitCode, (0, commands_1.insertSection)()),
|
|
44
45
|
'Shift-Enter': (0, prosemirror_commands_1.chainCommands)(prosemirror_commands_1.exitCode, commands_1.insertBreak),
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 Atypon Systems LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.sectionTitles = void 0;
|
|
19
|
+
exports.sectionTitles = new Map([
|
|
20
|
+
['MPSectionCategory:acknowledgement', 'Acknowledgments'],
|
|
21
|
+
['MPSectionCategory:availability', 'Availability'],
|
|
22
|
+
['MPSectionCategory:competing-interests', 'COI Statement'],
|
|
23
|
+
['MPSectionCategory:con', 'Contributed-by information'],
|
|
24
|
+
['MPSectionCategory:ethics-statement', 'Ethics Statement'],
|
|
25
|
+
['MPSectionCategory:financial-disclosure', 'Financial Disclosure'],
|
|
26
|
+
['MPSectionCategory:supplementary-material', 'Supplementary Material'],
|
|
27
|
+
['MPSectionCategory:supported-by', 'Supported By'],
|
|
28
|
+
]);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkForCompletion = exports.hasAutoCompletionSlack = void 0;
|
|
4
|
+
const transform_1 = require("@manuscripts/transform");
|
|
5
|
+
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
6
|
+
const section_titles_1 = require("../../lib/section-titles");
|
|
7
|
+
function cursorAtTheEndOfText(state, nodeSize, nodePos) {
|
|
8
|
+
const { from, to } = state.selection;
|
|
9
|
+
return from === to && to === nodePos + nodeSize - 1;
|
|
10
|
+
}
|
|
11
|
+
function hasAutoCompletionSlack(parentSection, titleSection) {
|
|
12
|
+
const category = parentSection.attrs.category;
|
|
13
|
+
const title = section_titles_1.sectionTitles.get(category);
|
|
14
|
+
if (category &&
|
|
15
|
+
title &&
|
|
16
|
+
titleSection.textContent &&
|
|
17
|
+
title.startsWith(titleSection.textContent)) {
|
|
18
|
+
const suggestionText = title.slice(titleSection.textContent.length);
|
|
19
|
+
return suggestionText;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return '';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.hasAutoCompletionSlack = hasAutoCompletionSlack;
|
|
26
|
+
function checkForCompletion(state) {
|
|
27
|
+
const section = (0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)(state.selection.$from, transform_1.schema.nodes.section);
|
|
28
|
+
const title = (0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)(state.selection.$from, transform_1.schema.nodes.section_title);
|
|
29
|
+
if (section &&
|
|
30
|
+
title &&
|
|
31
|
+
cursorAtTheEndOfText(state, title.node.nodeSize, title.pos)) {
|
|
32
|
+
const text = hasAutoCompletionSlack(section.node, title.node);
|
|
33
|
+
return text;
|
|
34
|
+
}
|
|
35
|
+
return '';
|
|
36
|
+
}
|
|
37
|
+
exports.checkForCompletion = checkForCompletion;
|
|
@@ -4,7 +4,9 @@ exports.sectionTitleKey = void 0;
|
|
|
4
4
|
const transform_1 = require("@manuscripts/transform");
|
|
5
5
|
const prosemirror_state_1 = require("prosemirror-state");
|
|
6
6
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
7
|
-
const
|
|
7
|
+
const prosemirror_view_1 = require("prosemirror-view");
|
|
8
|
+
const track_changes_utils_1 = require("../../lib/track-changes-utils");
|
|
9
|
+
const autocompletion_1 = require("./autocompletion");
|
|
8
10
|
exports.sectionTitleKey = new prosemirror_state_1.PluginKey('sectionNumbering');
|
|
9
11
|
const calculateSectionLevels = (node, startPos, sectionNumberMap, numbering = [0]) => {
|
|
10
12
|
node.forEach((childNode, offset) => {
|
|
@@ -35,6 +37,21 @@ const getPluginState = (doc) => {
|
|
|
35
37
|
exports.default = () => {
|
|
36
38
|
return new prosemirror_state_1.Plugin({
|
|
37
39
|
key: exports.sectionTitleKey,
|
|
40
|
+
props: {
|
|
41
|
+
decorations(state) {
|
|
42
|
+
const text = (0, autocompletion_1.checkForCompletion)(state);
|
|
43
|
+
if (text) {
|
|
44
|
+
const decoration = prosemirror_view_1.Decoration.widget(state.selection.from, () => {
|
|
45
|
+
const node = document.createElement('span');
|
|
46
|
+
node.classList.add('completion-bearer');
|
|
47
|
+
node.dataset.suggest = text;
|
|
48
|
+
return node;
|
|
49
|
+
});
|
|
50
|
+
return prosemirror_view_1.DecorationSet.create(state.doc, [decoration]);
|
|
51
|
+
}
|
|
52
|
+
return prosemirror_view_1.DecorationSet.empty;
|
|
53
|
+
},
|
|
54
|
+
},
|
|
38
55
|
state: {
|
|
39
56
|
init: (_, state) => {
|
|
40
57
|
return getPluginState(state.doc);
|
package/dist/cjs/versions.js
CHANGED
package/dist/es/commands.js
CHANGED
|
@@ -25,12 +25,14 @@ import { findChildrenByType, findParentNodeOfType, hasParentNodeOfType, } from '
|
|
|
25
25
|
import { getCommentKey, getCommentRange } from './lib/comments';
|
|
26
26
|
import { findBackmatter, findBibliographySection, findBody, insertSupplementsNode, } from './lib/doc';
|
|
27
27
|
import { findWordBoundaries, isNodeOfType, nearestAncestor, } from './lib/helpers';
|
|
28
|
+
import { sectionTitles } from './lib/section-titles';
|
|
28
29
|
import { isDeleted, isRejectedInsert } from './lib/track-changes-utils';
|
|
29
30
|
import { findParentNodeWithId, getChildOfType, getMatchingChild, } from './lib/utils';
|
|
30
31
|
import { setCommentSelection } from './plugins/comments';
|
|
31
32
|
import { getEditorProps } from './plugins/editor-props';
|
|
32
33
|
import { footnotesKey } from './plugins/footnotes';
|
|
33
34
|
import { getNewFootnotePos } from './plugins/footnotes/footnotes-utils';
|
|
35
|
+
import { checkForCompletion } from './plugins/section_title/autocompletion';
|
|
34
36
|
export const markActive = (type) => (state) => {
|
|
35
37
|
const { from, $from, to, empty } = state.selection;
|
|
36
38
|
return empty
|
|
@@ -446,16 +448,6 @@ export const insertSection = (subsection = false) => (state, dispatch, view) =>
|
|
|
446
448
|
}
|
|
447
449
|
return true;
|
|
448
450
|
};
|
|
449
|
-
const sectionTitles = new Map([
|
|
450
|
-
['MPSectionCategory:acknowledgement', 'Acknowledgments'],
|
|
451
|
-
['MPSectionCategory:availability', 'Availability'],
|
|
452
|
-
['MPSectionCategory:competing-interests', 'COI Statement'],
|
|
453
|
-
['MPSectionCategory:con', 'Contributed-by information'],
|
|
454
|
-
['MPSectionCategory:ethics-statement', 'Ethics Statement'],
|
|
455
|
-
['MPSectionCategory:financial-disclosure', 'Financial Disclosure'],
|
|
456
|
-
['MPSectionCategory:supplementary-material', 'Supplementary Material'],
|
|
457
|
-
['MPSectionCategory:supported-by', 'Supported By'],
|
|
458
|
-
]);
|
|
459
451
|
export const insertBackMatterSection = (category) => (state, dispatch, view) => {
|
|
460
452
|
const backmatter = findBackmatter(state.doc);
|
|
461
453
|
const sections = findChildrenByType(backmatter.node, schema.nodes.section);
|
|
@@ -1079,3 +1071,12 @@ export function mergeCellsWithSpace(state, dispatch) {
|
|
|
1079
1071
|
}
|
|
1080
1072
|
return true;
|
|
1081
1073
|
}
|
|
1074
|
+
export const autoComplete = (state, dispatch) => {
|
|
1075
|
+
const autocompleteText = checkForCompletion(state);
|
|
1076
|
+
if (autocompleteText) {
|
|
1077
|
+
const tr = state.tr.insertText(autocompleteText, state.selection.from);
|
|
1078
|
+
dispatch && dispatch(tr);
|
|
1079
|
+
return true;
|
|
1080
|
+
}
|
|
1081
|
+
return false;
|
|
1082
|
+
};
|
package/dist/es/keys/misc.js
CHANGED
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { schema } from '@manuscripts/transform';
|
|
17
|
-
import { chainCommands, exitCode, joinDown, joinUp, lift, toggleMark, wrapIn, } from 'prosemirror-commands';
|
|
17
|
+
import { chainCommands, createParagraphNear, exitCode, joinDown, joinUp, lift, liftEmptyBlock, newlineInCode, splitBlock, toggleMark, wrapIn, } from 'prosemirror-commands';
|
|
18
18
|
import { redo, undo } from 'prosemirror-history';
|
|
19
19
|
import { undoInputRule } from 'prosemirror-inputrules';
|
|
20
20
|
import { goToNextCell } from 'prosemirror-tables';
|
|
21
|
-
import { ignoreAtomBlockNodeBackward, ignoreAtomBlockNodeForward, ignoreMetaNodeBackspaceCommand, insertBlock, insertBreak, insertCrossReference, insertInlineCitation, insertInlineEquation, insertSection, selectAllIsolating, } from '../commands';
|
|
21
|
+
import { autoComplete, ignoreAtomBlockNodeBackward, ignoreAtomBlockNodeForward, ignoreMetaNodeBackspaceCommand, insertBlock, insertBreak, insertCrossReference, insertInlineCitation, insertInlineEquation, insertSection, selectAllIsolating, } from '../commands';
|
|
22
22
|
const customKeymap = {
|
|
23
23
|
Backspace: chainCommands(undoInputRule, ignoreAtomBlockNodeBackward, ignoreMetaNodeBackspaceCommand),
|
|
24
24
|
Delete: ignoreAtomBlockNodeForward,
|
|
@@ -37,6 +37,7 @@ const customKeymap = {
|
|
|
37
37
|
'Mod-Alt-=': toggleMark(schema.marks.superscript),
|
|
38
38
|
'Mod-Alt--': toggleMark(schema.marks.subscript),
|
|
39
39
|
'Ctrl->': wrapIn(schema.nodes.blockquote),
|
|
40
|
+
Enter: chainCommands(autoComplete, newlineInCode, createParagraphNear, liftEmptyBlock, splitBlock),
|
|
40
41
|
'Shift-Mod-Enter': insertSection(true),
|
|
41
42
|
'Mod-Enter': chainCommands(exitCode, insertSection()),
|
|
42
43
|
'Shift-Enter': chainCommands(exitCode, insertBreak),
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2019 Atypon Systems LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export const sectionTitles = new Map([
|
|
17
|
+
['MPSectionCategory:acknowledgement', 'Acknowledgments'],
|
|
18
|
+
['MPSectionCategory:availability', 'Availability'],
|
|
19
|
+
['MPSectionCategory:competing-interests', 'COI Statement'],
|
|
20
|
+
['MPSectionCategory:con', 'Contributed-by information'],
|
|
21
|
+
['MPSectionCategory:ethics-statement', 'Ethics Statement'],
|
|
22
|
+
['MPSectionCategory:financial-disclosure', 'Financial Disclosure'],
|
|
23
|
+
['MPSectionCategory:supplementary-material', 'Supplementary Material'],
|
|
24
|
+
['MPSectionCategory:supported-by', 'Supported By'],
|
|
25
|
+
]);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { schema, } from '@manuscripts/transform';
|
|
2
|
+
import { findParentNodeOfTypeClosestToPos } from 'prosemirror-utils';
|
|
3
|
+
import { sectionTitles } from '../../lib/section-titles';
|
|
4
|
+
function cursorAtTheEndOfText(state, nodeSize, nodePos) {
|
|
5
|
+
const { from, to } = state.selection;
|
|
6
|
+
return from === to && to === nodePos + nodeSize - 1;
|
|
7
|
+
}
|
|
8
|
+
export function hasAutoCompletionSlack(parentSection, titleSection) {
|
|
9
|
+
const category = parentSection.attrs.category;
|
|
10
|
+
const title = sectionTitles.get(category);
|
|
11
|
+
if (category &&
|
|
12
|
+
title &&
|
|
13
|
+
titleSection.textContent &&
|
|
14
|
+
title.startsWith(titleSection.textContent)) {
|
|
15
|
+
const suggestionText = title.slice(titleSection.textContent.length);
|
|
16
|
+
return suggestionText;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return '';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function checkForCompletion(state) {
|
|
23
|
+
const section = findParentNodeOfTypeClosestToPos(state.selection.$from, schema.nodes.section);
|
|
24
|
+
const title = findParentNodeOfTypeClosestToPos(state.selection.$from, schema.nodes.section_title);
|
|
25
|
+
if (section &&
|
|
26
|
+
title &&
|
|
27
|
+
cursorAtTheEndOfText(state, title.node.nodeSize, title.pos)) {
|
|
28
|
+
const text = hasAutoCompletionSlack(section.node, title.node);
|
|
29
|
+
return text;
|
|
30
|
+
}
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { schema } from '@manuscripts/transform';
|
|
2
2
|
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
3
3
|
import { findChildrenByType } from 'prosemirror-utils';
|
|
4
|
-
import {
|
|
4
|
+
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
5
|
+
import { isRejectedInsert } from '../../lib/track-changes-utils';
|
|
6
|
+
import { checkForCompletion } from './autocompletion';
|
|
5
7
|
export const sectionTitleKey = new PluginKey('sectionNumbering');
|
|
6
8
|
const calculateSectionLevels = (node, startPos, sectionNumberMap, numbering = [0]) => {
|
|
7
9
|
node.forEach((childNode, offset) => {
|
|
@@ -32,6 +34,21 @@ const getPluginState = (doc) => {
|
|
|
32
34
|
export default () => {
|
|
33
35
|
return new Plugin({
|
|
34
36
|
key: sectionTitleKey,
|
|
37
|
+
props: {
|
|
38
|
+
decorations(state) {
|
|
39
|
+
const text = checkForCompletion(state);
|
|
40
|
+
if (text) {
|
|
41
|
+
const decoration = Decoration.widget(state.selection.from, () => {
|
|
42
|
+
const node = document.createElement('span');
|
|
43
|
+
node.classList.add('completion-bearer');
|
|
44
|
+
node.dataset.suggest = text;
|
|
45
|
+
return node;
|
|
46
|
+
});
|
|
47
|
+
return DecorationSet.create(state.doc, [decoration]);
|
|
48
|
+
}
|
|
49
|
+
return DecorationSet.empty;
|
|
50
|
+
},
|
|
51
|
+
},
|
|
35
52
|
state: {
|
|
36
53
|
init: (_, state) => {
|
|
37
54
|
return getPluginState(state.doc);
|
package/dist/es/versions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '2.0.
|
|
1
|
+
export const VERSION = '2.0.36-LEAN-3883.0';
|
|
2
2
|
export const MATHJAX_VERSION = '3.2.2';
|
package/dist/types/commands.d.ts
CHANGED
|
@@ -70,4 +70,5 @@ export declare const insertTableFootnote: (tableElementNode: ManuscriptNode, pos
|
|
|
70
70
|
export declare const addRows: (direction: 'top' | 'bottom') => (state: EditorState, dispatch?: ((tr: Transaction) => void) | undefined) => boolean;
|
|
71
71
|
export declare const addColumns: (direction: 'right' | 'left') => (state: EditorState, dispatch?: ((tr: Transaction) => void) | undefined) => boolean;
|
|
72
72
|
export declare function mergeCellsWithSpace(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
|
73
|
+
export declare const autoComplete: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
73
74
|
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2019 Atypon Systems LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { SectionCategory } from '@manuscripts/transform';
|
|
17
|
+
export declare const sectionTitles: Map<SectionCategory, string>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SectionNode, SectionTitleNode } from '@manuscripts/transform';
|
|
2
|
+
import { EditorState } from 'prosemirror-state';
|
|
3
|
+
export declare function hasAutoCompletionSlack(parentSection: SectionNode, titleSection: SectionTitleNode): string;
|
|
4
|
+
export declare function checkForCompletion(state: EditorState): string;
|
package/dist/types/versions.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "2.0.
|
|
1
|
+
export declare const VERSION = "2.0.36-LEAN-3883.0";
|
|
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.0.
|
|
4
|
+
"version": "2.0.36-LEAN-3883.0",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@iarna/word-count": "^1.1.2",
|
|
33
33
|
"@manuscripts/json-schema": "2.2.11",
|
|
34
34
|
"@manuscripts/library": "1.3.11",
|
|
35
|
-
"@manuscripts/style-guide": "2.0.
|
|
35
|
+
"@manuscripts/style-guide": "2.0.12-LEAN-3883.1",
|
|
36
36
|
"@manuscripts/track-changes-plugin": "1.7.17",
|
|
37
37
|
"@manuscripts/transform": "2.3.29",
|
|
38
38
|
"@popperjs/core": "^2.11.8",
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
.ProseMirror
|
|
2
2
|
> div.body
|
|
3
|
-
section:not(.toc)
|
|
4
|
-
|
|
3
|
+
section:not(.toc)
|
|
4
|
+
.block-section_title
|
|
5
5
|
h1.empty-node[data-placeholder]::before {
|
|
6
6
|
content: attr(data-section-number) '. ' attr(data-placeholder);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
.ProseMirror
|
|
10
|
-
> div.body
|
|
11
|
-
section:not(.toc)
|
|
12
|
-
.block-section_title
|
|
13
|
-
h1::before {
|
|
9
|
+
.ProseMirror > div.body section:not(.toc) .block-section_title h1::before {
|
|
14
10
|
content: attr(data-section-number) '. ';
|
|
15
11
|
}
|
|
16
12
|
|
|
17
|
-
|
|
18
13
|
.ProseMirror > div .block-section_title > h1 {
|
|
19
14
|
font-size: 16pt !important;
|
|
20
15
|
font-style: normal !important;
|
|
@@ -39,8 +34,6 @@
|
|
|
39
34
|
font-size: 13.5pt !important;
|
|
40
35
|
}
|
|
41
36
|
|
|
42
|
-
|
|
43
|
-
|
|
44
37
|
.ProseMirror div.backmatter::before {
|
|
45
38
|
content: '';
|
|
46
39
|
border-bottom: 1px dashed #c9c9c9;
|
|
@@ -51,6 +44,15 @@
|
|
|
51
44
|
font-size: 13.5pt !important;
|
|
52
45
|
color: #6e6e6e !important;
|
|
53
46
|
}
|
|
47
|
+
.completion-bearer {
|
|
48
|
+
pointer-events: none;
|
|
49
|
+
}
|
|
50
|
+
.block-section_title .completion-bearer:after {
|
|
51
|
+
content: attr(data-suggest);
|
|
52
|
+
opacity: 0.5;
|
|
53
|
+
pointer-events: none;
|
|
54
|
+
font-style: italic;
|
|
55
|
+
}
|
|
54
56
|
|
|
55
57
|
.ProseMirror p.block {
|
|
56
58
|
font-size: 12pt !important;
|
|
@@ -154,8 +156,8 @@
|
|
|
154
156
|
position: static;
|
|
155
157
|
}
|
|
156
158
|
|
|
157
|
-
|
|
158
|
-
.comment-marker
|
|
159
|
+
.comment-marker.selected-comment > svg > path,
|
|
160
|
+
.comment-marker:active > svg > path {
|
|
159
161
|
stroke: #f7b314;
|
|
160
162
|
fill: #ffe0b2;
|
|
161
163
|
}
|
|
@@ -170,7 +172,8 @@
|
|
|
170
172
|
position: relative;
|
|
171
173
|
}
|
|
172
174
|
|
|
173
|
-
.block > div.comment-marker,
|
|
175
|
+
.block > div.comment-marker,
|
|
176
|
+
.figure-block > div.comment-marker {
|
|
174
177
|
top: -25px;
|
|
175
178
|
left: 100%;
|
|
176
179
|
}
|
|
@@ -209,7 +212,7 @@ span.comment-marker {
|
|
|
209
212
|
top: 12px;
|
|
210
213
|
}
|
|
211
214
|
|
|
212
|
-
.comment-marker[data-count=
|
|
215
|
+
.comment-marker[data-count='0'] {
|
|
213
216
|
display: none;
|
|
214
217
|
}
|
|
215
218
|
|
|
@@ -221,7 +224,7 @@ span.comment-marker {
|
|
|
221
224
|
content: attr(data-count);
|
|
222
225
|
top: 8px;
|
|
223
226
|
left: 8px;
|
|
224
|
-
background-color: #
|
|
227
|
+
background-color: #f7b314;
|
|
225
228
|
border-radius: 50%;
|
|
226
229
|
width: 12px;
|
|
227
230
|
height: 12px;
|
|
@@ -289,7 +292,7 @@ span.comment-marker {
|
|
|
289
292
|
font-size: 16px !important;
|
|
290
293
|
font-weight: 700 !important;
|
|
291
294
|
line-height: 24px !important;
|
|
292
|
-
margin: 0 !important
|
|
295
|
+
margin: 0 !important;
|
|
293
296
|
}
|
|
294
297
|
|
|
295
298
|
.keywords .keyword {
|
|
@@ -304,7 +307,7 @@ span.comment-marker {
|
|
|
304
307
|
position: relative;
|
|
305
308
|
cursor: default;
|
|
306
309
|
padding: 4px 8px;
|
|
307
|
-
border: 1px solid #
|
|
310
|
+
border: 1px solid #c9c9c9;
|
|
308
311
|
margin-top: 10px;
|
|
309
312
|
margin-bottom: 4px;
|
|
310
313
|
}
|
|
@@ -370,7 +373,7 @@ span.comment-marker {
|
|
|
370
373
|
|
|
371
374
|
.keywords .keyword-group-container {
|
|
372
375
|
position: relative;
|
|
373
|
-
|
|
376
|
+
margin: 0 0 36px !important;
|
|
374
377
|
}
|
|
375
378
|
|
|
376
379
|
.keywords .keyword-group {
|
|
@@ -444,8 +447,8 @@ span.comment-marker {
|
|
|
444
447
|
--inserted-pending-bg-color: #e6ffdb;
|
|
445
448
|
--inserted-pending-color: #01872e;
|
|
446
449
|
--accepted-bg-color: #e2e2e2;
|
|
447
|
-
--deleted-color: #
|
|
448
|
-
--deleted-pending-bg-color: #
|
|
450
|
+
--deleted-color: #f35143;
|
|
451
|
+
--deleted-pending-bg-color: #fff1f0;
|
|
449
452
|
--highlight-bg-color: #ffeebf;
|
|
450
453
|
--common-color: #353535;
|
|
451
454
|
--selected-pending-background-color: #ddf3fa;
|
|
@@ -474,22 +477,28 @@ span.selected-suggestion,
|
|
|
474
477
|
span.accepted .selected-suggestion,
|
|
475
478
|
.accepted .selected-suggestion > .block-container .block,
|
|
476
479
|
.accepted .selected-suggestion:not(:has(> .block-container)),
|
|
477
|
-
.selected-suggestion[data-track-status=
|
|
478
|
-
.selected-suggestion
|
|
479
|
-
.selected-suggestion
|
|
480
|
-
|
|
480
|
+
.selected-suggestion[data-track-status='accepted'],
|
|
481
|
+
.selected-suggestion > .block-container .block.accepted,
|
|
482
|
+
.selected-suggestion
|
|
483
|
+
> .block-container
|
|
484
|
+
.block:has([data-track-status='accepted']),
|
|
485
|
+
.selected-suggestion:not(:has(> .block-container)):has(
|
|
486
|
+
[data-track-status='accepted']
|
|
487
|
+
) {
|
|
481
488
|
background-color: var(--selected-accepted-background-color) !important;
|
|
482
489
|
border-width: 2px 0 2px 0 !important;
|
|
483
|
-
border-color: #
|
|
490
|
+
border-color: #c9c9c9 !important;
|
|
484
491
|
border-radius: 3px !important;
|
|
485
492
|
border-style: solid !important;
|
|
486
493
|
}
|
|
487
494
|
|
|
488
|
-
.block-bullet_list .selected-suggestion p,
|
|
495
|
+
.block-bullet_list .selected-suggestion p,
|
|
496
|
+
.block-ordered_list .selected-suggestion p {
|
|
489
497
|
margin: 0;
|
|
490
498
|
}
|
|
491
499
|
|
|
492
|
-
.block-bullet_list .selected-suggestion,
|
|
500
|
+
.block-bullet_list .selected-suggestion,
|
|
501
|
+
.block-ordered_list .selected-suggestion {
|
|
493
502
|
margin: 16px 0;
|
|
494
503
|
}
|
|
495
504
|
|
|
@@ -501,7 +510,10 @@ span.accepted .selected-suggestion,
|
|
|
501
510
|
}
|
|
502
511
|
|
|
503
512
|
.ProseMirror .selected-suggestion .inserted.pending,
|
|
504
|
-
.ProseMirror
|
|
513
|
+
.ProseMirror
|
|
514
|
+
.selected-suggestion
|
|
515
|
+
[data-track-op='insert'][data-track-status='pending']
|
|
516
|
+
.block,
|
|
505
517
|
.ProseMirror .selected-suggestion .deleted.pending {
|
|
506
518
|
background-color: var(--selected-pending-background-color) !important;
|
|
507
519
|
color: var(--common-color) !important;
|
|
@@ -544,7 +556,11 @@ span.accepted .selected-suggestion,
|
|
|
544
556
|
.ProseMirror .inserted.pending:has(.selected-suggestion),
|
|
545
557
|
.ProseMirror .deleted.pending:has(.selected-suggestion),
|
|
546
558
|
.ProseMirror .selected-suggestion .highlight,
|
|
547
|
-
.ProseMirror
|
|
559
|
+
.ProseMirror
|
|
560
|
+
.selected-suggestion
|
|
561
|
+
.graphical-abstract:has(
|
|
562
|
+
[data-track-status='pending'][data-track-op='insert']
|
|
563
|
+
) {
|
|
548
564
|
background: transparent !important;
|
|
549
565
|
color: var(--common-color);
|
|
550
566
|
text-decoration: none;
|
|
@@ -583,7 +599,7 @@ span.accepted .selected-suggestion,
|
|
|
583
599
|
.affiliation[data-track-status='pending'][data-track-op='delete'] {
|
|
584
600
|
text-decoration: line-through;
|
|
585
601
|
color: var(--deleted-color);
|
|
586
|
-
background-color: var(--deleted-pending-bg-color)
|
|
602
|
+
background-color: var(--deleted-pending-bg-color);
|
|
587
603
|
}
|
|
588
604
|
|
|
589
605
|
.contributor[data-track-op='delete']:not([data-track-status='rejected']),
|
|
@@ -597,7 +613,9 @@ span.accepted .selected-suggestion,
|
|
|
597
613
|
color: var(--inserted-pending-color);
|
|
598
614
|
text-decoration: underline;
|
|
599
615
|
}
|
|
600
|
-
.block-contributors,
|
|
616
|
+
.block-contributors,
|
|
617
|
+
.block-affiliations,
|
|
618
|
+
.keywords {
|
|
601
619
|
margin: 15px 0px;
|
|
602
620
|
}
|
|
603
621
|
.contributors {
|
|
@@ -698,7 +716,6 @@ span.accepted .selected-suggestion,
|
|
|
698
716
|
margin: 1rem 64px 0;
|
|
699
717
|
font-size: 12px;
|
|
700
718
|
color: #6e6e6e;
|
|
701
|
-
|
|
702
719
|
}
|
|
703
720
|
|
|
704
721
|
* {
|
|
@@ -736,7 +753,9 @@ span.accepted .selected-suggestion,
|
|
|
736
753
|
z-index: 10;
|
|
737
754
|
}
|
|
738
755
|
|
|
739
|
-
.ProseMirror td:hover > .table-context-menu-button,
|
|
756
|
+
.ProseMirror td:hover > .table-context-menu-button,
|
|
757
|
+
th:hover > .table-context-menu-button,
|
|
758
|
+
.open-context-menu {
|
|
740
759
|
visibility: visible !important;
|
|
741
760
|
}
|
|
742
761
|
|
|
@@ -761,7 +780,7 @@ span.accepted .selected-suggestion,
|
|
|
761
780
|
}
|
|
762
781
|
|
|
763
782
|
.section-category-button:not(.assigned) path {
|
|
764
|
-
fill: #
|
|
783
|
+
fill: #ffe0b2;
|
|
765
784
|
}
|
|
766
785
|
|
|
767
786
|
.section-category-button.assigned:after {
|
|
@@ -771,8 +790,8 @@ span.accepted .selected-suggestion,
|
|
|
771
790
|
content: '';
|
|
772
791
|
height: 8px;
|
|
773
792
|
width: 4px;
|
|
774
|
-
border-bottom: 2px solid #
|
|
775
|
-
border-right: 2px solid #
|
|
793
|
+
border-bottom: 2px solid #36b260;
|
|
794
|
+
border-right: 2px solid #36b260;
|
|
776
795
|
transform: rotate(45deg);
|
|
777
796
|
}
|
|
778
797
|
|
|
@@ -781,8 +800,8 @@ span.accepted .selected-suggestion,
|
|
|
781
800
|
}
|
|
782
801
|
.section-category.menu {
|
|
783
802
|
border-radius: 8px;
|
|
784
|
-
border: 1px solid #
|
|
785
|
-
box-shadow: 0px 4px 9px 0px rgba(0, 0, 0, 0.
|
|
803
|
+
border: 1px solid #e2e2e2;
|
|
804
|
+
box-shadow: 0px 4px 9px 0px rgba(0, 0, 0, 0.3);
|
|
786
805
|
}
|
|
787
806
|
|
|
788
807
|
.section-category.menu .menu-item {
|
|
@@ -809,8 +828,8 @@ span.accepted .selected-suggestion,
|
|
|
809
828
|
content: '';
|
|
810
829
|
height: 10px;
|
|
811
830
|
width: 5px;
|
|
812
|
-
border-bottom: 2px solid #
|
|
813
|
-
border-right: 2px solid #
|
|
831
|
+
border-bottom: 2px solid #36b260;
|
|
832
|
+
border-right: 2px solid #36b260;
|
|
814
833
|
transform: rotate(45deg);
|
|
815
834
|
}
|
|
816
835
|
|
|
@@ -826,16 +845,16 @@ span.accepted .selected-suggestion,
|
|
|
826
845
|
display: flex;
|
|
827
846
|
align-items: center;
|
|
828
847
|
border-radius: 6px;
|
|
829
|
-
background: #
|
|
848
|
+
background: #e2e2e2;
|
|
830
849
|
font-size: 12px;
|
|
831
850
|
font-style: normal;
|
|
832
851
|
font-weight: 400;
|
|
833
|
-
color:
|
|
852
|
+
color: #353535;
|
|
834
853
|
line-height: 16px;
|
|
835
854
|
}
|
|
836
855
|
|
|
837
856
|
.section-category.tooltip span {
|
|
838
|
-
color:
|
|
857
|
+
color: #353535;
|
|
839
858
|
font-size: 12px;
|
|
840
859
|
font-style: normal;
|
|
841
860
|
font-weight: 700;
|
|
File without changes
|