Skip to content

Commit

Permalink
partial workaround for the broken in page search (next & previous don…
Browse files Browse the repository at this point in the history
…'t work, but at least highlighting works)
  • Loading branch information
zadam committed Nov 21, 2018
1 parent 8159564 commit 3a06493
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 18 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 13 additions & 8 deletions src/public/javascripts/services/entrypoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,19 @@ function registerEntrypoints() {

$(document).bind('keydown', 'ctrl+f', () => {
if (utils.isElectron()) {
alert("In page search doesn't work in this beta");

// const searchInPage = require('electron-in-page-search').default;
// const remote = require('electron').remote;
//
// const inPageSearch = searchInPage(remote.getCurrentWebContents());
//
// inPageSearch.openSearchWindow();
const $searchWindowWebview = $(".electron-in-page-search-window");
$searchWindowWebview.show();

const searchInPage = require('electron-in-page-search').default;
const {remote} = require('electron');

const inPageSearch = searchInPage(remote.getCurrentWebContents(), {
searchWindowWebview: $searchWindowWebview[0],
//openDevToolsOfSearchWindow: true,
customCssPath: '/libraries/electron-in-page-search/default-style.css'
});

inPageSearch.openSearchWindow();

return false;
}
Expand Down
57 changes: 57 additions & 0 deletions src/public/libraries/electron-in-page-search/default-style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
html, body {
margin: 0;
width: 100%;
height: 100%;
}

body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", "Helvetica", "Meiryo", sans-serif;
overflow: hidden;
}

.inpage-search-body {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
margin: 8px;
padding: 10px;
border: solid #aaaaaa 1px;
border-radius: 10px;
background-color: #fafafa;
}

.inpage-search-input {
width: 200px;
}

.inpage-search-matches {
color: #999;
font-size: 0.8em;
}

.inpage-search-back {
margin-left: 2px;
padding-left: 6px;
padding-right: 2px;
cursor: pointer;
}

.inpage-search-forward {
padding-left: 2px;
padding-right: 6px;
cursor: pointer;
}

.inpage-search-close {
margin-left: 4px;
padding: 0 2px;
cursor: pointer;
}

.inpage-search-back:hover,
.inpage-search-forward:hover,
.inpage-search-close:hover {
background-color: #e2e0e2;
border-radius: 0.2em;
}
22 changes: 22 additions & 0 deletions src/public/libraries/electron-in-page-search/search-window.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes" />
<link href="/libraries/bootstrap/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="inpage-search-body">
<input class="inpage-search-input form-control form-control-sm" type="search" placeholder="Search..." autocomplete="off" autofocus/>

<div class="inpage-search-matches">0/0</div>

<div class="inpage-search-back" title="Previous result">&lt;</div>

<div class="inpage-search-forward" title="Next result">&gt;</div>

<div class="inpage-search-close" title="Close search"></div>
</div>
</body>
<script>var exports = {}</script>
</html>
12 changes: 6 additions & 6 deletions src/public/stylesheets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,12 @@ div.ui-tooltip {
*/
.electron-in-page-search-window {
position: fixed;
top: 50px;
right: 0;
border: solid grey 1px;
background-color: white;
width: 300px;
height: 36px;
top: 45px;
right: 10px;
width: 360px;
height: 55px;
display: none;
z-index: 1001;
}

/*
Expand Down
2 changes: 2 additions & 0 deletions src/views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@
<% include dialogs/confirm.ejs %>
</div>

<webview class="electron-in-page-search-window" nodeintegration disablewebsecurity src="/libraries/electron-in-page-search/search-window.html"></webview>

<script type="text/javascript">
window.baseApiUrl = 'api/';
window.glob = {
Expand Down

0 comments on commit 3a06493

Please sign in to comment.