Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,5 @@ src/content/.yarn/*
!src/content/.yarn/releases
!src/content/.yarn/sdks
!src/content/.yarn/versions

.vite/vitest/results.json
9 changes: 3 additions & 6 deletions src/BloomBrowserUI/bookEdit/editablePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { theOneBubbleManager, BubbleManager } from "./js/bubbleManager";

// This allows strong typing to be done for exported functions
export interface IPageFrameExports {
pageSelectionChanging(): void;
pageUnloading(): void;
disconnectForGarbageCollection(): void;
copySelection(): void;
Expand All @@ -38,10 +37,9 @@ export interface IPageFrameExports {
}

// This exports the functions that should be accessible from other IFrames or from C#.
// For example, editTabBundle.getEditablePageBundleExports().pageSelectionChanging() can be called.
// For example, editTabBundle.getEditablePageBundleExports().saveRequested() can be called.
import {
pageSelectionChanging,
getBodyContentForSavePage,
saveRequested,
userStylesheetContent,
pageUnloading,
disconnectForGarbageCollection,
Expand All @@ -53,8 +51,7 @@ import {
attachToCkEditor
} from "./js/bloomEditing";
export {
pageSelectionChanging,
getBodyContentForSavePage,
saveRequested,
userStylesheetContent,
pageUnloading,
disconnectForGarbageCollection,
Expand Down
18 changes: 11 additions & 7 deletions src/BloomBrowserUI/bookEdit/js/bloomEditing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import "jquery.hotkeys"; //makes the on(keydown work with keynames)
import "../../lib/jquery.resize"; // makes jquery resize work on all elements
import { getEditTabBundleExports } from "./bloomFrames";
import { showInvisibles, hideInvisibles } from "./showInvisibles";

import { postJson } from "../../utils/bloomApi";
//promise may be needed to run tests with phantomjs
//import promise = require('es6-promise');
//promise.Promise.polyfill();
Expand Down Expand Up @@ -1251,9 +1251,7 @@ export function localizeCkeditorTooltips(bar: JQuery) {
});
}

// This is invoked from C# when we are about to change pages. The C# code will save the changes
// to the page after we return from this (hopefully; certainly in debugging this is the case).
export const pageSelectionChanging = () => {
function removeOrigami() {
// We are mirroring the origami layoutToggleClickHandler() here, in case the user changes
// pages while the origami toggle in on.
// The DOM here is for just one page, so there's only ever one marginBox.
Expand All @@ -1263,10 +1261,16 @@ export const pageSelectionChanging = () => {
for (let i = 0; i < textLabels.length; i++) {
textLabels[i].remove();
}
};
}

// Called from C# by a RunJavaScript() in EditingView.CleanHtmlAndCopyToPageDom via
// editTabBundle.getEditablePageBundleExports().
export function saveRequested(forceFullSave: boolean) {
removeOrigami();
postJson("editView/saveHtml", {
forceFullSave: forceFullSave,
html: getBodyContentForSavePage(),
userStylesheetContent: userStylesheetContent()
});
}
export const getBodyContentForSavePage = () => {
const bubbleEditingOn = theOneBubbleManager.isComicEditingOn;
if (bubbleEditingOn) {
Expand Down
7 changes: 7 additions & 0 deletions src/BloomExe/Book/HtmlDom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ public HtmlDom(XmlDocument domToClone)
_dom = (XmlDocument)domToClone.Clone();
}

public static HtmlDom FromXmlNodeNoClone(XmlNode domToOwn)
{
var h = new HtmlDom();
h.RawDom.DocumentElement.AppendChild(h.RawDom.ImportNode(domToOwn, true));
return h;
}

/// <summary>
/// Make a DOM out of the input
/// </summary>
Expand Down
Loading