@manuscripts/body-editor 3.13.7 → 3.13.9
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/lib/paste.js +27 -5
- package/dist/cjs/versions.js +1 -1
- package/dist/es/lib/paste.js +27 -5
- package/dist/es/versions.js +1 -1
- package/dist/types/versions.d.ts +1 -1
- package/package.json +2 -2
- package/src/lib/paste.ts +33 -5
- package/src/versions.ts +1 -1
package/dist/cjs/lib/paste.js
CHANGED
|
@@ -128,11 +128,33 @@ const handlePaste = (view, event, slice) => {
|
|
|
128
128
|
tr.setMeta('uiEvent', 'paste');
|
|
129
129
|
tr.setMeta('paste', true);
|
|
130
130
|
const clipboardData = event.clipboardData;
|
|
131
|
-
const text = clipboardData?.getData('text/plain');
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
131
|
+
const text = clipboardData?.getData('text/plain')?.trim();
|
|
132
|
+
let href = text && (0, url_1.allowedHref)(text) ? text : null;
|
|
133
|
+
if (!href) {
|
|
134
|
+
const html = clipboardData?.getData('text/html');
|
|
135
|
+
const fromHtml = html
|
|
136
|
+
? new DOMParser()
|
|
137
|
+
.parseFromString(html, 'text/html')
|
|
138
|
+
.querySelector('a[href]')
|
|
139
|
+
?.getAttribute('href')
|
|
140
|
+
?.trim()
|
|
141
|
+
: null;
|
|
142
|
+
if (fromHtml && (0, url_1.allowedHref)(fromHtml)) {
|
|
143
|
+
href = fromHtml;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (href && selection instanceof prosemirror_state_1.TextSelection) {
|
|
147
|
+
const $from = selection.$from;
|
|
148
|
+
const canInsertLink = $from.parent.canReplaceWith($from.index(), $from.index(), transform_1.schema.nodes.link);
|
|
149
|
+
if (canInsertLink) {
|
|
150
|
+
const link = transform_1.schema.nodes.link.create({ href }, transform_1.schema.text(text || href));
|
|
151
|
+
dispatch(tr.insert(selection.from, prosemirror_model_1.Fragment.from(link)).scrollIntoView());
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
if (text) {
|
|
155
|
+
dispatch(tr.insertText(text, selection.from, selection.to).scrollIntoView());
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
136
158
|
}
|
|
137
159
|
const parent = (0, prosemirror_utils_1.findParentNode)((node) => node.type === transform_1.schema.nodes.section || node.type === transform_1.schema.nodes.body)(selection);
|
|
138
160
|
if ((slice.content.firstChild?.type === transform_1.schema.nodes.section ||
|
package/dist/cjs/versions.js
CHANGED
package/dist/es/lib/paste.js
CHANGED
|
@@ -123,11 +123,33 @@ export const handlePaste = (view, event, slice) => {
|
|
|
123
123
|
tr.setMeta('uiEvent', 'paste');
|
|
124
124
|
tr.setMeta('paste', true);
|
|
125
125
|
const clipboardData = event.clipboardData;
|
|
126
|
-
const text = clipboardData?.getData('text/plain');
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
126
|
+
const text = clipboardData?.getData('text/plain')?.trim();
|
|
127
|
+
let href = text && allowedHref(text) ? text : null;
|
|
128
|
+
if (!href) {
|
|
129
|
+
const html = clipboardData?.getData('text/html');
|
|
130
|
+
const fromHtml = html
|
|
131
|
+
? new DOMParser()
|
|
132
|
+
.parseFromString(html, 'text/html')
|
|
133
|
+
.querySelector('a[href]')
|
|
134
|
+
?.getAttribute('href')
|
|
135
|
+
?.trim()
|
|
136
|
+
: null;
|
|
137
|
+
if (fromHtml && allowedHref(fromHtml)) {
|
|
138
|
+
href = fromHtml;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (href && selection instanceof TextSelection) {
|
|
142
|
+
const $from = selection.$from;
|
|
143
|
+
const canInsertLink = $from.parent.canReplaceWith($from.index(), $from.index(), schema.nodes.link);
|
|
144
|
+
if (canInsertLink) {
|
|
145
|
+
const link = schema.nodes.link.create({ href }, schema.text(text || href));
|
|
146
|
+
dispatch(tr.insert(selection.from, Fragment.from(link)).scrollIntoView());
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
if (text) {
|
|
150
|
+
dispatch(tr.insertText(text, selection.from, selection.to).scrollIntoView());
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
131
153
|
}
|
|
132
154
|
const parent = findParentNode((node) => node.type === schema.nodes.section || node.type === schema.nodes.body)(selection);
|
|
133
155
|
if ((slice.content.firstChild?.type === schema.nodes.section ||
|
package/dist/es/versions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '3.13.
|
|
1
|
+
export const VERSION = '3.13.9';
|
|
2
2
|
export const MATHJAX_VERSION = '3.2.2';
|
package/dist/types/versions.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "3.13.
|
|
1
|
+
export declare const VERSION = "3.13.9";
|
|
2
2
|
export declare const MATHJAX_VERSION = "3.2.2";
|
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": "3.13.
|
|
4
|
+
"version": "3.13.9",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@iarna/word-count": "1.1.2",
|
|
44
44
|
"@manuscripts/style-guide": "3.6.3",
|
|
45
45
|
"@manuscripts/track-changes-plugin": "2.4.0",
|
|
46
|
-
"@manuscripts/transform": "4.4.
|
|
46
|
+
"@manuscripts/transform": "4.4.5",
|
|
47
47
|
"@popperjs/core": "2.11.8",
|
|
48
48
|
"citeproc": "2.4.63",
|
|
49
49
|
"codemirror": "5.65.19",
|
package/src/lib/paste.ts
CHANGED
|
@@ -185,12 +185,40 @@ export const handlePaste = (
|
|
|
185
185
|
tr.setMeta('paste', true)
|
|
186
186
|
|
|
187
187
|
const clipboardData = event.clipboardData
|
|
188
|
+
const text = clipboardData?.getData('text/plain')?.trim()
|
|
189
|
+
let href = text && allowedHref(text) ? text : null
|
|
190
|
+
if (!href) {
|
|
191
|
+
const html = clipboardData?.getData('text/html')
|
|
192
|
+
const fromHtml = html
|
|
193
|
+
? new DOMParser()
|
|
194
|
+
.parseFromString(html, 'text/html')
|
|
195
|
+
.querySelector('a[href]')
|
|
196
|
+
?.getAttribute('href')
|
|
197
|
+
?.trim()
|
|
198
|
+
: null
|
|
199
|
+
if (fromHtml && allowedHref(fromHtml)) {
|
|
200
|
+
href = fromHtml
|
|
201
|
+
}
|
|
202
|
+
}
|
|
188
203
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
204
|
+
if (href && selection instanceof TextSelection) {
|
|
205
|
+
const $from = selection.$from
|
|
206
|
+
const canInsertLink = $from.parent.canReplaceWith(
|
|
207
|
+
$from.index(),
|
|
208
|
+
$from.index(),
|
|
209
|
+
schema.nodes.link
|
|
210
|
+
)
|
|
211
|
+
if (canInsertLink) {
|
|
212
|
+
const link = schema.nodes.link.create({ href }, schema.text(text || href))
|
|
213
|
+
dispatch(tr.insert(selection.from, Fragment.from(link)).scrollIntoView())
|
|
214
|
+
return true
|
|
215
|
+
}
|
|
216
|
+
if (text) {
|
|
217
|
+
dispatch(
|
|
218
|
+
tr.insertText(text, selection.from, selection.to).scrollIntoView()
|
|
219
|
+
)
|
|
220
|
+
return true
|
|
221
|
+
}
|
|
194
222
|
}
|
|
195
223
|
|
|
196
224
|
// TODO:: all the cases below should be removed when figuring out issue of open slice sides from track-changes plugin
|
package/src/versions.ts
CHANGED