Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
587f8cb2
Commit
587f8cb2
authored
Nov 18, 2021
by
orozot
Committed by
Natalia Tepluhina
Nov 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: copy text from oneNote and PowerPoint
parent
0df08101
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
2 deletions
+35
-2
app/assets/javascripts/dropzone_input.js
app/assets/javascripts/dropzone_input.js
+7
-1
spec/frontend/dropzone_input_spec.js
spec/frontend/dropzone_input_spec.js
+28
-1
No files found.
app/assets/javascripts/dropzone_input.js
View file @
587f8cb2
...
@@ -44,6 +44,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) {
...
@@ -44,6 +44,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) {
let
addFileToForm
;
let
addFileToForm
;
let
updateAttachingMessage
;
let
updateAttachingMessage
;
let
uploadFile
;
let
uploadFile
;
let
hasPlainText
;
formTextarea
.
wrap
(
'
<div class="div-dropzone"></div>
'
);
formTextarea
.
wrap
(
'
<div class="div-dropzone"></div>
'
);
formTextarea
.
on
(
'
paste
'
,
(
event
)
=>
handlePaste
(
event
));
formTextarea
.
on
(
'
paste
'
,
(
event
)
=>
handlePaste
(
event
));
...
@@ -184,7 +185,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) {
...
@@ -184,7 +185,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) {
event
.
preventDefault
();
event
.
preventDefault
();
const
text
=
converter
.
convertToTableMarkdown
();
const
text
=
converter
.
convertToTableMarkdown
();
pasteText
(
text
);
pasteText
(
text
);
}
else
{
}
else
if
(
!
hasPlainText
(
pasteEvent
))
{
const
fileList
=
[...
clipboardData
.
files
];
const
fileList
=
[...
clipboardData
.
files
];
fileList
.
forEach
((
file
)
=>
{
fileList
.
forEach
((
file
)
=>
{
if
(
file
.
type
.
indexOf
(
'
image
'
)
!==
-
1
)
{
if
(
file
.
type
.
indexOf
(
'
image
'
)
!==
-
1
)
{
...
@@ -203,6 +204,11 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) {
...
@@ -203,6 +204,11 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) {
}
}
};
};
hasPlainText
=
(
data
)
=>
{
const
clipboardDataList
=
[...
data
.
clipboardData
.
items
];
return
clipboardDataList
.
some
((
item
)
=>
item
.
type
===
'
text/plain
'
);
};
pasteText
=
(
text
,
shouldPad
)
=>
{
pasteText
=
(
text
,
shouldPad
)
=>
{
let
formattedText
=
text
;
let
formattedText
=
text
;
if
(
shouldPad
)
{
if
(
shouldPad
)
{
...
...
spec/frontend/dropzone_input_spec.js
View file @
587f8cb2
...
@@ -32,6 +32,8 @@ describe('dropzone_input', () => {
...
@@ -32,6 +32,8 @@ describe('dropzone_input', () => {
});
});
describe
(
'
handlePaste
'
,
()
=>
{
describe
(
'
handlePaste
'
,
()
=>
{
let
form
;
const
triggerPasteEvent
=
(
clipboardData
=
{})
=>
{
const
triggerPasteEvent
=
(
clipboardData
=
{})
=>
{
const
event
=
$
.
Event
(
'
paste
'
);
const
event
=
$
.
Event
(
'
paste
'
);
const
origEvent
=
new
Event
(
'
paste
'
);
const
origEvent
=
new
Event
(
'
paste
'
);
...
@@ -45,11 +47,15 @@ describe('dropzone_input', () => {
...
@@ -45,11 +47,15 @@ describe('dropzone_input', () => {
beforeEach
(()
=>
{
beforeEach
(()
=>
{
loadFixtures
(
'
issues/new-issue.html
'
);
loadFixtures
(
'
issues/new-issue.html
'
);
const
form
=
$
(
'
#new_issue
'
);
form
=
$
(
'
#new_issue
'
);
form
.
data
(
'
uploads-path
'
,
TEST_UPLOAD_PATH
);
form
.
data
(
'
uploads-path
'
,
TEST_UPLOAD_PATH
);
dropzoneInput
(
form
);
dropzoneInput
(
form
);
});
});
afterEach
(()
=>
{
form
=
null
;
});
it
(
'
pastes Markdown tables
'
,
()
=>
{
it
(
'
pastes Markdown tables
'
,
()
=>
{
jest
.
spyOn
(
PasteMarkdownTable
.
prototype
,
'
isTable
'
);
jest
.
spyOn
(
PasteMarkdownTable
.
prototype
,
'
isTable
'
);
jest
.
spyOn
(
PasteMarkdownTable
.
prototype
,
'
convertToTableMarkdown
'
);
jest
.
spyOn
(
PasteMarkdownTable
.
prototype
,
'
convertToTableMarkdown
'
);
...
@@ -86,6 +92,27 @@ describe('dropzone_input', () => {
...
@@ -86,6 +92,27 @@ describe('dropzone_input', () => {
expect
(
axiosMock
.
history
.
post
[
0
].
data
.
get
(
'
file
'
).
name
).
toHaveLength
(
246
);
expect
(
axiosMock
.
history
.
post
[
0
].
data
.
get
(
'
file
'
).
name
).
toHaveLength
(
246
);
});
});
it
(
'
disables generated image file when clipboardData have both image and text
'
,
()
=>
{
const
TEST_PLAIN_TEXT
=
'
This wording is a plain text.
'
;
triggerPasteEvent
({
types
:
[
'
text/plain
'
,
'
Files
'
],
getData
:
()
=>
TEST_PLAIN_TEXT
,
items
:
[
{
kind
:
'
text
'
,
type
:
'
text/plain
'
,
},
{
kind
:
'
file
'
,
type
:
'
image/png
'
,
getAsFile
:
()
=>
new
Blob
(),
},
],
});
expect
(
form
.
find
(
'
.js-gfm-input
'
)[
0
].
value
).
toBe
(
''
);
});
it
(
'
display original file name in comment box
'
,
async
()
=>
{
it
(
'
display original file name in comment box
'
,
async
()
=>
{
const
axiosMock
=
new
MockAdapter
(
axios
);
const
axiosMock
=
new
MockAdapter
(
axios
);
triggerPasteEvent
({
triggerPasteEvent
({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment