Skip to content

Commit

Permalink
Fix: Context menu does not appear in the inputs (Can't copy or paste)
Browse files Browse the repository at this point in the history
  • Loading branch information
ollm committed Mar 28, 2024
1 parent cf78f76 commit 91cf4c8
Show file tree
Hide file tree
Showing 21 changed files with 193 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Stuck in a loop trying to read an epub file when the epub or zip is corrupt [`6388a9e`](https://github.com/ollm/OpenComic/commit/6388a9ef8eb118e1d337fb6becd68ec64b5defc3)
- Next chapter button not work inscroll mode if last page is smaller than the window and "Adjust to width" is enabled [`2bbd49e`](https://github.com/ollm/OpenComic/commit/2bbd49e43f9bb96c2dc00f21494acd7a92820331)
- PDF.js does not load files that have a hash (#) in the name [`5691073`](https://github.com/ollm/OpenComic/commit/56910730d1b0241370565bce787508ba0811b9a9)
- Context menu does not appear in the inputs (Can't copy or paste)

## [v1.1.0](https://github.com/ollm/OpenComic/releases/tag/v1.1.0) (13-01-2024)

Expand Down
6 changes: 6 additions & 0 deletions languages/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
"list": "Llista"
},
"contextMenu": {
"undo": "Desfer",
"redo": "Refer",
"cut": "Retallar",
"copy": "Copiar",
"paste": "Enganxar",
"selectAll": "Selecciona-ho tot",
"remove": "Retirar",
"favorite": "Favorit",
"openFileLocation": "Obre la ubicació del fitxer",
Expand Down
6 changes: 6 additions & 0 deletions languages/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
"list": "Jako seznam"
},
"contextMenu": {
"undo": "",
"redo": "",
"cut": "",
"copy": "",
"paste": "",
"selectAll": "",
"remove": "Odstranit",
"favorite": "",
"openFileLocation": "",
Expand Down
6 changes: 6 additions & 0 deletions languages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
"list": "Liste"
},
"contextMenu": {
"undo": "",
"redo": "",
"cut": "",
"copy": "",
"paste": "",
"selectAll": "",
"remove": "Entfernen",
"favorite": "",
"openFileLocation": "",
Expand Down
6 changes: 6 additions & 0 deletions languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
"list": "List"
},
"contextMenu": {
"undo": "Undo",
"redo": "Redo",
"cut": "Cut",
"copy": "Copy",
"paste": "Paste",
"selectAll": "Select all",
"remove": "Remove",
"favorite": "Favorite",
"openFileLocation": "Open file location",
Expand Down
6 changes: 6 additions & 0 deletions languages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
"list": "Lista"
},
"contextMenu": {
"undo": "Deshacer",
"redo": "Rehacer",
"cut": "Cortar",
"copy": "Copiar",
"paste": "Pegar",
"selectAll": "Seleccionar todo",
"remove": "Retirar",
"favorite": "Favorito",
"openFileLocation": "Abrir ubicación del archivo",
Expand Down
6 changes: 6 additions & 0 deletions languages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
"list": "Liste"
},
"contextMenu": {
"undo": "",
"redo": "",
"cut": "",
"copy": "",
"paste": "",
"selectAll": "",
"remove": "Retirer",
"favorite": "",
"openFileLocation": "",
Expand Down
6 changes: 6 additions & 0 deletions languages/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
"list": "Lista"
},
"contextMenu": {
"undo": "",
"redo": "",
"cut": "",
"copy": "",
"paste": "",
"selectAll": "",
"remove": "Töröl",
"favorite": "",
"openFileLocation": "",
Expand Down
6 changes: 6 additions & 0 deletions languages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
"list": "Lista"
},
"contextMenu": {
"undo": "",
"redo": "",
"cut": "",
"copy": "",
"paste": "",
"selectAll": "",
"remove": "Rimuovi",
"favorite": "",
"openFileLocation": "",
Expand Down
6 changes: 6 additions & 0 deletions languages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
"list": "一覧"
},
"contextMenu": {
"undo": "",
"redo": "",
"cut": "",
"copy": "",
"paste": "",
"selectAll": "",
"remove": "削除",
"favorite": "",
"openFileLocation": "",
Expand Down
6 changes: 6 additions & 0 deletions languages/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
"list": ""
},
"contextMenu": {
"undo": "",
"redo": "",
"cut": "",
"copy": "",
"paste": "",
"selectAll": "",
"remove": "",
"favorite": "",
"openFileLocation": "",
Expand Down
6 changes: 6 additions & 0 deletions languages/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
"list": "Lista"
},
"contextMenu": {
"undo": "",
"redo": "",
"cut": "",
"copy": "",
"paste": "",
"selectAll": "",
"remove": "Remover",
"favorite": "",
"openFileLocation": "",
Expand Down
6 changes: 6 additions & 0 deletions languages/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
"list": "Список"
},
"contextMenu": {
"undo": "",
"redo": "",
"cut": "",
"copy": "",
"paste": "",
"selectAll": "",
"remove": "Удалить",
"favorite": "",
"openFileLocation": "",
Expand Down
6 changes: 6 additions & 0 deletions languages/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
"list": "Lista"
},
"contextMenu": {
"undo": "",
"redo": "",
"cut": "",
"copy": "",
"paste": "",
"selectAll": "",
"remove": "Ta bort",
"favorite": "Favoritmarkera",
"openFileLocation": "Öppna filplats",
Expand Down
6 changes: 6 additions & 0 deletions languages/th.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
"list": "รายการ"
},
"contextMenu": {
"undo": "",
"redo": "",
"cut": "",
"copy": "",
"paste": "",
"selectAll": "",
"remove": "นำออก",
"favorite": "เรื่องที่ชอบ",
"openFileLocation": "เปิดตำแหน่งไฟล์",
Expand Down
6 changes: 6 additions & 0 deletions languages/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
"list": "Danh sách"
},
"contextMenu": {
"undo": "",
"redo": "",
"cut": "",
"copy": "",
"paste": "",
"selectAll": "",
"remove": "Xóa",
"favorite": "Yêu thích",
"openFileLocation": "Mở tệp trong trình quản lý tệp",
Expand Down
6 changes: 6 additions & 0 deletions languages/zh-hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
"list": "列表"
},
"contextMenu": {
"undo": "",
"redo": "",
"cut": "",
"copy": "",
"paste": "",
"selectAll": "",
"remove": "移除",
"favorite": "收藏",
"openFileLocation": "打开文件所在位置",
Expand Down
6 changes: 6 additions & 0 deletions languages/zh-hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
"list": "列表"
},
"contextMenu": {
"undo": "",
"redo": "",
"cut": "",
"copy": "",
"paste": "",
"selectAll": "",
"remove": "移除",
"favorite": "",
"openFileLocation": "",
Expand Down
19 changes: 19 additions & 0 deletions scripts/opencomic.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,13 @@ async function startApp()
if(config.checkReleases)
checkReleases.check();

loadContextMenu();

handlebarsContext.indexHeaderTitle = language.global.comics;

template.loadContentRight('index.content.right.empty.html', false);
template.loadHeader('index.header.html', false);
template.loadGlobalElement('global.elements.menus.html', 'global-menus');
template.loadGlobalElement('index.elements.menus.html', 'menus');
dom.loadIndexContentLeft(false);

Expand Down Expand Up @@ -540,6 +543,22 @@ async function startApp()

}

var currentContextMenuInput = false;

async function loadContextMenu()
{
electronRemote.getCurrentWindow().webContents.on('context-menu', function(event, props) {

currentContextMenuInput = document.activeElement;

if(props.isEditable)
events.activeContextMenu('#global-input-menu');
else if(props.selectionText && props.selectionText.trim() !== '')
events.activeContextMenu('#global-selection-menu');

});
}

var ShoSho = false;

async function loadShoSho()
Expand Down
3 changes: 3 additions & 0 deletions templates/body.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<div class="global-elements">
<div class="hover body-small">
<div></div>
</div>
<div class="global-menus">

</div>
<div class="menus">

Expand Down
68 changes: 68 additions & 0 deletions templates/global.elements.menus.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<div class="menu" id="global-selection-menu">
<div class="menu-simple elevation-2" onclick="events.desactiveMenu('#index-context-menu');" style="z-index: 125; user-select: none;">
<div class="menu-simple-content">
<div>

<div class="menu-simple-element menu-simple-element-little context-menu-favorite gamepad-item" onclick="events.desactiveMenu('#global-selection-menu'); electronRemote.getCurrentWindow().webContents.copy();">
<i class="material-icon menu-simple-icon-first">content_copy</i>
<span>{{language.global.contextMenu.copy}}</span>
</div>

<div class="menu-simple-separator separator-remove"></div>

<div class="menu-simple-element menu-simple-element-little context-menu-remove gamepad-item" onclick="events.desactiveMenu('#global-selection-menu'); electronRemote.getCurrentWindow().webContents.selectAll();">
<i class="material-icon menu-simple-icon-first">select_all</i>
{{language.global.contextMenu.selectAll}}
</div>

</div>
</div>
</div>
<div class="menu-close" onclick="events.desactiveMenu('#global-selection-menu');" oncontextmenu="events.desactiveMenu('#global-selection-menu');" style="z-index: 124; user-select: none;"></div>
</div>


<div class="menu" id="global-input-menu">
<div class="menu-simple elevation-2" onclick="events.desactiveMenu('#index-context-menu');" style="z-index: 125; user-select: none;">
<div class="menu-simple-content">
<div>

<div class="menu-simple-element menu-simple-element-little context-menu-favorite gamepad-item" onclick="events.desactiveMenu('#global-input-menu'); currentContextMenuInput.focus(); electronRemote.getCurrentWindow().webContents.cut();">
<i class="material-icon menu-simple-icon-first">content_cut</i>
<span>{{language.global.contextMenu.cut}}</span>
</div>

<div class="menu-simple-element menu-simple-element-little context-menu-favorite gamepad-item" onclick="events.desactiveMenu('#global-input-menu'); currentContextMenuInput.focus(); electronRemote.getCurrentWindow().webContents.copy();">
<i class="material-icon menu-simple-icon-first">content_copy</i>
<span>{{language.global.contextMenu.copy}}</span>
</div>

<div class="menu-simple-element menu-simple-element-little context-menu-favorite gamepad-item" onclick="events.desactiveMenu('#global-input-menu'); currentContextMenuInput.focus(); electronRemote.getCurrentWindow().webContents.paste();">
<i class="material-icon menu-simple-icon-first">content_paste</i>
<span>{{language.global.contextMenu.paste}}</span>
</div>

<div class="menu-simple-separator separator-remove"></div>

<div class="menu-simple-element menu-simple-element-little context-menu-remove gamepad-item" onclick="events.desactiveMenu('#global-input-menu'); currentContextMenuInput.focus(); electronRemote.getCurrentWindow().webContents.selectAll();">
<i class="material-icon menu-simple-icon-first">select_all</i>
{{language.global.contextMenu.selectAll}}
</div>

<div class="menu-simple-separator separator-remove"></div>

<div class="menu-simple-element menu-simple-element-little context-menu-favorite gamepad-item" onclick="events.desactiveMenu('#global-input-menu'); currentContextMenuInput.focus(); electronRemote.getCurrentWindow().webContents.undo();">
<i class="material-icon menu-simple-icon-first">undo</i>
<span>{{language.global.contextMenu.undo}}</span>
</div>

<div class="menu-simple-element menu-simple-element-little context-menu-favorite gamepad-item" onclick="events.desactiveMenu('#global-input-menu'); currentContextMenuInput.focus(); electronRemote.getCurrentWindow().webContents.redo();">
<i class="material-icon menu-simple-icon-first">redo</i>
<span>{{language.global.contextMenu.redo}}</span>
</div>

</div>
</div>
</div>
<div class="menu-close" onclick="events.desactiveMenu('#global-input-menu');" oncontextmenu="events.desactiveMenu('#global-input-menu');" style="z-index: 124; user-select: none;"></div>
</div>

0 comments on commit 91cf4c8

Please sign in to comment.