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

The RichText FieldType

This format is used by eZ P

 

This FieldType is not officially supported yet, it will be as of first s= table eZ Platform release.

This FieldType validates and stores s= tructured richtext, 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 FieldType's input for= mats 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 FieldType's  Value  object. See the example below.

Input formats

FieldType works with XML and also exp= ects an XML value as input, wether as a string,  DOMDocu= ment object or FieldType's  = Value  object. When the value is= given as a string or a DOMDocument  object, it will be checked fo= r conformance to the one of the supported input formats, then dispatched to= the appropriate converter, to be converted to the FieldType's internal for= mat. No conversion will be performed if providing the value in FieldType's = internal format, or when providing the value as FieldType's  Value  object. In the latter= case it will be expected that Value  object holds the value in FieldType's in= ternal format.

Currently supported inp= ut 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  

Example of the FieldType's internal format

=20
<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

Example of the FieldType's XHTML5 edit form= at

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
<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 FieldType's conversion test fixtures on GitHub.

For example, ezxml does not use explicit level attributes for <header= > elements, instead <header> element levels are indicated through = the level of nesting inside <section> elements.

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

<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\Field= Type\RichText\Value  offers following properties:

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

REST API specifics

Creating or updating 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 FieldType's  Value  object, it will be treated as a string. This mean= s you can use any supported input format for input over REST AP= I.

------=_Part_3931_1517930269.1485855919976--