rsaccon / Bespin playground (http://rsaccon.com/)

No description has been added.

commit 917: 664de15f7957
parent 916: 83e26074786c
branch: default
486638: defend the command line
Dion Almaer
12 months ago

Changed (Δ414 bytes):

Up to file-list frontend/js/bespin/editor/clipboard.js:

@@ -72,14 +72,22 @@ dojo.declare("bespin.editor.clipboard.DO
72
72
            id: 'copynpaster',
73
73
            style: "position: absolute; z-index: -400; top: -100px; left: -100px; width: 0; height: 0; border: none;"
74
74
        }, dojo.body());
75
        
75
76
        // * Defensively stop doing copy/cut/paste magic if you are in the command line
77
        var stopAction = function(e) {
78
            return e.target.id == "command";
79
        }
80
76
81
        // Copy
77
82
        this.beforecopyHandle = dojo.connect(document, "beforecopy", function(e) {
83
            if (stopAction(e)) return;
78
84
            e.preventDefault();
79
85
            copynpaster.focus();
80
86
        });
81
87
82
88
        this.copyHandle = dojo.connect(document, "copy", function(e) {
89
            if (stopAction(e)) return;
90
83
91
            var selectionText = editor.getSelectionAsText();
84
92
            
85
93
            if (selectionText && selectionText != '') {
@@ -92,11 +100,15 @@ dojo.declare("bespin.editor.clipboard.DO
92
100
93
101
        // Cut
94
102
        this.beforecutHandle = dojo.connect(document, "beforecut", function(e) {
103
            if (stopAction(e)) return;
104
95
105
            e.preventDefault();
96
106
            copynpaster.focus();
97
107
        });
98
108
99
109
        this.cutHandle = dojo.connect(document, "cut", function(e) {
110
            if (stopAction(e)) return;
111
100
112
            var selectionObject = editor.getSelection();
101
113
102
114
            if (selectionObject) {
@@ -114,11 +126,15 @@ dojo.declare("bespin.editor.clipboard.DO
114
126
115
127
        // Paste
116
128
        this.beforepasteHandle = dojo.connect(document, "beforepaste", function(e) {
129
            if (stopAction(e)) return;
130
117
131
            e.preventDefault();
118
132
            copynpaster.focus();
119
133
        });
120
134
121
135
        this.pasteHandle = dojo.connect(document, "paste", function(e) {
136
            if (stopAction(e)) return;
137
122
138
            e.preventDefault();
123
139
            var args = bespin.editor.utils.buildArgs();    
124
140
            args.chunk = e.clipboardData.getData('text/plain');