MCPcopy Create free account
hub / github.com/codecombat/codecombat / toggleACEPasteFeature

Function toggleACEPasteFeature

app/core/aceUtils.js:219–249  ·  view source on GitHub ↗
(editor, disabled = false)

Source from the content-addressed store, hash-verified

217}
218
219const toggleACEPasteFeature = function (editor, disabled = false) {
220 const pasteHandler = function (e) {
221 if (disabled) {
222 window.noty({
223 text: $.i18n.t('teachers.disable_paste_noty'),
224 type: 'warning',
225 })
226 e?.preventDefault?.()
227 e?.stopPropagation?.()
228 }
229 }
230 if (disabled) {
231 [
232 'drop', 'paste', 'contextmenu',
233 ].forEach(function (eventName) {
234 editor.container.addEventListener(eventName, pasteHandler, true)
235 })
236 editor.commands.addCommand({
237 name: 'breakThePaste',
238 bindKey: 'ctrl-v|ctrl-shift-v|cmd-v',
239 exec: pasteHandler,
240 })
241 editor.setOption('dragEnabled', false)
242 } else {
243 [
244 'drop', 'paste', 'contextmenu',
245 ].forEach(e => editor.container.removeEventListener(e, pasteHandler))
246 editor.commands.removeCommand('breakThePaste')
247 editor.setOption('dragEnabled', true)
248 }
249}
250
251module.exports = {
252 aceEditModes,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected