@manuscripts/body-editor 2.7.43 → 2.7.44-LEAN-4312.2

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.
@@ -16,7 +16,7 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.addHeaderRow = exports.addRows = exports.addInlineComment = exports.addNodeComment = exports.isCommentingAllowed = 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.insertAward = exports.insertAffiliation = exports.insertContributors = exports.insertAbstract = exports.insertBackmatterSection = exports.insertSection = exports.insertGraphicalAbstract = exports.insertBoxElement = exports.insertInlineFootnote = exports.insertFootnotesElement = exports.insertTableElementFooter = exports.insertInlineEquation = exports.insertCrossReference = exports.insertInlineCitation = exports.insertLink = exports.insertSectionLabel = exports.findPosBeforeFirstSubsection = exports.insertBreak = exports.deleteBlock = exports.insertBlock = exports.insertSupplement = exports.insertTable = exports.insertFigure = exports.insertGeneralTableFootnote = exports.insertInlineTableFootnote = exports.insertEmbed = exports.createBlock = exports.createSelection = exports.canInsert = exports.blockActive = exports.isNodeSelection = exports.markActive = exports.addToStart = void 0;
19
- exports.autoComplete = exports.addColumns = void 0;
19
+ exports.activateSearchReplace = exports.activateSearch = exports.autoComplete = exports.addColumns = void 0;
20
20
  const json_schema_1 = require("@manuscripts/json-schema");
21
21
  const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
22
22
  const transform_1 = require("@manuscripts/transform");
@@ -34,6 +34,7 @@ const track_changes_utils_1 = require("./lib/track-changes-utils");
34
34
  const utils_1 = require("./lib/utils");
35
35
  const comments_2 = require("./plugins/comments");
36
36
  const editor_props_1 = require("./plugins/editor-props");
37
+ const search_replace_1 = require("./plugins/search-replace");
37
38
  const autocompletion_1 = require("./plugins/section_title/autocompletion");
38
39
  const addToStart = (state, dispatch) => {
39
40
  const { selection } = state;
@@ -1160,3 +1161,21 @@ const autoComplete = (state, dispatch) => {
1160
1161
  return false;
1161
1162
  };
1162
1163
  exports.autoComplete = autoComplete;
1164
+ const activateSearch = (state, dispatch) => {
1165
+ const pluginState = search_replace_1.searchReplaceKey.getState(state);
1166
+ const tr = state.tr.setMeta(search_replace_1.searchReplaceKey, {
1167
+ active: !(pluginState === null || pluginState === void 0 ? void 0 : pluginState.active),
1168
+ });
1169
+ dispatch && dispatch(tr);
1170
+ return true;
1171
+ };
1172
+ exports.activateSearch = activateSearch;
1173
+ const activateSearchReplace = (state, dispatch) => {
1174
+ const pluginState = search_replace_1.searchReplaceKey.getState(state);
1175
+ const tr = state.tr.setMeta(search_replace_1.searchReplaceKey, {
1176
+ activeAdvanced: !(pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeAdvanced),
1177
+ });
1178
+ dispatch && dispatch(tr);
1179
+ return true;
1180
+ };
1181
+ exports.activateSearchReplace = activateSearchReplace;
@@ -39,6 +39,7 @@ const objects_1 = __importDefault(require("../plugins/objects"));
39
39
  const paragraphs_1 = __importDefault(require("../plugins/paragraphs"));
40
40
  const persist_1 = __importDefault(require("../plugins/persist"));
41
41
  const placeholder_1 = __importDefault(require("../plugins/placeholder"));
42
+ const search_replace_1 = __importDefault(require("../plugins/search-replace"));
42
43
  const section_title_1 = __importDefault(require("../plugins/section_title"));
43
44
  const section_category_1 = __importDefault(require("../plugins/section-category"));
44
45
  const sections_1 = __importDefault(require("../plugins/sections"));
@@ -77,6 +78,7 @@ exports.default = (props) => {
77
78
  (0, section_category_1.default)(props),
78
79
  (0, cross_references_1.default)(),
79
80
  (0, inspector_tabs_1.default)(),
81
+ (0, search_replace_1.default)(),
80
82
  ];
81
83
  if (props.collabProvider) {
82
84
  allPlugins.push((0, prosemirror_collab_1.collab)({ version: props.collabProvider.currentVersion }));
package/dist/cjs/index.js CHANGED
@@ -29,7 +29,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
29
29
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.affiliationLabel = exports.authorLabel = exports.metadata = exports.bibliographyPluginKey = exports.footnotesPluginKey = exports.objectsPluginKey = exports.selectedSuggestionKey = exports.PopperManager = exports.CollabProvider = exports.LevelSelector = exports.OutlineItemIcon = exports.ManuscriptOutline = void 0;
32
+ exports.affiliationLabel = exports.authorLabel = exports.metadata = exports.searchReplacePluginKey = exports.bibliographyPluginKey = exports.footnotesPluginKey = exports.objectsPluginKey = exports.selectedSuggestionKey = exports.PopperManager = exports.CollabProvider = exports.LevelSelector = exports.OutlineItemIcon = exports.ManuscriptOutline = void 0;
33
33
  __exportStar(require("./commands"), exports);
34
34
  var ManuscriptOutline_1 = require("./components/outline/ManuscriptOutline");
35
35
  Object.defineProperty(exports, "ManuscriptOutline", { enumerable: true, get: function () { return ManuscriptOutline_1.ManuscriptOutline; } });
@@ -63,6 +63,8 @@ var footnotes_1 = require("./plugins/footnotes");
63
63
  Object.defineProperty(exports, "footnotesPluginKey", { enumerable: true, get: function () { return footnotes_1.footnotesKey; } });
64
64
  var bibliography_1 = require("./plugins/bibliography");
65
65
  Object.defineProperty(exports, "bibliographyPluginKey", { enumerable: true, get: function () { return bibliography_1.bibliographyKey; } });
66
+ var search_replace_1 = require("./plugins/search-replace");
67
+ Object.defineProperty(exports, "searchReplacePluginKey", { enumerable: true, get: function () { return search_replace_1.searchReplaceKey; } });
66
68
  var references_1 = require("./lib/references");
67
69
  Object.defineProperty(exports, "metadata", { enumerable: true, get: function () { return references_1.metadata; } });
68
70
  var authors_1 = require("./lib/authors");
@@ -53,5 +53,9 @@ const customKeymap = {
53
53
  'Mod-Alt-c': commands_1.insertInlineCitation,
54
54
  'Mod-Alt-r': commands_1.insertCrossReference,
55
55
  'Shift-Mod-Alt-e': commands_1.insertInlineEquation,
56
+ 'Shift-Ctrl-h': commands_1.activateSearchReplace,
57
+ 'Shift-Mod-h': commands_1.activateSearchReplace,
58
+ 'Mod-f': commands_1.activateSearch,
59
+ 'Ctrl-f': commands_1.activateSearch,
56
60
  };
57
61
  exports.default = customKeymap;
package/dist/cjs/menus.js CHANGED
@@ -79,6 +79,20 @@ const getEditorMenus = (editor) => {
79
79
  isEnabled: isCommandValid(hierarchy_1.deleteClosestParentElement),
80
80
  run: doCommand(hierarchy_1.deleteClosestParentElement),
81
81
  },
82
+ {
83
+ role: 'separator',
84
+ },
85
+ {
86
+ id: 'find-replace',
87
+ role: 'find-replace',
88
+ label: 'Find and replace',
89
+ shortcut: {
90
+ mac: 'CommandOrControl+Shift+H',
91
+ pc: 'CommandOrControl+Shift+H',
92
+ },
93
+ isEnabled: isCommandValid(commands_1.activateSearchReplace),
94
+ run: doCommand(commands_1.activateSearchReplace),
95
+ },
82
96
  ],
83
97
  };
84
98
  const insert = {
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2024 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.searchReplaceKey = void 0;
19
+ const prosemirror_state_1 = require("prosemirror-state");
20
+ const prosemirror_view_1 = require("prosemirror-view");
21
+ const track_changes_utils_1 = require("../lib/track-changes-utils");
22
+ exports.searchReplaceKey = new prosemirror_state_1.PluginKey('findReplace');
23
+ function removeDiacritics(str) {
24
+ return str.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
25
+ }
26
+ function getMatches(doc, value, caseSensitive, ignoreDiacritics) {
27
+ if (!value) {
28
+ return [];
29
+ }
30
+ let normalised = caseSensitive ? value : value.toLocaleLowerCase();
31
+ if (ignoreDiacritics) {
32
+ normalised = removeDiacritics(normalised);
33
+ }
34
+ const matches = [];
35
+ doc.descendants((node, pos) => {
36
+ if ((0, track_changes_utils_1.isDeleted)(node) || (0, track_changes_utils_1.isDeletedText)(node)) {
37
+ return;
38
+ }
39
+ if (node.isText && node.text) {
40
+ let base = caseSensitive ? node.text : node.text.toLocaleLowerCase();
41
+ if (ignoreDiacritics) {
42
+ base = removeDiacritics(base);
43
+ }
44
+ let index = base.indexOf(normalised);
45
+ while (index !== -1) {
46
+ matches.push({
47
+ from: pos + index,
48
+ to: pos + index + normalised.length,
49
+ });
50
+ index = base.indexOf(normalised, index + normalised.length);
51
+ }
52
+ }
53
+ });
54
+ return matches;
55
+ }
56
+ function buildPluginState(state, oldData, newData, pointerChanged) {
57
+ const data = Object.assign(Object.assign({ value: '', replaceValue: '', active: false, activeAdvanced: false, currentMatch: -1, matches: [], caseSensitive: false, ignoreDiacritics: false }, oldData), newData);
58
+ if (pointerChanged) {
59
+ data.currentMatch = -1;
60
+ }
61
+ data.matches = getMatches(state.doc, data.value, data.caseSensitive, data.ignoreDiacritics);
62
+ return data;
63
+ }
64
+ exports.default = () => {
65
+ return new prosemirror_state_1.Plugin({
66
+ key: exports.searchReplaceKey,
67
+ state: {
68
+ init(config, instance) {
69
+ return buildPluginState(instance);
70
+ },
71
+ apply(tr, value, oldState, newState) {
72
+ const $old = exports.searchReplaceKey.getState(oldState);
73
+ if (!$old || tr.getMeta(exports.searchReplaceKey) || tr.getMeta('pointer')) {
74
+ return buildPluginState(newState, $old, tr.getMeta(exports.searchReplaceKey), !!tr.getMeta('pointer'));
75
+ }
76
+ return $old;
77
+ },
78
+ },
79
+ props: {
80
+ decorations: (state) => {
81
+ const pluginState = exports.searchReplaceKey.getState(state);
82
+ if (!pluginState ||
83
+ !pluginState.value ||
84
+ (!pluginState.active && !pluginState.activeAdvanced)) {
85
+ return prosemirror_view_1.DecorationSet.empty;
86
+ }
87
+ const decorations = [];
88
+ pluginState.matches.forEach(({ from, to }, i) => {
89
+ let className = 'search-result';
90
+ if (pluginState.currentMatch === i) {
91
+ className = className + ' search-result-selected';
92
+ }
93
+ decorations.push(prosemirror_view_1.Decoration.inline(from, to, {
94
+ class: className,
95
+ }));
96
+ });
97
+ return prosemirror_view_1.DecorationSet.create(state.doc, decorations);
98
+ },
99
+ },
100
+ view() {
101
+ return {
102
+ update() {
103
+ const element = document.querySelector('.search-result.search-result-selected');
104
+ if (element) {
105
+ const rect = element.getBoundingClientRect();
106
+ if (rect.bottom > window.innerHeight || rect.top < 150) {
107
+ element.scrollIntoView();
108
+ }
109
+ }
110
+ },
111
+ };
112
+ },
113
+ });
114
+ };
@@ -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 = '2.7.43';
4
+ exports.VERSION = '2.7.44-LEAN-4312.2';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -30,6 +30,7 @@ import { isDeleted } from './lib/track-changes-utils';
30
30
  import { findParentNodeWithId, getChildOfType, getMatchingChild, } from './lib/utils';
31
31
  import { setCommentSelection } from './plugins/comments';
32
32
  import { getEditorProps } from './plugins/editor-props';
33
+ import { searchReplaceKey } from './plugins/search-replace';
33
34
  import { checkForCompletion } from './plugins/section_title/autocompletion';
34
35
  export const addToStart = (state, dispatch) => {
35
36
  const { selection } = state;
@@ -1104,3 +1105,19 @@ export const autoComplete = (state, dispatch) => {
1104
1105
  }
1105
1106
  return false;
1106
1107
  };
1108
+ export const activateSearch = (state, dispatch) => {
1109
+ const pluginState = searchReplaceKey.getState(state);
1110
+ const tr = state.tr.setMeta(searchReplaceKey, {
1111
+ active: !(pluginState === null || pluginState === void 0 ? void 0 : pluginState.active),
1112
+ });
1113
+ dispatch && dispatch(tr);
1114
+ return true;
1115
+ };
1116
+ export const activateSearchReplace = (state, dispatch) => {
1117
+ const pluginState = searchReplaceKey.getState(state);
1118
+ const tr = state.tr.setMeta(searchReplaceKey, {
1119
+ activeAdvanced: !(pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeAdvanced),
1120
+ });
1121
+ dispatch && dispatch(tr);
1122
+ return true;
1123
+ };
@@ -34,6 +34,7 @@ import objects from '../plugins/objects';
34
34
  import paragraphs from '../plugins/paragraphs';
35
35
  import persist from '../plugins/persist';
36
36
  import placeholder from '../plugins/placeholder';
37
+ import search_replace from '../plugins/search-replace';
37
38
  import section_title from '../plugins/section_title';
38
39
  import section_category from '../plugins/section-category';
39
40
  import sections from '../plugins/sections';
@@ -72,6 +73,7 @@ export default (props) => {
72
73
  section_category(props),
73
74
  cross_references(),
74
75
  inspector_tabs(),
76
+ search_replace(),
75
77
  ];
76
78
  if (props.collabProvider) {
77
79
  allPlugins.push(collab({ version: props.collabProvider.currentVersion }));
package/dist/es/index.js CHANGED
@@ -37,6 +37,7 @@ export * from './lib/math';
37
37
  export { objectsKey as objectsPluginKey } from './plugins/objects';
38
38
  export { footnotesKey as footnotesPluginKey } from './plugins/footnotes';
39
39
  export { bibliographyKey as bibliographyPluginKey } from './plugins/bibliography';
40
+ export { searchReplaceKey as searchReplacePluginKey, } from './plugins/search-replace';
40
41
  export { metadata } from './lib/references';
41
42
  export { authorLabel, affiliationLabel, } from './lib/authors';
42
43
  export * from './plugins/inspector-tabs';
@@ -18,7 +18,7 @@ import { chainCommands, createParagraphNear, exitCode, joinBackward, joinDown, j
18
18
  import { redo, undo } from 'prosemirror-history';
19
19
  import { undoInputRule } from 'prosemirror-inputrules';
20
20
  import { goToNextCell } from 'prosemirror-tables';
21
- import { addToStart, autoComplete, ignoreAtomBlockNodeBackward, ignoreAtomBlockNodeForward, ignoreMetaNodeBackspaceCommand, insertBlock, insertBreak, insertCrossReference, insertInlineCitation, insertInlineEquation, insertSection, selectAllIsolating, } from '../commands';
21
+ import { activateSearch, activateSearchReplace, addToStart, autoComplete, ignoreAtomBlockNodeBackward, ignoreAtomBlockNodeForward, ignoreMetaNodeBackspaceCommand, insertBlock, insertBreak, insertCrossReference, insertInlineCitation, insertInlineEquation, insertSection, selectAllIsolating, } from '../commands';
22
22
  import { skipCommandTracking } from './list';
23
23
  const customKeymap = {
24
24
  Backspace: chainCommands(undoInputRule, ignoreAtomBlockNodeBackward, ignoreMetaNodeBackspaceCommand, skipCommandTracking(joinBackward)),
@@ -51,5 +51,9 @@ const customKeymap = {
51
51
  'Mod-Alt-c': insertInlineCitation,
52
52
  'Mod-Alt-r': insertCrossReference,
53
53
  'Shift-Mod-Alt-e': insertInlineEquation,
54
+ 'Shift-Ctrl-h': activateSearchReplace,
55
+ 'Shift-Mod-h': activateSearchReplace,
56
+ 'Mod-f': activateSearch,
57
+ 'Ctrl-f': activateSearch,
54
58
  };
55
59
  export default customKeymap;
package/dist/es/menus.js CHANGED
@@ -16,7 +16,7 @@
16
16
  import { getGroupCateogries, schema, } from '@manuscripts/transform';
17
17
  import { toggleMark } from 'prosemirror-commands';
18
18
  import { redo, undo } from 'prosemirror-history';
19
- import { addInlineComment, blockActive, canInsert, insertAbstract, insertAffiliation, insertAward, insertBackmatterSection, insertBlock, insertBoxElement, insertContributors, insertCrossReference, insertGraphicalAbstract, insertInlineCitation, insertInlineEquation, insertInlineFootnote, insertKeywords, insertLink, insertList, insertSection, markActive, } from './commands';
19
+ import { activateSearchReplace, addInlineComment, blockActive, canInsert, insertAbstract, insertAffiliation, insertAward, insertBackmatterSection, insertBlock, insertBoxElement, insertContributors, insertCrossReference, insertGraphicalAbstract, insertInlineCitation, insertInlineEquation, insertInlineFootnote, insertKeywords, insertLink, insertList, insertSection, markActive, } from './commands';
20
20
  import { openEmbedDialog } from './components/toolbar/InsertEmbedDialog';
21
21
  import { openInsertTableDialog } from './components/toolbar/InsertTableDialog';
22
22
  import { ListMenuItem } from './components/toolbar/ListMenuItem';
@@ -76,6 +76,20 @@ export const getEditorMenus = (editor) => {
76
76
  isEnabled: isCommandValid(deleteClosestParentElement),
77
77
  run: doCommand(deleteClosestParentElement),
78
78
  },
79
+ {
80
+ role: 'separator',
81
+ },
82
+ {
83
+ id: 'find-replace',
84
+ role: 'find-replace',
85
+ label: 'Find and replace',
86
+ shortcut: {
87
+ mac: 'CommandOrControl+Shift+H',
88
+ pc: 'CommandOrControl+Shift+H',
89
+ },
90
+ isEnabled: isCommandValid(activateSearchReplace),
91
+ run: doCommand(activateSearchReplace),
92
+ },
79
93
  ],
80
94
  };
81
95
  const insert = {
@@ -0,0 +1,111 @@
1
+ /*!
2
+ * © 2024 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 { Plugin, PluginKey } from 'prosemirror-state';
17
+ import { Decoration, DecorationSet } from 'prosemirror-view';
18
+ import { isDeleted, isDeletedText } from '../lib/track-changes-utils';
19
+ export const searchReplaceKey = new PluginKey('findReplace');
20
+ function removeDiacritics(str) {
21
+ return str.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
22
+ }
23
+ function getMatches(doc, value, caseSensitive, ignoreDiacritics) {
24
+ if (!value) {
25
+ return [];
26
+ }
27
+ let normalised = caseSensitive ? value : value.toLocaleLowerCase();
28
+ if (ignoreDiacritics) {
29
+ normalised = removeDiacritics(normalised);
30
+ }
31
+ const matches = [];
32
+ doc.descendants((node, pos) => {
33
+ if (isDeleted(node) || isDeletedText(node)) {
34
+ return;
35
+ }
36
+ if (node.isText && node.text) {
37
+ let base = caseSensitive ? node.text : node.text.toLocaleLowerCase();
38
+ if (ignoreDiacritics) {
39
+ base = removeDiacritics(base);
40
+ }
41
+ let index = base.indexOf(normalised);
42
+ while (index !== -1) {
43
+ matches.push({
44
+ from: pos + index,
45
+ to: pos + index + normalised.length,
46
+ });
47
+ index = base.indexOf(normalised, index + normalised.length);
48
+ }
49
+ }
50
+ });
51
+ return matches;
52
+ }
53
+ function buildPluginState(state, oldData, newData, pointerChanged) {
54
+ const data = Object.assign(Object.assign({ value: '', replaceValue: '', active: false, activeAdvanced: false, currentMatch: -1, matches: [], caseSensitive: false, ignoreDiacritics: false }, oldData), newData);
55
+ if (pointerChanged) {
56
+ data.currentMatch = -1;
57
+ }
58
+ data.matches = getMatches(state.doc, data.value, data.caseSensitive, data.ignoreDiacritics);
59
+ return data;
60
+ }
61
+ export default () => {
62
+ return new Plugin({
63
+ key: searchReplaceKey,
64
+ state: {
65
+ init(config, instance) {
66
+ return buildPluginState(instance);
67
+ },
68
+ apply(tr, value, oldState, newState) {
69
+ const $old = searchReplaceKey.getState(oldState);
70
+ if (!$old || tr.getMeta(searchReplaceKey) || tr.getMeta('pointer')) {
71
+ return buildPluginState(newState, $old, tr.getMeta(searchReplaceKey), !!tr.getMeta('pointer'));
72
+ }
73
+ return $old;
74
+ },
75
+ },
76
+ props: {
77
+ decorations: (state) => {
78
+ const pluginState = searchReplaceKey.getState(state);
79
+ if (!pluginState ||
80
+ !pluginState.value ||
81
+ (!pluginState.active && !pluginState.activeAdvanced)) {
82
+ return DecorationSet.empty;
83
+ }
84
+ const decorations = [];
85
+ pluginState.matches.forEach(({ from, to }, i) => {
86
+ let className = 'search-result';
87
+ if (pluginState.currentMatch === i) {
88
+ className = className + ' search-result-selected';
89
+ }
90
+ decorations.push(Decoration.inline(from, to, {
91
+ class: className,
92
+ }));
93
+ });
94
+ return DecorationSet.create(state.doc, decorations);
95
+ },
96
+ },
97
+ view() {
98
+ return {
99
+ update() {
100
+ const element = document.querySelector('.search-result.search-result-selected');
101
+ if (element) {
102
+ const rect = element.getBoundingClientRect();
103
+ if (rect.bottom > window.innerHeight || rect.top < 150) {
104
+ element.scrollIntoView();
105
+ }
106
+ }
107
+ },
108
+ };
109
+ },
110
+ });
111
+ };
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.7.43';
1
+ export const VERSION = '2.7.44-LEAN-4312.2';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -80,3 +80,5 @@ export declare const addRows: (direction: 'top' | 'bottom') => (state: EditorSta
80
80
  export declare const addHeaderRow: (direction: 'above' | 'below') => (state: EditorState, dispatch?: ((tr: Transaction) => void) | undefined) => boolean;
81
81
  export declare const addColumns: (direction: 'right' | 'left') => (state: EditorState, dispatch?: ((tr: Transaction) => void) | undefined) => boolean;
82
82
  export declare const autoComplete: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
83
+ export declare const activateSearch: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
84
+ export declare const activateSearchReplace: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
@@ -38,6 +38,7 @@ export * from './lib/math';
38
38
  export { objectsKey as objectsPluginKey } from './plugins/objects';
39
39
  export { footnotesKey as footnotesPluginKey } from './plugins/footnotes';
40
40
  export { bibliographyKey as bibliographyPluginKey } from './plugins/bibliography';
41
+ export { searchReplaceKey as searchReplacePluginKey, SearchReplacePluginState, } from './plugins/search-replace';
41
42
  export { metadata, BibliographyItemAttrs } from './lib/references';
42
43
  export { authorLabel, affiliationLabel, AffiliationAttrs, ContributorAttrs, } from './lib/authors';
43
44
  export * from './plugins/inspector-tabs';
@@ -0,0 +1,32 @@
1
+ /*!
2
+ * © 2024 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 { Plugin, PluginKey } from 'prosemirror-state';
17
+ export type SearchReplacePluginState = {
18
+ value: string;
19
+ matches: Array<{
20
+ from: number;
21
+ to: number;
22
+ }>;
23
+ replaceValue: string;
24
+ active: boolean;
25
+ activeAdvanced: boolean;
26
+ currentMatch: number;
27
+ caseSensitive: boolean;
28
+ ignoreDiacritics: boolean;
29
+ };
30
+ export declare const searchReplaceKey: PluginKey<SearchReplacePluginState>;
31
+ declare const _default: () => Plugin<SearchReplacePluginState>;
32
+ export default _default;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.7.43";
1
+ export declare const VERSION = "2.7.44-LEAN-4312.2";
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.7.43",
4
+ "version": "2.7.44-LEAN-4312.2",
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",
35
+ "@manuscripts/style-guide": "2.0.35-LEAN-4312.0",
36
36
  "@manuscripts/track-changes-plugin": "1.9.4",
37
37
  "@manuscripts/transform": "3.0.40",
38
38
  "@popperjs/core": "^2.11.8",
@@ -54,7 +54,8 @@
54
54
  font-size: 13.5pt !important;
55
55
  }
56
56
 
57
- .ProseMirror div.backmatter:not(.empty-node)::before, .ProseMirror div.abstracts:not(.empty-node)::after {
57
+ .ProseMirror div.backmatter:not(.empty-node)::before,
58
+ .ProseMirror div.abstracts:not(.empty-node)::after {
58
59
  content: '';
59
60
  border-bottom: 1px dashed #c9c9c9;
60
61
  display: block;
@@ -155,12 +156,13 @@
155
156
  .ProseMirror .figure-block .position-menu {
156
157
  position: absolute;
157
158
  top: 4px;
158
- left: calc( 100% + 4px );
159
+ left: calc(100% - 96px);
159
160
  z-index: 2;
160
161
  cursor: pointer;
162
+ padding-left: 100px;
161
163
  }
162
164
  .ProseMirror .box-element .figure-block .position-menu {
163
- left: calc( 100% + 20px );
165
+ left: calc(100% - 82px);
164
166
  }
165
167
 
166
168
  .ProseMirror .block-container.block-box_element {
@@ -268,7 +270,8 @@
268
270
  position: relative;
269
271
  }
270
272
 
271
- .comment-marker:has(+ .block-contributors), .comment-marker:has(+ .block-affiliations) {
273
+ .comment-marker:has(+ .block-contributors),
274
+ .comment-marker:has(+ .block-affiliations) {
272
275
  height: 0;
273
276
  top: 0;
274
277
  right: 60px;
@@ -302,7 +305,8 @@ figure.block > .comment-marker {
302
305
  left: 0;
303
306
  }
304
307
 
305
- section > .comment-marker, .body > .comment-marker {
308
+ section > .comment-marker,
309
+ .body > .comment-marker {
306
310
  top: 12px;
307
311
  float: right;
308
312
  left: -64px;
@@ -560,8 +564,8 @@ span.comment-marker {
560
564
  .ProseMirror {
561
565
  --inserted-pending-bg-color: #e6ffdb;
562
566
  --inserted-pending-color: #01872e;
563
- --updated-pending-bg-color: #E6F7FC;
564
- --updated-pending-color: #0284B0;
567
+ --updated-pending-bg-color: #e6f7fc;
568
+ --updated-pending-color: #0284b0;
565
569
  --accepted-bg-color: #e2e2e2;
566
570
  --deleted-color: #f35143;
567
571
  --deleted-pending-bg-color: #fff1f0;
@@ -591,7 +595,8 @@ span.comment-marker {
591
595
 
592
596
  .selected-suggestion:not(.block-container):not(.graphical-abstract):not(
593
597
  .keywords
594
- ):not(figure):not(figure .equation), .footnote-marker-selected {
598
+ ):not(figure):not(figure .equation),
599
+ .footnote-marker-selected {
595
600
  border-width: 2px 0 2px 0 !important;
596
601
  border-style: solid !important;
597
602
  }
@@ -675,7 +680,6 @@ span.comment-marker {
675
680
  top: calc(50% + 1px);
676
681
  }
677
682
 
678
-
679
683
  .selected-suggestion .equation.deleted:after,
680
684
  .selected-suggestion.equation.deleted:after {
681
685
  content: none;
@@ -714,15 +718,25 @@ figure .selected-suggestion {
714
718
  }
715
719
 
716
720
  /* Inserted Block */
717
- .tracking-visible .ProseMirror [data-track-op='insert'][data-track-status='pending'] .block,
718
- .tracking-visible .ProseMirror [data-track-op='wrap_with_node'][data-track-status='pending'] .block {
721
+ .tracking-visible
722
+ .ProseMirror
723
+ [data-track-op='insert'][data-track-status='pending']
724
+ .block,
725
+ .tracking-visible
726
+ .ProseMirror
727
+ [data-track-op='wrap_with_node'][data-track-status='pending']
728
+ .block {
719
729
  box-shadow: inset 3px 0 0 var(--inserted-pending-color);
720
730
  }
721
731
 
722
- .selected-suggestion[data-track-status='pending'][data-track-op='insert'] .block,
723
- .selected-suggestion[data-track-status='pending'][data-track-op='insert'] .block,
724
- .selected-suggestion[data-track-op='wrap_with_node'][data-track-status='pending'] .block {
725
- box-shadow: inset 6px 0 0 var(--inserted-pending-color), inset 9px 0 0 var(--inserted-pending-bg-color) !important;
732
+ .selected-suggestion[data-track-status='pending'][data-track-op='insert']
733
+ .block,
734
+ .selected-suggestion[data-track-status='pending'][data-track-op='insert']
735
+ .block,
736
+ .selected-suggestion[data-track-op='wrap_with_node'][data-track-status='pending']
737
+ .block {
738
+ box-shadow: inset 6px 0 0 var(--inserted-pending-color),
739
+ inset 9px 0 0 var(--inserted-pending-bg-color) !important;
726
740
  animation: fadeOutBackground 3s forwards;
727
741
  --fade-color: var(--inserted-pending-bg-color);
728
742
  }
@@ -738,13 +752,19 @@ figure .selected-suggestion {
738
752
  display: grid;
739
753
  }
740
754
 
741
- .tracking-visible .ProseMirror [data-track-status='pending'][data-track-op='delete'] .block {
755
+ .tracking-visible
756
+ .ProseMirror
757
+ [data-track-status='pending'][data-track-op='delete']
758
+ .block {
742
759
  box-shadow: inset 3px 0 0 var(--deleted-color);
743
760
  }
744
761
 
745
- .selected-suggestion[data-track-status='pending'][data-track-op='delete'] .block,
746
- .selected-suggestion[data-track-status='pending'][data-track-op='delete'] .block {
747
- box-shadow: inset 6px 0 0 var(--deleted-color), inset 9px 0 0 var(--deleted-pending-bg-color) !important;
762
+ .selected-suggestion[data-track-status='pending'][data-track-op='delete']
763
+ .block,
764
+ .selected-suggestion[data-track-status='pending'][data-track-op='delete']
765
+ .block {
766
+ box-shadow: inset 6px 0 0 var(--deleted-color),
767
+ inset 9px 0 0 var(--deleted-pending-bg-color) !important;
748
768
  animation: fadeOutBackground 3s forwards;
749
769
  --fade-color: var(--deleted-pending-bg-color);
750
770
  }
@@ -753,7 +773,10 @@ figure .selected-suggestion {
753
773
  .tracking-visible .ProseMirror [data-track-op='set_attrs'] .block,
754
774
  .tracking-visible .block:has(figure[data-track-op='set_attrs']),
755
775
  .tracking-visible figure.block:has(.equation.set_attrs),
756
- .tracking-visible .ProseMirror [data-track-op='node_split'][data-track-status='pending'] .block {
776
+ .tracking-visible
777
+ .ProseMirror
778
+ [data-track-op='node_split'][data-track-status='pending']
779
+ .block {
757
780
  box-shadow: inset 3px 0 0 var(--updated-border-color);
758
781
  }
759
782
 
@@ -762,7 +785,8 @@ figure .selected-suggestion {
762
785
  .block:has(figure.selected-suggestion[data-track-op='set_attrs']),
763
786
  .selected-suggestion[data-track-op='node_split'] .block,
764
787
  figure.block:has(.equation.set_attrs.selected-suggestion) {
765
- box-shadow: inset 6px 0 0 var(--updated-border-color), inset 9px 0 0 var(--updated-bg-color) !important;
788
+ box-shadow: inset 6px 0 0 var(--updated-border-color),
789
+ inset 9px 0 0 var(--updated-bg-color) !important;
766
790
  animation: fadeOutBackground 3s forwards;
767
791
  --fade-color: var(--updated-bg-color);
768
792
  }
@@ -820,8 +844,10 @@ figure.block:has(.equation.set_attrs.selected-suggestion) {
820
844
  text-decoration: underline;
821
845
  }
822
846
 
823
- .tracking-visible .contributor[data-track-status='pending'][data-track-op='set_attrs'],
824
- .tracking-visible .affiliation[data-track-status='pending'][data-track-op='set_attrs'] {
847
+ .tracking-visible
848
+ .contributor[data-track-status='pending'][data-track-op='set_attrs'],
849
+ .tracking-visible
850
+ .affiliation[data-track-status='pending'][data-track-op='set_attrs'] {
825
851
  background: var(--updated-bg-color);
826
852
  color: var(--common-color);
827
853
  border-color: var(--updated-border-color);
@@ -840,7 +866,7 @@ figure.block:has(.equation.set_attrs.selected-suggestion) {
840
866
  margin: 15px 0px;
841
867
  }
842
868
  .block-award {
843
- position: relative
869
+ position: relative;
844
870
  }
845
871
  .block-awards.empty-node {
846
872
  display: none;
@@ -859,7 +885,8 @@ figure.block:has(.equation.set_attrs.selected-suggestion) {
859
885
  .contributors-list .separator {
860
886
  margin-right: 4px;
861
887
  }
862
- .block-contributors .tools-panel, .block-affiliations .tools-panel {
888
+ .block-contributors .tools-panel,
889
+ .block-affiliations .tools-panel {
863
890
  position: initial;
864
891
  display: flex;
865
892
  flex: 1;
@@ -1097,7 +1124,8 @@ th:hover > .table-context-menu-button,
1097
1124
  pointer-events: none;
1098
1125
  }
1099
1126
 
1100
- .ProseMirror .block-contributors .action-gutter , .ProseMirror .block-affiliations .action-gutter{
1127
+ .ProseMirror .block-contributors .action-gutter,
1128
+ .ProseMirror .block-affiliations .action-gutter {
1101
1129
  right: 15px;
1102
1130
  pointer-events: none;
1103
1131
  }
@@ -1109,13 +1137,18 @@ th:hover > .table-context-menu-button,
1109
1137
  text-align: center;
1110
1138
  margin: 42px 52px;
1111
1139
  }
1112
- .tracking-visible .ProseMirror .block-embed[data-track-status='pending'][data-track-op='delete'] .block > * {
1113
- opacity: 0.3
1140
+ .tracking-visible
1141
+ .ProseMirror
1142
+ .block-embed[data-track-status='pending'][data-track-op='delete']
1143
+ .block
1144
+ > * {
1145
+ opacity: 0.3;
1114
1146
  }
1115
1147
  .ProseMirror .block-embed .tools-panel {
1116
1148
  position: relative;
1117
1149
  }
1118
- .ProseMirror .block-embed .block-gutter, .block-embed .action-gutter {
1150
+ .ProseMirror .block-embed .block-gutter,
1151
+ .block-embed .action-gutter {
1119
1152
  display: none;
1120
1153
  }
1121
1154
 
@@ -1130,7 +1163,14 @@ th:hover > .table-context-menu-button,
1130
1163
  right: 7%;
1131
1164
  z-index: 10;
1132
1165
  border-radius: 4px;
1133
- border: 1px solid #C9C9C9;
1134
- background: #FFF;
1135
- box-shadow: 0 4px 9px 0 rgba(0, 0, 0, 0.30);
1166
+ border: 1px solid #c9c9c9;
1167
+ background: #fff;
1168
+ box-shadow: 0 4px 9px 0 rgba(0, 0, 0, 0.3);
1169
+ }
1170
+
1171
+ .search-result {
1172
+ background-color: #e5eb3e;
1173
+ }
1174
+ .search-result.search-result-selected {
1175
+ background-color: #ffbdf8;
1136
1176
  }
package/styles/Editor.css CHANGED
@@ -232,10 +232,8 @@
232
232
  }
233
233
 
234
234
  .ProseMirror .figure-block > .listing {
235
- /*grid-row: listing;*/
236
235
  grid-column-start: 1;
237
236
  grid-column-end: -1;
238
- /*margin-top: 0;*/
239
237
  padding: 0;
240
238
  min-height: 0;
241
239
  overflow: visible;
@@ -243,7 +241,6 @@
243
241
  }
244
242
 
245
243
  .ProseMirror .figure-block > figcaption {
246
- /*grid-row: caption;*/
247
244
  grid-column-start: 1;
248
245
  grid-column-end: -1;
249
246
  margin-top: 0;
@@ -712,8 +709,8 @@
712
709
  .action-gutter {
713
710
  pointer-events: visible;
714
711
  opacity: 1;
715
- /* z-index: 2; */
716
712
  }
713
+
717
714
  .ProseMirror .block-box_element:hover > .block-gutter {
718
715
  opacity: 1;
719
716
  z-index: 2;
@@ -802,7 +799,6 @@
802
799
  .ProseMirror pre {
803
800
  cursor: pointer;
804
801
  display: block;
805
- /*min-height: 34px;*/
806
802
  padding: 5px;
807
803
  width: auto;
808
804
  min-width: 200px;
@@ -890,7 +886,6 @@
890
886
  display: inline-flex;
891
887
  align-items: center;
892
888
  justify-content: center;
893
- /*z-index: 2;*/
894
889
  cursor: pointer;
895
890
  background-size: contain;
896
891
  background-position: center center;