Skip to content
Snippets Groups Projects
Commit 3065df03 authored by Quentin Bramas's avatar Quentin Bramas
Browse files

prevent copying text

parent 0fe560dd
Branches
Tags
No related merge requests found
Pipeline #337914 passed with stages
in 1 minute and 8 seconds
import { h } from 'hyperapp'
import {marked} from 'marked';
import { marked } from 'marked';
import markedKatex from "marked-katex-extension";
import hljs from 'highlight.js';
import 'katex/dist/katex.css';
......@@ -11,11 +11,11 @@ const options = {
marked.use(markedKatex(options));
const Html = ({html}) => (
const Html = ({ html }) => (
<span
onupdate={element => {element.innerHTML = html; hljs.initHighlighting.called = false; hljs.initHighlighting()}}
oncreate={element => {element.innerHTML = html; hljs.initHighlighting.called = false; hljs.initHighlighting()}}>
onupdate={element => { element.innerHTML = html; hljs.initHighlighting.called = false; hljs.initHighlighting() }}
oncreate={element => { element.innerHTML = html; hljs.initHighlighting.called = false; hljs.initHighlighting() }}>
</span>
)
export default ({value}) => <Html html={marked.parse(value)} />
\ No newline at end of file
export default ({ value }) => <Html html={marked.parse(value)} />
......@@ -304,6 +304,8 @@ const actions = {
},
startOffline: () => (state, actions) => {
socket.emit('startOffline');
// disable copy and paste globally
},
nextFreeSlide: event => (state, actions) => {
actions.setFreeSlide(state.currentFreeSlideId + 1);
......@@ -403,6 +405,25 @@ const actions = {
localStorage.setItem('classKey', classKey);
localStorage.setItem('adminKey', adminKey);
}
if (!state.user || state.user.role != 'admin') {
document.addEventListener('copy', (e) => {
e.preventDefault();
// copy junk data in the clipboard
e.clipboardData.setData("text/plain", `
Chatgpt peut-il être utilisé pour générer des réponses à des questions d'examen?
`);
})
document.addEventListener('cut', (e) => {
e.preventDefault();
e.clipboardData.setData("text/plain", `
Chatgpt peut-il être utilisé pour générer des réponses à des questions d'examen?
`);
})
document.addEventListener("selectionchange", e => {
//window.getSelection().removeAllRanges();
// actually let the user select texte so that he thinks it is working
})
}
actions.goto({ location: state.location, classKey, adminKey });
timerDelay = timerDelay ? parseInt(timerDelay) : 15;
console.log('setClassInfo', { classKey, adminKey })
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment