@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.
- package/dist/cjs/citation-sources/crossref.js +27 -54
- package/dist/cjs/commands.js +3 -3
- package/dist/cjs/configs/editor-views.js +4 -4
- package/dist/cjs/lib/array-reducer.js +45 -0
- package/dist/cjs/plugins/bibliography/index.js +11 -1
- package/dist/cjs/testing/default-editor-data.js +0 -22
- package/dist/cjs/views/CitationEditorWrapper.js +65 -0
- package/dist/cjs/views/ReferencesEditor.js +50 -0
- package/dist/cjs/views/base_node_view.js +1 -1
- package/dist/cjs/views/bibliography_element.js +20 -27
- package/dist/cjs/views/citation.js +1 -72
- package/dist/cjs/views/citation_editable.js +91 -106
- package/dist/cjs/views/cross_reference_editable.js +12 -10
- package/dist/cjs/views/link_editable.js +42 -34
- package/dist/es/citation-sources/crossref.js +27 -54
- package/dist/es/commands.js +3 -3
- package/dist/es/configs/editor-views.js +4 -4
- package/dist/es/lib/array-reducer.js +41 -0
- package/dist/es/plugins/bibliography/index.js +11 -1
- package/dist/es/testing/default-editor-data.js +0 -22
- package/dist/es/views/CitationEditorWrapper.js +38 -0
- package/dist/es/views/ReferencesEditor.js +23 -0
- package/dist/es/views/base_node_view.js +1 -1
- package/dist/es/views/bibliography_element.js +21 -28
- package/dist/es/views/citation.js +1 -49
- package/dist/es/views/citation_editable.js +92 -107
- package/dist/es/views/cross_reference_editable.js +12 -10
- package/dist/es/views/editable_block.js +1 -1
- package/dist/es/views/link_editable.js +42 -34
- package/dist/types/citation-sources/crossref.d.ts +2 -11
- package/dist/types/commands.d.ts +3 -3
- package/dist/types/components/views/LinkForm.d.ts +2 -2
- package/dist/types/configs/ManuscriptsEditor.d.ts +1 -6
- package/dist/types/configs/editor-plugins.d.ts +1 -2
- package/dist/types/configs/editor-views.d.ts +1 -3
- package/dist/types/lib/array-reducer.d.ts +25 -0
- package/dist/types/lib/context-menu.d.ts +1 -1
- package/dist/types/plugins/bibliography/index.d.ts +1 -1
- package/dist/types/views/CitationEditorWrapper.d.ts +3 -0
- package/dist/types/views/ReferencesEditor.d.ts +4 -0
- package/dist/types/views/base_node_view.d.ts +0 -3
- package/dist/types/views/bibliography_element.d.ts +6 -5
- package/dist/types/views/citation.d.ts +2 -14
- package/dist/types/views/citation_editable.d.ts +12 -6
- package/dist/types/views/cross_reference.d.ts +0 -1
- package/dist/types/views/editable_block.d.ts +2 -4
- package/dist/types/views/keyword_group.d.ts +3 -15
- package/dist/types/views/link_editable.d.ts +3 -0
- package/package.json +3 -3
- package/dist/cjs/plugins/models.js +0 -48
- package/dist/cjs/views/ReactView.js +0 -94
- package/dist/es/plugins/models.js +0 -45
- package/dist/es/views/ReactView.js +0 -66
- package/dist/types/plugins/models.d.ts +0 -28
- package/dist/types/views/ReactView.d.ts +0 -33
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { TextSelection } from 'prosemirror-state';
|
|
17
|
-
import React from 'react';
|
|
18
17
|
import { LinkForm } from '../components/views/LinkForm';
|
|
19
18
|
import { createEditableNodeView } from './creators';
|
|
20
19
|
import { LinkView } from './link';
|
|
20
|
+
import ReactSubView from './ReactSubView';
|
|
21
21
|
export class LinkEditableView extends LinkView {
|
|
22
22
|
constructor() {
|
|
23
23
|
super(...arguments);
|
|
@@ -46,43 +46,51 @@ export class LinkEditableView extends LinkView {
|
|
|
46
46
|
title: this.node.attrs.title,
|
|
47
47
|
text: this.node.textContent,
|
|
48
48
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}, handleRemove: () => {
|
|
57
|
-
const { tr } = this.view.state;
|
|
58
|
-
const pos = this.getPos();
|
|
59
|
-
const to = pos + this.node.nodeSize;
|
|
60
|
-
tr.replaceWith(pos, to, this.node.content).setSelection(TextSelection.create(tr.doc, pos));
|
|
61
|
-
this.view.focus();
|
|
62
|
-
this.view.dispatch(tr);
|
|
63
|
-
this.closeForm();
|
|
64
|
-
}, handleSave: (data) => {
|
|
65
|
-
const tr = this.view.state.tr;
|
|
66
|
-
const pos = this.getPos();
|
|
67
|
-
if (data.href !== originalValue.href ||
|
|
68
|
-
data.title !== originalValue.title) {
|
|
69
|
-
tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, this.node.attrs), { href: data.href, title: data.title }));
|
|
70
|
-
}
|
|
71
|
-
if (data.text !== originalValue.text) {
|
|
72
|
-
tr.insertText(data.text, pos + 1, pos + this.node.nodeSize - 1);
|
|
73
|
-
}
|
|
74
|
-
tr.setSelection(TextSelection.create(tr.doc, pos));
|
|
75
|
-
this.view.focus();
|
|
76
|
-
this.view.dispatch(tr);
|
|
77
|
-
this.closeForm();
|
|
78
|
-
} }), this.popperContainer);
|
|
49
|
+
const componentProps = {
|
|
50
|
+
value: originalValue,
|
|
51
|
+
handleCancel: this.handleCancel,
|
|
52
|
+
handleRemove: this.handleRemove,
|
|
53
|
+
handleSave: this.handleSave,
|
|
54
|
+
};
|
|
55
|
+
this.popperContainer = ReactSubView(this.props, LinkForm, componentProps, this.node, this.getPos, this.view);
|
|
79
56
|
this.props.popper.show(this.dom, this.popperContainer, 'bottom');
|
|
80
57
|
};
|
|
58
|
+
this.handleCancel = () => {
|
|
59
|
+
const tr = this.view.state.tr;
|
|
60
|
+
const pos = this.getPos();
|
|
61
|
+
tr.setSelection(TextSelection.create(tr.doc, pos));
|
|
62
|
+
this.view.focus();
|
|
63
|
+
this.view.dispatch(tr);
|
|
64
|
+
this.closeForm();
|
|
65
|
+
};
|
|
66
|
+
this.handleRemove = () => {
|
|
67
|
+
const tr = this.view.state.tr;
|
|
68
|
+
const pos = this.getPos();
|
|
69
|
+
const to = pos + this.node.nodeSize;
|
|
70
|
+
tr.replaceWith(pos, to, this.node.content).setSelection(TextSelection.create(tr.doc, pos));
|
|
71
|
+
this.view.focus();
|
|
72
|
+
this.view.dispatch(tr);
|
|
73
|
+
this.closeForm();
|
|
74
|
+
};
|
|
75
|
+
this.handleSave = (value) => {
|
|
76
|
+
const tr = this.view.state.tr;
|
|
77
|
+
const link = this.node;
|
|
78
|
+
const pos = this.getPos();
|
|
79
|
+
if (value.href !== link.attrs.href || value.title !== link.attrs.title) {
|
|
80
|
+
tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, this.node.attrs), { href: value.href, title: value.title }));
|
|
81
|
+
}
|
|
82
|
+
if (value.text !== link.textContent) {
|
|
83
|
+
tr.insertText(value.text, pos + 1, pos + this.node.nodeSize - 1);
|
|
84
|
+
}
|
|
85
|
+
tr.setSelection(TextSelection.create(tr.doc, pos));
|
|
86
|
+
this.view.focus();
|
|
87
|
+
this.view.dispatch(tr);
|
|
88
|
+
this.closeForm();
|
|
89
|
+
};
|
|
81
90
|
this.closeForm = () => {
|
|
91
|
+
var _a;
|
|
82
92
|
this.props.popper.destroy();
|
|
83
|
-
|
|
84
|
-
this.props.unmountReactComponent(this.popperContainer);
|
|
85
|
-
}
|
|
93
|
+
(_a = this.popperContainer) === null || _a === void 0 ? void 0 : _a.remove();
|
|
86
94
|
};
|
|
87
95
|
}
|
|
88
96
|
}
|
|
@@ -13,14 +13,5 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
interface SearchResults {
|
|
19
|
-
items: BibliographyItem[];
|
|
20
|
-
total: number;
|
|
21
|
-
}
|
|
22
|
-
export declare const crossref: {
|
|
23
|
-
fetch: (item: Partial<BibliographyItem>) => Promise<Partial<BibliographyItem>>;
|
|
24
|
-
search: (query: string, rows: number, mailto: string, tokenSource?: CancelToken) => Promise<SearchResults>;
|
|
25
|
-
};
|
|
26
|
-
export {};
|
|
16
|
+
import { BibliographyItemSource } from '@manuscripts/style-guide';
|
|
17
|
+
export declare const crossref: BibliographyItemSource;
|
package/dist/types/commands.d.ts
CHANGED
|
@@ -32,15 +32,15 @@ export declare const deleteBlock: (typeToDelete: string) => (state: ManuscriptEd
|
|
|
32
32
|
export declare const insertBreak: EditorAction;
|
|
33
33
|
export declare const insertSectionLabel: (state: ManuscriptEditorState, dispatch?: Dispatch, currentTr?: Transaction) => boolean;
|
|
34
34
|
export declare const insertLink: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
35
|
-
export declare const insertInlineCitation: (state: ManuscriptEditorState, dispatch?: Dispatch
|
|
35
|
+
export declare const insertInlineCitation: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
36
36
|
export declare const insertCrossReference: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
37
37
|
export declare const insertInlineEquation: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
38
38
|
export declare const insertInlineFootnote: (kind: 'footnote' | 'endnote') => (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
39
39
|
export declare const insertGraphicalAbstract: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
40
40
|
export declare const insertSection: (subsection?: boolean) => (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
41
41
|
export declare const insertList: (type: ManuscriptNodeType, style?: string) => (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
42
|
-
export declare const insertBibliographySection: (
|
|
43
|
-
export declare const insertTOCSection: (
|
|
42
|
+
export declare const insertBibliographySection: () => boolean;
|
|
43
|
+
export declare const insertTOCSection: () => boolean;
|
|
44
44
|
export declare const ifInTableBody: (command: (state: ManuscriptEditorState) => boolean) => (state: ManuscriptEditorState) => boolean;
|
|
45
45
|
export declare const isAtStartOfTextBlock: (state: ManuscriptEditorState, $cursor: ResolvedPos, view?: ManuscriptEditorView) => boolean;
|
|
46
46
|
export declare const isTextSelection: (selection: Selection) => selection is TextSelection;
|
|
@@ -20,8 +20,8 @@ export interface LinkValue {
|
|
|
20
20
|
title?: string;
|
|
21
21
|
}
|
|
22
22
|
export declare const LinkForm: React.FC<{
|
|
23
|
-
handleCancel: (
|
|
24
|
-
handleRemove: (
|
|
23
|
+
handleCancel: () => void;
|
|
24
|
+
handleRemove: () => void;
|
|
25
25
|
handleSave: (value: LinkValue) => void;
|
|
26
26
|
value: LinkValue;
|
|
27
27
|
}>;
|
|
@@ -16,11 +16,10 @@
|
|
|
16
16
|
import 'prosemirror-view/style/prosemirror.css';
|
|
17
17
|
import { CommentAnnotation, Manuscript, Model, UserProfile } from '@manuscripts/json-schema';
|
|
18
18
|
import { Capabilities, FileAttachment, FileManagement } from '@manuscripts/style-guide';
|
|
19
|
-
import {
|
|
19
|
+
import { ManuscriptNode } from '@manuscripts/transform';
|
|
20
20
|
import { History } from 'history';
|
|
21
21
|
import { EditorState, Plugin } from 'prosemirror-state';
|
|
22
22
|
import { EditorView } from 'prosemirror-view';
|
|
23
|
-
import React from 'react';
|
|
24
23
|
import { DefaultTheme } from 'styled-components';
|
|
25
24
|
import { CollabProvider } from '../classes/collabProvider';
|
|
26
25
|
import { Dispatch } from '../commands';
|
|
@@ -41,15 +40,11 @@ export interface EditorProps {
|
|
|
41
40
|
doc: ManuscriptNode;
|
|
42
41
|
getModelMap: () => Map<string, Model>;
|
|
43
42
|
getManuscript: () => Manuscript;
|
|
44
|
-
saveModel: <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
|
|
45
43
|
deleteModel: (id: string) => Promise<string>;
|
|
46
44
|
getFiles: () => FileAttachment[];
|
|
47
45
|
fileManagement: FileManagement;
|
|
48
46
|
popper: PopperManager;
|
|
49
47
|
history: History;
|
|
50
|
-
renderReactComponent: (child: React.ReactNode, container: HTMLElement) => void;
|
|
51
|
-
unmountReactComponent: (container: HTMLElement) => void;
|
|
52
|
-
components: Record<string, React.ComponentType<any>>;
|
|
53
48
|
getCapabilities: () => Capabilities;
|
|
54
49
|
cslProps: CSLProps;
|
|
55
50
|
setComment: (comment?: CommentAnnotation) => void;
|
|
@@ -17,7 +17,7 @@ import 'prosemirror-gapcursor/style/gapcursor.css';
|
|
|
17
17
|
import 'prosemirror-tables/style/tables.css';
|
|
18
18
|
import { CommentAnnotation, Manuscript, Model } from '@manuscripts/json-schema';
|
|
19
19
|
import { Capabilities } from '@manuscripts/style-guide';
|
|
20
|
-
import {
|
|
20
|
+
import { ManuscriptSchema } from '@manuscripts/transform';
|
|
21
21
|
import { Plugin } from 'prosemirror-state';
|
|
22
22
|
import { CollabProvider } from '../classes/collabProvider';
|
|
23
23
|
import { PopperManager } from '../lib/popper';
|
|
@@ -25,7 +25,6 @@ import { CSLProps } from './ManuscriptsEditor';
|
|
|
25
25
|
interface PluginProps {
|
|
26
26
|
getModelMap: () => Map<string, Model>;
|
|
27
27
|
getManuscript: () => Manuscript;
|
|
28
|
-
saveModel: <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
|
|
29
28
|
deleteModel: (id: string) => Promise<string>;
|
|
30
29
|
setComment: (comment?: CommentAnnotation) => void;
|
|
31
30
|
setSelectedComment: (id?: string) => void;
|
|
@@ -15,11 +15,9 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { DefaultTheme } from 'styled-components';
|
|
17
17
|
import { Dispatch } from '../commands';
|
|
18
|
-
import { CitationViewProps } from '../views/citation';
|
|
19
18
|
import { EditableBlockProps } from '../views/editable_block';
|
|
20
19
|
import { FigureProps } from '../views/figure_editable';
|
|
21
|
-
|
|
22
|
-
type EditorProps = EditableBlockProps & CitationViewProps & FigureProps & KeywordsElementProps & {
|
|
20
|
+
type EditorProps = EditableBlockProps & FigureProps & {
|
|
23
21
|
theme: DefaultTheme;
|
|
24
22
|
};
|
|
25
23
|
declare const _default: (props: EditorProps, dispatch: Dispatch) => {
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
export type Update<T> = {
|
|
17
|
+
type: 'update';
|
|
18
|
+
items: T[];
|
|
19
|
+
};
|
|
20
|
+
export type Delete<T> = {
|
|
21
|
+
type: 'delete';
|
|
22
|
+
item: T;
|
|
23
|
+
};
|
|
24
|
+
export type Action<T> = Update<T> | Delete<T>;
|
|
25
|
+
export declare const arrayReducer: <T>(isEqual?: (a: T, b: T) => boolean) => (state: T[], action: Action<T>) => T[];
|
|
@@ -17,7 +17,7 @@ import { CommentAnnotation } from '@manuscripts/json-schema';
|
|
|
17
17
|
import { ManuscriptEditorView, ManuscriptNode } from '@manuscripts/transform';
|
|
18
18
|
export declare const sectionLevel: (depth: number) => string;
|
|
19
19
|
interface Actions {
|
|
20
|
-
setComment?: (comment
|
|
20
|
+
setComment?: (comment: CommentAnnotation) => void;
|
|
21
21
|
}
|
|
22
22
|
export declare class ContextMenu {
|
|
23
23
|
private readonly node;
|
|
@@ -26,8 +26,8 @@ export interface PluginState {
|
|
|
26
26
|
citations: CiteProc.Citation[];
|
|
27
27
|
bibliographyItems: Map<string, BibliographyItem>;
|
|
28
28
|
renderedCitations: Map<string, string>;
|
|
29
|
+
citationCounts: Map<string, number>;
|
|
29
30
|
provider: CitationProvider;
|
|
30
|
-
refresh?: boolean;
|
|
31
31
|
}
|
|
32
32
|
export interface BibliographyProps {
|
|
33
33
|
cslProps: CSLProps;
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
/// <reference types="react" />
|
|
17
16
|
import { Model } from '@manuscripts/json-schema';
|
|
18
17
|
import { ManuscriptEditorView, ManuscriptNode } from '@manuscripts/transform';
|
|
19
18
|
import { Attrs, Node } from 'prosemirror-model';
|
|
@@ -25,8 +24,6 @@ export interface BaseNodeProps {
|
|
|
25
24
|
getModelMap: () => Map<string, Model>;
|
|
26
25
|
popper: PopperManager;
|
|
27
26
|
cslProps: CSLProps;
|
|
28
|
-
renderReactComponent: (child: React.ReactElement, container: HTMLElement) => void;
|
|
29
|
-
unmountReactComponent: (container: HTMLElement) => void;
|
|
30
27
|
}
|
|
31
28
|
export declare class BaseNodeView<PropsType extends BaseNodeProps> implements NodeView {
|
|
32
29
|
readonly props: PropsType;
|
|
@@ -14,23 +14,24 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { CommentAnnotation } from '@manuscripts/json-schema';
|
|
17
|
-
import React from 'react';
|
|
18
17
|
import { BaseNodeProps } from './base_node_view';
|
|
19
18
|
import BlockView from './block_view';
|
|
20
19
|
import { EditableBlockProps } from './editable_block';
|
|
21
20
|
interface BibliographyElementViewProps extends BaseNodeProps {
|
|
22
21
|
setComment: (comment?: CommentAnnotation) => void;
|
|
23
|
-
components: Record<string, React.ComponentType<any>>;
|
|
24
22
|
}
|
|
25
23
|
export declare class BibliographyElementBlockView<PropsType extends BibliographyElementViewProps & EditableBlockProps> extends BlockView<PropsType> {
|
|
26
|
-
container
|
|
27
|
-
|
|
24
|
+
private container;
|
|
25
|
+
private editor;
|
|
26
|
+
private decoder;
|
|
28
27
|
gutterButtons: () => HTMLElement[];
|
|
29
|
-
showPopper: (
|
|
28
|
+
showPopper: (id: string) => void;
|
|
30
29
|
stopEvent: () => boolean;
|
|
31
30
|
ignoreMutation: () => boolean;
|
|
32
31
|
updateContents: () => Promise<void>;
|
|
33
32
|
createElement: () => void;
|
|
33
|
+
private handleSave;
|
|
34
|
+
private handleDelete;
|
|
34
35
|
}
|
|
35
36
|
declare const _default: (props: BaseNodeProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<BibliographyElementBlockView<any>>;
|
|
36
37
|
export default _default;
|
|
@@ -13,26 +13,14 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { BibliographyItem } from '@manuscripts/json-schema';
|
|
17
16
|
import { ManuscriptNodeView } from '@manuscripts/transform';
|
|
18
|
-
import React from 'react';
|
|
19
17
|
import { BaseNodeProps, BaseNodeView } from './base_node_view';
|
|
20
|
-
export
|
|
21
|
-
components: Record<string, React.ComponentType<any>>;
|
|
22
|
-
projectID: string;
|
|
23
|
-
}
|
|
24
|
-
export declare class CitationView<PropsType extends CitationViewProps> extends BaseNodeView<PropsType> implements ManuscriptNodeView {
|
|
25
|
-
protected popperContainer?: HTMLDivElement;
|
|
26
|
-
showPopper: () => void;
|
|
18
|
+
export declare class CitationView<PropsType extends BaseNodeProps> extends BaseNodeView<PropsType> implements ManuscriptNodeView {
|
|
27
19
|
ignoreMutation: () => boolean;
|
|
28
|
-
selectNode: () => void;
|
|
29
|
-
deselectNode: () => void;
|
|
30
|
-
destroy: () => void;
|
|
31
20
|
initialise: () => this;
|
|
32
21
|
updateContents: () => void;
|
|
33
22
|
renderTrackChangesReview: () => HTMLSpanElement;
|
|
34
|
-
getCitation: () => import("@manuscripts/json-schema").Citation;
|
|
35
|
-
getBibliographyItems: () => BibliographyItem[];
|
|
23
|
+
getCitation: () => import("@manuscripts/json-schema/dist/types").Citation;
|
|
36
24
|
}
|
|
37
25
|
declare const _default: (props: BaseNodeProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<CitationView<any>>;
|
|
38
26
|
export default _default;
|
|
@@ -13,18 +13,24 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { CitationView
|
|
16
|
+
import { CitationView } from './citation';
|
|
17
17
|
import { EditableBlockProps } from './editable_block';
|
|
18
|
-
export declare class CitationEditableView extends CitationView<
|
|
18
|
+
export declare class CitationEditableView extends CitationView<EditableBlockProps> {
|
|
19
|
+
private decoder;
|
|
20
|
+
private editor;
|
|
21
|
+
selectNode: () => void;
|
|
22
|
+
deselectNode: () => void;
|
|
23
|
+
destroy: () => void;
|
|
19
24
|
showPopper: () => void;
|
|
20
|
-
private handleClose;
|
|
21
25
|
private handleCancel;
|
|
22
|
-
private
|
|
23
|
-
private
|
|
26
|
+
private handleSave;
|
|
27
|
+
private handleUncite;
|
|
24
28
|
private handleCite;
|
|
29
|
+
private handleDelete;
|
|
30
|
+
private handleComment;
|
|
25
31
|
private insertBibliographyNode;
|
|
26
|
-
private importItems;
|
|
27
32
|
private updateNode;
|
|
33
|
+
private findPosition;
|
|
28
34
|
}
|
|
29
35
|
declare const _default: (props: EditableBlockProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<CitationEditableView>;
|
|
30
36
|
export default _default;
|
|
@@ -20,7 +20,6 @@ export interface CrossReferenceViewProps extends BaseNodeProps {
|
|
|
20
20
|
history: History;
|
|
21
21
|
}
|
|
22
22
|
export declare class CrossReferenceView<PropsType extends CrossReferenceViewProps> extends BaseNodeView<PropsType> implements ManuscriptNodeView {
|
|
23
|
-
protected popperContainer?: HTMLDivElement;
|
|
24
23
|
selectNode: () => void;
|
|
25
24
|
handleClick: () => void;
|
|
26
25
|
updateContents: () => void;
|
|
@@ -13,9 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { CommentAnnotation
|
|
16
|
+
import { CommentAnnotation } from '@manuscripts/json-schema';
|
|
17
17
|
import { Capabilities } from '@manuscripts/style-guide';
|
|
18
|
-
import { Build } from '@manuscripts/transform';
|
|
19
18
|
import { DefaultTheme } from 'styled-components';
|
|
20
19
|
import { Dispatch } from '../commands';
|
|
21
20
|
import { ContextMenu } from '../lib/context-menu';
|
|
@@ -25,8 +24,7 @@ type Constructor<T> = new (...args: any[]) => T;
|
|
|
25
24
|
export interface EditableBlockProps extends BaseNodeProps {
|
|
26
25
|
getCapabilities: () => Capabilities;
|
|
27
26
|
retrySync: (componentIDs: string[]) => Promise<void>;
|
|
28
|
-
|
|
29
|
-
setComment?: (comment?: CommentAnnotation) => void;
|
|
27
|
+
setComment: (comment: CommentAnnotation) => void;
|
|
30
28
|
dispatch?: Dispatch;
|
|
31
29
|
theme?: DefaultTheme;
|
|
32
30
|
}
|
|
@@ -13,26 +13,14 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Model } from '@manuscripts/json-schema';
|
|
17
|
-
import { Capabilities } from '@manuscripts/style-guide';
|
|
18
|
-
import { Build } from '@manuscripts/transform';
|
|
19
|
-
import { DefaultTheme } from 'styled-components';
|
|
20
|
-
import { Dispatch } from '../commands';
|
|
21
|
-
import { BaseNodeProps } from './base_node_view';
|
|
22
16
|
import BlockView from './block_view';
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
dispatch?: Dispatch;
|
|
26
|
-
theme?: DefaultTheme;
|
|
27
|
-
retrySync: (componentIDs: string[]) => Promise<void>;
|
|
28
|
-
saveModel: <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
|
|
29
|
-
}
|
|
30
|
-
export declare class KeywordGroupView extends BlockView<BaseNodeProps & KeywordsElementProps> {
|
|
17
|
+
import { EditableBlockProps } from './editable_block';
|
|
18
|
+
export declare class KeywordGroupView extends BlockView<EditableBlockProps> {
|
|
31
19
|
private element;
|
|
32
20
|
private addingTools;
|
|
33
21
|
ignoreMutation: () => boolean;
|
|
34
22
|
stopEvent: () => boolean;
|
|
35
23
|
createElement: () => void;
|
|
36
24
|
}
|
|
37
|
-
declare const _default: (props: BaseNodeProps, dispatch?: Dispatch | undefined) => import("../types").NodeViewCreator<KeywordGroupView>;
|
|
25
|
+
declare const _default: (props: import("./base_node_view").BaseNodeProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<KeywordGroupView>;
|
|
38
26
|
export default _default;
|
|
@@ -21,6 +21,9 @@ export declare class LinkEditableView extends LinkView<EditableBlockProps> {
|
|
|
21
21
|
destroy: () => void;
|
|
22
22
|
deselectNode: () => void;
|
|
23
23
|
private showForm;
|
|
24
|
+
private handleCancel;
|
|
25
|
+
private handleRemove;
|
|
26
|
+
private handleSave;
|
|
24
27
|
private closeForm;
|
|
25
28
|
}
|
|
26
29
|
declare const _default: (props: EditableBlockProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<LinkEditableView>;
|
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.6.
|
|
4
|
+
"version": "1.6.14",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@manuscripts/assets": "^0.6.4",
|
|
32
32
|
"@manuscripts/json-schema": "^2.2.2",
|
|
33
33
|
"@manuscripts/library": "1.3.2",
|
|
34
|
-
"@manuscripts/style-guide": "1.
|
|
34
|
+
"@manuscripts/style-guide": "1.7.0",
|
|
35
35
|
"@manuscripts/track-changes-plugin": "^1.7.5",
|
|
36
36
|
"@manuscripts/transform": "2.0.4",
|
|
37
37
|
"astrocite-eutils": "^0.16.4",
|
|
@@ -126,4 +126,4 @@
|
|
|
126
126
|
"resolutions": {
|
|
127
127
|
"@types/react": "^17.0.2"
|
|
128
128
|
}
|
|
129
|
-
}
|
|
129
|
+
}
|
|
@@ -1,48 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.REMOVE = exports.UPDATE = exports.INSERT = exports.modelsKey = void 0;
|
|
19
|
-
const prosemirror_state_1 = require("prosemirror-state");
|
|
20
|
-
exports.modelsKey = new prosemirror_state_1.PluginKey('models');
|
|
21
|
-
exports.INSERT = 'INSERT';
|
|
22
|
-
exports.UPDATE = 'UPDATE';
|
|
23
|
-
exports.REMOVE = 'REMOVE';
|
|
24
|
-
exports.default = (props) => {
|
|
25
|
-
return new prosemirror_state_1.Plugin({
|
|
26
|
-
key: exports.modelsKey,
|
|
27
|
-
state: {
|
|
28
|
-
init: () => {
|
|
29
|
-
return {};
|
|
30
|
-
},
|
|
31
|
-
apply: (tr) => {
|
|
32
|
-
const meta = tr.getMeta(exports.modelsKey);
|
|
33
|
-
if (meta) {
|
|
34
|
-
if (meta[exports.INSERT]) {
|
|
35
|
-
meta[exports.INSERT].forEach(props.saveModel);
|
|
36
|
-
}
|
|
37
|
-
if (meta[exports.UPDATE]) {
|
|
38
|
-
meta[exports.UPDATE].forEach(props.saveModel);
|
|
39
|
-
}
|
|
40
|
-
if (meta[exports.REMOVE]) {
|
|
41
|
-
meta[exports.REMOVE].forEach(props.deleteModel);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return {};
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
};
|
|
@@ -1,94 +0,0 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
-
}
|
|
23
|
-
Object.defineProperty(o, k2, desc);
|
|
24
|
-
}) : (function(o, m, k, k2) {
|
|
25
|
-
if (k2 === undefined) k2 = k;
|
|
26
|
-
o[k2] = m[k];
|
|
27
|
-
}));
|
|
28
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
-
}) : function(o, v) {
|
|
31
|
-
o["default"] = v;
|
|
32
|
-
});
|
|
33
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
-
};
|
|
43
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
const react_1 = __importStar(require("react"));
|
|
45
|
-
const react_dom_1 = __importDefault(require("react-dom"));
|
|
46
|
-
const styled_components_1 = require("styled-components");
|
|
47
|
-
exports.default = (dispatch, theme) => (Component, contentDOMElementType, nodeViewProps) => (initialNode, view, getPos) => {
|
|
48
|
-
const root = document.createElement('div');
|
|
49
|
-
const reactChild = root.appendChild(document.createElement('div'));
|
|
50
|
-
let contentDOM;
|
|
51
|
-
if (contentDOMElementType) {
|
|
52
|
-
contentDOM = document.createElement(contentDOMElementType);
|
|
53
|
-
root.appendChild(contentDOM);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
contentDOM = null;
|
|
57
|
-
}
|
|
58
|
-
let subscriber;
|
|
59
|
-
const setNode = (next) => {
|
|
60
|
-
subscriber && subscriber(next);
|
|
61
|
-
};
|
|
62
|
-
const subscribe = (func) => {
|
|
63
|
-
subscriber = func;
|
|
64
|
-
};
|
|
65
|
-
const unsubscribe = () => {
|
|
66
|
-
subscriber = null;
|
|
67
|
-
};
|
|
68
|
-
const Wrapped = () => {
|
|
69
|
-
const [node, setNode] = (0, react_1.useState)(initialNode);
|
|
70
|
-
(0, react_1.useEffect)(() => {
|
|
71
|
-
subscribe((node) => {
|
|
72
|
-
setNode(node);
|
|
73
|
-
});
|
|
74
|
-
return () => {
|
|
75
|
-
unsubscribe();
|
|
76
|
-
};
|
|
77
|
-
}, []);
|
|
78
|
-
const setNodeAttrs = (0, react_1.useCallback)((nextAttrs) => {
|
|
79
|
-
const { selection, tr } = view.state;
|
|
80
|
-
tr.setNodeMarkup(getPos(), undefined, Object.assign(Object.assign({}, node.attrs), nextAttrs)).setSelection(selection.map(tr.doc, tr.mapping));
|
|
81
|
-
dispatch(tr);
|
|
82
|
-
}, [node.attrs]);
|
|
83
|
-
if (!node.attrs) {
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
return (react_1.default.createElement(styled_components_1.ThemeProvider, { theme: theme },
|
|
87
|
-
react_1.default.createElement(Component, { nodeAttrs: node.attrs, setNodeAttrs: setNodeAttrs, viewProps: { node, view, getPos }, dispatch: dispatch, contentDOM: contentDOM })));
|
|
88
|
-
};
|
|
89
|
-
react_dom_1.default.render(react_1.default.createElement(Wrapped, null), reactChild);
|
|
90
|
-
return Object.assign({ dom: root, contentDOM, destroy: () => react_dom_1.default.unmountComponentAtNode(reactChild), update: (next) => {
|
|
91
|
-
setNode(next);
|
|
92
|
-
return true;
|
|
93
|
-
} }, nodeViewProps);
|
|
94
|
-
};
|