@manuscripts/body-editor 1.6.13 → 1.6.14

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.
Files changed (55) hide show
  1. package/dist/cjs/citation-sources/crossref.js +27 -54
  2. package/dist/cjs/commands.js +3 -3
  3. package/dist/cjs/configs/editor-views.js +4 -4
  4. package/dist/cjs/lib/array-reducer.js +45 -0
  5. package/dist/cjs/plugins/bibliography/index.js +11 -1
  6. package/dist/cjs/testing/default-editor-data.js +0 -22
  7. package/dist/cjs/views/CitationEditorWrapper.js +65 -0
  8. package/dist/cjs/views/ReferencesEditor.js +50 -0
  9. package/dist/cjs/views/base_node_view.js +1 -1
  10. package/dist/cjs/views/bibliography_element.js +20 -27
  11. package/dist/cjs/views/citation.js +1 -72
  12. package/dist/cjs/views/citation_editable.js +91 -106
  13. package/dist/cjs/views/cross_reference_editable.js +12 -10
  14. package/dist/cjs/views/link_editable.js +42 -34
  15. package/dist/es/citation-sources/crossref.js +27 -54
  16. package/dist/es/commands.js +3 -3
  17. package/dist/es/configs/editor-views.js +4 -4
  18. package/dist/es/lib/array-reducer.js +41 -0
  19. package/dist/es/plugins/bibliography/index.js +11 -1
  20. package/dist/es/testing/default-editor-data.js +0 -22
  21. package/dist/es/views/CitationEditorWrapper.js +38 -0
  22. package/dist/es/views/ReferencesEditor.js +23 -0
  23. package/dist/es/views/base_node_view.js +1 -1
  24. package/dist/es/views/bibliography_element.js +21 -28
  25. package/dist/es/views/citation.js +1 -49
  26. package/dist/es/views/citation_editable.js +92 -107
  27. package/dist/es/views/cross_reference_editable.js +12 -10
  28. package/dist/es/views/editable_block.js +1 -1
  29. package/dist/es/views/link_editable.js +42 -34
  30. package/dist/types/citation-sources/crossref.d.ts +2 -11
  31. package/dist/types/commands.d.ts +3 -3
  32. package/dist/types/components/views/LinkForm.d.ts +2 -2
  33. package/dist/types/configs/ManuscriptsEditor.d.ts +1 -6
  34. package/dist/types/configs/editor-plugins.d.ts +1 -2
  35. package/dist/types/configs/editor-views.d.ts +1 -3
  36. package/dist/types/lib/array-reducer.d.ts +25 -0
  37. package/dist/types/lib/context-menu.d.ts +1 -1
  38. package/dist/types/plugins/bibliography/index.d.ts +1 -1
  39. package/dist/types/views/CitationEditorWrapper.d.ts +3 -0
  40. package/dist/types/views/ReferencesEditor.d.ts +4 -0
  41. package/dist/types/views/base_node_view.d.ts +0 -3
  42. package/dist/types/views/bibliography_element.d.ts +6 -5
  43. package/dist/types/views/citation.d.ts +2 -14
  44. package/dist/types/views/citation_editable.d.ts +12 -6
  45. package/dist/types/views/cross_reference.d.ts +0 -1
  46. package/dist/types/views/editable_block.d.ts +2 -4
  47. package/dist/types/views/keyword_group.d.ts +3 -15
  48. package/dist/types/views/link_editable.d.ts +3 -0
  49. package/package.json +3 -3
  50. package/dist/cjs/plugins/models.js +0 -48
  51. package/dist/cjs/views/ReactView.js +0 -94
  52. package/dist/es/plugins/models.js +0 -45
  53. package/dist/es/views/ReactView.js +0 -66
  54. package/dist/types/plugins/models.d.ts +0 -28
  55. package/dist/types/views/ReactView.d.ts +0 -33
@@ -1,45 +0,0 @@
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 { Plugin, PluginKey } from 'prosemirror-state';
17
- export const modelsKey = new PluginKey('models');
18
- export const INSERT = 'INSERT';
19
- export const UPDATE = 'UPDATE';
20
- export const REMOVE = 'REMOVE';
21
- export default (props) => {
22
- return new Plugin({
23
- key: modelsKey,
24
- state: {
25
- init: () => {
26
- return {};
27
- },
28
- apply: (tr) => {
29
- const meta = tr.getMeta(modelsKey);
30
- if (meta) {
31
- if (meta[INSERT]) {
32
- meta[INSERT].forEach(props.saveModel);
33
- }
34
- if (meta[UPDATE]) {
35
- meta[UPDATE].forEach(props.saveModel);
36
- }
37
- if (meta[REMOVE]) {
38
- meta[REMOVE].forEach(props.deleteModel);
39
- }
40
- }
41
- return {};
42
- },
43
- },
44
- });
45
- };
@@ -1,66 +0,0 @@
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 React, { useCallback, useEffect, useState } from 'react';
17
- import ReactDOM from 'react-dom';
18
- import { ThemeProvider } from 'styled-components';
19
- export default (dispatch, theme) => (Component, contentDOMElementType, nodeViewProps) => (initialNode, view, getPos) => {
20
- const root = document.createElement('div');
21
- const reactChild = root.appendChild(document.createElement('div'));
22
- let contentDOM;
23
- if (contentDOMElementType) {
24
- contentDOM = document.createElement(contentDOMElementType);
25
- root.appendChild(contentDOM);
26
- }
27
- else {
28
- contentDOM = null;
29
- }
30
- let subscriber;
31
- const setNode = (next) => {
32
- subscriber && subscriber(next);
33
- };
34
- const subscribe = (func) => {
35
- subscriber = func;
36
- };
37
- const unsubscribe = () => {
38
- subscriber = null;
39
- };
40
- const Wrapped = () => {
41
- const [node, setNode] = useState(initialNode);
42
- useEffect(() => {
43
- subscribe((node) => {
44
- setNode(node);
45
- });
46
- return () => {
47
- unsubscribe();
48
- };
49
- }, []);
50
- const setNodeAttrs = useCallback((nextAttrs) => {
51
- const { selection, tr } = view.state;
52
- tr.setNodeMarkup(getPos(), undefined, Object.assign(Object.assign({}, node.attrs), nextAttrs)).setSelection(selection.map(tr.doc, tr.mapping));
53
- dispatch(tr);
54
- }, [node.attrs]);
55
- if (!node.attrs) {
56
- return null;
57
- }
58
- return (React.createElement(ThemeProvider, { theme: theme },
59
- React.createElement(Component, { nodeAttrs: node.attrs, setNodeAttrs: setNodeAttrs, viewProps: { node, view, getPos }, dispatch: dispatch, contentDOM: contentDOM })));
60
- };
61
- ReactDOM.render(React.createElement(Wrapped, null), reactChild);
62
- return Object.assign({ dom: root, contentDOM, destroy: () => ReactDOM.unmountComponentAtNode(reactChild), update: (next) => {
63
- setNode(next);
64
- return true;
65
- } }, nodeViewProps);
66
- };
@@ -1,28 +0,0 @@
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 { Model } from '@manuscripts/json-schema';
17
- import { Build } from '@manuscripts/transform';
18
- import { Plugin, PluginKey } from 'prosemirror-state';
19
- export declare const modelsKey: PluginKey<any>;
20
- export declare const INSERT = "INSERT";
21
- export declare const UPDATE = "UPDATE";
22
- export declare const REMOVE = "REMOVE";
23
- interface Props {
24
- saveModel: <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
25
- deleteModel: (id: string) => Promise<string>;
26
- }
27
- declare const _default: (props: Props) => Plugin<Record<string, unknown>>;
28
- export default _default;
@@ -1,33 +0,0 @@
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 { ManuscriptEditorView, ManuscriptNode } from '@manuscripts/transform';
17
- import { NodeView } from 'prosemirror-view';
18
- import React from 'react';
19
- import { DefaultTheme } from 'styled-components';
20
- import { Dispatch } from '../commands';
21
- export interface ReactViewComponentProps<NodeT extends ManuscriptNode> {
22
- nodeAttrs: NodeT['attrs'];
23
- setNodeAttrs: (nextAttrs: Partial<NodeT['attrs']>) => void;
24
- contentDOM?: HTMLElement | null;
25
- viewProps: {
26
- view: ManuscriptEditorView;
27
- getPos: () => number;
28
- node: ManuscriptNode;
29
- };
30
- dispatch: Dispatch;
31
- }
32
- declare const _default: (dispatch: Dispatch, theme: DefaultTheme) => <NodeT extends import("prosemirror-model").Node>(Component: React.FC<ReactViewComponentProps<NodeT>>, contentDOMElementType?: keyof HTMLElementTagNameMap | null, nodeViewProps?: NodeView) => (initialNode: ManuscriptNode, view: ManuscriptEditorView, getPos: () => number) => NodeView;
33
- export default _default;