/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
#include "domstubs.idl"
interface nsISelectionController;
interface nsIDocumentStateListener;
interface nsIEditActionListener;
interface nsIInlineSpellChecker;
interface nsITransferable;
webidl Document;
webidl Element;
webidl Node;
webidl Selection;
%{C++
namespace mozilla {
class EditorBase;
class HTMLEditor;
class TextEditor;
} // namespace mozilla
%}
[scriptable, builtinclass, uuid(094be624-f0bf-400f-89e2-6a84baab9474)]
interface nsIEditor : nsISupports
{
%{C++
typedef short EDirection;
typedef short EStripWrappers;
%}
const short eNone = 0;
const short eNext = 1;
const short ePrevious = 2;
const short eNextWord = 3;
const short ePreviousWord = 4;
const short eToBeginningOfLine = 5;
const short eToEndOfLine = 6;
const short eStrip = 0;
const short eNoStrip = 1;
// If you want an HTML editor to behave as a plaintext editor, specify this
// flag. Note that this is always set if the instance is a text editor.
const long eEditorPlaintextMask = 0x0001;
// We don't support single line editor mode with HTML editors. Therefore,
// don't specify this for HTML editor.
const long eEditorSingleLineMask = 0x0002;
// We don't support password editor mode with HTML editors. Therefore,
// don't specify this for HTML editor.
const long eEditorPasswordMask = 0x0004;
// When the editor should be in readonly mode (currently, same as "disabled"),
// you can specify this flag with any editor instances. Note that setting
// this flag does not change the style of editor. This just changes the
// internal editor's readonly state.
const long eEditorReadonlyMask = 0x0008;
// If you want an HTML editor to work as an email composer, specify this flag.
// And you can specify this to text editor too for making spellchecker for
// the text editor should work exactly same as email composer's.
const long eEditorMailMask = 0x0020;
// allow the editor to set font: monospace on the root node
const long eEditorEnableWrapHackMask = 0x0040;
// If you want to move focus from an HTML editor with tab navigation,
// specify this flag. This is not available with text editors becase
// it's always tabbable.
// Note that if this is not specified, link navigation is also enabled in
// the editable content.
const long eEditorAllowInteraction = 0x0200;
// when this flag is set, the internal direction of the editor is RTL.
// if neither of the direction flags are set, the direction is determined
// from the text control's content node.
const long eEditorRightToLeft = 0x0800;
// when this flag is set, the internal direction of the editor is LTR.
const long eEditorLeftToRight = 0x1000;
// when this flag is set, the editor's text content is not spell checked.
const long eEditorSkipSpellCheck = 0x2000;
/*
* The valid values for newlines handling.
* Can't change the values unless we remove
* use of the pref.
*/
const long eNewlinesPasteIntact = 0;
const long eNewlinesPasteToFirst = 1;
const long eNewlinesReplaceWithSpaces = 2;
const long eNewlinesStrip = 3;
const long eNewlinesReplaceWithCommas = 4;
const long eNewlinesStripSurroundingWhitespace = 5;
readonly attribute Selection selection;
[can_run_script]
void setAttributeOrEquivalent(in Element element,
in AString sourceAttrName,
in AString sourceAttrValue,
in boolean aSuppressTransaction);
[can_run_script]
void removeAttributeOrEquivalent(in Element element,
in AString sourceAttrName,
in boolean aSuppressTransaction);
/** edit flags for this editor. May be set at any time. */
[setter_can_run_script] attribute unsigned long flags;
/**
* the MimeType of the document
*/
attribute AString contentsMIMEType;
/** Returns true if we have a document that is not marked read-only */
readonly attribute boolean isDocumentEditable;
/** Returns true if the current selection anchor is editable */
readonly attribute boolean isSelectionEditable;
/**
* the DOM Document this editor is associated with, refcounted.
*/
readonly attribute Document document;
/** the body element, i.e. the root of the editable document.
*/
readonly attribute Element rootElement;
/**
* the selection controller for the current presentation, refcounted.
*/
readonly attribute nsISelectionController selectionController;
/* ------------ Selected content removal -------------- */
/**
* DeleteSelection removes all nodes in the current selection.
* @param aDir if eNext, delete to the right (for example, the DEL key)
* if ePrevious, delete to the left (for example, the BACKSPACE key)
* @param stripWrappers If eStrip, strip any empty inline elements left
* behind after the deletion; if eNoStrip, don't. If in
* doubt, pass eStrip -- eNoStrip is only for if you're
* about to insert text or similar right after.
*/
[can_run_script]
void deleteSelection(in short action, in short stripWrappers);
/* ------------ Document info and file methods -------------- */
/** Returns true if the document has no *meaningful* content */
readonly attribute boolean documentIsEmpty;
/** Returns true if the document is modifed and needs saving */
readonly attribute boolean documentModified;
/**
* Sets document's character set. This is available only when the editor
* instance is an HTMLEditor since it's odd to change character set of
* parent document of `` and `