@manuscripts/body-editor 1.9.21 → 1.9.22-LEAN-3607.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.
@@ -24,7 +24,6 @@ const prosemirror_schema_list_1 = require("prosemirror-schema-list");
24
24
  const prosemirror_state_1 = require("prosemirror-state");
25
25
  const prosemirror_transform_1 = require("prosemirror-transform");
26
26
  const prosemirror_utils_1 = require("prosemirror-utils");
27
- const list_1 = require("./keys/list");
28
27
  const helpers_1 = require("./lib/helpers");
29
28
  const track_changes_utils_1 = require("./lib/track-changes-utils");
30
29
  const utils_1 = require("./lib/utils");
@@ -427,7 +426,7 @@ const findListsAtSameLevel = (doc, list) => {
427
426
  });
428
427
  return lists;
429
428
  };
430
- const insertList = (type, style) => (state, dispatch) => {
429
+ const insertList = (type, style) => (state, dispatch, view) => {
431
430
  const list = findSelectedList(state.selection);
432
431
  if (list) {
433
432
  if (!dispatch) {
@@ -442,8 +441,23 @@ const insertList = (type, style) => (state, dispatch) => {
442
441
  return true;
443
442
  }
444
443
  else {
445
- const command = (0, prosemirror_schema_list_1.wrapInList)(type, { listStyleType: style });
446
- return (0, list_1.skipCommandTracking)(command)(state, dispatch);
444
+ const { selection } = state;
445
+ let tr = state.tr;
446
+ return (0, prosemirror_schema_list_1.wrapInList)(type, { listStyleType: style })(state, (tempTr) => {
447
+ const range = selection.$from.blockRange(selection.$to);
448
+ if (range && dispatch) {
449
+ tempTr.steps.map((step) => {
450
+ if (step instanceof prosemirror_transform_1.ReplaceAroundStep) {
451
+ dispatch(tr.step(step));
452
+ tr = (view === null || view === void 0 ? void 0 : view.state.tr) || tr;
453
+ }
454
+ else {
455
+ tr.step(step);
456
+ }
457
+ });
458
+ dispatch(tr);
459
+ }
460
+ });
447
461
  }
448
462
  };
449
463
  exports.insertList = insertList;
@@ -19,6 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.bulletListCallback = exports.BulletListView = void 0;
22
+ const track_changes_utils_1 = require("../lib/track-changes-utils");
22
23
  const block_view_1 = __importDefault(require("./block_view"));
23
24
  const creators_1 = require("./creators");
24
25
  const ordered_list_1 = require("./ordered_list");
@@ -30,6 +31,10 @@ class BulletListView extends block_view_1.default {
30
31
  if (this.contentDOM) {
31
32
  const type = this.node.attrs.listStyleType || 'bullet';
32
33
  this.contentDOM.style.listStyleType = ordered_list_1.JATS_HTML_LIST_STYLE_MAPPING[type];
34
+ if (this.node.attrs.dataTracked) {
35
+ const classes = (0, track_changes_utils_1.getChangeClasses)(this.node.attrs.dataTracked);
36
+ this.contentDOM.className = classes.join(' ');
37
+ }
33
38
  }
34
39
  };
35
40
  }
@@ -19,6 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.orderedListCallback = exports.OrderedListView = exports.JATS_HTML_LIST_STYLE_MAPPING = void 0;
22
+ const track_changes_utils_1 = require("../lib/track-changes-utils");
22
23
  const block_view_1 = __importDefault(require("./block_view"));
23
24
  const creators_1 = require("./creators");
24
25
  exports.JATS_HTML_LIST_STYLE_MAPPING = {
@@ -38,6 +39,10 @@ class OrderedListView extends block_view_1.default {
38
39
  if (this.contentDOM) {
39
40
  const type = this.node.attrs.listStyleType || 'order';
40
41
  this.contentDOM.style.listStyleType = exports.JATS_HTML_LIST_STYLE_MAPPING[type];
42
+ if (this.node.attrs.dataTracked) {
43
+ const classes = (0, track_changes_utils_1.getChangeClasses)(this.node.attrs.dataTracked);
44
+ this.contentDOM.className = classes.join(' ');
45
+ }
41
46
  }
42
47
  };
43
48
  }
@@ -19,9 +19,8 @@ import { buildComment, generateID, isElementNodeType, isFootnoteNode, isInBiblio
19
19
  import { NodeRange } from 'prosemirror-model';
20
20
  import { wrapInList } from 'prosemirror-schema-list';
21
21
  import { NodeSelection, TextSelection, } from 'prosemirror-state';
22
- import { findWrapping } from 'prosemirror-transform';
22
+ import { findWrapping, ReplaceAroundStep } from 'prosemirror-transform';
23
23
  import { findChildrenByType, findParentNodeOfType, } from 'prosemirror-utils';
24
- import { skipCommandTracking } from './keys/list';
25
24
  import { isNodeOfType, nearestAncestor } from './lib/helpers';
26
25
  import { isDeleted, isRejectedInsert } from './lib/track-changes-utils';
27
26
  import { findParentNodeWithId, getChildOfType } from './lib/utils';
@@ -405,7 +404,7 @@ const findListsAtSameLevel = (doc, list) => {
405
404
  });
406
405
  return lists;
407
406
  };
408
- export const insertList = (type, style) => (state, dispatch) => {
407
+ export const insertList = (type, style) => (state, dispatch, view) => {
409
408
  const list = findSelectedList(state.selection);
410
409
  if (list) {
411
410
  if (!dispatch) {
@@ -420,8 +419,23 @@ export const insertList = (type, style) => (state, dispatch) => {
420
419
  return true;
421
420
  }
422
421
  else {
423
- const command = wrapInList(type, { listStyleType: style });
424
- return skipCommandTracking(command)(state, dispatch);
422
+ const { selection } = state;
423
+ let tr = state.tr;
424
+ return wrapInList(type, { listStyleType: style })(state, (tempTr) => {
425
+ const range = selection.$from.blockRange(selection.$to);
426
+ if (range && dispatch) {
427
+ tempTr.steps.map((step) => {
428
+ if (step instanceof ReplaceAroundStep) {
429
+ dispatch(tr.step(step));
430
+ tr = (view === null || view === void 0 ? void 0 : view.state.tr) || tr;
431
+ }
432
+ else {
433
+ tr.step(step);
434
+ }
435
+ });
436
+ dispatch(tr);
437
+ }
438
+ });
425
439
  }
426
440
  };
427
441
  export const insertBibliographySection = () => {
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { getChangeClasses } from '../lib/track-changes-utils';
16
17
  import BlockView from './block_view';
17
18
  import { createNodeOrElementView } from './creators';
18
19
  import { JATS_HTML_LIST_STYLE_MAPPING } from './ordered_list';
@@ -24,6 +25,10 @@ export class BulletListView extends BlockView {
24
25
  if (this.contentDOM) {
25
26
  const type = this.node.attrs.listStyleType || 'bullet';
26
27
  this.contentDOM.style.listStyleType = JATS_HTML_LIST_STYLE_MAPPING[type];
28
+ if (this.node.attrs.dataTracked) {
29
+ const classes = getChangeClasses(this.node.attrs.dataTracked);
30
+ this.contentDOM.className = classes.join(' ');
31
+ }
27
32
  }
28
33
  };
29
34
  }
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { getChangeClasses } from '../lib/track-changes-utils';
16
17
  import BlockView from './block_view';
17
18
  import { createNodeOrElementView } from './creators';
18
19
  export const JATS_HTML_LIST_STYLE_MAPPING = {
@@ -32,6 +33,10 @@ export class OrderedListView extends BlockView {
32
33
  if (this.contentDOM) {
33
34
  const type = this.node.attrs.listStyleType || 'order';
34
35
  this.contentDOM.style.listStyleType = JATS_HTML_LIST_STYLE_MAPPING[type];
36
+ if (this.node.attrs.dataTracked) {
37
+ const classes = getChangeClasses(this.node.attrs.dataTracked);
38
+ this.contentDOM.className = classes.join(' ');
39
+ }
35
40
  }
36
41
  };
37
42
  }
@@ -41,7 +41,7 @@ export declare const insertInlineEquation: (state: ManuscriptEditorState, dispat
41
41
  export declare const insertInlineFootnote: (kind: 'footnote' | 'endnote') => (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
42
42
  export declare const insertGraphicalAbstract: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
43
43
  export declare const insertSection: (subsection?: boolean) => (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
44
- export declare const insertList: (type: ManuscriptNodeType, style?: string) => (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
44
+ export declare const insertList: (type: ManuscriptNodeType, style?: string) => (state: ManuscriptEditorState, dispatch?: Dispatch, view?: EditorView) => boolean;
45
45
  export declare const insertBibliographySection: () => boolean;
46
46
  export declare const insertTOCSection: () => boolean;
47
47
  export declare const ifInTableBody: (command: (state: ManuscriptEditorState) => boolean) => (state: ManuscriptEditorState) => boolean;
@@ -14,16 +14,17 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { EditorState } from 'prosemirror-state';
17
+ import { EditorView } from 'prosemirror-view';
17
18
  import { ReactNode } from 'react';
18
19
  import { Dispatch } from './commands';
19
20
  export interface ToolbarButtonConfig {
20
21
  title: string;
21
22
  content: ReactNode;
22
23
  isActive?: (state: EditorState) => boolean;
23
- run: (state: EditorState, dispatch: Dispatch) => void;
24
+ run: (state: EditorState, dispatch: Dispatch, view?: EditorView) => void;
24
25
  isEnabled: (state: EditorState) => boolean;
25
26
  options?: {
26
- [key: string]: (state: EditorState, dispatch: Dispatch) => void;
27
+ [key: string]: (state: EditorState, dispatch: Dispatch, view?: EditorView) => void;
27
28
  };
28
29
  }
29
30
  export interface ToolbarConfig {
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.9.21",
4
+ "version": "1.9.22-LEAN-3607.0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",