@manuscripts/body-editor 1.10.0 → 1.10.1-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");
@@ -450,7 +449,7 @@ function toggleOffList(state, dispatch) {
450
449
  return false;
451
450
  }
452
451
  }
453
- const insertList = (type, style) => (state, dispatch) => {
452
+ const insertList = (type, style) => (state, dispatch, view) => {
454
453
  const list = findSelectedList(state.selection);
455
454
  if (list) {
456
455
  if (!dispatch) {
@@ -468,8 +467,23 @@ const insertList = (type, style) => (state, dispatch) => {
468
467
  return true;
469
468
  }
470
469
  else {
471
- const command = (0, prosemirror_schema_list_1.wrapInList)(type, { listStyleType: style });
472
- return (0, list_1.skipCommandTracking)(command)(state, dispatch);
470
+ const { selection } = state;
471
+ let tr = state.tr;
472
+ return (0, prosemirror_schema_list_1.wrapInList)(type, { listStyleType: style })(state, (tempTr) => {
473
+ const range = selection.$from.blockRange(selection.$to);
474
+ if (range && dispatch) {
475
+ tempTr.steps.map((step) => {
476
+ if (step instanceof prosemirror_transform_1.ReplaceAroundStep) {
477
+ dispatch(tr.step(step));
478
+ tr = (view === null || view === void 0 ? void 0 : view.state.tr) || tr;
479
+ }
480
+ else {
481
+ tr.step(step);
482
+ }
483
+ });
484
+ dispatch(tr);
485
+ }
486
+ });
473
487
  }
474
488
  };
475
489
  exports.insertList = insertList;
@@ -38,6 +38,7 @@ const inline_footnote_editable_1 = __importDefault(require("../views/inline_foot
38
38
  const keyword_1 = __importDefault(require("../views/keyword"));
39
39
  const keyword_group_1 = __importDefault(require("../views/keyword_group"));
40
40
  const link_editable_1 = __importDefault(require("../views/link_editable"));
41
+ const list_item_1 = __importDefault(require("../views/list_item"));
41
42
  const listing_editable_1 = __importDefault(require("../views/listing_editable"));
42
43
  const listing_element_editable_1 = __importDefault(require("../views/listing_element_editable"));
43
44
  const ordered_list_editable_1 = __importDefault(require("../views/ordered_list_editable"));
@@ -75,6 +76,7 @@ exports.default = (props, dispatch) => {
75
76
  link: (0, link_editable_1.default)(props, dispatch),
76
77
  listing: (0, listing_editable_1.default)(props),
77
78
  listing_element: (0, listing_element_editable_1.default)(props),
79
+ list_item: (0, list_item_1.default)(props),
78
80
  ordered_list: (0, ordered_list_editable_1.default)(props),
79
81
  paragraph: (0, paragraph_editable_1.default)(props),
80
82
  placeholder: (0, placeholder_1.default)(props),
@@ -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,16 @@ 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
+ this.dom.setAttribute('data-track-status', this.node.attrs.dataTracked[0].status);
38
+ this.dom.setAttribute('data-track-op', this.node.attrs.dataTracked[0].operation);
39
+ }
40
+ else {
41
+ this.dom.removeAttribute('data-track-status');
42
+ this.dom.removeAttribute('data-track-op');
43
+ }
33
44
  }
34
45
  };
35
46
  }
@@ -0,0 +1,39 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.listItemCallback = exports.ListItemView = void 0;
22
+ const track_changes_utils_1 = require("../lib/track-changes-utils");
23
+ const block_view_1 = __importDefault(require("./block_view"));
24
+ const creators_1 = require("./creators");
25
+ class ListItemView extends block_view_1.default {
26
+ constructor() {
27
+ super(...arguments);
28
+ this.elementType = 'li';
29
+ }
30
+ }
31
+ exports.ListItemView = ListItemView;
32
+ const listItemCallback = (node, dom) => {
33
+ if (node.attrs.dataTracked) {
34
+ const classes = (0, track_changes_utils_1.getChangeClasses)(node.attrs.dataTracked);
35
+ dom.className = classes.join(' ');
36
+ }
37
+ };
38
+ exports.listItemCallback = listItemCallback;
39
+ exports.default = (0, creators_1.createNodeOrElementView)(ListItemView, 'li', exports.listItemCallback);
@@ -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,16 @@ 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
+ this.dom.setAttribute('data-track-status', this.node.attrs.dataTracked[0].status);
46
+ this.dom.setAttribute('data-track-op', this.node.attrs.dataTracked[0].operation);
47
+ }
48
+ else {
49
+ this.dom.removeAttribute('data-track-status');
50
+ this.dom.removeAttribute('data-track-op');
51
+ }
41
52
  }
42
53
  };
43
54
  }
@@ -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, liftTarget } from 'prosemirror-transform';
22
+ import { findWrapping, liftTarget, 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';
@@ -428,7 +427,7 @@ function toggleOffList(state, dispatch) {
428
427
  return false;
429
428
  }
430
429
  }
431
- export const insertList = (type, style) => (state, dispatch) => {
430
+ export const insertList = (type, style) => (state, dispatch, view) => {
432
431
  const list = findSelectedList(state.selection);
433
432
  if (list) {
434
433
  if (!dispatch) {
@@ -446,8 +445,23 @@ export const insertList = (type, style) => (state, dispatch) => {
446
445
  return true;
447
446
  }
448
447
  else {
449
- const command = wrapInList(type, { listStyleType: style });
450
- return skipCommandTracking(command)(state, dispatch);
448
+ const { selection } = state;
449
+ let tr = state.tr;
450
+ return wrapInList(type, { listStyleType: style })(state, (tempTr) => {
451
+ const range = selection.$from.blockRange(selection.$to);
452
+ if (range && dispatch) {
453
+ tempTr.steps.map((step) => {
454
+ if (step instanceof ReplaceAroundStep) {
455
+ dispatch(tr.step(step));
456
+ tr = (view === null || view === void 0 ? void 0 : view.state.tr) || tr;
457
+ }
458
+ else {
459
+ tr.step(step);
460
+ }
461
+ });
462
+ dispatch(tr);
463
+ }
464
+ });
451
465
  }
452
466
  };
453
467
  export const insertBibliographySection = () => {
@@ -33,6 +33,7 @@ import inlineFootnote from '../views/inline_footnote_editable';
33
33
  import keyword from '../views/keyword';
34
34
  import keywordGroup from '../views/keyword_group';
35
35
  import link from '../views/link_editable';
36
+ import list_item from '../views/list_item';
36
37
  import listing from '../views/listing_editable';
37
38
  import listingElement from '../views/listing_element_editable';
38
39
  import orderedList from '../views/ordered_list_editable';
@@ -70,6 +71,7 @@ export default (props, dispatch) => {
70
71
  link: link(props, dispatch),
71
72
  listing: listing(props),
72
73
  listing_element: listingElement(props),
74
+ list_item: list_item(props),
73
75
  ordered_list: orderedList(props),
74
76
  paragraph: paragraph(props),
75
77
  placeholder: placeholder(props),
@@ -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,16 @@ 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
+ this.dom.setAttribute('data-track-status', this.node.attrs.dataTracked[0].status);
32
+ this.dom.setAttribute('data-track-op', this.node.attrs.dataTracked[0].operation);
33
+ }
34
+ else {
35
+ this.dom.removeAttribute('data-track-status');
36
+ this.dom.removeAttribute('data-track-op');
37
+ }
27
38
  }
28
39
  };
29
40
  }
@@ -0,0 +1,31 @@
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 { getChangeClasses } from '../lib/track-changes-utils';
17
+ import BlockView from './block_view';
18
+ import { createNodeOrElementView } from './creators';
19
+ export class ListItemView extends BlockView {
20
+ constructor() {
21
+ super(...arguments);
22
+ this.elementType = 'li';
23
+ }
24
+ }
25
+ export const listItemCallback = (node, dom) => {
26
+ if (node.attrs.dataTracked) {
27
+ const classes = getChangeClasses(node.attrs.dataTracked);
28
+ dom.className = classes.join(' ');
29
+ }
30
+ };
31
+ export default createNodeOrElementView(ListItemView, 'li', listItemCallback);
@@ -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,16 @@ 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
+ this.dom.setAttribute('data-track-status', this.node.attrs.dataTracked[0].status);
40
+ this.dom.setAttribute('data-track-op', this.node.attrs.dataTracked[0].operation);
41
+ }
42
+ else {
43
+ this.dom.removeAttribute('data-track-status');
44
+ this.dom.removeAttribute('data-track-op');
45
+ }
35
46
  }
36
47
  };
37
48
  }
@@ -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;
@@ -281,6 +281,7 @@ declare const _default: (props: EditorProps, dispatch: Dispatch) => {
281
281
  destroy: () => void;
282
282
  handleDecorations: (decorations: readonly import("prosemirror-view").Decoration[]) => void;
283
283
  } & import("../views/listing_element").ListingElementView<any>>;
284
+ list_item: import("../types").NodeViewCreator<import("../views/list_item").ListItemView<any>>;
284
285
  ordered_list: import("../types").NodeViewCreator<{
285
286
  gutterButtons: () => HTMLElement[];
286
287
  actionGutterButtons: () => HTMLElement[];
@@ -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 {
@@ -0,0 +1,24 @@
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 { ManuscriptNode } from '@manuscripts/transform';
17
+ import { BaseNodeProps } from './base_node_view';
18
+ import BlockView from './block_view';
19
+ export declare class ListItemView<PropsType extends BaseNodeProps> extends BlockView<PropsType> {
20
+ elementType: string;
21
+ }
22
+ export declare const listItemCallback: (node: ManuscriptNode, dom: HTMLElement) => void;
23
+ declare const _default: (props: BaseNodeProps) => import("../types").NodeViewCreator<ListItemView<any>>;
24
+ export default _default;
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.10.0",
4
+ "version": "1.10.1-LEAN-3607.0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",