Quellcode durchsuchen

added "redo cut element" button (cf #494)

Gildas vor 5 Jahren
Ursprung
Commit
3c848a6354

+ 4 - 0
_locales/de/messages.json

@@ -607,6 +607,10 @@
 		"message": "Wiederherstellen aller entfernten Elemente",
 		"description": "Title of the button 'Restore all removed elements' in the editor"
 	},
+	"editorRedoCutPage": {
+		"message": "Entfernen des zuletzt wiederhergestellten Elements",
+		"description": "Title of the button 'Remove last restored element' in the editor"
+	},
 	"editorSavePage": {
 		"message": "Speichern der Webseite",
 		"description": "Title of the button 'Save the page' in the editor"

+ 4 - 0
_locales/en/messages.json

@@ -607,6 +607,10 @@
 		"message": "Restore all removed elements",
 		"description": "Title of the button 'Restore all removed elements' in the editor"
 	},
+	"editorRedoCutPage": {
+		"message": "Remove last restored element",
+		"description": "Title of the button 'Remove last restored element' in the editor"
+	},
 	"editorSavePage": {
 		"message": "Save the page",
 		"description": "Title of the button 'Save the page' in the editor"

+ 4 - 0
_locales/es/messages.json

@@ -607,6 +607,10 @@
 		"message": "Restore all removed elements",
 		"description": "Title of the button 'Restore all removed elements' in the editor"
 	},
+	"editorRedoCutPage": {
+		"message": "Remove last restored element",
+		"description": "Title of the button 'Remove last restored element' in the editor"
+	},
 	"editorSavePage": {
 		"message": "Save the page",
 		"description": "Title of the button 'Save the page' in the editor"

+ 4 - 0
_locales/fr/messages.json

@@ -607,6 +607,10 @@
 		"message": "Restaurer tous les élements supprimés",
 		"description": "Title of the button 'Restore all removed elements' in the editor"
 	},
+	"editorRedoCutPage": {
+		"message": "Supprimer le dernier élement restauré",
+		"description": "Title of the button 'Remove last restored element' in the editor"
+	},
 	"editorSavePage": {
 		"message": "Sauver la page",
 		"description": "Title of the button 'Save the page' in the editor"

+ 4 - 0
_locales/ja/messages.json

@@ -607,6 +607,10 @@
 		"message": "削除されたすべての要素を復元する",
 		"description": "Title of the button 'Restore all removed elements' in the editor"
 	},
+	"editorRedoCutPage": {
+		"message": "Remove last restored element",
+		"description": "Title of the button 'Remove last restored element' in the editor"
+	},
 	"editorSavePage": {
 		"message": "ページを保存する",
 		"description": "Title of the button 'Save the page' in the editor"

+ 4 - 0
_locales/pl/messages.json

@@ -607,6 +607,10 @@
 		"message": "Przywróć wszystkie usunięte elementy",
 		"description": "Title of the button 'Restore all removed elements' in the editor"
 	},
+	"editorRedoCutPage": {
+		"message": "Remove last restored element",
+		"description": "Title of the button 'Remove last restored element' in the editor"
+	},
 	"editorSavePage": {
 		"message": "Zapisz stronę",
 		"description": "Title of the button 'Save the page' in the editor"

+ 4 - 0
_locales/ru/messages.json

@@ -607,6 +607,10 @@
 		"message": "Восстановить все удалённые элементы",
 		"description": "Title of the button 'Restore all removed elements' in the editor"
 	},
+	"editorRedoCutPage": {
+		"message": "Remove last restored element",
+		"description": "Title of the button 'Remove last restored element' in the editor"
+	},
 	"editorSavePage": {
 		"message": "Сохранить страницу",
 		"description": "Title of the button 'Save the page' in the editor"

+ 4 - 0
_locales/uk/messages.json

@@ -607,6 +607,10 @@
 		"message": "Restore all removed elements",
 		"description": "Title of the button 'Restore all removed elements' in the editor"
 	},
+	"editorRedoCutPage": {
+		"message": "Remove last restored element",
+		"description": "Title of the button 'Remove last restored element' in the editor"
+	},
 	"editorSavePage": {
 		"message": "Зберегти сторінку",
 		"description": "Title of the button 'Save the page' in the editor"

+ 4 - 0
_locales/zh_CN/messages.json

@@ -607,6 +607,10 @@
 		"message": "还原所有被移除的元素",
 		"description": "Title of the button 'Restore all removed elements' in the editor"
 	},
+	"editorRedoCutPage": {
+		"message": "Remove last restored element",
+		"description": "Title of the button 'Remove last restored element' in the editor"
+	},
 	"editorSavePage": {
 		"message": "保存该页面",
 		"description": "Title of the button 'Save the page' in the editor"

+ 4 - 0
_locales/zh_TW/messages.json

@@ -607,6 +607,10 @@
 		"message": "還原所有被移除的元素",
 		"description": "Title of the button 'Restore all removed elements' in the editor"
 	},
+	"editorRedoCutPage": {
+		"message": "Remove last restored element",
+		"description": "Title of the button 'Remove last restored element' in the editor"
+	},
 	"editorSavePage": {
 		"message": "保存該頁面",
 		"description": "Title of the button 'Save the page' in the editor"

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

@@ -43,6 +43,7 @@ singlefile.extension.ui.bg.editor = (() => {
 	const cutPageButton = document.querySelector(".cut-page-button");
 	const undoCutPageButton = document.querySelector(".undo-cut-page-button");
 	const undoAllCutPageButton = document.querySelector(".undo-all-cut-page-button");
+	const redoCutPageButton = document.querySelector(".redo-cut-page-button");
 	const savePageButton = document.querySelector(".save-page-button");
 
 	let tabData, tabDataContents = [];
@@ -63,6 +64,7 @@ singlefile.extension.ui.bg.editor = (() => {
 	cutPageButton.title = browser.i18n.getMessage("editorCutPage");
 	undoCutPageButton.title = browser.i18n.getMessage("editorUndoCutPage");
 	undoAllCutPageButton.title = browser.i18n.getMessage("editorUndoAllCutPage");
+	redoCutPageButton.title = browser.i18n.getMessage("editorRedoCutPage");
 	savePageButton.title = browser.i18n.getMessage("editorSavePage");
 
 	addYellowNoteButton.onclick = () => editorElement.contentWindow.postMessage(JSON.stringify({ method: "addNote", color: "note-yellow" }), "*");
@@ -167,6 +169,9 @@ singlefile.extension.ui.bg.editor = (() => {
 	undoAllCutPageButton.onclick = () => {
 		editorElement.contentWindow.postMessage(JSON.stringify({ method: "undoAllCutPage" }), "*");
 	};
+	redoCutPageButton.onclick = () => {
+		editorElement.contentWindow.postMessage(JSON.stringify({ method: "redoCutPage" }), "*");
+	};
 	savePageButton.onclick = () => {
 		savePage();
 	};

+ 17 - 6
extension/ui/content/content-ui-editor-web.js

@@ -809,7 +809,7 @@ table {
 
 	let NOTES_WEB_STYLESHEET, MASK_WEB_STYLESHEET, HIGHLIGHTS_WEB_STYLESHEET;
 	let selectedNote, anchorElement, maskNoteElement, maskPageElement, highlightSelectionMode, removeHighlightMode, resizingNoteMode, movingNoteMode, highlightColor, collapseNoteTimeout, cuttingMode;
-	let removedElements = [];
+	let removedElements = [], removedElementIndex = 0;
 
 	window.onmessage = async event => {
 		const message = JSON.parse(event.data);
@@ -868,13 +868,21 @@ table {
 			document.body.removeEventListener("mouseout", highlightElementToCut);
 		}
 		if (message.method == "undoCutPage") {
-			if (removedElements.length) {
-				removedElements.pop().classList.remove(REMOVED_CONTENT_CLASS);
+			if (removedElementIndex) {
+				removedElements[removedElementIndex - 1].classList.remove(REMOVED_CONTENT_CLASS);
+				removedElementIndex--;
 			}
 		}
 		if (message.method == "undoAllCutPage") {
-			while (removedElements.length) {
-				removedElements.pop().classList.remove(REMOVED_CONTENT_CLASS);
+			while (removedElementIndex) {
+				removedElements[removedElementIndex - 1].classList.remove(REMOVED_CONTENT_CLASS);
+				removedElementIndex--;
+			}
+		}
+		if (message.method == "redoCutPage") {
+			if (removedElementIndex < removedElements.length) {
+				removedElements[removedElementIndex].classList.add(REMOVED_CONTENT_CLASS);
+				removedElementIndex++;
 			}
 		}
 		if (message.method == "getContent") {
@@ -1184,7 +1192,9 @@ table {
 			let element = event.target;
 			if (document.documentElement != element && element.tagName.toLowerCase() != NOTE_TAGNAME) {
 				element.classList.add(REMOVED_CONTENT_CLASS);
-				removedElements.push(element);
+				removedElements[removedElementIndex] = element;
+				removedElementIndex++;
+				removedElements.length = removedElementIndex;
 				onUpdate(false);
 			}
 		}
@@ -1337,6 +1347,7 @@ table {
 		});
 		const article = new Readability(document, { classesToPreserve }).parse();
 		removedElements = [];
+		removedElementIndex = 0;
 		document.body.innerHTML = "";
 		const domParser = new DOMParser();
 		const doc = domParser.parseFromString(article.content, "text/html");

+ 1 - 0
extension/ui/pages/editor.html

@@ -44,6 +44,7 @@
 			<img type="button" class="cut-page-button cut-disabled" src="/extension/ui/resources/button_cut.png">
 			<img type="button" class="undo-cut-page-button" src="/extension/ui/resources/button_undo_cut.png">
 			<img type="button" class="undo-all-cut-page-button" src="/extension/ui/resources/button_undo_all_cut.png">
+			<img type="button" class="redo-cut-page-button" src="/extension/ui/resources/button_redo_cut.png">
 			<div class="separator"></div>
 		</div>
 		<div class="buttons">

BIN
extension/ui/resources/button_redo_cut.png