Index: trunk/extensions/VisualEditor/cut-copy-paste.html |
— | — | @@ -1,16 +0,0 @@ |
2 | | -<!doctype html> |
3 | | -<html> |
4 | | -<head> |
5 | | - <title>-----cut-----copy-----paste-----</title> |
6 | | - <script src="modules/jquery/jquery.js"></script> |
7 | | - <script src="contentEditable/rangy/rangy-core.js"></script> |
8 | | - <script src="cut-copy-paste.js"></script> |
9 | | -</head> |
10 | | -<body> |
11 | | - <div id="editor" contenteditable="true"> |
12 | | - <p>Here is some text. I dare you to mess with me.</p> |
13 | | - <p>More text here. Don't you dare!</p> |
14 | | - </div> |
15 | | - <div id="paste" contenteditable="true" style="height: 1px; width: 1px; position: absolute; left: -20000px;"></div> |
16 | | -</body> |
17 | | -</html> |
\ No newline at end of file |
Index: trunk/extensions/VisualEditor/cut-copy-paste.js |
— | — | @@ -1,38 +0,0 @@ |
2 | | -$(function() { |
3 | | - var paste = {}; |
4 | | - |
5 | | - $('#editor') |
6 | | - .on('cut copy', function(event) { |
7 | | - console.log(event); |
8 | | - var range = rangy.getSelection().getRangeAt(0); |
9 | | - var key = range.toString().replace(/( |\r\n|\n|\r|\t)/gm,""); |
10 | | - |
11 | | - paste = {}; |
12 | | - paste[key] = 'some wikidom'; |
13 | | - |
14 | | - if (event.type == 'cut') { |
15 | | - console.log('tell model to cut from: ' + range.startOffset + ' to: ' + range.endOffset); |
16 | | - } |
17 | | - }) |
18 | | - .on('beforepaste paste', function(event) { |
19 | | - console.log(event); |
20 | | - |
21 | | - $('#paste').html(''); |
22 | | - $('#paste').focus(); |
23 | | - |
24 | | - setTimeout(function() { |
25 | | - var key = $('#paste').text().replace(/( |\r\n|\n|\r|\t)/gm,""); |
26 | | - |
27 | | - console.log(paste); |
28 | | - |
29 | | - if (paste[key]) { |
30 | | - alert('you pasted from wikidom'); |
31 | | - } else { |
32 | | - alert('i don\'t know where you pasted from'); |
33 | | - } |
34 | | - |
35 | | - }, 1); |
36 | | - }); |
37 | | - |
38 | | - |
39 | | -}); |
\ No newline at end of file |