@manuscripts/body-editor 1.2.17-LEAN-2143 → 1.2.18

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.
@@ -14,34 +14,17 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
- return new (P || (P = Promise))(function (resolve, reject) {
20
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
- step((generator = generator.apply(thisArg, _arguments || [])).next());
24
- });
25
- };
26
17
  var __importDefault = (this && this.__importDefault) || function (mod) {
27
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
28
19
  };
29
20
  Object.defineProperty(exports, "__esModule", { value: true });
30
21
  exports.CitationView = void 0;
31
22
  const json_schema_1 = require("@manuscripts/json-schema");
32
- const library_1 = require("@manuscripts/library");
33
- const transform_1 = require("@manuscripts/transform");
34
23
  const prosemirror_model_1 = require("prosemirror-model");
35
24
  const react_1 = __importDefault(require("react"));
36
25
  const dompurify_1 = require("../lib/dompurify");
37
26
  const base_node_view_1 = require("./base_node_view");
38
27
  const creators_1 = require("./creators");
39
- const createCitation = (citations, citation) => __awaiter(void 0, void 0, void 0, function* () {
40
- const styleOpts = { bundleID: transform_1.DEFAULT_BUNDLE };
41
- const citationStyle = yield (0, library_1.loadCitationStyle)(styleOpts);
42
- const citationText = library_1.CitationProvider.makeCitationCluster(citations, citation, citationStyle);
43
- return citationText;
44
- });
45
28
  class CitationView extends base_node_view_1.BaseNodeView {
46
29
  constructor() {
47
30
  super(...arguments);
@@ -100,24 +83,14 @@ class CitationView extends base_node_view_1.BaseNodeView {
100
83
  this.updateContents();
101
84
  return this;
102
85
  };
103
- this.updateContents = () => __awaiter(this, void 0, void 0, function* () {
104
- var _a;
105
- const citations = new Map();
106
- (_a = this.props.modelMap) === null || _a === void 0 ? void 0 : _a.forEach((value) => {
107
- if (value.objectType === 'MPBibliographyItem') {
108
- citations.set(value._id, value);
109
- }
110
- });
111
- const nodeModel = this.props.getModel(this.node.attrs.rid);
112
- const citationText = yield createCitation(citations, nodeModel);
113
- console.log('Citation text', citationText, this.node);
86
+ this.updateContents = () => {
114
87
  const fragment = (0, dompurify_1.sanitize)(this.node.attrs.contents, {
115
88
  ALLOWED_TAGS: ['i', 'b', 'span', 'sup', 'sub', '#text'],
116
89
  });
117
90
  this.dom.innerHTML = '';
118
91
  this.dom.appendChild(fragment);
119
92
  this.setDomAttrs(this.node, this.dom, ['rid', 'contents', 'selectedText']);
120
- });
93
+ };
121
94
  this.getCitation = () => {
122
95
  const citation = this.props.getModel(this.node.attrs.rid);
123
96
  if (!citation) {
@@ -13,29 +13,12 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
- return new (P || (P = Promise))(function (resolve, reject) {
19
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
- step((generator = generator.apply(thisArg, _arguments || [])).next());
23
- });
24
- };
25
16
  import { ObjectTypes, } from '@manuscripts/json-schema';
26
- import { CitationProvider, loadCitationStyle } from '@manuscripts/library';
27
- import { DEFAULT_BUNDLE } from '@manuscripts/transform';
28
17
  import { DOMSerializer } from 'prosemirror-model';
29
18
  import React from 'react';
30
19
  import { sanitize } from '../lib/dompurify';
31
20
  import { BaseNodeView } from './base_node_view';
32
21
  import { createNodeView } from './creators';
33
- const createCitation = (citations, citation) => __awaiter(void 0, void 0, void 0, function* () {
34
- const styleOpts = { bundleID: DEFAULT_BUNDLE };
35
- const citationStyle = yield loadCitationStyle(styleOpts);
36
- const citationText = CitationProvider.makeCitationCluster(citations, citation, citationStyle);
37
- return citationText;
38
- });
39
22
  export class CitationView extends BaseNodeView {
40
23
  constructor() {
41
24
  super(...arguments);
@@ -94,24 +77,14 @@ export class CitationView extends BaseNodeView {
94
77
  this.updateContents();
95
78
  return this;
96
79
  };
97
- this.updateContents = () => __awaiter(this, void 0, void 0, function* () {
98
- var _a;
99
- const citations = new Map();
100
- (_a = this.props.modelMap) === null || _a === void 0 ? void 0 : _a.forEach((value) => {
101
- if (value.objectType === 'MPBibliographyItem') {
102
- citations.set(value._id, value);
103
- }
104
- });
105
- const nodeModel = this.props.getModel(this.node.attrs.rid);
106
- const citationText = yield createCitation(citations, nodeModel);
107
- console.log('Citation text', citationText, this.node);
80
+ this.updateContents = () => {
108
81
  const fragment = sanitize(this.node.attrs.contents, {
109
82
  ALLOWED_TAGS: ['i', 'b', 'span', 'sup', 'sub', '#text'],
110
83
  });
111
84
  this.dom.innerHTML = '';
112
85
  this.dom.appendChild(fragment);
113
86
  this.setDomAttrs(this.node, this.dom, ['rid', 'contents', 'selectedText']);
114
- });
87
+ };
115
88
  this.getCitation = () => {
116
89
  const citation = this.props.getModel(this.node.attrs.rid);
117
90
  if (!citation) {
@@ -25,7 +25,6 @@ export interface BaseNodeProps {
25
25
  getModel: <T extends Model>(id: string) => T | undefined;
26
26
  renderReactComponent: (child: React.ReactElement, container: HTMLElement) => void;
27
27
  unmountReactComponent: (container: HTMLElement) => void;
28
- modelMap?: Map<string, Model>;
29
28
  }
30
29
  export declare class BaseNodeView<PropsType extends BaseNodeProps> implements NodeView {
31
30
  readonly props: PropsType;
@@ -30,7 +30,7 @@ export declare class CitationView<PropsType extends CitationViewProps> extends B
30
30
  deselectNode: () => void;
31
31
  destroy: () => void;
32
32
  initialise: () => this;
33
- updateContents: () => Promise<void>;
33
+ updateContents: () => void;
34
34
  getCitation: () => Citation;
35
35
  }
36
36
  declare const _default: (props: BaseNodeProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<CitationView<any>>;
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.2.17-LEAN-2143",
4
+ "version": "1.2.18",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -31,10 +31,10 @@
31
31
  "@manuscripts/assets": "^0.6.2",
32
32
  "@manuscripts/comment-editor": "^1.0.1",
33
33
  "@manuscripts/json-schema": "^2.0.2",
34
- "@manuscripts/library": "^1.1.2-LEAN-2143",
34
+ "@manuscripts/library": "^1.1.2",
35
35
  "@manuscripts/style-guide": "^1.1.7",
36
36
  "@manuscripts/title-editor": "^1.1.0",
37
- "@manuscripts/track-changes-plugin": "^1.5.0",
37
+ "@manuscripts/track-changes-plugin": "1.5.2",
38
38
  "@manuscripts/transform": "^1.3.0",
39
39
  "astrocite-eutils": "^0.16.4",
40
40
  "axios": "^1.2.2",