@manuscripts/body-editor 1.7.6-LEAN-3342-2 → 1.7.6
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/commands.js +1 -27
- package/dist/cjs/lib/context-menu.js +0 -11
- package/dist/es/commands.js +0 -25
- package/dist/es/lib/context-menu.js +1 -12
- package/dist/types/commands.d.ts +0 -2
- package/package.json +1 -1
package/dist/cjs/commands.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.insertTableFootnote = exports.updateCommentAnnotationState = exports.addComment = exports.deleteHighlightMarkers = exports.insertHighlight = exports.createAndFillTableElement = exports.selectAllIsolating = exports.ignoreAtomBlockNodeForward = exports.isAtEndOfTextBlock = exports.ignoreAtomBlockNodeBackward = exports.isTextSelection = exports.isAtStartOfTextBlock = exports.ifInTableBody = exports.insertTOCSection = exports.insertBibliographySection = exports.insertList = exports.insertSection = exports.insertGraphicalAbstract = exports.insertInlineFootnote = exports.insertInlineEquation = exports.insertCrossReference = exports.insertInlineCitation = exports.insertLink = exports.insertSectionLabel = exports.insertBreak = exports.deleteBlock = exports.insertBlock = exports.insertFileAsFigure = exports.
|
|
18
|
+
exports.insertTableFootnote = exports.updateCommentAnnotationState = exports.addComment = exports.deleteHighlightMarkers = exports.insertHighlight = exports.createAndFillTableElement = exports.selectAllIsolating = exports.ignoreAtomBlockNodeForward = exports.isAtEndOfTextBlock = exports.ignoreAtomBlockNodeBackward = exports.isTextSelection = exports.isAtStartOfTextBlock = exports.ifInTableBody = exports.insertTOCSection = exports.insertBibliographySection = exports.insertList = exports.insertSection = exports.insertGraphicalAbstract = exports.insertInlineFootnote = exports.insertInlineEquation = exports.insertCrossReference = exports.insertInlineCitation = exports.insertLink = exports.insertSectionLabel = exports.insertBreak = exports.deleteBlock = exports.insertBlock = exports.insertFileAsFigure = exports.createBlock = exports.createSelection = exports.canInsert = exports.blockActive = exports.isNodeSelection = exports.markActive = void 0;
|
|
19
19
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
20
|
const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
|
|
21
21
|
const transform_1 = require("@manuscripts/transform");
|
|
@@ -122,32 +122,6 @@ const createBlock = (nodeType, position, state, dispatch) => {
|
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
124
|
exports.createBlock = createBlock;
|
|
125
|
-
const insertGeneralFootnote = (tableNode, position, view, tableElementFooter) => {
|
|
126
|
-
var _a;
|
|
127
|
-
const { state, dispatch } = view;
|
|
128
|
-
const generalNote = state.schema.nodes.paragraph.create({
|
|
129
|
-
placeholder: 'Add general note here',
|
|
130
|
-
});
|
|
131
|
-
const tr = state.tr;
|
|
132
|
-
const pos = (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length)
|
|
133
|
-
? position + tableElementFooter[0].pos + 2
|
|
134
|
-
: position + (((_a = tableNode.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize) || 0);
|
|
135
|
-
if (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length) {
|
|
136
|
-
tr.insert(pos, generalNote);
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
const tableElementFooter = transform_1.schema.nodes.table_element_footer.create({
|
|
140
|
-
id: (0, transform_1.generateID)(json_schema_1.ObjectTypes.TableElementFooter),
|
|
141
|
-
}, [generalNote]);
|
|
142
|
-
tr.insert(pos, tableElementFooter);
|
|
143
|
-
}
|
|
144
|
-
if (dispatch && pos) {
|
|
145
|
-
const selection = (0, exports.createSelection)(state.schema.nodes.paragraph, pos, tr.doc);
|
|
146
|
-
view === null || view === void 0 ? void 0 : view.focus();
|
|
147
|
-
dispatch(tr.setSelection(selection).scrollIntoView());
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
exports.insertGeneralFootnote = insertGeneralFootnote;
|
|
151
125
|
const insertFileAsFigure = (file, state, dispatch) => {
|
|
152
126
|
const position = findBlockInsertPosition(state);
|
|
153
127
|
if (position === null || !dispatch) {
|
|
@@ -135,7 +135,6 @@ class ContextMenu {
|
|
|
135
135
|
this.addPopperEventListeners();
|
|
136
136
|
};
|
|
137
137
|
this.showEditMenu = (target) => {
|
|
138
|
-
var _a;
|
|
139
138
|
const menu = document.createElement('div');
|
|
140
139
|
menu.className = 'menu';
|
|
141
140
|
const $pos = this.resolvePos();
|
|
@@ -168,16 +167,6 @@ class ContextMenu {
|
|
|
168
167
|
}
|
|
169
168
|
if (type === transform_1.schema.nodes.table_element) {
|
|
170
169
|
const isInTable = (0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.table)(this.view.state.selection);
|
|
171
|
-
const tableElementFooter = (0, prosemirror_utils_1.findChildrenByType)(this.node, transform_1.schema.nodes.table_element_footer);
|
|
172
|
-
const hasGeneralNote = tableElementFooter.length &&
|
|
173
|
-
((_a = tableElementFooter[0].node.firstChild) === null || _a === void 0 ? void 0 : _a.type) === transform_1.schema.nodes.paragraph;
|
|
174
|
-
if (!hasGeneralNote) {
|
|
175
|
-
menu.appendChild(this.createMenuSection((section) => {
|
|
176
|
-
section.appendChild(this.createMenuItem('Add General Note', () => {
|
|
177
|
-
(0, commands_1.insertGeneralFootnote)(this.node, this.getPos(), this.view, tableElementFooter);
|
|
178
|
-
}));
|
|
179
|
-
}));
|
|
180
|
-
}
|
|
181
170
|
if (isInTable) {
|
|
182
171
|
menu.appendChild(this.createMenuSection((section) => {
|
|
183
172
|
section.appendChild(this.createMenuItem('Add Reference Note', () => {
|
package/dist/es/commands.js
CHANGED
|
@@ -113,31 +113,6 @@ export const createBlock = (nodeType, position, state, dispatch) => {
|
|
|
113
113
|
dispatch(tr.setSelection(selection).scrollIntoView());
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
|
-
export const insertGeneralFootnote = (tableNode, position, view, tableElementFooter) => {
|
|
117
|
-
var _a;
|
|
118
|
-
const { state, dispatch } = view;
|
|
119
|
-
const generalNote = state.schema.nodes.paragraph.create({
|
|
120
|
-
placeholder: 'Add general note here',
|
|
121
|
-
});
|
|
122
|
-
const tr = state.tr;
|
|
123
|
-
const pos = (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length)
|
|
124
|
-
? position + tableElementFooter[0].pos + 2
|
|
125
|
-
: position + (((_a = tableNode.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize) || 0);
|
|
126
|
-
if (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length) {
|
|
127
|
-
tr.insert(pos, generalNote);
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
const tableElementFooter = schema.nodes.table_element_footer.create({
|
|
131
|
-
id: generateID(ObjectTypes.TableElementFooter),
|
|
132
|
-
}, [generalNote]);
|
|
133
|
-
tr.insert(pos, tableElementFooter);
|
|
134
|
-
}
|
|
135
|
-
if (dispatch && pos) {
|
|
136
|
-
const selection = createSelection(state.schema.nodes.paragraph, pos, tr.doc);
|
|
137
|
-
view === null || view === void 0 ? void 0 : view.focus();
|
|
138
|
-
dispatch(tr.setSelection(selection).scrollIntoView());
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
116
|
export const insertFileAsFigure = (file, state, dispatch) => {
|
|
142
117
|
const position = findBlockInsertPosition(state);
|
|
143
118
|
if (position === null || !dispatch) {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { isInBibliographySection, nodeNames, schema, } from '@manuscripts/transform';
|
|
17
17
|
import { findChildrenByType, hasParentNodeOfType } from 'prosemirror-utils';
|
|
18
|
-
import { addComment, createBlock,
|
|
18
|
+
import { addComment, createBlock, insertTableFootnote } from '../commands';
|
|
19
19
|
import { PopperManager } from './popper';
|
|
20
20
|
const popper = new PopperManager();
|
|
21
21
|
const listTypes = [schema.nodes.ordered_list, schema.nodes.bullet_list];
|
|
@@ -131,7 +131,6 @@ export class ContextMenu {
|
|
|
131
131
|
this.addPopperEventListeners();
|
|
132
132
|
};
|
|
133
133
|
this.showEditMenu = (target) => {
|
|
134
|
-
var _a;
|
|
135
134
|
const menu = document.createElement('div');
|
|
136
135
|
menu.className = 'menu';
|
|
137
136
|
const $pos = this.resolvePos();
|
|
@@ -164,16 +163,6 @@ export class ContextMenu {
|
|
|
164
163
|
}
|
|
165
164
|
if (type === schema.nodes.table_element) {
|
|
166
165
|
const isInTable = hasParentNodeOfType(schema.nodes.table)(this.view.state.selection);
|
|
167
|
-
const tableElementFooter = findChildrenByType(this.node, schema.nodes.table_element_footer);
|
|
168
|
-
const hasGeneralNote = tableElementFooter.length &&
|
|
169
|
-
((_a = tableElementFooter[0].node.firstChild) === null || _a === void 0 ? void 0 : _a.type) === schema.nodes.paragraph;
|
|
170
|
-
if (!hasGeneralNote) {
|
|
171
|
-
menu.appendChild(this.createMenuSection((section) => {
|
|
172
|
-
section.appendChild(this.createMenuItem('Add General Note', () => {
|
|
173
|
-
insertGeneralFootnote(this.node, this.getPos(), this.view, tableElementFooter);
|
|
174
|
-
}));
|
|
175
|
-
}));
|
|
176
|
-
}
|
|
177
166
|
if (isInTable) {
|
|
178
167
|
menu.appendChild(this.createMenuSection((section) => {
|
|
179
168
|
section.appendChild(this.createMenuItem('Add Reference Note', () => {
|
package/dist/types/commands.d.ts
CHANGED
|
@@ -18,7 +18,6 @@ import { FileAttachment } from '@manuscripts/style-guide';
|
|
|
18
18
|
import { ManuscriptEditorState, ManuscriptEditorView, ManuscriptMarkType, ManuscriptNode, ManuscriptNodeType, ManuscriptTransaction } from '@manuscripts/transform';
|
|
19
19
|
import { ResolvedPos } from 'prosemirror-model';
|
|
20
20
|
import { Command, NodeSelection, Selection, TextSelection, Transaction } from 'prosemirror-state';
|
|
21
|
-
import { NodeWithPos } from 'prosemirror-utils';
|
|
22
21
|
import { EditorAction } from './types';
|
|
23
22
|
export type Dispatch = (tr: ManuscriptTransaction) => void;
|
|
24
23
|
export declare const markActive: (type: ManuscriptMarkType) => (state: ManuscriptEditorState) => boolean;
|
|
@@ -27,7 +26,6 @@ export declare const blockActive: (type: ManuscriptNodeType) => (state: Manuscri
|
|
|
27
26
|
export declare const canInsert: (type: ManuscriptNodeType) => (state: ManuscriptEditorState) => boolean;
|
|
28
27
|
export declare const createSelection: (nodeType: ManuscriptNodeType, position: number, doc: ManuscriptNode) => Selection;
|
|
29
28
|
export declare const createBlock: (nodeType: ManuscriptNodeType, position: number, state: ManuscriptEditorState, dispatch?: Dispatch) => void;
|
|
30
|
-
export declare const insertGeneralFootnote: (tableNode: ManuscriptNode, position: number, view: ManuscriptEditorView, tableElementFooter?: NodeWithPos[]) => void;
|
|
31
29
|
export declare const insertFileAsFigure: (file: FileAttachment, state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
32
30
|
export declare const insertBlock: (nodeType: ManuscriptNodeType) => (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
33
31
|
export declare const deleteBlock: (typeToDelete: string) => (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
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.7.6
|
|
4
|
+
"version": "1.7.6",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|