-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(prompt): add prompt support (#250)
* feat(context-menu): create webview on wayland * dynamic generate menu items on html * add context_menu.html * add check mouse hit on context-menu webview * fix: context menu prompt back to verso * feat(context-menu): on linux, handle selection * fix: disble right click on context menu * organize code * adding cfg target linux * fix(linux): shift context menu to avoid overflow, best effort * prompt temp * add alert prompt * refactor: move prompt and context menu to components * remove redundant import * feat(prompt): add ok/cancel, yes/no prompt * feat(prompt): add input prompt dialog * fix: add serde to all platform's dep * refactor: organize verso html files * update gitignore * refactor: remove dialog show method depends on Window * refactor: code clean * fix: don't show context menu when prompt exist * update css * fix(prompt): handle resize when prompt exists * fix(prompt): close prompt when navigate to new url * chore: restore default home page * chore: fix linux mod path, remove unused pipeline fn * feat: handle EmbedderMsg::PromptPermission * refactor: rename components to webview and move WebView into it
- Loading branch information
Showing
17 changed files
with
741 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<html> | ||
<head> | ||
<style> | ||
body { | ||
font-family: Arial, Helvetica, sans-serif; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 0; | ||
margin: 0; | ||
background-color: #7d818644; | ||
} | ||
.dialog { | ||
display: flex; | ||
background: #ffffff; | ||
width: 400px; | ||
min-height: 110px; | ||
max-height: 300px; | ||
flex-direction: column; | ||
align-items: center; | ||
border-radius: 10px; | ||
box-shadow: 0 0 50px #ccc; | ||
box-sizing: border-box; | ||
padding: 8px; | ||
gap: 8px; | ||
} | ||
.msg { | ||
display: inline-block; | ||
width: 100%; | ||
min-height: 90px; | ||
text-align: center; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="dialog"> | ||
<div id="msg" class="msg"></div> | ||
<button onclick="sendToVersoAndClose()">Ok</button> | ||
</div> | ||
</body> | ||
<script> | ||
let url = URL.parse(window.location.href); | ||
let msg = url.searchParams.get('msg'); | ||
|
||
// Set dialog message | ||
const msgEl = document.getElementById('msg'); | ||
msgEl.textContent = msg ?? ''; | ||
|
||
function sendToVersoAndClose() { | ||
window.alert(''); // Use as an IPC between Verso and WebView | ||
window.close(); | ||
} | ||
</script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<html> | ||
<head> | ||
<style> | ||
body { | ||
font-family: Arial, Helvetica, sans-serif; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 0; | ||
margin: 0; | ||
background-color: #7d818644; | ||
} | ||
.dialog { | ||
display: flex; | ||
background: #ffffff; | ||
width: 400px; | ||
min-height: 110px; | ||
max-height: 300px; | ||
flex-direction: column; | ||
align-items: center; | ||
border-radius: 10px; | ||
box-shadow: 0 0 50px #ccc; | ||
box-sizing: border-box; | ||
padding: 8px; | ||
gap: 8px; | ||
} | ||
.msg { | ||
display: inline-block; | ||
width: 100%; | ||
min-height: 90px; | ||
text-align: center; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="dialog"> | ||
<div id="msg" class="msg"></div> | ||
<div class="btn-group"> | ||
<button onclick="sendToVersoAndClose('cancel')">Cancel</button> | ||
<button onclick="sendToVersoAndClose('ok')">Ok</button> | ||
</div> | ||
</div> | ||
</body> | ||
<script> | ||
let url = URL.parse(window.location.href); | ||
let msg = url.searchParams.get('msg'); | ||
|
||
// Set dialog message | ||
const msgEl = document.getElementById('msg'); | ||
msgEl.textContent = msg ?? ''; | ||
|
||
function sendToVersoAndClose(action) { | ||
window.alert(action); // Use as an IPC between Verso and WebView | ||
window.close(); | ||
} | ||
</script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<html> | ||
<head> | ||
<style> | ||
body { | ||
font-family: Arial, Helvetica, sans-serif; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 0; | ||
margin: 0; | ||
background-color: #7d818644; | ||
} | ||
.dialog { | ||
display: flex; | ||
background: #ffffff; | ||
width: 400px; | ||
min-height: 110px; | ||
max-height: 300px; | ||
flex-direction: column; | ||
align-items: center; | ||
border-radius: 10px; | ||
box-shadow: 0 0 50px #ccc; | ||
box-sizing: border-box; | ||
padding: 8px; | ||
gap: 8px; | ||
} | ||
.msg { | ||
display: inline-block; | ||
width: 100%; | ||
min-height: 90px; | ||
text-align: center; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="dialog"> | ||
<div id="msg" class="msg"></div> | ||
<input type="text" id="input" /> | ||
<div class="btn-group"> | ||
<button onclick="sendToVersoAndClose('cancel')">Cancel</button> | ||
<button onclick="sendToVersoAndClose('ok')">Ok</button> | ||
</div> | ||
</div> | ||
</body> | ||
<script> | ||
const inputEl = document.getElementById('input'); | ||
const msgEl = document.getElementById('msg'); | ||
|
||
const params = URL.parse(window.location.href).searchParams; | ||
|
||
// Set input default value | ||
const defaultValue = params.get('defaultValue'); | ||
if (typeof defaultValue === 'string' || defaultValue instanceof String) { | ||
inputEl.defaultValue = defaultValue; | ||
} | ||
|
||
// Set dialog message | ||
const msg = params.get('msg'); | ||
msgEl.textContent = msg ?? ''; | ||
|
||
function sendToVersoAndClose(action) { | ||
// Use as an IPC between Verso and WebView | ||
window.alert( | ||
JSON.stringify({ | ||
action, | ||
value: inputEl.value, | ||
}) | ||
); | ||
window.close(); | ||
} | ||
</script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<html> | ||
<body> | ||
<div style="display: block"> | ||
<button onclick="window.alert('<a> HREF </a>');">alert</button> | ||
<button onclick="sendConfirm();">confirm</button> | ||
<button onclick="sendPrompt('');">prompt</button> | ||
<button onclick="sendPrompt(null, '>> default value >>');"> | ||
prompt with default value | ||
</button> | ||
</div> | ||
|
||
<div style="display: inline-block" id="result"></div> | ||
|
||
<script> | ||
const resultEl = document.getElementById('result'); | ||
|
||
function sendConfirm(text) { | ||
let result = window.confirm(text); | ||
resultEl.textContent = JSON.stringify(result); | ||
console.log(result); | ||
} | ||
|
||
function sendPrompt(text, defaultValue) { | ||
let result = window.prompt(text, defaultValue); | ||
resultEl.textContent = JSON.stringify(result); | ||
console.log(result); | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<html> | ||
<head> | ||
<style> | ||
body { | ||
font-family: Arial, Helvetica, sans-serif; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 0; | ||
margin: 0; | ||
background-color: #7d818644; | ||
} | ||
.dialog { | ||
display: flex; | ||
background: #ffffff; | ||
width: 400px; | ||
min-height: 110px; | ||
max-height: 300px; | ||
flex-direction: column; | ||
align-items: center; | ||
border-radius: 10px; | ||
box-shadow: 0 0 50px #ccc; | ||
box-sizing: border-box; | ||
padding: 8px; | ||
gap: 8px; | ||
} | ||
.msg { | ||
display: inline-block; | ||
width: 100%; | ||
min-height: 90px; | ||
text-align: center; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="dialog"> | ||
<div id="msg" class="msg"></div> | ||
<div class="btn-group"> | ||
<button onclick="sendToVersoAndClose('no')">No</button> | ||
<button onclick="sendToVersoAndClose('yes')">Yes</button> | ||
</div> | ||
</div> | ||
</body> | ||
<script> | ||
let url = URL.parse(window.location.href); | ||
let msg = url.searchParams.get('msg'); | ||
|
||
// Set dialog message | ||
const msgEl = document.getElementById('msg'); | ||
msgEl.textContent = msg ?? ''; | ||
|
||
function sendToVersoAndClose(action) { | ||
window.alert(action); // Use as an IPC between Verso and WebView | ||
window.close(); | ||
} | ||
</script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
mod webview; | ||
/// WebView | ||
pub use webview::{Panel, WebView}; | ||
/// Context Menu | ||
pub mod context_menu; | ||
/// Prompt Dialog | ||
pub mod prompt; |
Oops, something went wrong.