LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
IAdvancedHTMLEditor Class Referenceabstract

Interface for HTML/WYSIWYG editors with some advanced functionality. More...

#include "iadvancedhtmleditor.h"

Classes

struct  CustomTag
 Describes a single custom tag. More...
 

Public Types

typedef QPair< QRegExp, QString > Replacement_t
 
typedef QList< Replacement_tReplacements_t
 
typedef QList< CustomTagCustomTags_t
 

Public Member Functions

virtual ~IAdvancedHTMLEditor ()
 
virtual void InsertHTML (const QString &html)=0
 Inserts the given HTML at the current cursor position. More...
 
virtual void SetCustomTags (const CustomTags_t &tags)=0
 Adds support for custom tags not present in HTML standard. More...
 
virtual QAction * AddInlineTagInserter (const QString &tagName, const QVariantMap &params)=0
 Adds a custom action to wrap selected text into given tag. More...
 
virtual void ExecJS (const QString &js)=0
 Executes the given js in the context of the content. More...
 

Detailed Description

Interface for HTML/WYSIWYG editors with some advanced functionality.

Custom tags

It is sometimes desirable to add support for custom tags not defined in HTML standards, like LJ's user tags. This is done via the SetCustomTags() method, which operates on a list of CustomTag structures.

Each custom tag consists of a tag name that is used to identify the tag, and the function that makes HTML out of the given tag with the given attributes and contents. The converter function is invoked each time the web view is should be re-rendered after HTML edit has been modified. See the documentation of CustomTag for more information.

All of the above is implemented using XML parsing, so the document should be a valid XML document as well.

Definition at line 36 of file iadvancedhtmleditor.h.

Member Typedef Documentation

◆ CustomTags_t

◆ Replacement_t

typedef QPair<QRegExp, QString> IAdvancedHTMLEditor::Replacement_t

Definition at line 41 of file iadvancedhtmleditor.h.

◆ Replacements_t

Constructor & Destructor Documentation

◆ ~IAdvancedHTMLEditor()

virtual IAdvancedHTMLEditor::~IAdvancedHTMLEditor ( )
inlinevirtual

Definition at line 39 of file iadvancedhtmleditor.h.

Member Function Documentation

◆ AddInlineTagInserter()

virtual QAction* IAdvancedHTMLEditor::AddInlineTagInserter ( const QString &  tagName,
const QVariantMap &  params 
)
pure virtual

Adds a custom action to wrap selected text into given tag.

For example, to insert an action to wrap selected text into <span style="font-weight: bold" id="sometext">...</span> one should call this function like this:

QVariantMap params;
params ["style"] = "font-weight: bold";
params ["id"] = "sometext";
auto action = editor->AddInlineTagInserter ("span", params);
action->setText ("Name of your action");
// further customize the action
Parameters
[in]tagNameThe name of the tag to be inserted.
[in]paramsThe parameters of the tag.

◆ ExecJS()

virtual void IAdvancedHTMLEditor::ExecJS ( const QString &  js)
pure virtual

Executes the given js in the context of the content.

Parameters
[in]jsThe JavaScript code to execute.

◆ InsertHTML()

virtual void IAdvancedHTMLEditor::InsertHTML ( const QString &  html)
pure virtual

Inserts the given HTML at the current cursor position.

This function is somewhat analogous to DOM's execCommand("insertHTML", ...).

Parameters
[in]htmlThe HTML to insert.

◆ SetCustomTags()

virtual void IAdvancedHTMLEditor::SetCustomTags ( const CustomTags_t tags)
pure virtual

Adds support for custom tags not present in HTML standard.

This function should be called before ITextEditor::SetContents().

See the IAdvancedHTMLEditor class reference for more information about tags mappings.

Parameters
[in]tagsThe tags mapping.

The documentation for this class was generated from the following file: