mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-25 11:16:51 +00:00
test page for copy and paste support
This commit is contained in:
parent
0ced900973
commit
2530451094
Notes:
Gabriel Wicke
2012-02-27 16:40:01 +00:00
16
cut-copy-paste.html
Normal file
16
cut-copy-paste.html
Normal file
|
@ -0,0 +1,16 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>-----cut-----copy-----paste-----</title>
|
||||
<script src="modules/jquery/jquery.js"></script>
|
||||
<script src="contentEditable/rangy/rangy-core.js"></script>
|
||||
<script src="cut-copy-paste.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="editor" contenteditable="true">
|
||||
<p>Here is some text. I dare you to mess with me.</p>
|
||||
<p>More text here. Don't you dare!</p>
|
||||
</div>
|
||||
<div id="paste" contenteditable="true" style="height: 1px; width: 1px; position: absolute; left: -20000px;"></div>
|
||||
</body>
|
||||
</html>
|
31
cut-copy-paste.js
Normal file
31
cut-copy-paste.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
$(function() {
|
||||
var paste = {};
|
||||
|
||||
$('#editor')
|
||||
.on('copy', function(event) {
|
||||
var range = rangy.getSelection().getRangeAt(0);
|
||||
var key = range.toString().replace(/( |\r\n|\n|\r|\t)/gm,"");
|
||||
|
||||
paste = {};
|
||||
paste[key] = 'some wikidom';
|
||||
})
|
||||
.on('paste', function(event) {
|
||||
$('#paste').html('');
|
||||
$('#paste').focus();
|
||||
|
||||
setTimeout(function() {
|
||||
var key = $('#paste').text().replace(/( |\r\n|\n|\r|\t)/gm,"");
|
||||
|
||||
console.log(paste);
|
||||
|
||||
if (paste[key]) {
|
||||
alert('you pasted from wikidom');
|
||||
} else {
|
||||
alert('i don\'t know where you pasted from');
|
||||
}
|
||||
|
||||
}, 1);
|
||||
});
|
||||
|
||||
|
||||
});
|
Loading…
Reference in a new issue