michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: #include "domstubs.idl" michael@0: michael@0: interface nsIEditor; michael@0: michael@0: [scriptable, uuid(24f3f4da-18a4-448d-876d-7360fefac029)] michael@0: michael@0: interface nsIEditingSession : nsISupports michael@0: { michael@0: /** michael@0: * Error codes when we fail to create an editor michael@0: * is placed in attribute editorStatus michael@0: */ michael@0: const long eEditorOK = 0; michael@0: const long eEditorCreationInProgress = 1; michael@0: const long eEditorErrorCantEditMimeType = 2; michael@0: const long eEditorErrorFileNotFound = 3; michael@0: const long eEditorErrorCantEditFramesets = 8; michael@0: const long eEditorErrorUnknown = 9; michael@0: michael@0: /** michael@0: * Status after editor creation and document loading michael@0: * Value is one of the above error codes michael@0: */ michael@0: readonly attribute unsigned long editorStatus; michael@0: michael@0: /** michael@0: * Make this window editable michael@0: * @param aWindow nsIDOMWindow, the window the embedder needs to make editable michael@0: * @param aEditorType string, "html" "htmlsimple" "text" "textsimple" michael@0: * @param aMakeWholeDocumentEditable if PR_TRUE make the whole document in michael@0: * aWindow editable, otherwise it's the michael@0: * embedder who should make the document michael@0: * (or part of it) editable. michael@0: * @param aInteractive if PR_FALSE turn off scripting and plugins michael@0: */ michael@0: void makeWindowEditable(in nsIDOMWindow window, in string aEditorType, michael@0: in boolean doAfterUriLoad, michael@0: in boolean aMakeWholeDocumentEditable, michael@0: in boolean aInteractive); michael@0: michael@0: /** michael@0: * Test whether a specific window has had its editable flag set; it may have an editor michael@0: * now, or will get one after the uri load. michael@0: * michael@0: * Use this, passing the content root window, to test if we've set up editing michael@0: * for this content. michael@0: */ michael@0: boolean windowIsEditable(in nsIDOMWindow window); michael@0: michael@0: /** michael@0: * Get the editor for this window. May return null michael@0: */ michael@0: nsIEditor getEditorForWindow(in nsIDOMWindow window); michael@0: michael@0: /** michael@0: * Setup editor and related support objects michael@0: */ michael@0: void setupEditorOnWindow(in nsIDOMWindow window); michael@0: michael@0: /** michael@0: * Destroy editor and related support objects michael@0: */ michael@0: void tearDownEditorOnWindow(in nsIDOMWindow window); michael@0: michael@0: void setEditorOnControllers(in nsIDOMWindow aWindow, michael@0: in nsIEditor aEditor); michael@0: michael@0: /** michael@0: * Disable scripts and plugins in aWindow. michael@0: */ michael@0: void disableJSAndPlugins(in nsIDOMWindow aWindow); michael@0: michael@0: /** michael@0: * Restore JS and plugins (enable/disable them) according to the state they michael@0: * were before the last call to disableJSAndPlugins. michael@0: */ michael@0: void restoreJSAndPlugins(in nsIDOMWindow aWindow); michael@0: michael@0: /** michael@0: * Removes all the editor's controllers/listeners etc and makes the window michael@0: * uneditable. michael@0: */ michael@0: void detachFromWindow(in nsIDOMWindow aWindow); michael@0: michael@0: /** michael@0: * Undos detachFromWindow(), reattaches this editing session/editor michael@0: * to the window. michael@0: */ michael@0: void reattachToWindow(in nsIDOMWindow aWindow); michael@0: michael@0: /** michael@0: * Whether this session has disabled JS and plugins. michael@0: */ michael@0: readonly attribute boolean jsAndPluginsDisabled; michael@0: }; michael@0: