2002-03-14 22:11:14 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2001-03-27 23:11:08 +00:00
|
|
|
*
|
2012-05-21 11:12:37 +00:00
|
|
|
* 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/. */
|
2001-03-27 23:11:08 +00:00
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
#include "domstubs.idl"
|
2001-07-16 02:40:48 +00:00
|
|
|
|
2001-11-01 15:26:34 +00:00
|
|
|
interface nsIURI;
|
2007-01-07 11:01:35 +00:00
|
|
|
interface nsIContent;
|
2001-07-16 02:40:48 +00:00
|
|
|
interface nsISelectionController;
|
|
|
|
interface nsIDocumentStateListener;
|
|
|
|
interface nsIOutputStream;
|
|
|
|
interface nsITransactionManager;
|
|
|
|
interface nsITransaction;
|
2012-11-14 19:23:35 +00:00
|
|
|
interface nsIEditorObserver;
|
2001-07-16 02:40:48 +00:00
|
|
|
interface nsIEditActionListener;
|
2005-02-01 21:12:53 +00:00
|
|
|
interface nsIInlineSpellChecker;
|
2010-01-11 01:45:45 +00:00
|
|
|
interface nsITransferable;
|
2001-04-12 23:37:08 +00:00
|
|
|
|
2018-05-11 17:46:15 +00:00
|
|
|
webidl Document;
|
2018-04-27 03:35:18 +00:00
|
|
|
webidl Element;
|
2018-05-24 17:18:34 +00:00
|
|
|
webidl Node;
|
2018-05-08 17:52:36 +00:00
|
|
|
webidl Selection;
|
2018-04-27 03:35:18 +00:00
|
|
|
|
2016-12-20 12:47:31 +00:00
|
|
|
%{C++
|
|
|
|
namespace mozilla {
|
2017-08-04 06:01:36 +00:00
|
|
|
class EditorBase;
|
|
|
|
class HTMLEditor;
|
|
|
|
class TextEditor;
|
2016-12-20 12:47:31 +00:00
|
|
|
} // namespace mozilla
|
|
|
|
%}
|
|
|
|
|
2017-08-04 04:57:56 +00:00
|
|
|
[scriptable, builtinclass, uuid(094be624-f0bf-400f-89e2-6a84baab9474)]
|
2001-03-27 23:11:08 +00:00
|
|
|
interface nsIEditor : nsISupports
|
|
|
|
{
|
|
|
|
%{C++
|
|
|
|
typedef short EDirection;
|
2012-05-10 14:54:33 +00:00
|
|
|
typedef short EStripWrappers;
|
2001-03-27 23:11:08 +00:00
|
|
|
%}
|
|
|
|
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;
|
|
|
|
|
2012-05-10 14:54:33 +00:00
|
|
|
const short eStrip = 0;
|
|
|
|
const short eNoStrip = 1;
|
|
|
|
|
2020-01-24 08:33:42 +00:00
|
|
|
// only plain text entry is allowed via events
|
|
|
|
const long eEditorPlaintextMask = 0x0001;
|
|
|
|
// enter key and CR-LF handled specially
|
|
|
|
const long eEditorSingleLineMask = 0x0002;
|
|
|
|
// text is not entered into content, only a representative character
|
|
|
|
const long eEditorPasswordMask = 0x0004;
|
|
|
|
// editing events are disabled. Editor may still accept focus.
|
|
|
|
const long eEditorReadonlyMask = 0x0008;
|
|
|
|
// text input is limited to certain character types, use mFilter
|
2020-03-19 13:18:16 +00:00
|
|
|
const long eEditorFilterInputMask = 0x0010;
|
2020-01-24 08:33:42 +00:00
|
|
|
// use mail-compose editing rules
|
2020-03-19 13:18:16 +00:00
|
|
|
const long eEditorMailMask = 0x0020;
|
2020-01-24 08:33:42 +00:00
|
|
|
// allow the editor to set font: monospace on the root node
|
2020-03-19 13:18:16 +00:00
|
|
|
const long eEditorEnableWrapHackMask = 0x0040;
|
2020-01-24 08:33:42 +00:00
|
|
|
// bit for widgets (form elements)
|
2020-03-19 13:18:16 +00:00
|
|
|
const long eEditorWidgetMask = 0x0080;
|
2020-01-24 08:33:42 +00:00
|
|
|
// this HTML editor should not create css styles
|
2020-03-19 13:18:16 +00:00
|
|
|
const long eEditorNoCSSMask = 0x0100;
|
2020-01-24 08:33:42 +00:00
|
|
|
// whether HTML document specific actions are executed or not.
|
|
|
|
// e.g., if this flag is set, the editor doesn't handle Tab key.
|
|
|
|
// besides, anchors of HTML are not clickable.
|
2020-03-19 13:18:16 +00:00
|
|
|
const long eEditorAllowInteraction = 0x0200;
|
2020-01-24 08:33:42 +00:00
|
|
|
// when this is set, the characters in password editor are always masked.
|
|
|
|
// see bug 530367 for the detail.
|
2020-03-19 13:18:16 +00:00
|
|
|
const long eEditorDontEchoPassword = 0x0400;
|
2020-01-24 08:33:42 +00:00
|
|
|
// 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.
|
2020-03-19 13:18:16 +00:00
|
|
|
const long eEditorRightToLeft = 0x0800;
|
2020-01-24 08:33:42 +00:00
|
|
|
// when this flag is set, the internal direction of the editor is LTR.
|
2020-03-19 13:18:16 +00:00
|
|
|
const long eEditorLeftToRight = 0x1000;
|
2020-01-24 08:33:42 +00:00
|
|
|
// when this flag is set, the editor's text content is not spell checked.
|
2020-03-19 13:18:16 +00:00
|
|
|
const long eEditorSkipSpellCheck = 0x2000;
|
2020-01-24 08:33:42 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
|
2018-05-08 17:52:36 +00:00
|
|
|
readonly attribute Selection selection;
|
2002-03-14 22:11:14 +00:00
|
|
|
|
2019-03-30 11:55:29 +00:00
|
|
|
[can_run_script]
|
2018-04-27 03:35:18 +00:00
|
|
|
void setAttributeOrEquivalent(in Element element,
|
2002-03-14 22:11:14 +00:00
|
|
|
in AString sourceAttrName,
|
2002-09-17 12:04:59 +00:00
|
|
|
in AString sourceAttrValue,
|
|
|
|
in boolean aSuppressTransaction);
|
2019-03-30 11:55:29 +00:00
|
|
|
[can_run_script]
|
2018-04-27 03:35:18 +00:00
|
|
|
void removeAttributeOrEquivalent(in Element element,
|
2018-09-06 08:02:43 +00:00
|
|
|
in AString sourceAttrName,
|
2002-09-17 12:04:59 +00:00
|
|
|
in boolean aSuppressTransaction);
|
2001-03-27 23:11:08 +00:00
|
|
|
|
2002-03-14 22:11:14 +00:00
|
|
|
/** edit flags for this editor. May be set at any time. */
|
2020-10-09 02:37:47 +00:00
|
|
|
[setter_can_run_script] attribute unsigned long flags;
|
2001-03-27 23:11:08 +00:00
|
|
|
|
2002-09-18 19:42:38 +00:00
|
|
|
/**
|
|
|
|
* the MimeType of the document
|
|
|
|
*/
|
2020-09-15 14:40:54 +00:00
|
|
|
attribute AString contentsMIMEType;
|
2002-09-18 19:42:38 +00:00
|
|
|
|
|
|
|
/** Returns true if we have a document that is not marked read-only */
|
|
|
|
readonly attribute boolean isDocumentEditable;
|
|
|
|
|
2011-08-17 17:28:03 +00:00
|
|
|
/** Returns true if the current selection anchor is editable */
|
|
|
|
readonly attribute boolean isSelectionEditable;
|
|
|
|
|
2001-03-27 23:11:08 +00:00
|
|
|
/**
|
2002-03-14 22:11:14 +00:00
|
|
|
* the DOM Document this editor is associated with, refcounted.
|
2001-03-27 23:11:08 +00:00
|
|
|
*/
|
2018-05-11 17:46:15 +00:00
|
|
|
readonly attribute Document document;
|
2001-03-27 23:11:08 +00:00
|
|
|
|
2002-03-14 22:11:14 +00:00
|
|
|
/** the body element, i.e. the root of the editable document.
|
2001-03-27 23:11:08 +00:00
|
|
|
*/
|
2018-04-27 03:35:18 +00:00
|
|
|
readonly attribute Element rootElement;
|
2001-03-27 23:11:08 +00:00
|
|
|
|
2002-03-14 22:11:14 +00:00
|
|
|
/**
|
|
|
|
* the selection controller for the current presentation, refcounted.
|
2001-03-27 23:11:08 +00:00
|
|
|
*/
|
2002-03-14 22:11:14 +00:00
|
|
|
readonly attribute nsISelectionController selectionController;
|
2001-03-27 23:11:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* ------------ Selected content removal -------------- */
|
|
|
|
|
2015-05-28 15:58:42 +00:00
|
|
|
/**
|
2001-03-27 23:11:08 +00:00
|
|
|
* DeleteSelection removes all nodes in the current selection.
|
2002-09-18 19:42:38 +00:00
|
|
|
* @param aDir if eNext, delete to the right (for example, the DEL key)
|
|
|
|
* if ePrevious, delete to the left (for example, the BACKSPACE key)
|
2012-05-10 14:54:33 +00:00
|
|
|
* @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.
|
2001-03-27 23:11:08 +00:00
|
|
|
*/
|
2019-05-07 22:27:29 +00:00
|
|
|
[can_run_script]
|
2012-05-10 14:54:33 +00:00
|
|
|
void deleteSelection(in short action, in short stripWrappers);
|
2001-03-27 23:11:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* ------------ Document info and file methods -------------- */
|
2015-05-28 15:58:42 +00:00
|
|
|
|
2001-03-27 23:11:08 +00:00
|
|
|
/** Returns true if the document has no *meaningful* content */
|
2002-03-14 22:11:14 +00:00
|
|
|
readonly attribute boolean documentIsEmpty;
|
2015-05-28 15:58:42 +00:00
|
|
|
|
2001-03-27 23:11:08 +00:00
|
|
|
/** Returns true if the document is modifed and needs saving */
|
2002-03-14 22:11:14 +00:00
|
|
|
readonly attribute boolean documentModified;
|
2001-03-27 23:11:08 +00:00
|
|
|
|
|
|
|
/** Sets the current 'Save' document character set */
|
2019-05-08 06:26:25 +00:00
|
|
|
[can_run_script] // setter only
|
2003-06-17 16:40:34 +00:00
|
|
|
attribute ACString documentCharacterSet;
|
2001-03-27 23:11:08 +00:00
|
|
|
|
2002-03-14 22:11:14 +00:00
|
|
|
/** to be used ONLY when we need to override the doc's modification
|
|
|
|
* state (such as when it's saved).
|
2001-12-10 15:23:11 +00:00
|
|
|
*/
|
2019-05-09 07:37:51 +00:00
|
|
|
[can_run_script]
|
2002-03-14 22:11:14 +00:00
|
|
|
void resetModificationCount();
|
2001-12-10 15:23:11 +00:00
|
|
|
|
2002-03-14 22:11:14 +00:00
|
|
|
/** Gets the modification count of the document we are editing.
|
|
|
|
* @return the modification count of the document being edited.
|
|
|
|
* Zero means unchanged.
|
2001-12-10 15:23:11 +00:00
|
|
|
*/
|
2002-03-14 22:11:14 +00:00
|
|
|
long getModificationCount();
|
2001-12-10 15:23:11 +00:00
|
|
|
|
2002-03-14 22:11:14 +00:00
|
|
|
/** called each time we modify the document.
|
|
|
|
* Increments the modification count of the document.
|
|
|
|
* @param aModCount the number of modifications by which
|
|
|
|
* to increase or decrease the count
|
2001-12-10 15:23:11 +00:00
|
|
|
*/
|
2019-05-09 07:37:51 +00:00
|
|
|
[can_run_script]
|
2002-03-14 22:11:14 +00:00
|
|
|
void incrementModificationCount(in long aModCount);
|
2015-05-28 15:58:42 +00:00
|
|
|
|
2001-03-27 23:11:08 +00:00
|
|
|
/* ------------ Transaction methods -------------- */
|
|
|
|
|
2002-03-14 22:11:14 +00:00
|
|
|
/** transactionManager Get the transaction manager the editor is using.
|
2001-03-27 23:11:08 +00:00
|
|
|
*/
|
2017-03-21 11:57:15 +00:00
|
|
|
readonly attribute nsITransactionManager transactionManager;
|
2001-03-27 23:11:08 +00:00
|
|
|
|
2003-04-04 20:50:25 +00:00
|
|
|
/** doTransaction() fires a transaction.
|
2002-03-14 22:11:14 +00:00
|
|
|
* It is provided here so clients can create their own transactions.
|
2015-05-28 15:58:42 +00:00
|
|
|
* If a transaction manager is present, it is used.
|
2001-03-27 23:11:08 +00:00
|
|
|
* Otherwise, the transaction is just executed directly.
|
|
|
|
*
|
|
|
|
* @param aTxn the transaction to execute
|
|
|
|
*/
|
2019-05-09 07:37:51 +00:00
|
|
|
[can_run_script]
|
2003-04-04 20:50:25 +00:00
|
|
|
void doTransaction(in nsITransaction txn);
|
2001-03-27 23:11:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
/** turn the undo system on or off
|
2012-10-25 16:32:24 +00:00
|
|
|
* @param aEnable if PR_TRUE, the undo system is turned on if available
|
|
|
|
* if PR_FALSE the undo system is turned off if it
|
2002-03-14 22:11:14 +00:00
|
|
|
* was previously on
|
2012-10-25 16:32:24 +00:00
|
|
|
* @return if aEnable is PR_TRUE, returns NS_OK if
|
2002-03-14 22:11:14 +00:00
|
|
|
* the undo system could be initialized properly
|
2012-10-25 16:32:24 +00:00
|
|
|
* if aEnable is PR_FALSE, returns NS_OK.
|
2001-03-27 23:11:08 +00:00
|
|
|
*/
|
2002-03-14 22:11:14 +00:00
|
|
|
void enableUndo(in boolean enable);
|
|
|
|
|
|
|
|
/** undo reverses the effects of the last Do operation,
|
|
|
|
* if Undo is enabled in the editor.
|
|
|
|
* It is provided here so clients need no knowledge of whether
|
|
|
|
* the editor has a transaction manager or not.
|
|
|
|
* If a transaction manager is present, it is told to undo,
|
2015-05-28 15:58:42 +00:00
|
|
|
* and the result of that undo is returned.
|
2002-03-14 22:11:14 +00:00
|
|
|
* Otherwise, the Undo request is ignored and an
|
|
|
|
* error NS_ERROR_NOT_AVAILABLE is returned.
|
2001-03-27 23:11:08 +00:00
|
|
|
*
|
|
|
|
*/
|
2019-03-12 01:50:41 +00:00
|
|
|
[can_run_script]
|
2002-03-14 22:11:14 +00:00
|
|
|
void undo(in unsigned long count);
|
2001-03-27 23:11:08 +00:00
|
|
|
|
|
|
|
/** returns state information about the undo system.
|
2012-10-25 16:32:24 +00:00
|
|
|
* @param aIsEnabled [OUT] PR_TRUE if undo is enabled
|
|
|
|
* @param aCanUndo [OUT] PR_TRUE if at least one transaction is
|
2002-03-14 22:11:14 +00:00
|
|
|
* currently ready to be undone.
|
2001-03-27 23:11:08 +00:00
|
|
|
*/
|
2002-03-14 22:11:14 +00:00
|
|
|
void canUndo(out boolean isEnabled, out boolean canUndo);
|
|
|
|
|
|
|
|
/** redo reverses the effects of the last Undo operation
|
|
|
|
* It is provided here so clients need no knowledge of whether
|
|
|
|
* the editor has a transaction manager or not.
|
|
|
|
* If a transaction manager is present, it is told to redo and the
|
|
|
|
* result of the previously undone transaction is reapplied to the document.
|
|
|
|
* If no transaction is available for Redo, or if the document
|
|
|
|
* has no transaction manager, the Redo request is ignored and an
|
|
|
|
* error NS_ERROR_NOT_AVAILABLE is returned.
|
2001-03-27 23:11:08 +00:00
|
|
|
*
|
|
|
|
*/
|
2019-03-12 01:50:41 +00:00
|
|
|
[can_run_script]
|
2002-03-14 22:11:14 +00:00
|
|
|
void redo(in unsigned long count);
|
2001-03-27 23:11:08 +00:00
|
|
|
|
|
|
|
/** returns state information about the redo system.
|
2012-10-25 16:32:24 +00:00
|
|
|
* @param aIsEnabled [OUT] PR_TRUE if redo is enabled
|
|
|
|
* @param aCanRedo [OUT] PR_TRUE if at least one transaction is
|
2002-03-14 22:11:14 +00:00
|
|
|
currently ready to be redone.
|
2001-03-27 23:11:08 +00:00
|
|
|
*/
|
2002-03-14 22:11:14 +00:00
|
|
|
void canRedo(out boolean isEnabled, out boolean canRedo);
|
2001-03-27 23:11:08 +00:00
|
|
|
|
2002-03-14 22:11:14 +00:00
|
|
|
/** beginTransaction is a signal from the caller to the editor that
|
|
|
|
* the caller will execute multiple updates to the content tree
|
|
|
|
* that should be treated as a single logical operation,
|
2001-03-27 23:11:08 +00:00
|
|
|
* in the most efficient way possible.<br>
|
2002-03-14 22:11:14 +00:00
|
|
|
* All transactions executed between a call to beginTransaction and
|
|
|
|
* endTransaction will be undoable as an atomic action.<br>
|
|
|
|
* endTransaction must be called after beginTransaction.<br>
|
|
|
|
* Calls to beginTransaction can be nested, as long as endTransaction
|
|
|
|
* is called once per beginUpdate.
|
2001-03-27 23:11:08 +00:00
|
|
|
*/
|
2020-04-03 08:32:01 +00:00
|
|
|
[can_run_script]
|
2002-03-14 22:11:14 +00:00
|
|
|
void beginTransaction();
|
2001-03-27 23:11:08 +00:00
|
|
|
|
2002-03-14 22:11:14 +00:00
|
|
|
/** endTransaction is a signal to the editor that the caller is
|
|
|
|
* finished updating the content model.<br>
|
|
|
|
* beginUpdate must be called before endTransaction is called.<br>
|
|
|
|
* Calls to beginTransaction can be nested, as long as endTransaction
|
|
|
|
* is called once per beginTransaction.
|
2001-03-27 23:11:08 +00:00
|
|
|
*/
|
2019-05-09 07:37:51 +00:00
|
|
|
[can_run_script]
|
2002-03-14 22:11:14 +00:00
|
|
|
void endTransaction();
|
2001-03-27 23:11:08 +00:00
|
|
|
|
2018-08-01 11:16:30 +00:00
|
|
|
/**
|
|
|
|
* While setting the flag with this method to false, CreateElementTransaction,
|
|
|
|
* DeleteRangeTransaction, DeleteTextTransaction, InsertNodeTransaction,
|
|
|
|
* InsertTextTransaction and SplitNodeTransaction won't change Selection
|
|
|
|
* after modifying the DOM tree.
|
|
|
|
* Note that calling this with false does not guarantee that Selection won't
|
|
|
|
* be changed because other transaction may ignore this flag, editor itself
|
|
|
|
* may change selection, and current selection may become invalid after
|
|
|
|
* changing the DOM tree, etc.
|
|
|
|
* After calling this method with true, the caller should guarantee that
|
|
|
|
* Selection should be positioned where user expects.
|
|
|
|
*
|
|
|
|
* @param should false if you don't want above transactions to modify
|
|
|
|
* Selection automatically after modifying the DOM tree.
|
|
|
|
* Note that calling this with false does not guarantee
|
|
|
|
* that Selection is never changed.
|
|
|
|
*/
|
2002-03-14 22:11:14 +00:00
|
|
|
void setShouldTxnSetSelection(in boolean should);
|
2001-04-12 03:41:06 +00:00
|
|
|
|
2005-02-01 21:12:53 +00:00
|
|
|
/* ------------ Inline Spell Checking methods -------------- */
|
|
|
|
|
2005-12-05 18:07:33 +00:00
|
|
|
/** Returns the inline spell checker associated with this object. The spell
|
|
|
|
* checker is lazily created, so this function may create the object for
|
|
|
|
* you during this call.
|
|
|
|
* @param autoCreate If true, this will create a spell checker object
|
|
|
|
* if one does not exist yet for this editor. If false
|
|
|
|
* and the object has not been created, this function
|
|
|
|
* WILL RETURN NULL.
|
|
|
|
*/
|
|
|
|
nsIInlineSpellChecker getInlineSpellChecker(in boolean autoCreate);
|
2005-02-01 21:12:53 +00:00
|
|
|
|
2006-07-29 00:04:40 +00:00
|
|
|
/** Called when the user manually overrides the spellchecking state for this
|
|
|
|
* editor.
|
|
|
|
* @param enable The new state of spellchecking in this editor, as
|
|
|
|
* requested by the user.
|
|
|
|
*/
|
|
|
|
void setSpellcheckUserOverride(in boolean enable);
|
|
|
|
|
2001-03-27 23:11:08 +00:00
|
|
|
/* ------------ Clipboard methods -------------- */
|
|
|
|
|
|
|
|
/** cut the currently selected text, putting it into the OS clipboard
|
|
|
|
* What if no text is selected?
|
|
|
|
* What about mixed selections?
|
|
|
|
* What are the clipboard formats?
|
|
|
|
*/
|
2019-05-07 22:27:29 +00:00
|
|
|
[can_run_script]
|
2002-03-14 22:11:14 +00:00
|
|
|
void cut();
|
2001-03-27 23:11:08 +00:00
|
|
|
|
2019-07-29 06:21:14 +00:00
|
|
|
/**
|
|
|
|
* canCut() returns true if selected content is allowed to be copied to the
|
|
|
|
* clipboard and to be removed.
|
|
|
|
* Note that this always returns true if the editor is in a non-chrome
|
|
|
|
* HTML/XHTML document.
|
|
|
|
* FYI: Current user in script is only BlueGriffon.
|
|
|
|
*/
|
2002-03-14 22:11:14 +00:00
|
|
|
boolean canCut();
|
2015-01-15 21:47:56 +00:00
|
|
|
|
2001-03-27 23:11:08 +00:00
|
|
|
/** copy the currently selected text, putting it into the OS clipboard
|
|
|
|
* What if no text is selected?
|
|
|
|
* What about mixed selections?
|
|
|
|
* What are the clipboard formats?
|
|
|
|
*/
|
2002-03-14 22:11:14 +00:00
|
|
|
void copy();
|
2015-01-15 21:47:56 +00:00
|
|
|
|
2019-07-29 06:21:14 +00:00
|
|
|
/**
|
|
|
|
* canCopy() returns true if selected content is allowed to be copied to
|
|
|
|
* the clipboard.
|
|
|
|
* Note that this always returns true if the editor is in a non-chrome
|
|
|
|
* HTML/XHTML document.
|
|
|
|
* FYI: Current user in script is only BlueGriffon.
|
|
|
|
*/
|
2002-03-14 22:11:14 +00:00
|
|
|
boolean canCopy();
|
2015-01-15 21:47:56 +00:00
|
|
|
|
2001-03-27 23:11:08 +00:00
|
|
|
/** paste the text in the OS clipboard at the cursor position, replacing
|
|
|
|
* the selected text (if any)
|
|
|
|
*/
|
2019-03-12 01:55:03 +00:00
|
|
|
[can_run_script]
|
2019-04-25 07:14:39 +00:00
|
|
|
void paste(in long aClipboardType);
|
2001-03-27 23:11:08 +00:00
|
|
|
|
2010-01-11 01:45:45 +00:00
|
|
|
/** Paste the text in |aTransferable| at the cursor position, replacing the
|
|
|
|
* selected text (if any).
|
|
|
|
*/
|
2019-03-12 01:55:03 +00:00
|
|
|
[can_run_script]
|
2010-01-11 01:45:45 +00:00
|
|
|
void pasteTransferable(in nsITransferable aTransferable);
|
|
|
|
|
2001-03-27 23:11:08 +00:00
|
|
|
/** Can we paste? True if the doc is modifiable, and we have
|
|
|
|
* pasteable data in the clipboard.
|
|
|
|
*/
|
2019-04-25 07:14:39 +00:00
|
|
|
boolean canPaste(in long aClipboardType);
|
2001-03-27 23:11:08 +00:00
|
|
|
|
|
|
|
/* ------------ Selection methods -------------- */
|
|
|
|
|
|
|
|
/** sets the document selection to the entire contents of the document */
|
2019-03-26 10:06:43 +00:00
|
|
|
[can_run_script]
|
2002-03-14 22:11:14 +00:00
|
|
|
void selectAll();
|
2001-03-27 23:11:08 +00:00
|
|
|
|
Bug 662591 - HTMLEditor should set caret to start of first editable text node or before first editable inline node r=m_kato
Currently, HTMLEditor doesn't initialize caret position when it gets focus by
itself in most cases. Only when it's in designMode, it may move caret to the
first visible (not checking CSS actually).
In most cases, caret position is adjusted when EditorBase::InitializeSelection()
calls Selection::SetAncestorLimiter(). If selected range is outside of
new limiter, it moves caret to start of the new limiter. However, this is
really different behavior from the other browsers. The other browsers try
to move caret to the first editable text node or before the first editable
content such as <img>, <input>, etc.
This difference causes a serious incompatible issue with Draft.js. It doesn't
initialize caret position when it gets focus but it assumes that caret is
always set to before <br> element if there is no other content.
So, let's try to behave as what other browsers do as far as possible.
This patch makes editor behave as:
* if selection is already in the editing host except start of the editing host,
does nothing.
* if there is non-editable element before any editable node, move caret to
start of the editing host.
* if there is editable text node or element node which cannot have a text node,
move its start or before it.
* if there is no editable nodes which can contain text nodes, move caret to
start of the editing host.
Note that before applying this patch, in designMode, BeginningOfDocument() used
document element instead of <body> element. Therefore, it may set odd position
if <head> element has some text nodes with <script> or <style>. However,
this doesn't make sense and for making more consistent behavior between
designMode and contenteditable, this patch makes it use editing host (it's
<body> element if it's in designMode).
MozReview-Commit-ID: 5neYoTMq6Cc
--HG--
extra : rebase_source : c4d06b6864a221d7cd2833a007d73f7d67821e95
2018-03-02 05:20:25 +00:00
|
|
|
/**
|
|
|
|
* Collapses selection at start of the document. If it's an HTML editor,
|
|
|
|
* collapses selection at start of current editing host (<body> element if
|
|
|
|
* it's in designMode) instead. If there is a non-editable node before any
|
|
|
|
* editable text nodes or inline elements which can have text nodes as their
|
|
|
|
* children, collapses selection at start of the editing host. If there is
|
|
|
|
* an editable text node which is not collapsed, collapses selection at
|
|
|
|
* start of the text node. If there is an editable inline element which
|
|
|
|
* cannot have text nodes as its child, collapses selection at before the
|
|
|
|
* element node. Otherwise, collapses selection at start of the editing
|
|
|
|
* host.
|
|
|
|
*/
|
2002-03-14 22:11:14 +00:00
|
|
|
void beginningOfDocument();
|
2001-03-27 23:11:08 +00:00
|
|
|
|
|
|
|
/** sets the document selection to the end of the document */
|
2002-03-14 22:11:14 +00:00
|
|
|
void endOfDocument();
|
2001-03-27 23:11:08 +00:00
|
|
|
|
|
|
|
/* ------------ Node manipulation methods -------------- */
|
|
|
|
|
|
|
|
/**
|
2002-03-14 22:11:14 +00:00
|
|
|
* setAttribute() sets the attribute of aElement.
|
2001-03-27 23:11:08 +00:00
|
|
|
* No checking is done to see if aAttribute is a legal attribute of the node,
|
|
|
|
* or if aValue is a legal value of aAttribute.
|
|
|
|
*
|
|
|
|
* @param aElement the content element to operate on
|
|
|
|
* @param aAttribute the string representation of the attribute to set
|
|
|
|
* @param aValue the value to set aAttribute to
|
|
|
|
*/
|
2019-05-08 06:26:25 +00:00
|
|
|
[can_run_script]
|
2018-04-27 03:35:18 +00:00
|
|
|
void setAttribute(in Element aElement, in AString attributestr,
|
2002-03-14 22:11:14 +00:00
|
|
|
in AString attvalue);
|
2001-03-27 23:11:08 +00:00
|
|
|
|
|
|
|
/**
|
2002-03-14 22:11:14 +00:00
|
|
|
* removeAttribute() deletes aAttribute from the attribute list of aElement.
|
2001-03-27 23:11:08 +00:00
|
|
|
* If aAttribute is not an attribute of aElement, nothing is done.
|
|
|
|
*
|
|
|
|
* @param aElement the content element to operate on
|
|
|
|
* @param aAttribute the string representation of the attribute to get
|
|
|
|
*/
|
2019-05-08 05:09:56 +00:00
|
|
|
[can_run_script]
|
2018-04-27 03:35:18 +00:00
|
|
|
void removeAttribute(in Element aElement,
|
2002-03-14 22:11:14 +00:00
|
|
|
in AString aAttribute);
|
2001-03-27 23:11:08 +00:00
|
|
|
|
|
|
|
/**
|
2018-05-24 17:18:34 +00:00
|
|
|
* cloneAttributes() is similar to Node::cloneNode(),
|
2002-03-14 22:11:14 +00:00
|
|
|
* it assures the attribute nodes of the destination are identical
|
|
|
|
* with the source node by copying all existing attributes from the
|
|
|
|
* source and deleting those not in the source.
|
2018-05-24 17:18:34 +00:00
|
|
|
* This is used when the destination element already exists
|
2001-03-27 23:11:08 +00:00
|
|
|
*
|
|
|
|
* @param aDestNode the destination element to operate on
|
|
|
|
* @param aSourceNode the source element to copy attributes from
|
|
|
|
*/
|
2019-03-30 11:55:29 +00:00
|
|
|
[can_run_script]
|
2018-05-24 17:18:34 +00:00
|
|
|
void cloneAttributes(in Element aDestElement, in Element aSourceElement);
|
2001-03-27 23:11:08 +00:00
|
|
|
|
2015-05-28 15:58:42 +00:00
|
|
|
/**
|
2002-03-14 22:11:14 +00:00
|
|
|
* insertNode inserts aNode into aParent at aPosition.
|
|
|
|
* No checking is done to verify the legality of the insertion.
|
|
|
|
* That is the responsibility of the caller.
|
2001-03-27 23:11:08 +00:00
|
|
|
* @param aNode The DOM Node to insert.
|
|
|
|
* @param aParent The node to insert the new object into
|
|
|
|
* @param aPosition The place in aParent to insert the new node
|
|
|
|
* 0=first child, 1=second child, etc.
|
|
|
|
* any number > number of current children = last child
|
|
|
|
*/
|
2019-03-30 11:55:29 +00:00
|
|
|
[can_run_script]
|
2018-05-24 17:18:34 +00:00
|
|
|
void insertNode(in Node node,
|
|
|
|
in Node parent,
|
|
|
|
in long aPosition);
|
2001-03-27 23:11:08 +00:00
|
|
|
|
|
|
|
|
2015-05-28 15:58:42 +00:00
|
|
|
/**
|
2002-03-14 22:11:14 +00:00
|
|
|
* deleteNode removes aChild from aParent.
|
2001-03-27 23:11:08 +00:00
|
|
|
* @param aChild The node to delete
|
|
|
|
*/
|
2019-05-07 22:27:29 +00:00
|
|
|
[can_run_script]
|
2018-05-24 17:18:34 +00:00
|
|
|
void deleteNode(in Node child);
|
2001-03-27 23:11:08 +00:00
|
|
|
|
2002-03-14 22:11:14 +00:00
|
|
|
/* ------------ Output methods -------------- */
|
2001-03-27 23:11:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Output methods:
|
|
|
|
* aFormatType is a mime type, like text/plain.
|
|
|
|
*/
|
2002-03-25 22:39:19 +00:00
|
|
|
AString outputToString(in AString formatType,
|
|
|
|
in unsigned long flags);
|
2001-03-27 23:11:08 +00:00
|
|
|
|
2007-11-08 04:02:57 +00:00
|
|
|
/* ------------ Various listeners methods --------------
|
|
|
|
* nsIEditor holds strong references to the editor observers, action listeners
|
|
|
|
* and document state listeners.
|
|
|
|
*/
|
2001-03-27 23:11:08 +00:00
|
|
|
|
|
|
|
/** add an EditorObserver to the editors list of observers. */
|
2012-11-14 19:23:35 +00:00
|
|
|
void addEditorObserver(in nsIEditorObserver observer);
|
2001-03-27 23:11:08 +00:00
|
|
|
|
|
|
|
/** add an EditActionListener to the editors list of listeners. */
|
2002-03-14 22:11:14 +00:00
|
|
|
void addEditActionListener(in nsIEditActionListener listener);
|
2001-03-27 23:11:08 +00:00
|
|
|
|
|
|
|
/** Remove an EditActionListener from the editor's list of listeners. */
|
2002-03-14 22:11:14 +00:00
|
|
|
void removeEditActionListener(in nsIEditActionListener listener);
|
2001-03-27 23:11:08 +00:00
|
|
|
|
|
|
|
/** Add a DocumentStateListener to the editors list of doc state listeners. */
|
2002-03-14 22:11:14 +00:00
|
|
|
void addDocumentStateListener(in nsIDocumentStateListener listener);
|
2001-03-27 23:11:08 +00:00
|
|
|
|
|
|
|
/** Remove a DocumentStateListener to the editors list of doc state listeners. */
|
2002-03-14 22:11:14 +00:00
|
|
|
void removeDocumentStateListener(in nsIDocumentStateListener listener);
|
2001-03-27 23:11:08 +00:00
|
|
|
|
2016-12-20 12:47:31 +00:00
|
|
|
/**
|
|
|
|
* forceCompositionEnd() force the composition end
|
|
|
|
*/
|
|
|
|
void forceCompositionEnd();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* whether this editor has active IME transaction
|
|
|
|
*/
|
|
|
|
readonly attribute boolean composing;
|
2017-08-04 06:01:36 +00:00
|
|
|
|
2019-07-22 03:53:36 +00:00
|
|
|
/**
|
|
|
|
* unmask() is available only when the editor is a passwrod field. This
|
|
|
|
* unmasks characters in specified by aStart and aEnd. If there have
|
|
|
|
* already unmasked characters, they are masked when this is called.
|
|
|
|
* Note that if you calls this without non-zero `aTimeout`, you bear
|
|
|
|
* responsibility for masking password with calling `mask()`. I.e.,
|
|
|
|
* user inputting password won't be masked automacitally. If user types
|
|
|
|
* a new character and echo is enabled, unmasked range is expanded to
|
|
|
|
* including it.
|
|
|
|
*
|
2019-07-29 12:21:02 +00:00
|
|
|
* @param aStart Optional, first index to show the character. If you
|
|
|
|
* specify middle of a surrogate pair, this expands the
|
|
|
|
* range to include the prceding high surrogate
|
|
|
|
* automatically.
|
|
|
|
* If omitted, it means that all characters of the
|
|
|
|
* password becomes unmasked.
|
2019-07-22 03:56:33 +00:00
|
|
|
* @param aEnd Optional, next index of last unmasked character. If
|
|
|
|
* you specify middle of a surrogate pair, the expands
|
|
|
|
* the range to include the following low surrogate.
|
2019-07-22 03:53:36 +00:00
|
|
|
* If omitted or negative value, it means unmasking all
|
|
|
|
* characters after aStart. Specifying same index
|
|
|
|
* throws an exception.
|
|
|
|
* @param aTimeout Optional, specify milliseconds to hide the unmasked
|
|
|
|
* characters if you want to show them temporarily.
|
|
|
|
* If omitted or 0, it means this won't mask the characters
|
|
|
|
* automatically.
|
|
|
|
*/
|
|
|
|
[can_run_script, optional_argc] void unmask(
|
2019-07-29 12:21:02 +00:00
|
|
|
[optional] in unsigned long aStart,
|
2019-07-22 03:53:36 +00:00
|
|
|
[optional] in long long aEnd,
|
|
|
|
[optional] in unsigned long aTimeout);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mask() is available only when the editor is a password field. This masks
|
|
|
|
* all unmasked characters immediately.
|
|
|
|
*/
|
|
|
|
[can_run_script] void mask();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* These attributes are available only when the editor is a password field.
|
|
|
|
* unmaskedStart is first unmasked character index, or 0 if there is no
|
|
|
|
* unmasked characters.
|
|
|
|
* unmaskedEnd is next index of the last unmasked character. 0 means there
|
|
|
|
* is no unmasked characters.
|
|
|
|
*/
|
|
|
|
readonly attribute unsigned long unmaskedStart;
|
|
|
|
readonly attribute unsigned long unmaskedEnd;
|
|
|
|
|
2019-07-22 03:55:13 +00:00
|
|
|
/**
|
|
|
|
* autoMaskingEnabled is true if unmasked range and newly inputted characters
|
|
|
|
* are masked automatically. That's the default state. If false, until
|
|
|
|
* `mask()` is called, unmasked range and newly inputted characters are
|
|
|
|
* unmasked.
|
|
|
|
*/
|
|
|
|
readonly attribute boolean autoMaskingEnabled;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* passwordMask attribute is a mask character which is used to mask password.
|
|
|
|
*/
|
|
|
|
readonly attribute AString passwordMask;
|
|
|
|
|
2020-01-24 08:33:42 +00:00
|
|
|
/**
|
|
|
|
* The length of the contents in characters.
|
|
|
|
* XXX change this type to 'unsigned long'
|
|
|
|
*/
|
|
|
|
readonly attribute long textLength;
|
|
|
|
|
|
|
|
/** Get and set the body wrap width.
|
|
|
|
*
|
|
|
|
* Special values:
|
|
|
|
* 0 = wrap to window width
|
|
|
|
* -1 = no wrap at all
|
|
|
|
*/
|
|
|
|
attribute long wrapWidth;
|
|
|
|
|
|
|
|
/** Get and set newline handling.
|
|
|
|
*
|
|
|
|
* Values are the constants defined above.
|
|
|
|
*/
|
|
|
|
attribute long newlineHandling;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inserts a string at the current location,
|
|
|
|
* given by the selection.
|
|
|
|
* If the selection is not collapsed, the selection is deleted
|
|
|
|
* and the insertion takes place at the resulting collapsed selection.
|
|
|
|
*
|
|
|
|
* @param aString the string to be inserted
|
|
|
|
*/
|
|
|
|
[can_run_script]
|
|
|
|
void insertText(in AString aStringToInsert);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Insert a line break into the content model.
|
|
|
|
* The interpretation of a break is up to the implementation:
|
|
|
|
* it may enter a character, split a node in the tree, etc.
|
|
|
|
* This may be more efficient than calling InsertText with a newline.
|
|
|
|
*/
|
|
|
|
[can_run_script]
|
|
|
|
void insertLineBreak();
|
|
|
|
|
2017-08-04 06:01:36 +00:00
|
|
|
%{C++
|
|
|
|
/**
|
|
|
|
* AsEditorBase() returns a pointer to EditorBase class.
|
|
|
|
*
|
|
|
|
* In order to avoid circular dependency issues, this method is defined
|
|
|
|
* in mozilla/EditorBase.h. Consumers need to #include that header.
|
|
|
|
*/
|
|
|
|
inline mozilla::EditorBase* AsEditorBase();
|
|
|
|
inline const mozilla::EditorBase* AsEditorBase() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* AsTextEditor() returns a pointer to TextEditor class.
|
|
|
|
*
|
|
|
|
* In order to avoid circular dependency issues, this method is defined
|
|
|
|
* in mozilla/TextEditor.h. Consumers need to #include that header.
|
|
|
|
*/
|
|
|
|
inline mozilla::TextEditor* AsTextEditor();
|
|
|
|
inline const mozilla::TextEditor* AsTextEditor() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* AsHTMLEditor() returns a pointer to HTMLEditor class.
|
|
|
|
*
|
|
|
|
* In order to avoid circular dependency issues, this method is defined
|
|
|
|
* in mozilla/HTMLEditor.h. Consumers need to #include that header.
|
|
|
|
*/
|
|
|
|
inline mozilla::HTMLEditor* AsHTMLEditor();
|
|
|
|
inline const mozilla::HTMLEditor* AsHTMLEditor() const;
|
|
|
|
%}
|
2010-12-07 06:30:05 +00:00
|
|
|
};
|