Document Modelling

Text fields

Model text fields in Sophora.

Text

There are multiple options to configure an input field as text. A few parameters are available to all of them:

Parameters
ParameterDescriptionDefaultRange of Values
Default ValueYou can define a default text which will be assigned to this property initially in every new document. The default value will be assigned just once; if you alter or delete the content of the property, the default value will not be reassigned to it under any circumstances.An arbitrary string
Character CounterDetermine, whether a character counter should be displayed next to the input field. A maximum is displayed if the parameter Max. Character Count is configured.falsetrue/false
Number of LinesThis determines the number of lines the input field will display at the same time. For example, if you set it to 2, the input field will always have a height of 2 text lines. You still may enter more lines of text, you then can scroll up and down within text field. Solely if Number of Lines is set to 1, there will always be just a single text line and you also cannot enter paragraphs.1positive integers
Validation ExpressionYou can configure a regular expression the text in the input field is checked against, for example if the field should only contain lowercase characters. If a user violates this regex, he cannot save the document.See here

Text

This field may only contain unformatted plain text.

Parameters
ParameterDescriptionDefaultRange of Values
Max. Character Count
###
Specify a limit for the number of characters this field should contain. If the number is exceeded it is still possible to save the document, yet a warning will be displayed to the user. The maximum is also displayed in the character counter.UnlimitedPositive integers
Spell Checking AvailableDetermine, whether spell checking should be available within this input field.falsetrue/false
Inherit Structure ValueSee herefalsetrue/false
PlaceholderYou can set a placeholder text for the field which will be displayed whenever the field is empty. Unlike the default text, the placeholder text does reappear even when the property has been altered. The placeholder text may contain bold or italic letters, even if the property itself does not support markup.An arbitrary string

Text (Multi)

A text (multi) property may contain multiple text fields, though it is not possible to enrich them with any kind of markup. Nevertheless, you still can make spell checking available and you may also set a maximum number of text fields (by default, there is no limitation on the number of text fields within this property).

Text (Fixed Size)

This is an input field for content depending on size and font. The width, height and font of the field each can be configured by parameters. The field wraps words at the end of text lines automatically with hyphens and supports spell checking. The content is saved in XML format to preserve manual and automatic line breaks. On the right you can see an example of the format in which the content of such a field is saved.

<property name="sophora-demo:fixedSizeText">
	<value>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&#xD;
		&lt;sophora&gt;&#xD;
			&lt;logicalContent&gt;&#xD;
				&lt;line&gt;A text field of 400 x 300 pixels per page in font "Arial" (16 pt). Only one page is allowed. This field type supports automatic hyphenation.&lt;/line&gt;&#xD;
				&lt;manualhyphenations /&gt;&#xD;
			&lt;/logicalContent&gt;&#xD;
			&lt;visualContent&gt;&#xD;
				&lt;line&gt;A text field of 400 x 300 pixels per page in &lt;/line&gt;&#xD;
				&lt;line&gt;font "Arial" (16 pt). Only one page is allo-&lt;/line&gt;&#xD;
				&lt;line&gt;wed. This field type supports automatic hy-&lt;/line&gt;&#xD;
				&lt;line&gt;phenation.&lt;/line&gt;&#xD;
			&lt;/visualContent&gt;&#xD;
		&lt;/sophora&gt;
	</value>
</property>
Parameters
ParameterDescriptionDefault ValueRange of Values
Max. Character Count
###
Specify a limit for the number of characters this field should contain. If the number is exceeded it is still possible to save the document, yet a warning will be displayed to the user. The maximum is also displayed in the character counter.UnlimitedPositive integers
Max. Width in Pixels
###
The fixed width of the field and therefore maximum width of the text in pixels. This value will be overruled by Max. Width in Characters.0Positive integers
Max. Height in Pixels
###
The fixed height of the field and therefore maximum height of the text in pixels. This value will be overruled by Max. Height in Lines.0Positive integers
Max. Width in Characters
###
The fixed width of the field and therefore maximum number of characters per line. This value overrules Max. Width in Pixels and requires a monospace font.0Positive integers
Max. Height in Lines
###
The fixed height of the field and therefore maximum number of text lines. This value overrules Max. Height in Pixels.1Positive integers
Page Exceeding ErrorPrevents the saving of a document if the maximum number of lines is exceeded (otherwise there will be just a warning). Has no effect, if it is allowed to create multiple pages.falsetrue/false
Multiple Pages Allowed
###
Specify, whether only one or multiple pages should be allowed. This is only available for users of the Teletext 2.0 add-on.falsetrue/false
Spell Checking AvailableDetermine, whether spell checking should be available within this input field.falsetrue/false
Font NameSelect a special font for this input field. Note, that each font has to be installed on your operating system.RobotoThe fonts that are installed on your OS
Font StyleSelect a font style.NormalNormal, Bold, Italic
Font SizeSelect a font size. Will only be applied if a font name is selected.12Positive integers
Text ColorSpecify the text color. You can choose out of a few predefined ones or configure your own color based on RGB values. The add-on Teletext 2.0 must be purchased to use this feature.Black (0, 0, 0)Any color
Text Color ChangeableEnables the user to change the color of words. The add-on Teletext 2.0 must be purchased to use this feature.falsetrue/false
Background ColorSpecify the background color. You can choose out of a few predefined ones or configure your own color based on RGB values. The add-on Teletext 2.0 must be purchased to use this feature.White (255, 255, 255)Any color
Background Color ChangeableEnables the user to change the background color of the text field. The add-on Teletext 2.0 must be purchased to use this feature.falsetrue/false
Text LinksAllows the use of text links by dragging a document onto selected text.The add-on Teletext 2.0 must be purchased to use this feature.falsetrue/false
Line counterShow a line counter.falsetrue/false

Text (with Styles)

This field may contain rich text, i.e. formatted text with bold or italic letters etc.

Parameters
ParameterDescriptionDefault ValueRange of Values
Max. Character Count
###
Specify a limit for the number of characters this field should contain. If the number is exceeded it is still possible to save the document, yet a warning will be displayed to the user. The maximum is also displayed in the character counter.UnlimitedPositive integers
Spell Checking AvailableDetermine, whether spell checking should be available within this input field.falsetrue/false
Text Links SupportedYou can configure, whether text links, i.e. links to other documents or external links, should be supported within the field.falsetrue/false
Supported MarkupsYou may define which types of markups should be supported and which should not.NoneLanguages, Abbreviations, Quotes
PlaceholderYou can set a placeholder text for the field which will be displayed whenever the field is empty. Unlike the default text, the placeholder text does reappear even when the property has been altered. The placeholder text may contain bold or italic letters, even if the property itself does not support markup.An arbitrary string

Text (with Teaser Image)

This field type allows you to provide a teaser image in addition to the unformatted text. A teaser image is added to the document as a new component, when the user drags an image document and drops it onto the label associated with this input field.

Parameters
ParameterDescriptionDefault ValueRange of Values
Max. Character CountSpecify a limit for the number of characters this field should contain. If the number is exceeded it is still possible to save the document, yet a warning will be displayed to the user. The maximum is also displayed in the character counter.UnlimitedPositive integers
Image Node TypeThe exact node type name of image documents, e.g. sophora-extension-nt:image.Node type name
Image Child NodeThe name of the document's childnode that is supposed to contain the image reference or image component box, e.g. sophora-demo:teaserImage. This child node additionally needs to be configured in a certain way, please read the next paragraph.Child node name

In order to add a teaser image to an input field of the type Text (with Teaser Image), the document needs not only the string property configured as such. It also needs an additional nodetype that you have to add in the document's CND beforehand, in our example we call it sophora-demo:teaserImage. This property name is the one you have to enter into the Image Child Node parameter field in the property configuration of your text property. The child node sophora-demo:teaserImage itself, on the other hand, shall not appear anywhere in the documents formular tabs. Nevertheless, you do have to configure it on the components tab - drag it there on the components tab of the child node editor. Finally, you have to select the image reference node type (not the image node type itself) or the component box node type that can contain images as a valid child node type for sophora-demo:teaserImage.

Text (with Teaser Image and Style)

This input field is a combination of both the text with teaser image and the text with styles. All configuration parameters can be found in the section of the respective input field types and work just the same.

Copytext

The copytext is Sophora's most convenient and advanced field type for writing texts. The copytext supports different paragraph styles, paragraph images and boxes. The input field type Copytext requires the node type sophora-extension-nt:copytext as valid child node.

The following instructions will help you to configure the necessary node type configurations. If you do not have a node type configuration for the mentioned node types, you have to create a new one.

In the nodetype sophora-extension-nt:copytext, you should

  • add its child node sophora-extension:paragraph to the components tab
  • add a label to it (e.g. Paragraph)
  • add sophora-extension-nt:paragraph as a valid child node type to it

In the nodetype sophora-extension-nt:paragraph, you should

  • add the child nodes sophora-extension:paragraphbox and sophora-extension:paragraphimage to the components tab
  • add the respective labels to it (e.g. Paragraph Box)
  • add subtypes of sophora-extension-nt:group as valid child node types to the paragraph box and sophora-extension-nt:paragraphimage to the paragraph images

In the nodetype sophora-extension-nt:paragraphimage, you should

  • add its childnode sophora-extension:image to the components tab
  • add a label to it (e.g. Image)
  • add all reference document types for images as valid child node types

Now you are ready to configure a copytext field into a document. In the configuration of the childnode you want to configure as a copytext, you need to select Copytext as the input field type and sophora-extension-nt:copytext as the valid child node name. You also have to select the set of paragraph types you would like to enable for this copytext instance. Additionally you can select a default paragraph type. New paragraphs will be created with this type seleted. Otherwise, the default paragraph type is automatically determined from the set of enabled paragraph types.

Paragraph Table Settings

Paragraph tables support additional settings such as alignment, that can be activated using toggle buttons. Each button represents a single value out of a select value provider, that can be used to set a CSS class in the rendering of the table.

To enable the use of these settings, you have to perform the following configuration steps:

  • In the nodetype editor of sophora-extension-nt:copytextTableSettings, move the property sophora-extension:tableSettings onto the Base tab.
  • Modify the property's settings; select Checkbox (Multi) as input field type.
  • Select a select value provider of your choice and set the additionally required settings.

Last modified on 2/22/24

The content of this page is licensed under the CC BY 4.0 License. Code samples are licensed under the MIT License.

Icon