Просмотр исходного кода

add print button in the annotation editor

Gildas 5 лет назад
Родитель
Сommit
fd9dbfc0c3

+ 4 - 0
_locales/de/messages.json

@@ -643,6 +643,10 @@
 		"message": "Speichern der Webseite",
 		"description": "Title of the button 'Save the page' in the editor"
 	},
+	"editorPrintPage": {
+		"message": "Drucken der Webseite",
+		"description": "Title of the button 'Print the page' in the editor"
+	},	
 	"pendingsTitle": {
 		"message": "Pending saves",
 		"description": "Title of the pending save page 'Pending saves' in the editor"

+ 4 - 0
_locales/en/messages.json

@@ -643,6 +643,10 @@
 		"message": "Save the page",
 		"description": "Title of the button 'Save the page' in the editor"
 	},
+	"editorPrintPage": {
+		"message": "Print the page",
+		"description": "Title of the button 'Print the page' in the editor"
+	},
 	"pendingsTitle": {
 		"message": "Pending saves",
 		"description": "Title of the pending save page 'Pending saves' in the editor"

+ 4 - 0
_locales/es/messages.json

@@ -643,6 +643,10 @@
 		"message": "Save the page",
 		"description": "Title of the button 'Save the page' in the editor"
 	},
+	"editorPrintPage": {
+		"message": "Print the page",
+		"description": "Title of the button 'Print the page' in the editor"
+	},
 	"pendingsTitle": {
 		"message": "Pending saves",
 		"description": "Title of the pending save page 'Pending saves' in the editor"

+ 4 - 0
_locales/fr/messages.json

@@ -643,6 +643,10 @@
 		"message": "Sauver la page",
 		"description": "Title of the button 'Save the page' in the editor"
 	},
+	"editorPrintPage": {
+		"message": "Imprimer la page",
+		"description": "Title of the button 'Print the page' in the editor"
+	},
 	"pendingsTitle": {
 		"message": "Sauvegardes en cours",
 		"description": "Title of the pending save page 'Pending saves' in the editor"

+ 4 - 0
_locales/ja/messages.json

@@ -643,6 +643,10 @@
 		"message": "ページを保存する",
 		"description": "Title of the button 'Save the page' in the editor"
 	},
+	"editorPrintPage": {
+		"message": "Print the page",
+		"description": "Title of the button 'Print the page' in the editor"
+	},
 	"pendingsTitle": {
 		"message": "保留中の保存",
 		"description": "Title of the pending save page 'Pending saves' in the editor"

+ 4 - 0
_locales/pl/messages.json

@@ -643,6 +643,10 @@
 		"message": "Zapisz stronę",
 		"description": "Title of the button 'Save the page' in the editor"
 	},
+	"editorPrintPage": {
+		"message": "Print the page",
+		"description": "Title of the button 'Print the page' in the editor"
+	},
 	"pendingsTitle": {
 		"message": "Oczekujące zapisy",
 		"description": "Title of the pending save page 'Pending saves' in the editor"

+ 4 - 0
_locales/ru/messages.json

@@ -643,6 +643,10 @@
 		"message": "Сохранить страницу",
 		"description": "Title of the button 'Save the page' in the editor"
 	},
+	"editorPrintPage": {
+		"message": "Print the page",
+		"description": "Title of the button 'Print the page' in the editor"
+	},
 	"pendingsTitle": {
 		"message": "Отложенное сохранение",
 		"description": "Title of the pending save page 'Pending saves' in the editor"

+ 4 - 0
_locales/uk/messages.json

@@ -643,6 +643,10 @@
 		"message": "Зберегти сторінку",
 		"description": "Title of the button 'Save the page' in the editor"
 	},
+	"editorPrintPage": {
+		"message": "Print the page",
+		"description": "Title of the button 'Print the page' in the editor"
+	},
 	"pendingsTitle": {
 		"message": "Pending saves",
 		"description": "Title of the pending save page 'Pending saves' in the editor"

+ 4 - 0
_locales/zh_CN/messages.json

@@ -643,6 +643,10 @@
 		"message": "保存该页面",
 		"description": "Title of the button 'Save the page' in the editor"
 	},
+	"editorPrintPage": {
+		"message": "Print the page",
+		"description": "Title of the button 'Print the page' in the editor"
+	},
 	"pendingsTitle": {
 		"message": "挂起保存项",
 		"description": "Title of the pending save page 'Pending saves' in the editor"

+ 4 - 0
_locales/zh_TW/messages.json

@@ -643,6 +643,10 @@
 		"message": "保存該頁面",
 		"description": "Title of the button 'Save the page' in the editor"
 	},
+	"editorPrintPage": {
+		"message": "Print the page",
+		"description": "Title of the button 'Print the page' in the editor"
+	},
 	"pendingsTitle": {
 		"message": "掛起保存項",
 		"description": "Title of the pending save page 'Pending saves' in the editor"

+ 1 - 1
extension/lib/woleet/woleet.js

@@ -26,7 +26,7 @@
 this.woleet = this.woleet || (() => {
 
 	const urlService = "https://api.woleet.io/v1/anchor";
-	const apiKey = "__WOLEET_API_KEY__";
+	const apiKey = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhYzZmZTMzMi0wODNjLTRjZmMtYmYxNC0xNWU5MTJmMWY4OWIiLCJpYXQiOjE1NzYxNzQzNDV9.n31j9ctJj7R1Vjwyc5yd1d6Cmg0NDnpwSaLWsqtZJQA";
 
 	return {
 		anchor

+ 5 - 0
extension/ui/bg/ui-editor.js

@@ -47,6 +47,7 @@ singlefile.extension.ui.bg.editor = (() => {
 	const undoAllCutPageButton = document.querySelector(".undo-all-cut-page-button");
 	const redoCutPageButton = document.querySelector(".redo-cut-page-button");
 	const savePageButton = document.querySelector(".save-page-button");
+	const printPageButton = document.querySelector(".print-page-button");
 
 	let tabData, tabDataContents = [];
 
@@ -69,6 +70,7 @@ singlefile.extension.ui.bg.editor = (() => {
 	undoAllCutPageButton.title = browser.i18n.getMessage("editorUndoAllCutPage");
 	redoCutPageButton.title = browser.i18n.getMessage("editorRedoCutPage");
 	savePageButton.title = browser.i18n.getMessage("editorSavePage");
+	printPageButton.title = browser.i18n.getMessage("editorPrintPage");
 
 	addYellowNoteButton.onclick = () => editorElement.contentWindow.postMessage(JSON.stringify({ method: "addNote", color: "note-yellow" }), "*");
 	addPinkNoteButton.onclick = () => editorElement.contentWindow.postMessage(JSON.stringify({ method: "addNote", color: "note-pink" }), "*");
@@ -191,6 +193,9 @@ singlefile.extension.ui.bg.editor = (() => {
 	savePageButton.onclick = () => {
 		savePage();
 	};
+	printPageButton.onclick = () => {
+		editorElement.contentWindow.postMessage(JSON.stringify({ method: "printPage" }), "*");
+	};
 	let updatedResources = {};
 
 	window.onmessage = event => {

+ 7 - 0
extension/ui/content/content-ui-editor-web.js

@@ -909,6 +909,9 @@ table {
 			onUpdate(true);
 			window.parent.postMessage(JSON.stringify({ "method": "setContent", content: getContent(message.compressHTML, message.updatedResources) }), "*");
 		}
+		if (message.method == "printPage") {
+			window.print();
+		}
 	};
 	window.onresize = reflowNotes;
 
@@ -1316,6 +1319,10 @@ table {
 			window.parent.postMessage(JSON.stringify({ "method": "savePage" }), "*");
 			event.preventDefault();
 		}
+		if (event.key.toLowerCase() == "p" && event.ctrlKey) {
+			window.print();
+			event.preventDefault();
+		}
 	}
 
 	function highlightCutElement() {

+ 3 - 2
extension/ui/pages/editor.html

@@ -49,12 +49,13 @@
 			<div class="separator"></div>
 		</div>
 		<div class="buttons">
-			<img type="button" class="save-page-button" src="/extension/ui/resources/button_download.png">
+			<img type="button" class="print-page-button" src="/extension/ui/resources/button_print.png">
+			<img type="button" class="save-page-button" src="/extension/ui/resources/button_download.png">			
 		</div>
 	</div>
 	<iframe class="editor"
 		srcdoc="&lt;!DOCTYPE html&gt; &lt;body&gt;&lt;script src=/extension/ui/content/content-ui-editor-web.js&gt;&lt;/script&gt;&lt;script src=/lib/single-file/index.js&gt;&lt;/script&gt;&lt;script src=/lib/single-file/modules/html-serializer.js&gt;&lt;/script&gt;&lt;script src=/extension/lib/readability/Readability.js&gt;&lt;/script&gt;&lt;/script&gt;&lt;script src=/extension/lib/readability/Readability-readerable.js&gt;&lt;/script&gt;&lt;/body&gt;"
-		sandbox="allow-scripts"></iframe>
+		sandbox="allow-scripts allow-modals"></iframe>
 	<script type="text/javascript"
 		src="/extension/lib/single-file/browser-polyfill/chrome-browser-polyfill.js"></script>
 	<script src="/lib/single-file/index.js"></script>

+ 2 - 0
extension/ui/pages/help.html

@@ -518,6 +518,8 @@
 							class="icon button"> (undo all)
 					<li>redo removes by clicking the button <img src="../resources/button_redo_cut.png"
 							class="icon button"></li>
+					<li>print the page by clicking the button <img src="../resources/button_print.png"
+							class="icon button"> or by pressing <code>Ctrl-P</code></li>
 					<li>save the page by clicking the button <img src="../resources/button_download.png"
 							class="icon button"> or by pressing <code>Ctrl-S</code></li>
 				</ul>

BIN
extension/ui/resources/button_print.png