|
|
@@ -24,6 +24,7 @@ this.docHelper = this.docHelper || (() => {
|
|
|
const PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME = "data-single-file-preserved-space-element";
|
|
|
const WIN_ID_ATTRIBUTE_NAME = "data-frame-tree-win-id";
|
|
|
const RESPONSIVE_IMAGE_ATTRIBUTE_NAME = "data-single-file-responsive-image";
|
|
|
+ const INPUT_VALUE_ATTRIBUTE_NAME = "data-single-file-value";
|
|
|
|
|
|
return {
|
|
|
preProcessDoc,
|
|
|
@@ -32,7 +33,8 @@ this.docHelper = this.docHelper || (() => {
|
|
|
windowIdAttributeName,
|
|
|
preservedSpaceAttributeName,
|
|
|
removedContentAttributeName,
|
|
|
- responsiveImagesAttributeName
|
|
|
+ responsiveImagesAttributeName,
|
|
|
+ inputValueAttributeName
|
|
|
};
|
|
|
|
|
|
function preProcessDoc(doc, win, options) {
|
|
|
@@ -60,6 +62,7 @@ this.docHelper = this.docHelper || (() => {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+ retrieveInputValues(doc, options);
|
|
|
return {
|
|
|
canvasData: getCanvasData(doc),
|
|
|
stylesheetContents: getStylesheetContents(doc),
|
|
|
@@ -81,6 +84,7 @@ this.docHelper = this.docHelper || (() => {
|
|
|
doc.querySelectorAll("[" + preservedSpaceAttributeName(options.sessionId) + "]").forEach(element => element.removeAttribute(preservedSpaceAttributeName(options.sessionId)));
|
|
|
}
|
|
|
doc.querySelectorAll("[" + responsiveImagesAttributeName(options.sessionId) + "]").forEach(element => element.removeAttribute(responsiveImagesAttributeName(options.sessionId)));
|
|
|
+ doc.querySelectorAll("[" + inputValueAttributeName(options.sessionId) + "]").forEach(element => element.removeAttribute(inputValueAttributeName(options.sessionId)));
|
|
|
}
|
|
|
|
|
|
function responsiveImagesAttributeName(sessionId) {
|
|
|
@@ -99,6 +103,10 @@ this.docHelper = this.docHelper || (() => {
|
|
|
return WIN_ID_ATTRIBUTE_NAME + (sessionId ? "-" + sessionId : "");
|
|
|
}
|
|
|
|
|
|
+ function inputValueAttributeName(sessionId) {
|
|
|
+ return INPUT_VALUE_ATTRIBUTE_NAME + (sessionId ? "-" + sessionId : "");
|
|
|
+ }
|
|
|
+
|
|
|
function getCanvasData(doc) {
|
|
|
if (doc) {
|
|
|
const canvasData = [];
|
|
|
@@ -167,6 +175,18 @@ this.docHelper = this.docHelper || (() => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ function retrieveInputValues(doc, options) {
|
|
|
+ doc.querySelectorAll("input").forEach(input => input.setAttribute(inputValueAttributeName(options.sessionId), input.value));
|
|
|
+ doc.querySelectorAll("textarea").forEach(textarea => textarea.setAttribute(inputValueAttributeName(options.sessionId), textarea.value));
|
|
|
+ doc.querySelectorAll("select").forEach(select => {
|
|
|
+ select.querySelectorAll("option").forEach(option => {
|
|
|
+ if (option.selected) {
|
|
|
+ option.setAttribute(inputValueAttributeName(options.sessionId), "");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
function serialize(doc) {
|
|
|
const docType = doc.doctype;
|
|
|
let docTypeString = "";
|