LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
IAdvancedHTMLEditor::CustomTag Struct Reference

Describes a single custom tag. More...

#include "iadvancedhtmleditor.h"

Public Types

enum class  TagType {
  Empty ,
  Inline ,
  Block
}
 

Public Attributes

QString TagName_
 The name of the custom tag, like lj.
 
TagType TagType_ = TagType::Inline
 
std::function< void(QDomElement &)> ToKnown_
 The converter of an instance of the tag to HTML.
 
std::function< bool(QDomElement &)> FromKnown_
 The converter of an instance of the tag from HTML.
 

Detailed Description

Describes a single custom tag.

Definition at line 46 of file iadvancedhtmleditor.h.

Member Enumeration Documentation

◆ TagType

Enumerator
Empty 
Inline 
Block 

Definition at line 52 of file iadvancedhtmleditor.h.

Member Data Documentation

◆ FromKnown_

std::function<bool (QDomElement&)> IAdvancedHTMLEditor::CustomTag::FromKnown_

The converter of an instance of the tag from HTML.

This function is invoked to convert an instance of the tag (passed as a QDomElement) from HTML. The conversion should be done in-place: the resulting XML should be contained in the passed QDomElement.

An example function that turns back the boldified <lj user="$username"/> got from CustomTag::ToKnown_:

[] (QDomElement& elem)
{
const auto& user = elem.text ();
elem.setTagName ("lj");
elem.setAttribute ("user", user);
const auto& childNodes = elem.childNodes ();
while (!childNodes.isEmpty ())
elem.removeChild (childNodes.at (0));
}

One can leave this function unset, in this case the tag will marked as non-modifyable.

This function should return true if the convertation succeeded, otherwise it should return false.

Definition at line 113 of file iadvancedhtmleditor.h.

◆ TagName_

QString IAdvancedHTMLEditor::CustomTag::TagName_

The name of the custom tag, like lj.

Definition at line 50 of file iadvancedhtmleditor.h.

◆ TagType_

TagType IAdvancedHTMLEditor::CustomTag::TagType_ = TagType::Inline

Definition at line 59 of file iadvancedhtmleditor.h.

◆ ToKnown_

std::function<void (QDomElement&)> IAdvancedHTMLEditor::CustomTag::ToKnown_

The converter of an instance of the tag to HTML.

This function is invoked to convert an instance of the tag (passed as a QDomElement) to HTML. The conversion should be done in-place: the resulting HTML should be contained in the passed QDomElement.

An example function that boldifies <lj user="$username"/>:

[] (QDomElement& elem)
{
const auto& user = elem.attribute ("user");
elem.setTagName ("strong");
elem.removeAttribute ("user");
elem.appendChild (elem.ownerDocument ().createTextNode (user));
}

Definition at line 81 of file iadvancedhtmleditor.h.


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