Преглед изворни кода

Allow restoring all removed elements

Former-commit-id: 22fc1470ba4d5346b83e3421fb87db75d4b22b7c
Egor Duda пре 6 година
родитељ
комит
1a33153832

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

@@ -40,6 +40,7 @@ singlefile.extension.ui.bg.editor = (() => {
 	const addGreenNoteButton = document.querySelector(".add-note-green-button");
 	const editPageButton = document.querySelector(".edit-page-button");
 	const cutPageButton = document.querySelector(".cut-page-button");
+	const undoCutPageButton = document.querySelector(".undo-cut-page-button");
 	const savePageButton = document.querySelector(".save-page-button");
 
 	let tabData;
@@ -57,6 +58,7 @@ singlefile.extension.ui.bg.editor = (() => {
 	removeHighlightButton.title = browser.i18n.getMessage("editorRemoveHighlight");
 	editPageButton.title = browser.i18n.getMessage("editorEditPage");
 	cutPageButton.title = browser.i18n.getMessage("editorCutPage");
+	undoCutPageButton.title = browser.i18n.getMessage("editorUndoCutPage");
 	savePageButton.title = browser.i18n.getMessage("editorSavePage");
 
 	addYellowNoteButton.onclick = () => editorElement.contentWindow.postMessage(JSON.stringify({ method: "addNote", color: "note-yellow" }), "*");
@@ -148,6 +150,9 @@ singlefile.extension.ui.bg.editor = (() => {
 			editorElement.contentWindow.postMessage(JSON.stringify({ method: "disableCutPage" }), "*");
 		}
 	};
+	undoCutPageButton.onclick = () => {
+		editorElement.contentWindow.postMessage(JSON.stringify({ method: "undoCutPage" }), "*");
+	};
 	savePageButton.onclick = () => {
 		savePage();
 	};

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

@@ -127,6 +127,12 @@
 			document.body.removeEventListener ("mouseover", cutter);
 			document.body.removeEventListener ("mouseout", cutter);
 		}
+		if (message.method == "undoCutPage" ) {
+			var removedElements = document.getElementsByClassName("single-file-removed");
+			while (removedElements.length) {
+				removedElements[0].classList.remove ("single-file-removed");
+			}
+		}
 		if (message.method == "getContent") {
 			serializeShadowRoots(document);
 			const doc = document.cloneNode(true);

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

@@ -36,6 +36,7 @@
 				src="/extension/ui/resources/button_highlighter_delete.png">
 			<img type="button" class="edit-page-button edit-disabled" src="/extension/ui/resources/button_note_edit.png">
 			<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">
 			<div class="separator"></div>
 		</div>
 		<div class="buttons">

BIN
extension/ui/resources/button_undo_cut.png