Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
epoc-editor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
learninglab
epoc
epoc-editor
Merge requests
!24
Resolve "Contextual menu"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Contextual menu"
153-contextual-menu
into
main
Overview
0
Commits
19
Pipelines
0
Changes
18
Merged
VIAUD Nathan
requested to merge
153-contextual-menu
into
main
2 years ago
Overview
0
Commits
19
Pipelines
0
Changes
18
Expand
Closes
#153 (closed)
0
0
Merge request reports
Compare
main
version 25
d44a7cfb
2 years ago
version 24
afbe73d8
2 years ago
version 23
df5dd647
2 years ago
version 22
633ab0c5
2 years ago
version 21
931ebd87
2 years ago
version 20
add3ee25
2 years ago
version 19
c4204e28
2 years ago
version 18
cc5073e5
2 years ago
version 17
23398be4
2 years ago
version 16
d5fb12e2
2 years ago
version 15
73363e7d
2 years ago
version 14
857cdd13
2 years ago
version 13
ee1f80da
2 years ago
version 12
1fff839e
2 years ago
version 11
d6084c36
2 years ago
version 10
e2798931
2 years ago
version 9
3607d0dd
2 years ago
version 8
a85fd8a3
2 years ago
version 7
3397adc4
2 years ago
version 6
549299c8
2 years ago
version 5
4990e1fe
2 years ago
version 4
52604aae
2 years ago
version 3
8f711d2e
2 years ago
version 2
4b24341b
2 years ago
version 1
b520b7bb
2 years ago
main (base)
and
latest version
latest version
de75a1f5
19 commits,
2 years ago
version 25
d44a7cfb
18 commits,
2 years ago
version 24
afbe73d8
17 commits,
2 years ago
version 23
df5dd647
16 commits,
2 years ago
version 22
633ab0c5
15 commits,
2 years ago
version 21
931ebd87
14 commits,
2 years ago
version 20
add3ee25
13 commits,
2 years ago
version 19
c4204e28
12 commits,
2 years ago
version 18
cc5073e5
11 commits,
2 years ago
version 17
23398be4
10 commits,
2 years ago
version 16
d5fb12e2
9 commits,
2 years ago
version 15
73363e7d
9 commits,
2 years ago
version 14
857cdd13
8 commits,
2 years ago
version 13
ee1f80da
7 commits,
2 years ago
version 12
1fff839e
6 commits,
2 years ago
version 11
d6084c36
5 commits,
2 years ago
version 10
e2798931
4 commits,
2 years ago
version 9
3607d0dd
3 commits,
2 years ago
version 8
a85fd8a3
2 commits,
2 years ago
version 7
3397adc4
3 commits,
2 years ago
version 6
549299c8
4 commits,
2 years ago
version 5
4990e1fe
3 commits,
2 years ago
version 4
52604aae
2 commits,
2 years ago
version 3
8f711d2e
2 commits,
2 years ago
version 2
4b24341b
1 commit,
2 years ago
version 1
b520b7bb
1 commit,
2 years ago
18 files
+
817
−
204
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
18
Search (e.g. *.vue) (Ctrl+P)
electron/components/contextMenu.js
+
235
−
38
Options
// const { Menu } = require('electron');
// const { BrowserWindow } = require('electron');
// const { sendToFrontend } = require('./ipc');
// const { screen } = require('electron');
// const contextTemplate = [
// {
// label: 'Ajouter',
// submenu: [
// {
// label: 'Ajouter du texte',
// click: () => { sendToFrontend(BrowserWindow.getFocusedWindow(),'addPage', { type: 'text', pos: getRelativeCursorPosition() }); }
// },
// {
// label: 'Ajouter une vidéo',
// click: () => { sendToFrontend(BrowserWindow.getFocusedWindow(), 'addPage', { type: 'video', pos: getRelativeCursorPosition() }); }
// }
// ]
// },
// ];
// function getRelativeCursorPosition() {
// const cursorPosition = screen.getCursorScreenPoint();
// // Get the position of the current window
// const windowPosition = BrowserWindow.getFocusedWindow().getPosition();
// // Calculate the cursor position relative to the current window
// const cursorPositionRelativeToWindow = {
// x: cursorPosition.x - windowPosition[0],
// y: cursorPosition.y - windowPosition[1]
// };
// return cursorPositionRelativeToWindow;
// }
//? the context menu is currently disabled
// module.exports.popupMenu = Menu.buildFromTemplate(contextTemplate);
\ No newline at end of file
const
{
BrowserWindow
}
=
require
(
'
electron
'
);
const
isDev
=
process
.
env
.
IS_DEV
===
'
true
'
;
function
getTemplateFromContext
(
callback
,
data
)
{
const
onClick
=
(
label
,
data
)
=>
{
callback
(
BrowserWindow
.
getFocusedWindow
(),
label
,
data
);
};
const
standardActions
=
[
{
label
:
'
Undo
'
,
click
:
()
=>
onClick
(
'
undo
'
)
},
{
label
:
'
Redo
'
,
click
:
()
=>
onClick
(
'
redo
'
)
}
];
const
menu
=
[];
if
(
data
.
context
===
'
flow
'
)
{
menu
.
push
(
{
label
:
'
Ajouter
'
,
submenu
:
getPagesFromContext
(
onClick
,
{
position
:
data
.
position
},
'
addPage
'
,
data
.
context
)
},
{
label
:
'
Coller ici
'
,
click
:
()
=>
onClick
(
'
paste
'
,
{
position
:
data
.
position
})
}
);
}
else
if
(
data
.
context
===
'
page
'
||
data
.
context
===
'
activity
'
||
data
.
context
===
'
pageWithQuestion
'
)
{
if
(
isDev
)
{
menu
.
push
(
{
label
:
'
Ajouter
'
,
submenu
:
getContentFromContext
(
onClick
,
{
id
:
data
.
id
},
data
.
context
),
}
);
}
menu
.
push
(
{
label
:
'
Insérer après
'
,
submenu
:
getPagesFromContext
(
onClick
,
{
id
:
data
.
id
},
'
insertAfter
'
,
data
.
context
)
},
{
label
:
'
Insérer avant
'
,
submenu
:
getPagesFromContext
(
onClick
,
{
id
:
data
.
id
},
'
insertBefore
'
,
data
.
context
)
},
{
label
:
'
Dupliquer
'
,
click
:
()
=>
onClick
(
'
duplicatePage
'
,
{
id
:
data
.
id
})
},
{
label
:
'
Supprimer
'
,
click
:
()
=>
onClick
(
'
deleteNode
'
,
{
id
:
data
.
id
})
},
{
type
:
'
separator
'
},
{
label
:
'
Copier
'
,
click
:
()
=>
onClick
(
'
copy
'
,
{
id
:
data
.
id
})
}
);
}
else
if
(
data
.
context
===
'
content
'
)
{
menu
.
push
(
{
label
:
'
Supprimer
'
,
click
:
()
=>
onClick
(
'
deleteContent
'
,
{
pageId
:
data
.
pageId
,
id
:
data
.
id
})
},
// {
// label: 'Dupliquer',
// click: () => onClick('duplicateContent', { pageId: data.pageId, id: data.id })
// },
);
}
else
if
(
data
.
context
===
'
chapter
'
)
{
menu
.
push
(
{
label
:
'
Insérer à la fin
'
,
submenu
:
getPagesFromContext
(
onClick
,
{
id
:
data
.
id
},
'
insertAtEnd
'
,
data
.
context
)
},
{
label
:
'
Insérer au début
'
,
submenu
:
getPagesFromContext
(
onClick
,
{
id
:
data
.
id
},
'
insertAtStart
'
,
data
.
context
)
},
{
label
:
'
Supprimer
'
,
click
:
()
=>
onClick
(
'
deleteNode
'
,
{
id
:
data
.
id
})
}
);
}
else
if
(
data
.
context
===
'
epoc
'
)
{
menu
.
push
(
{
label
:
'
Ajouter un nouveau chapitre
'
,
click
:
()
=>
onClick
(
'
addChapter
'
)
}
);
}
else
if
(
data
.
context
===
'
selection
'
)
{
menu
.
push
(
{
label
:
'
Supprimer
'
,
click
:
()
=>
onClick
(
'
deleteSelection
'
,
{
selection
:
data
.
selection
})
},
{
label
:
'
Copier
'
,
click
:
()
=>
onClick
(
'
copySelection
'
,
{
selection
:
data
.
selection
})
}
);
}
menu
.
push
({
type
:
'
separator
'
},
...
standardActions
);
return
menu
;
}
function
getPagesFromContext
(
onClick
,
data
,
event
,
context
)
{
const
contents
=
[
{
label
:
'
Ajouter une page Texte
'
,
click
:
()
=>
onClick
(
event
,
{
type
:
'
text
'
,
...
data
})
},
{
label
:
'
Ajouter une page Vidéo
'
,
click
:
()
=>
onClick
(
event
,
{
type
:
'
video
'
,
...
data
})
},
{
label
:
'
Ajouter une page Audio
'
,
click
:
()
=>
onClick
(
event
,
{
type
:
'
audio
'
,
...
data
})
},
];
const
questions
=
[
{
label
:
'
Ajouter une activité QCM
'
,
click
:
()
=>
onClick
(
event
,
{
type
:
'
choice
'
,
...
data
})
},
{
label
:
'
Ajouter une activité Drag & Drop
'
,
click
:
()
=>
onClick
(
event
,
{
type
:
'
drag-and-drop
'
,
...
data
})
},
{
label
:
'
Ajouter une activité Reorder
'
,
click
:
()
=>
onClick
(
event
,
{
type
:
'
reorder
'
,
...
data
})
},
{
label
:
'
Ajouter une activité Swipe
'
,
click
:
()
=>
onClick
(
event
,
{
type
:
'
swipe
'
,
...
data
})
},
{
label
:
'
Ajouter une activité Liste Déroulante
'
,
click
:
()
=>
onClick
(
event
,
{
type
:
'
dropdown-list
'
,
...
data
})
},
];
const
menu
=
[...
contents
,
{
type
:
'
separator
'
},
...
questions
];
if
(
context
===
'
flow
'
)
{
const
addChapter
=
[
{
type
:
'
separator
'
},
{
label
:
'
Ajouter un chapitre
'
,
click
:
()
=>
onClick
(
'
addChapter
'
)
}
];
return
[...
menu
,
...
addChapter
];
}
return
menu
;
}
function
getContentFromContext
(
onClick
,
data
,
context
)
{
const
questions
=
[
{
label
:
'
Ajouter une question QCM
'
,
click
:
()
=>
onClick
(
'
addContent
'
,
{
type
:
'
choice
'
,
...
data
})
},
{
label
:
'
Ajouter une question Drag & Drop
'
,
click
:
()
=>
onClick
(
'
addContent
'
,
{
type
:
'
drag-and-drop
'
,
...
data
})
},
{
label
:
'
Ajouter une question Reorder
'
,
click
:
()
=>
onClick
(
'
addContent
'
,
{
type
:
'
reorder
'
,
...
data
})
},
{
label
:
'
Ajouter une question Swipe
'
,
click
:
()
=>
onClick
(
'
addContent
'
,
{
type
:
'
swipe
'
,
...
data
})
},
{
label
:
'
Ajouter une question Liste Déroulante
'
,
click
:
()
=>
onClick
(
'
addContent
'
,
{
type
:
'
dropdown-list
'
,
...
data
})
}
];
const
contents
=
[
{
label
:
'
Ajouter un contenu Texte
'
,
click
:
()
=>
onClick
(
'
addContent
'
,
{
type
:
'
text
'
,
...
data
})
},
{
label
:
'
Ajouter un contenu Vidéo
'
,
click
:
()
=>
onClick
(
'
addContent
'
,
{
type
:
'
video
'
,
...
data
})
},
{
label
:
'
Ajouter un contenu Audio
'
,
click
:
()
=>
onClick
(
'
addContent
'
,
{
type
:
'
audio
'
,
...
data
})
}
];
if
(
context
===
'
activity
'
)
{
return
questions
;
}
else
if
(
context
===
'
page
'
)
{
return
[...
contents
,
{
type
:
'
separator
'
},
...
questions
];
}
else
if
(
context
===
'
pageWithQuestion
'
)
{
return
contents
;
}
}
module
.
exports
=
{
getTemplateFromContext
};
\ No newline at end of file
Loading