(editor, disabled = false)
| 217 | } |
| 218 | |
| 219 | const 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 | |
| 251 | module.exports = { |
| 252 | aceEditModes, |
nothing calls this directly
no outgoing calls
no test coverage detected