@manuscripts/article-editor 4.2.43 → 4.2.45
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/components/projects/EditorElement.js +34 -4
- package/dist/cjs/components/projects/EditorElement.js.map +1 -1
- package/dist/cjs/lib/utils.js +27 -1
- package/dist/cjs/lib/utils.js.map +1 -1
- package/dist/es/components/projects/EditorElement.js +35 -5
- package/dist/es/components/projects/EditorElement.js.map +1 -1
- package/dist/es/lib/utils.js +25 -0
- package/dist/es/lib/utils.js.map +1 -1
- package/dist/types/lib/utils.d.ts +4 -1
- package/package.json +5 -5
@@ -44,6 +44,7 @@ const react_dnd_1 = require("react-dnd");
|
|
44
44
|
const use_connect_editor_1 = require("../../hooks/use-connect-editor");
|
45
45
|
const use_watch_title_1 = require("../../hooks/use-watch-title");
|
46
46
|
const node_attrs_1 = require("../../lib/node-attrs");
|
47
|
+
const utils_1 = require("../../lib/utils");
|
47
48
|
const store_1 = require("../../store");
|
48
49
|
const Icons_1 = require("../track-changes/suggestion-list/Icons");
|
49
50
|
const EditorElement = () => {
|
@@ -66,20 +67,49 @@ const EditorElement = () => {
|
|
66
67
|
return false;
|
67
68
|
}
|
68
69
|
const resolvedPos = view.state.doc.resolve(docPos.pos);
|
70
|
+
const mediaInfo = (0, body_editor_1.getMediaTypeInfo)(file.name);
|
69
71
|
const attrs = {
|
70
72
|
src: file.id,
|
71
73
|
};
|
72
|
-
|
74
|
+
let targetNode = view.state.doc.nodeAt(docPos.pos) || resolvedPos.parent;
|
75
|
+
let mediaNodeWithPos;
|
76
|
+
if (targetNode.type === transform_1.schema.nodes.figcaption ||
|
77
|
+
targetNode.type === transform_1.schema.nodes.caption ||
|
78
|
+
targetNode.type === transform_1.schema.nodes.caption_title) {
|
79
|
+
mediaNodeWithPos = (0, prosemirror_utils_1.findParentNodeClosestToPos)(resolvedPos, (node) => node.type === transform_1.schema.nodes.embed);
|
80
|
+
if (mediaNodeWithPos) {
|
81
|
+
targetNode = mediaNodeWithPos.node;
|
82
|
+
}
|
83
|
+
}
|
73
84
|
switch (targetNode.type) {
|
74
85
|
case transform_1.schema.nodes.figure: {
|
75
86
|
const figure = targetNode;
|
76
87
|
(0, node_attrs_1.setNodeAttrs)(view.state, dispatch, figure.attrs.id, attrs);
|
77
88
|
break;
|
78
89
|
}
|
90
|
+
case transform_1.schema.nodes.embed: {
|
91
|
+
const media = targetNode;
|
92
|
+
(0, node_attrs_1.setNodeAttrs)(view.state, dispatch, media.attrs.id, {
|
93
|
+
href: file.id,
|
94
|
+
mimetype: mediaInfo.mimetype,
|
95
|
+
mimeSubtype: mediaInfo.mimeSubtype,
|
96
|
+
});
|
97
|
+
break;
|
98
|
+
}
|
79
99
|
case transform_1.schema.nodes.figcaption:
|
80
100
|
case transform_1.schema.nodes.caption:
|
81
101
|
case transform_1.schema.nodes.caption_title: {
|
82
|
-
|
102
|
+
if (mediaNodeWithPos) {
|
103
|
+
const media = mediaNodeWithPos.node;
|
104
|
+
(0, node_attrs_1.setNodeAttrs)(view.state, dispatch, media.attrs.id, {
|
105
|
+
href: file.id,
|
106
|
+
mimetype: mediaInfo.mimetype,
|
107
|
+
mimeSubtype: mediaInfo.mimeSubtype,
|
108
|
+
});
|
109
|
+
}
|
110
|
+
else {
|
111
|
+
addFigureAtFigCaptionPosition(editor, resolvedPos, attrs, file);
|
112
|
+
}
|
83
113
|
break;
|
84
114
|
}
|
85
115
|
case transform_1.schema.nodes.figure_element: {
|
@@ -92,7 +122,7 @@ const EditorElement = () => {
|
|
92
122
|
view.focus();
|
93
123
|
dispatch(tr);
|
94
124
|
// after dispatch is called - the view.state changes and becomes the new state of the editor so exactly the view.state has to be used to make changes on the actual state
|
95
|
-
(0,
|
125
|
+
(0, utils_1.insertMediaOrFigure)(file, view, dispatch);
|
96
126
|
}
|
97
127
|
}
|
98
128
|
return true;
|
@@ -138,7 +168,7 @@ const addFigureAtFigCaptionPosition = (editor, resolvePos, attrs, file) => {
|
|
138
168
|
const transaction = view.state.tr.setSelection(prosemirror_state_1.NodeSelection.near(resolvePos));
|
139
169
|
view.focus();
|
140
170
|
dispatch(transaction);
|
141
|
-
(0,
|
171
|
+
(0, utils_1.insertMediaOrFigure)(file, view, dispatch);
|
142
172
|
}
|
143
173
|
};
|
144
174
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"EditorElement.js","sourceRoot":"","sources":["../../../../src/components/projects/EditorElement.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;GAUG;AACH,0DAMiC;AACjC,0DAA2D;AAC3D,
|
1
|
+
{"version":3,"file":"EditorElement.js","sourceRoot":"","sources":["../../../../src/components/projects/EditorElement.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;GAUG;AACH,0DAMiC;AACjC,0DAA2D;AAC3D,sDAO+B;AAE/B,yDAA8D;AAC9D,yDAAuE;AACvE,+CAAuC;AACvC,yCAAmC;AAEnC,uEAAiE;AACjE,iEAA2D;AAC3D,qDAAmD;AACnD,2CAAqD;AACrD,uCAAsC;AACtC,kEAAkE;AAElE,MAAM,aAAa,GAAa,GAAG,EAAE;IACnC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAC,EAAE,CAAC,CAAA;IACtC,MAAM,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,GAAG,IAAA,gBAAQ,EAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACvD,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,aAAa,EAAE,KAAK,CAAC,aAAa;KACnC,CAAC,CAAC,CAAA;IAEH,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAA,qCAAgB,GAAE,CAAA;IACvD,IAAA,+BAAa,GAAE,CAAA;IAEf,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG,IAAA,mB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AE,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,CAAA;KAC3D;SAAM;QACL,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,GAAG,gBAAgB,CAAC,CAAA;KACtE;AACH,CAAC,CAAA;AAED,MAAM,iBAAiB,GAAG,CAAC,MAAkB,EAAE,EAAE,CAC/C,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAA;AAEpC,MAAM,YAAY,GAAG,CACnB,IAA0B,EAC1B,QAAmC,EACnC,KAA8B,EAC9B,GAAW,EACX,EAAE;IACF,MAAM,MAAM,GAAG,kBAAM,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC;QAC/C,GAAG,KAAK;QACR,EAAE,EAAE,IAAA,0BAAc,EAAC,kBAAM,CAAC,KAAK,CAAC,MAAM,CAAC;KACxC,CAAe,CAAA;IAChB,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IAC5C,QAAQ,CAAC,EAAE,CAAC,CAAA;AACd,CAAC,CAAA;AAED,kBAAe,aAAa,CAAA"}
|
package/dist/cjs/lib/utils.js
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.scrollIntoView = exports.decodeHTMLEntities = exports.getParentNode = void 0;
|
3
|
+
exports.insertMediaOrFigure = exports.scrollIntoView = exports.decodeHTMLEntities = exports.getParentNode = void 0;
|
4
|
+
/*!
|
5
|
+
* The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
|
6
|
+
*
|
7
|
+
* Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
|
8
|
+
*
|
9
|
+
* The Original Code is manuscripts-frontend.
|
10
|
+
*
|
11
|
+
* The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
|
12
|
+
*
|
13
|
+
* All portions of the code written by Atypon Systems LLC are Copyright (c) 2024 Atypon Systems LLC. All Rights Reserved.
|
14
|
+
*/
|
15
|
+
const body_editor_1 = require("@manuscripts/body-editor");
|
4
16
|
const getParentNode = (state, pos) => {
|
5
17
|
const resolvedPos = state.doc.resolve(pos);
|
6
18
|
for (let depth = resolvedPos.depth; depth > 0; depth--) {
|
@@ -34,4 +46,18 @@ const scrollIntoView = (element) => {
|
|
34
46
|
}
|
35
47
|
};
|
36
48
|
exports.scrollIntoView = scrollIntoView;
|
49
|
+
const insertMediaOrFigure = (file, view, dispatch) => {
|
50
|
+
const mediaInfo = (0, body_editor_1.getMediaTypeInfo)(file.name);
|
51
|
+
if (mediaInfo.isVideo || mediaInfo.isAudio) {
|
52
|
+
(0, body_editor_1.insertEmbed)(view.state, dispatch, {
|
53
|
+
href: file.id,
|
54
|
+
mimetype: mediaInfo.mimetype,
|
55
|
+
mimeSubtype: mediaInfo.mimeSubtype,
|
56
|
+
});
|
57
|
+
}
|
58
|
+
else {
|
59
|
+
(0, body_editor_1.insertFigure)(file, view.state, dispatch);
|
60
|
+
}
|
61
|
+
};
|
62
|
+
exports.insertMediaOrFigure = insertMediaOrFigure;
|
37
63
|
//# sourceMappingURL=utils.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG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GAAG,EAAE;QACtD,OAAO,CAAC,cAAc,EAAE,CAAA;KACzB;AACH,CAAC,CAAA;AALY,QAAA,cAAc,kBAK1B;AAEM,MAAM,mBAAmB,GAAG,CACjC,IAAoB,EACpB,IAA0B,EAC1B,QAAmC,EACnC,EAAE;IACF,MAAM,SAAS,GAAG,IAAA,8BAAgB,EAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC7C,IAAI,SAAS,CAAC,OAAO,IAAI,SAAS,CAAC,OAAO,EAAE;QAC1C,IAAA,yBAAW,EAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE;YAChC,IAAI,EAAE,IAAI,CAAC,EAAE;YACb,QAAQ,EAAE,SAAS,CAAC,QAAQ;YAC5B,WAAW,EAAE,SAAS,CAAC,WAAW;SACnC,CAAC,CAAA;KACH;SAAM;QACL,IAAA,0BAAY,EAAC,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;KACzC;AACH,CAAC,CAAA;AAfY,QAAA,mBAAmB,uBAe/B"}
|
@@ -9,7 +9,7 @@
|
|
9
9
|
*
|
10
10
|
* All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
|
11
11
|
*/
|
12
|
-
import { findParentElement, getMatchingChild,
|
12
|
+
import { findParentElement, getMatchingChild, getMediaTypeInfo, } from '@manuscripts/body-editor';
|
13
13
|
import { Category, Dialog } from '@manuscripts/style-guide';
|
14
14
|
import { generateNodeID, schema, } from '@manuscripts/transform';
|
15
15
|
import { NodeSelection } from 'prosemirror-state';
|
@@ -19,6 +19,7 @@ import { useDrop } from 'react-dnd';
|
|
19
19
|
import { useConnectEditor } from '../../hooks/use-connect-editor';
|
20
20
|
import { useWatchTitle } from '../../hooks/use-watch-title';
|
21
21
|
import { setNodeAttrs } from '../../lib/node-attrs';
|
22
|
+
import { insertMediaOrFigure } from '../../lib/utils';
|
22
23
|
import { useStore } from '../../store';
|
23
24
|
import { SpriteMap } from '../track-changes/suggestion-list/Icons';
|
24
25
|
const EditorElement = () => {
|
@@ -41,20 +42,49 @@ const EditorElement = () => {
|
|
41
42
|
return false;
|
42
43
|
}
|
43
44
|
const resolvedPos = view.state.doc.resolve(docPos.pos);
|
45
|
+
const mediaInfo = getMediaTypeInfo(file.name);
|
44
46
|
const attrs = {
|
45
47
|
src: file.id,
|
46
48
|
};
|
47
|
-
|
49
|
+
let targetNode = view.state.doc.nodeAt(docPos.pos) || resolvedPos.parent;
|
50
|
+
let mediaNodeWithPos;
|
51
|
+
if (targetNode.type === schema.nodes.figcaption ||
|
52
|
+
targetNode.type === schema.nodes.caption ||
|
53
|
+
targetNode.type === schema.nodes.caption_title) {
|
54
|
+
mediaNodeWithPos = findParentNodeClosestToPos(resolvedPos, (node) => node.type === schema.nodes.embed);
|
55
|
+
if (mediaNodeWithPos) {
|
56
|
+
targetNode = mediaNodeWithPos.node;
|
57
|
+
}
|
58
|
+
}
|
48
59
|
switch (targetNode.type) {
|
49
60
|
case schema.nodes.figure: {
|
50
61
|
const figure = targetNode;
|
51
62
|
setNodeAttrs(view.state, dispatch, figure.attrs.id, attrs);
|
52
63
|
break;
|
53
64
|
}
|
65
|
+
case schema.nodes.embed: {
|
66
|
+
const media = targetNode;
|
67
|
+
setNodeAttrs(view.state, dispatch, media.attrs.id, {
|
68
|
+
href: file.id,
|
69
|
+
mimetype: mediaInfo.mimetype,
|
70
|
+
mimeSubtype: mediaInfo.mimeSubtype,
|
71
|
+
});
|
72
|
+
break;
|
73
|
+
}
|
54
74
|
case schema.nodes.figcaption:
|
55
75
|
case schema.nodes.caption:
|
56
76
|
case schema.nodes.caption_title: {
|
57
|
-
|
77
|
+
if (mediaNodeWithPos) {
|
78
|
+
const media = mediaNodeWithPos.node;
|
79
|
+
setNodeAttrs(view.state, dispatch, media.attrs.id, {
|
80
|
+
href: file.id,
|
81
|
+
mimetype: mediaInfo.mimetype,
|
82
|
+
mimeSubtype: mediaInfo.mimeSubtype,
|
83
|
+
});
|
84
|
+
}
|
85
|
+
else {
|
86
|
+
addFigureAtFigCaptionPosition(editor, resolvedPos, attrs, file);
|
87
|
+
}
|
58
88
|
break;
|
59
89
|
}
|
60
90
|
case schema.nodes.figure_element: {
|
@@ -67,7 +97,7 @@ const EditorElement = () => {
|
|
67
97
|
view.focus();
|
68
98
|
dispatch(tr);
|
69
99
|
// after dispatch is called - the view.state changes and becomes the new state of the editor so exactly the view.state has to be used to make changes on the actual state
|
70
|
-
|
100
|
+
insertMediaOrFigure(file, view, dispatch);
|
71
101
|
}
|
72
102
|
}
|
73
103
|
return true;
|
@@ -113,7 +143,7 @@ const addFigureAtFigCaptionPosition = (editor, resolvePos, attrs, file) => {
|
|
113
143
|
const transaction = view.state.tr.setSelection(NodeSelection.near(resolvePos));
|
114
144
|
view.focus();
|
115
145
|
dispatch(transaction);
|
116
|
-
|
146
|
+
insertMediaOrFigure(file, view, dispatch);
|
117
147
|
}
|
118
148
|
};
|
119
149
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"EditorElement.js","sourceRoot":"","sources":["../../../../src/components/projects/EditorElement.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAEL,iBAAiB,EACjB,gBAAgB,EAChB,
|
1
|
+
{"version":3,"file":"EditorElement.js","sourceRoot":"","sources":["../../../../src/components/projects/EditorElement.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAEL,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,GAEjB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAGL,cAAc,EAGd,MAAM,GACP,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAE,aAAa,EAAe,MAAM,mBAAmB,CAAA;AAC9D,OAAO,EAAE,0BAA0B,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AACvE,OAAO,KAAK,EA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a,CAAC;QAC/C,GAAG,KAAK;QACR,EAAE,EAAE,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;KACxC,CAAe,CAAA;IAChB,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IAC5C,QAAQ,CAAC,EAAE,CAAC,CAAA;AACd,CAAC,CAAA;AAED,eAAe,aAAa,CAAA"}
|
package/dist/es/lib/utils.js
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
/*!
|
2
|
+
* The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
|
3
|
+
*
|
4
|
+
* Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
|
5
|
+
*
|
6
|
+
* The Original Code is manuscripts-frontend.
|
7
|
+
*
|
8
|
+
* The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
|
9
|
+
*
|
10
|
+
* All portions of the code written by Atypon Systems LLC are Copyright (c) 2024 Atypon Systems LLC. All Rights Reserved.
|
11
|
+
*/
|
12
|
+
import { getMediaTypeInfo, insertEmbed, insertFigure, } from '@manuscripts/body-editor';
|
1
13
|
export const getParentNode = (state, pos) => {
|
2
14
|
const resolvedPos = state.doc.resolve(pos);
|
3
15
|
for (let depth = resolvedPos.depth; depth > 0; depth--) {
|
@@ -28,4 +40,17 @@ export const scrollIntoView = (element) => {
|
|
28
40
|
element.scrollIntoView();
|
29
41
|
}
|
30
42
|
};
|
43
|
+
export const insertMediaOrFigure = (file, view, dispatch) => {
|
44
|
+
const mediaInfo = getMediaTypeInfo(file.name);
|
45
|
+
if (mediaInfo.isVideo || mediaInfo.isAudio) {
|
46
|
+
insertEmbed(view.state, dispatch, {
|
47
|
+
href: file.id,
|
48
|
+
mimetype: mediaInfo.mimetype,
|
49
|
+
mimeSubtype: mediaInfo.mimeSubtype,
|
50
|
+
});
|
51
|
+
}
|
52
|
+
else {
|
53
|
+
insertFigure(file, view.state, dispatch);
|
54
|
+
}
|
55
|
+
};
|
31
56
|
//# sourceMappingURL=utils.js.map
|
package/dist/es/lib/utils.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAEL,gBAAgB,EAChB,WAAW,EACX,YAAY,GACb,MAAM,0BAA0B,CAAA;AAIjC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAkB,EAAE,GAAW,EAAE,EAAE;IAC/D,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAE1C,KAAK,IAAI,KAAK,GAAG,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE;QACtD,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACtC,IAAI,MAAM,CAAC,MAAM,KAAK,KAAK,EAAE;YAC3B,IAAI,MAAM,CAAC,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE;gBAC/C,MAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAA;gBAC/C,IAAI,WAAW,CAAC,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE;oBACnD,OAAO,WAA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LLC. All Rights Reserved.
|
11
11
|
*/
|
12
|
-
import {
|
12
|
+
import { FileAttachment } from '@manuscripts/body-editor';
|
13
|
+
import { ManuscriptEditorView } from '@manuscripts/transform';
|
14
|
+
import { EditorState, Transaction } from 'prosemirror-state';
|
13
15
|
export declare const getParentNode: (state: EditorState, pos: number) => import("prosemirror-model").Node | null;
|
14
16
|
export declare const decodeHTMLEntities: (text: string) => string;
|
15
17
|
export declare const scrollIntoView: (element: HTMLElement) => void;
|
18
|
+
export declare const insertMediaOrFigure: (file: FileAttachment, view: ManuscriptEditorView, dispatch: (tr: Transaction) => void) => void;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@manuscripts/article-editor",
|
3
|
-
"version": "4.2.
|
3
|
+
"version": "4.2.45",
|
4
4
|
"license": "CPAL-1.0",
|
5
5
|
"description": "React components for editing and viewing manuscripts",
|
6
6
|
"repository": "github:Atypon-OpenSource/manuscripts-article-editor",
|
@@ -32,11 +32,11 @@
|
|
32
32
|
"@fontsource/pt-sans": "5.2.5",
|
33
33
|
"@fontsource/pt-serif": "5.2.5",
|
34
34
|
"@headlessui/react": "2.2.3",
|
35
|
-
"@manuscripts/body-editor": "3.2.
|
35
|
+
"@manuscripts/body-editor": "3.2.37",
|
36
36
|
"@manuscripts/json-schema": "2.2.12",
|
37
|
-
"@manuscripts/style-guide": "3.1.
|
38
|
-
"@manuscripts/track-changes-plugin": "2.0.
|
39
|
-
"@manuscripts/transform": "4.2.
|
37
|
+
"@manuscripts/style-guide": "3.1.7",
|
38
|
+
"@manuscripts/track-changes-plugin": "2.0.9",
|
39
|
+
"@manuscripts/transform": "4.2.11",
|
40
40
|
"@popperjs/core": "2.11.8",
|
41
41
|
"date-fns": "4.1.0",
|
42
42
|
"dompurify": "3.2.5",
|