@manuscripts/body-editor 2.6.1-remove-toc.0 → 2.6.1
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/configs/editor-plugins.js +2 -0
- package/dist/cjs/configs/editor-views.js +2 -0
- package/dist/cjs/node-type-icons.js +1 -0
- package/dist/cjs/plugins/paragraphs.js +1 -1
- package/dist/cjs/plugins/toc.js +87 -0
- package/dist/cjs/versions.js +1 -1
- package/dist/cjs/views/toc_element.js +50 -0
- package/dist/cjs/views/toc_element_editable.js +21 -0
- package/dist/es/configs/editor-plugins.js +2 -0
- package/dist/es/configs/editor-views.js +2 -0
- package/dist/es/node-type-icons.js +1 -0
- package/dist/es/plugins/paragraphs.js +1 -1
- package/dist/es/plugins/toc.js +84 -0
- package/dist/es/versions.js +1 -1
- package/dist/es/views/toc_element.js +43 -0
- package/dist/es/views/toc_element_editable.js +19 -0
- package/dist/types/configs/editor-views.d.ts +34 -0
- package/dist/types/plugins/toc.d.ts +19 -0
- package/dist/types/versions.d.ts +1 -1
- package/dist/types/views/toc_element.d.ts +26 -0
- package/dist/types/views/toc_element_editable.d.ts +51 -0
- package/package.json +2 -2
|
@@ -42,6 +42,7 @@ const section_category_1 = __importDefault(require("../plugins/section-category"
|
|
|
42
42
|
const sections_1 = __importDefault(require("../plugins/sections"));
|
|
43
43
|
const selected_suggestion_1 = __importDefault(require("../plugins/selected-suggestion"));
|
|
44
44
|
const tables_cursor_fix_1 = __importDefault(require("../plugins/tables-cursor-fix"));
|
|
45
|
+
const toc_1 = __importDefault(require("../plugins/toc"));
|
|
45
46
|
const rules_1 = __importDefault(require("../rules"));
|
|
46
47
|
exports.default = (props) => {
|
|
47
48
|
const allPlugins = [
|
|
@@ -61,6 +62,7 @@ exports.default = (props) => {
|
|
|
61
62
|
(0, elements_1.default)(),
|
|
62
63
|
(0, persist_1.default)(),
|
|
63
64
|
(0, sections_1.default)(),
|
|
65
|
+
(0, toc_1.default)(),
|
|
64
66
|
(0, bibliography_1.default)(props),
|
|
65
67
|
(0, objects_1.default)(),
|
|
66
68
|
(0, affiliations_1.default)(),
|
|
@@ -52,6 +52,7 @@ const table_cell_1 = __importDefault(require("../views/table_cell"));
|
|
|
52
52
|
const table_element_editable_1 = __importDefault(require("../views/table_element_editable"));
|
|
53
53
|
const table_element_footer_1 = __importDefault(require("../views/table_element_footer"));
|
|
54
54
|
const title_editable_1 = __importDefault(require("../views/title_editable"));
|
|
55
|
+
const toc_element_editable_1 = __importDefault(require("../views/toc_element_editable"));
|
|
55
56
|
exports.default = (props, dispatch) => {
|
|
56
57
|
return {
|
|
57
58
|
title: (0, title_editable_1.default)(props, dispatch),
|
|
@@ -87,6 +88,7 @@ exports.default = (props, dispatch) => {
|
|
|
87
88
|
table_cell: (0, table_cell_1.default)(props),
|
|
88
89
|
table_header: (0, table_cell_1.default)(props),
|
|
89
90
|
table_element_footer: (0, table_element_footer_1.default)(props),
|
|
91
|
+
toc_element: (0, toc_element_editable_1.default)(props),
|
|
90
92
|
comments: (0, empty_1.default)('comments'),
|
|
91
93
|
supplements: (0, empty_1.default)('supplements'),
|
|
92
94
|
author_notes: (0, author_notes_1.default)(props, dispatch),
|
|
@@ -33,6 +33,7 @@ const icons = new Map([
|
|
|
33
33
|
[nodes.pullquote_element, style_guide_1.OutlinePullQuoteIcon],
|
|
34
34
|
[nodes.section, style_guide_1.OutlineSectionIcon],
|
|
35
35
|
[nodes.table_element, style_guide_1.OutlineTableIcon],
|
|
36
|
+
[nodes.toc_section, style_guide_1.OutlineSectionIcon],
|
|
36
37
|
[nodes.graphical_abstract_section, style_guide_1.OutlineSectionIcon],
|
|
37
38
|
[nodes.footnotes_section, style_guide_1.OutlineSectionIcon],
|
|
38
39
|
]);
|
|
@@ -22,7 +22,7 @@ exports.default = () => {
|
|
|
22
22
|
appendTransaction: (transactions, oldState, newState) => {
|
|
23
23
|
const positionsToJoin = [];
|
|
24
24
|
const tr = newState.tr;
|
|
25
|
-
if (!transactions.some((
|
|
25
|
+
if (!transactions.some((transaction) => transaction.docChanged)) {
|
|
26
26
|
return null;
|
|
27
27
|
}
|
|
28
28
|
const joinAdjacentParagraphs = (parent, pos) => (node, offset, index) => {
|
|
@@ -0,0 +1,87 @@
|
|
|
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.tocKey = void 0;
|
|
19
|
+
const transform_1 = require("@manuscripts/transform");
|
|
20
|
+
const prosemirror_state_1 = require("prosemirror-state");
|
|
21
|
+
const utils_1 = require("../lib/utils");
|
|
22
|
+
exports.tocKey = new prosemirror_state_1.PluginKey('toc');
|
|
23
|
+
const buildTOCList = (list, node, depth = 1, prefix = '') => {
|
|
24
|
+
list.classList.add('manuscript-toc-list');
|
|
25
|
+
if (depth > 1) {
|
|
26
|
+
list.classList.add('manuscript-toc-inner-list');
|
|
27
|
+
}
|
|
28
|
+
let index = 1;
|
|
29
|
+
node.forEach((child) => {
|
|
30
|
+
if (child.type === transform_1.schema.nodes.body) {
|
|
31
|
+
for (const childNode of (0, utils_1.iterateChildren)(child)) {
|
|
32
|
+
if ((0, transform_1.isSectionNodeType)(childNode.type) && !(0, transform_1.isTOCSectionNode)(childNode)) {
|
|
33
|
+
const numbering = `${prefix}${index}`;
|
|
34
|
+
const firstChildNode = childNode.child(0);
|
|
35
|
+
if (firstChildNode.type ===
|
|
36
|
+
firstChildNode.type.schema.nodes.section_title) {
|
|
37
|
+
const item = document.createElement('li');
|
|
38
|
+
item.classList.add('manuscript-toc-list-item');
|
|
39
|
+
item.setAttribute('data-referenced-section', childNode.attrs.id);
|
|
40
|
+
item.setAttribute('data-referenced-section-path-length', String(depth));
|
|
41
|
+
item.textContent = `${numbering ? `${numbering}.` : ''} ${firstChildNode.textContent || 'Untitled Section'}`;
|
|
42
|
+
list.appendChild(item);
|
|
43
|
+
}
|
|
44
|
+
index++;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
exports.default = () => {
|
|
51
|
+
return new prosemirror_state_1.Plugin({
|
|
52
|
+
key: exports.tocKey,
|
|
53
|
+
appendTransaction(transactions, oldState, newState) {
|
|
54
|
+
if (!transactions.some((transaction) => transaction.docChanged || transaction.getMeta('update'))) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const { tr } = newState;
|
|
58
|
+
const nodesToUpdate = [];
|
|
59
|
+
tr.doc.descendants((node, pos) => {
|
|
60
|
+
if (node.type === node.type.schema.nodes.toc_element) {
|
|
61
|
+
const list = document.createElement('ul');
|
|
62
|
+
buildTOCList(list, newState.doc);
|
|
63
|
+
const contents = list.outerHTML;
|
|
64
|
+
if (contents !== node.attrs.contents) {
|
|
65
|
+
nodesToUpdate.push({
|
|
66
|
+
node,
|
|
67
|
+
pos,
|
|
68
|
+
id: node.attrs.id || (0, transform_1.generateNodeID)(transform_1.schema.nodes.toc_element),
|
|
69
|
+
contents,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
if (nodesToUpdate.length) {
|
|
75
|
+
for (const { node, pos, id, contents } of nodesToUpdate) {
|
|
76
|
+
tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, node.attrs), { contents,
|
|
77
|
+
id }));
|
|
78
|
+
}
|
|
79
|
+
if (tr.selection instanceof prosemirror_state_1.NodeSelection) {
|
|
80
|
+
tr.setSelection(prosemirror_state_1.NodeSelection.create(tr.doc, tr.selection.from));
|
|
81
|
+
}
|
|
82
|
+
tr.setMeta('origin', exports.tocKey);
|
|
83
|
+
return tr;
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
};
|
package/dist/cjs/versions.js
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
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.TOCElementView = void 0;
|
|
22
|
+
const dompurify_1 = require("../lib/dompurify");
|
|
23
|
+
const block_view_1 = __importDefault(require("./block_view"));
|
|
24
|
+
const creators_1 = require("./creators");
|
|
25
|
+
class TOCElementView extends block_view_1.default {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
this.ignoreMutation = () => true;
|
|
29
|
+
this.stopEvent = () => true;
|
|
30
|
+
this.updateContents = () => {
|
|
31
|
+
try {
|
|
32
|
+
const fragment = (0, dompurify_1.sanitize)(this.node.attrs.contents);
|
|
33
|
+
this.element.innerHTML = '';
|
|
34
|
+
this.element.appendChild(fragment);
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
console.error(e);
|
|
38
|
+
window.alert('There was an error loading the HTML purifier, please reload to try again');
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
this.createElement = () => {
|
|
42
|
+
this.element = document.createElement('div');
|
|
43
|
+
this.element.className = 'block';
|
|
44
|
+
this.element.setAttribute('id', this.node.attrs.id);
|
|
45
|
+
this.dom.appendChild(this.element);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.TOCElementView = TOCElementView;
|
|
50
|
+
exports.default = (0, creators_1.createNodeView)(TOCElementView);
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
const creators_1 = require("./creators");
|
|
19
|
+
const editable_block_1 = require("./editable_block");
|
|
20
|
+
const toc_element_1 = require("./toc_element");
|
|
21
|
+
exports.default = (0, creators_1.createEditableNodeView)((0, editable_block_1.EditableBlock)(toc_element_1.TOCElementView));
|
|
@@ -37,6 +37,7 @@ import section_category from '../plugins/section-category';
|
|
|
37
37
|
import sections from '../plugins/sections';
|
|
38
38
|
import selected_suggestion from '../plugins/selected-suggestion';
|
|
39
39
|
import table_editing_fix from '../plugins/tables-cursor-fix';
|
|
40
|
+
import toc from '../plugins/toc';
|
|
40
41
|
import rules from '../rules';
|
|
41
42
|
export default (props) => {
|
|
42
43
|
const allPlugins = [
|
|
@@ -56,6 +57,7 @@ export default (props) => {
|
|
|
56
57
|
elements(),
|
|
57
58
|
persist(),
|
|
58
59
|
sections(),
|
|
60
|
+
toc(),
|
|
59
61
|
bibliography(props),
|
|
60
62
|
objects(),
|
|
61
63
|
affiliations(),
|
|
@@ -47,6 +47,7 @@ import tableCell from '../views/table_cell';
|
|
|
47
47
|
import tableElement from '../views/table_element_editable';
|
|
48
48
|
import tableElementFooter from '../views/table_element_footer';
|
|
49
49
|
import title from '../views/title_editable';
|
|
50
|
+
import tocElement from '../views/toc_element_editable';
|
|
50
51
|
export default (props, dispatch) => {
|
|
51
52
|
return {
|
|
52
53
|
title: title(props, dispatch),
|
|
@@ -82,6 +83,7 @@ export default (props, dispatch) => {
|
|
|
82
83
|
table_cell: tableCell(props),
|
|
83
84
|
table_header: tableCell(props),
|
|
84
85
|
table_element_footer: tableElementFooter(props),
|
|
86
|
+
toc_element: tocElement(props),
|
|
85
87
|
comments: empty('comments'),
|
|
86
88
|
supplements: empty('supplements'),
|
|
87
89
|
author_notes: authorNotes(props, dispatch),
|
|
@@ -27,6 +27,7 @@ const icons = new Map([
|
|
|
27
27
|
[nodes.pullquote_element, OutlinePullQuoteIcon],
|
|
28
28
|
[nodes.section, OutlineSectionIcon],
|
|
29
29
|
[nodes.table_element, OutlineTableIcon],
|
|
30
|
+
[nodes.toc_section, OutlineSectionIcon],
|
|
30
31
|
[nodes.graphical_abstract_section, OutlineSectionIcon],
|
|
31
32
|
[nodes.footnotes_section, OutlineSectionIcon],
|
|
32
33
|
]);
|
|
@@ -20,7 +20,7 @@ export default () => {
|
|
|
20
20
|
appendTransaction: (transactions, oldState, newState) => {
|
|
21
21
|
const positionsToJoin = [];
|
|
22
22
|
const tr = newState.tr;
|
|
23
|
-
if (!transactions.some((
|
|
23
|
+
if (!transactions.some((transaction) => transaction.docChanged)) {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
26
|
const joinAdjacentParagraphs = (parent, pos) => (node, offset, index) => {
|
|
@@ -0,0 +1,84 @@
|
|
|
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 { generateNodeID, isSectionNodeType, isTOCSectionNode, schema, } from '@manuscripts/transform';
|
|
17
|
+
import { NodeSelection, Plugin, PluginKey } from 'prosemirror-state';
|
|
18
|
+
import { iterateChildren } from '../lib/utils';
|
|
19
|
+
export const tocKey = new PluginKey('toc');
|
|
20
|
+
const buildTOCList = (list, node, depth = 1, prefix = '') => {
|
|
21
|
+
list.classList.add('manuscript-toc-list');
|
|
22
|
+
if (depth > 1) {
|
|
23
|
+
list.classList.add('manuscript-toc-inner-list');
|
|
24
|
+
}
|
|
25
|
+
let index = 1;
|
|
26
|
+
node.forEach((child) => {
|
|
27
|
+
if (child.type === schema.nodes.body) {
|
|
28
|
+
for (const childNode of iterateChildren(child)) {
|
|
29
|
+
if (isSectionNodeType(childNode.type) && !isTOCSectionNode(childNode)) {
|
|
30
|
+
const numbering = `${prefix}${index}`;
|
|
31
|
+
const firstChildNode = childNode.child(0);
|
|
32
|
+
if (firstChildNode.type ===
|
|
33
|
+
firstChildNode.type.schema.nodes.section_title) {
|
|
34
|
+
const item = document.createElement('li');
|
|
35
|
+
item.classList.add('manuscript-toc-list-item');
|
|
36
|
+
item.setAttribute('data-referenced-section', childNode.attrs.id);
|
|
37
|
+
item.setAttribute('data-referenced-section-path-length', String(depth));
|
|
38
|
+
item.textContent = `${numbering ? `${numbering}.` : ''} ${firstChildNode.textContent || 'Untitled Section'}`;
|
|
39
|
+
list.appendChild(item);
|
|
40
|
+
}
|
|
41
|
+
index++;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
export default () => {
|
|
48
|
+
return new Plugin({
|
|
49
|
+
key: tocKey,
|
|
50
|
+
appendTransaction(transactions, oldState, newState) {
|
|
51
|
+
if (!transactions.some((transaction) => transaction.docChanged || transaction.getMeta('update'))) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const { tr } = newState;
|
|
55
|
+
const nodesToUpdate = [];
|
|
56
|
+
tr.doc.descendants((node, pos) => {
|
|
57
|
+
if (node.type === node.type.schema.nodes.toc_element) {
|
|
58
|
+
const list = document.createElement('ul');
|
|
59
|
+
buildTOCList(list, newState.doc);
|
|
60
|
+
const contents = list.outerHTML;
|
|
61
|
+
if (contents !== node.attrs.contents) {
|
|
62
|
+
nodesToUpdate.push({
|
|
63
|
+
node,
|
|
64
|
+
pos,
|
|
65
|
+
id: node.attrs.id || generateNodeID(schema.nodes.toc_element),
|
|
66
|
+
contents,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
if (nodesToUpdate.length) {
|
|
72
|
+
for (const { node, pos, id, contents } of nodesToUpdate) {
|
|
73
|
+
tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, node.attrs), { contents,
|
|
74
|
+
id }));
|
|
75
|
+
}
|
|
76
|
+
if (tr.selection instanceof NodeSelection) {
|
|
77
|
+
tr.setSelection(NodeSelection.create(tr.doc, tr.selection.from));
|
|
78
|
+
}
|
|
79
|
+
tr.setMeta('origin', tocKey);
|
|
80
|
+
return tr;
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
};
|
package/dist/es/versions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '2.6.1
|
|
1
|
+
export const VERSION = '2.6.1';
|
|
2
2
|
export const MATHJAX_VERSION = '3.2.2';
|
|
@@ -0,0 +1,43 @@
|
|
|
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 { sanitize } from '../lib/dompurify';
|
|
17
|
+
import BlockView from './block_view';
|
|
18
|
+
import { createNodeView } from './creators';
|
|
19
|
+
export class TOCElementView extends BlockView {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.ignoreMutation = () => true;
|
|
23
|
+
this.stopEvent = () => true;
|
|
24
|
+
this.updateContents = () => {
|
|
25
|
+
try {
|
|
26
|
+
const fragment = sanitize(this.node.attrs.contents);
|
|
27
|
+
this.element.innerHTML = '';
|
|
28
|
+
this.element.appendChild(fragment);
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
console.error(e);
|
|
32
|
+
window.alert('There was an error loading the HTML purifier, please reload to try again');
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
this.createElement = () => {
|
|
36
|
+
this.element = document.createElement('div');
|
|
37
|
+
this.element.className = 'block';
|
|
38
|
+
this.element.setAttribute('id', this.node.attrs.id);
|
|
39
|
+
this.dom.appendChild(this.element);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export default createNodeView(TOCElementView);
|
|
@@ -0,0 +1,19 @@
|
|
|
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 { createEditableNodeView } from './creators';
|
|
17
|
+
import { EditableBlock } from './editable_block';
|
|
18
|
+
import { TOCElementView } from './toc_element';
|
|
19
|
+
export default createEditableNodeView(EditableBlock(TOCElementView));
|
|
@@ -365,6 +365,40 @@ declare const _default: (props: EditorProps, dispatch: Dispatch) => {
|
|
|
365
365
|
destroy: () => void;
|
|
366
366
|
handleDecorations: (decorations: readonly import("prosemirror-view").Decoration[]) => void;
|
|
367
367
|
}>;
|
|
368
|
+
toc_element: import("../types").NodeViewCreator<{
|
|
369
|
+
gutterButtons: () => HTMLElement[];
|
|
370
|
+
actionGutterButtons: () => HTMLElement[];
|
|
371
|
+
createAddButton: () => HTMLElement | null;
|
|
372
|
+
createEditButton: () => HTMLElement | null;
|
|
373
|
+
createMenu: () => import("../lib/context-menu").ContextMenu;
|
|
374
|
+
viewAttributes: {
|
|
375
|
+
id: string;
|
|
376
|
+
placeholder: string;
|
|
377
|
+
};
|
|
378
|
+
initialise: () => void;
|
|
379
|
+
updateContents: () => void;
|
|
380
|
+
onUpdateContent(): void;
|
|
381
|
+
updateClasses: () => void;
|
|
382
|
+
updateAttributes: () => void;
|
|
383
|
+
createElement: () => void;
|
|
384
|
+
createDOM: () => void;
|
|
385
|
+
createGutter: (className: string, buttons: HTMLElement[]) => void;
|
|
386
|
+
dom: HTMLElement;
|
|
387
|
+
contentDOM?: HTMLElement | undefined;
|
|
388
|
+
syncErrors: import("../types").SyncError[];
|
|
389
|
+
elementType: string;
|
|
390
|
+
readonly props: EditorProps;
|
|
391
|
+
node: import("prosemirror-model").Node;
|
|
392
|
+
readonly view: import("prosemirror-view").EditorView;
|
|
393
|
+
readonly getPos: () => number;
|
|
394
|
+
decorations: readonly import("prosemirror-view").Decoration[];
|
|
395
|
+
update: (newNode: import("prosemirror-model").Node, decorations: readonly import("prosemirror-view").Decoration[]) => boolean;
|
|
396
|
+
setDomAttrs(node: import("prosemirror-model").Node, element: HTMLElement, omit?: string[]): void;
|
|
397
|
+
selectNode: () => void;
|
|
398
|
+
deselectNode: () => void;
|
|
399
|
+
destroy: () => void;
|
|
400
|
+
handleDecorations: (decorations: readonly import("prosemirror-view").Decoration[]) => void;
|
|
401
|
+
} & import("../views/toc_element").TOCElementView>;
|
|
368
402
|
comments: () => {
|
|
369
403
|
dom: HTMLDivElement;
|
|
370
404
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
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 declare const tocKey: PluginKey<any>;
|
|
18
|
+
declare const _default: () => Plugin<null>;
|
|
19
|
+
export default _default;
|
package/dist/types/versions.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "2.6.1
|
|
1
|
+
export declare const VERSION = "2.6.1";
|
|
2
2
|
export declare const MATHJAX_VERSION = "3.2.2";
|
|
@@ -0,0 +1,26 @@
|
|
|
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 { TOCElementNode } from '@manuscripts/transform';
|
|
17
|
+
import BlockView from './block_view';
|
|
18
|
+
export declare class TOCElementView extends BlockView<TOCElementNode> {
|
|
19
|
+
private element;
|
|
20
|
+
ignoreMutation: () => boolean;
|
|
21
|
+
stopEvent: () => boolean;
|
|
22
|
+
updateContents: () => void;
|
|
23
|
+
createElement: () => void;
|
|
24
|
+
}
|
|
25
|
+
declare const _default: (props: import("./base_node_view").BaseNodeProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<TOCElementView>;
|
|
26
|
+
export default _default;
|
|
@@ -0,0 +1,51 @@
|
|
|
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 { TOCElementView } from './toc_element';
|
|
17
|
+
declare const _default: (props: import("../configs/ManuscriptsEditor").EditorProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<{
|
|
18
|
+
gutterButtons: () => HTMLElement[];
|
|
19
|
+
actionGutterButtons: () => HTMLElement[];
|
|
20
|
+
createAddButton: () => HTMLElement | null;
|
|
21
|
+
createEditButton: () => HTMLElement | null;
|
|
22
|
+
createMenu: () => import("../lib/context-menu").ContextMenu;
|
|
23
|
+
viewAttributes: {
|
|
24
|
+
id: string;
|
|
25
|
+
placeholder: string;
|
|
26
|
+
};
|
|
27
|
+
initialise: () => void;
|
|
28
|
+
updateContents: () => void;
|
|
29
|
+
onUpdateContent(): void;
|
|
30
|
+
updateClasses: () => void;
|
|
31
|
+
updateAttributes: () => void;
|
|
32
|
+
createElement: () => void;
|
|
33
|
+
createDOM: () => void;
|
|
34
|
+
createGutter: (className: string, buttons: HTMLElement[]) => void;
|
|
35
|
+
dom: HTMLElement;
|
|
36
|
+
contentDOM?: HTMLElement | undefined;
|
|
37
|
+
syncErrors: import("../types").SyncError[];
|
|
38
|
+
elementType: string;
|
|
39
|
+
readonly props: import("../configs/ManuscriptsEditor").EditorProps;
|
|
40
|
+
node: import("prosemirror-model").Node;
|
|
41
|
+
readonly view: import("prosemirror-view").EditorView;
|
|
42
|
+
readonly getPos: () => number;
|
|
43
|
+
decorations: readonly import("prosemirror-view").Decoration[];
|
|
44
|
+
update: (newNode: import("prosemirror-model").Node, decorations: readonly import("prosemirror-view").Decoration[]) => boolean;
|
|
45
|
+
setDomAttrs(node: import("prosemirror-model").Node, element: HTMLElement, omit?: string[]): void;
|
|
46
|
+
selectNode: () => void;
|
|
47
|
+
deselectNode: () => void;
|
|
48
|
+
destroy: () => void;
|
|
49
|
+
handleDecorations: (decorations: readonly import("prosemirror-view").Decoration[]) => void;
|
|
50
|
+
} & TOCElementView>;
|
|
51
|
+
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": "2.6.1
|
|
4
|
+
"version": "2.6.1",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@manuscripts/library": "1.3.11",
|
|
35
35
|
"@manuscripts/style-guide": "2.0.22",
|
|
36
36
|
"@manuscripts/track-changes-plugin": "1.8.1",
|
|
37
|
-
"@manuscripts/transform": "3.0.12
|
|
37
|
+
"@manuscripts/transform": "3.0.12",
|
|
38
38
|
"@popperjs/core": "^2.11.8",
|
|
39
39
|
"astrocite-eutils": "^0.16.4",
|
|
40
40
|
"codemirror": "^5.58.1",
|