Message-ID: <531023654.3410.1485853006826.JavaMail.confluence@ip-10-127-227-164> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_3409_1124706038.1485853006825" ------=_Part_3409_1124706038.1485853006825 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html The RichText Field Type

The RichText Field Type

This Field Type validates and= stores structured rich text, and exposes it in several formats.

Name Internal name Expected input
RichText
ezrichtext
mixed

=20 =20

Input expectations

Type Description Example
string
XML document in one of the Field Type's input fo= rmats as a string. See the example below.
DOMDocument

XML document in one of the Field = Type's input formats as a

DOMDocument object.

See the example below.
eZ\Publish\Core\FieldType\RichText\Value
An instance of the Field Type's Value object. See the example below.

Input formats

Field Type works with XML and also ex= pects an XML value as input, whether as a string, DOMDoc= ument object or Field Type's <= strong>Value object. When the value is giv= en as a string or a DOMDocument object, it will be checked for confo= rmance with one of the supported input formats, then dispatched to the appr= opriate converter, to be converted to the Field Type's internal format. No = conversion will be performed if providing the value in Field Type's interna= l format or as Field Type's Value object. In the latter case it will be expected that Value obje= ct holds the value in Field Type's internal format.

Currently supported input= formats are described in the table below:

Name Description
eZ Publish Docbook variant FieldType's internal format
XHTML5 editing format Typically used with in-browser HTML editor
Legacy eZXML format Compatibility with legacy eZXML format, used by = XmlText FieldType 

Examp= le of the Field Type's internal format

=20
<?xml version=3D"1.0" encoding=3D"UTF-8"?>
<section xmlns=3D"http://docbook.org/ns/docbook"
         xmlns:xlink=3D"http://www.w3.org/1999/xlink"
         xmlns:ezxhtml=3D"http://ez.no/xmlns/ezpublish/docbook/xhtml"
         xmlns:ezcustom=3D"http://ez.no/xmlns/ezpublish/docbook/custom"
         version=3D"5.0-variant ezpublish-1.0">
    <title ezxhtml:level=3D"2">This is a title.</title>
    <para ezxhtml:class=3D"paraClass">This is a paragraph.</para&g=
t;
</section>
=20

Exa= mple of the Field Type's XHTML5 edit format

This format is used by eZ Platform Online Editor and will change with it= 's needs as we continue to evolve this part of the UI.


=20
<?xml version=3D"1.0" encoding=3D"UTF-8"?>
<section xmlns=3D"http://ez.no/namespaces/ezpublish5/xhtml5/edit">
    <h2>This is a title.</h2>
    <p class=3D"paraClass">This is a paragraph.</p>
</section>
=20

For more information about internal format and input formats, see Field Type's conversion test fixtures on GitHub.

Example of using XML document in internal format as a string

=20
...
=20
$contentService =3D $repository->getContentService();
$contentTypeService =3D $repository->getContentTypeService();
=20
$contentType =3D $contentTypeService->loadContentTypeByIdentifier( "arti=
cle" );
$contentCreateStruct =3D $contentService->newContentCreateStruct( $conte=
ntType, "eng-GB" );
=20
$inputString =3D <<<DOCBOOK
<?xml version=3D"1.0" encoding=3D"UTF-8"?>
<section xmlns=3D"http://docbook.org/ns/docbook"
         xmlns:xlink=3D"http://www.w3.org/1999/xlink"
         xmlns:ezxhtml=3D"http://ez.no/xmlns/ezpublish/docbook/xhtml"
         xmlns:ezcustom=3D"http://ez.no/xmlns/ezpublish/docbook/custom"
         version=3D"5.0-variant ezpublish-1.0">
    <title ezxhtml:level=3D"2">This is a title.</title>
    <para ezxhtml:class=3D"paraClass">This is a paragraph.</para&g=
t;
</section>
DOCBOOK;
=20
$contentCreateStruct->setField( "description", $inputString );
=20
...
=20

Value object API

eZ\Publish\Core\FieldTy= pe\RichText\Value offers following properties:<= /p>

Property Type Description
xml
DOMDocument
Internal format value as an instance of DOMDocument.

REST API specifics

Creating or updat= ing Content

When creating RichText content with t= he REST API, it is possible to provide data as a string, using the "x= ml" fieldValue key:

=20
<fieldValue>
    <value key=3D"xml">&lt;?xml version=3D"1.0" encoding=3D"UTF-8=
"?&gt;
&lt;section xmlns=3D"http://docbook.org/ns/docbook" xmlns:xlink=3D"http=
://www.w3.org/1999/xlink" xmlns:ezxhtml=3D"http://ez.no/xmlns/ezpublish/doc=
book/xhtml" xmlns:ezcustom=3D"http://ez.no/xmlns/ezpublish/docbook/custom" =
version=3D"5.0-variant ezpublish-1.0"&gt;
&lt;title ezxhtml:level=3D"2"&gt;This is a title.&lt;/title&=
;gt;
&lt;/section&gt;
</value>
</fieldValue>
=20

When the value given over REST API is= transformed into a Field Type's Value object, it will be treated as a string. This means y= ou can use any supported input format for input over REST API.<= /span>

------=_Part_3409_1124706038.1485853006825--