Back to bricks list
Introduction
Technical Documentation
Other Classes
RichText
Version

RichText

Class to manipulate the rich texts content

:return: [description] :rtype: [type]

Attributes

blocks: Listeditor_version: strversion: int

Functions

__INIT__

Initialize self. See help(type(self)) for accurate signature.

Parameters:
NameTypeDefault valueDescription
rich_text_dtoOptional
target_versionint
ADD_FIGURE

Add a figure to the rich text content

Parameters:
NameTypeDefault valueDescription
figure_dataRichTextFigureData
parameter_namestr
Return type:
RichTextBlock
ADD_FILE

Add a file to the rich text content

Parameters:
NameTypeDefault valueDescription
file_dataRichTextFileData
parameter_namestr
Return type:
RichTextBlock
ADD_FILE_VIEW

Add a view to a rich text content. This view is not associated with a resource

Parameters:
NameTypeDefault valueDescription
file_viewRichTextViewFileData View to add
parameter_namestr Name of the parameter where to insert the block. if none, the block is appended , optional
Return type:
RichTextBlock
ADD_FORMULA

Add a math formula to the rich text content

Parameters:
NameTypeDefault valueDescription
formulastr :param formula_data: math formula using the katex syntax :type formula_data:
parameter_namestr Name of the parameter where to insert the block. if none, the block is appended , optional
Return type:
RichTextBlock
ADD_HEADER

Add a header to the rich text content

Parameters:
NameTypeDefault valueDescription
textstr
levelRichTextParagraphHeaderLevel
Return type:
RichTextBlock
ADD_LIST

Add a list to the rich text content

Parameters:
NameTypeDefault valueDescription
dataRichTextParagraphListData
Return type:
RichTextBlock
ADD_NOTE_RESOURCE_VIEW

Add a view to a rich text content used in note. This requires the note to call the view

Parameters:
NameTypeDefault valueDescription
resource_viewRichTextNoteResourceViewData View to add
parameter_namestr Name of the parameter where to insert the block. if none, the block is appended , optional
Return type:
RichTextBlock
ADD_PARAGRAPH

Add a paragraph to the rich text content

Parameters:
NameTypeDefault valueDescription
textstr
Return type:
RichTextBlock
ADD_RESOURCE_VIEW
Parameters:
NameTypeDefault valueDescription
resource_viewRichTextResourceViewData
parameter_namestr
Return type:
RichTextBlock
ADD_TIMESTAMP

Add a timestamp to the rich text content

Parameters:
NameTypeDefault valueDescription
timestamp_dataRichTextTimestampData
parameter_namestr
Return type:
RichTextBlock
APPEND_BLOCK

Append a block to the rich text content

Parameters:
NameTypeDefault valueDescription
blockRichTextBlock Block to add
Return type:
int
APPEND_RICH_TEXT
Parameters:
NameTypeDefault valueDescription
rich_textRichText
GENERATE_ID
Return type:
str
GET_ASSOCIATED_RESOURCES
Return type:
Set
GET_BLOCK_AT_INDEX

Get the block at the given index

Parameters:
NameTypeDefault valueDescription
indexint
Return type:
RichTextBlock
GET_BLOCK_BY_ID

Get the block by its id

Parameters:
NameTypeDefault valueDescription
block_idstr Id of the block
Return type:
Optional
GET_BLOCK_INDEX_BY_ID

Get the block index by its id

Parameters:
NameTypeDefault valueDescription
block_idstr Id of the block
Return type:
int
GET_BLOCKS
Return type:
List
GET_BLOCKS_BY_TYPE

Get the blocks of the given type

Parameters:
NameTypeDefault valueDescription
block_typeRichTextBlockType
Return type:
List
GET_FIGURES_DATA
Return type:
List
GET_FILE_VIEWS_DATA
Return type:
List
GET_FILES_DATA
Return type:
List
GET_RESOURCE_VIEWS_DATA
Return type:
List
HAS_VIEW_CONFIG

Check if the rich text contains a resource view with the given view_config_id

Parameters:
NameTypeDefault valueDescription
view_config_idstr
Return type:
bool
INSERT_BLOCK_AT_INDEX

Insert an element in the rich text content at the given index

Parameters:
NameTypeDefault valueDescription
indexint
blockRichTextBlock
IS_EMPTY
Return type:
bool
REPLACE_BLOCK_AT_INDEX

Replace a block at the given index

Parameters:
NameTypeDefault valueDescription
indexint
blockRichTextBlock
REPLACE_BLOCK_BY_ID

Replace a block by its id

Parameters:
NameTypeDefault valueDescription
block_idstr
blockRichTextBlock
REPLACE_BLOCK_DATA_BY_ID

Replace the data of a block by its id

Parameters:
NameTypeDefault valueDescription
block_idstr
dataAny
REPLACE_RESOURCE_VIEWS_WITH_PARAMETERS

Method to remove the resource view from the rich text content and replace it when parameters. Useful when creating a template (because templates can't have resource views)

SERIALIZE

Serialize the object into a json object. For SerializableRField, this method is called when the resource is saved.

Return type:
dict
SET_PARAMETER

Replace the parameter in the rich text content text

Parameters:
NameTypeDefault valueDescription
parameter_namestr
valuestr
TO_DTO
Return type:
RichTextDTO
TO_DTO_JSON_DICT
Return type:
dict
CREATE_BLOCK - @classmethod

Create a block

Parameters:
NameTypeDefault valueDescription
id_str
block_typeRichTextBlockType
dataAny
Return type:
RichTextBlock
CREATE_FORMULA - @classmethod

summary

Parameters:
NameTypeDefault valueDescription
id_str Id of the block
formulastr Math formula using the katex syntax
Return type:
RichTextBlock
CREATE_HEADER - @classmethod

Create a paragraph block

Parameters:
NameTypeDefault valueDescription
id_str
textstr
levelRichTextParagraphHeaderLevel
Return type:
RichTextBlock
CREATE_LIST - @classmethod

Create a list block

Parameters:
NameTypeDefault valueDescription
id_str
dataRichTextParagraphListData
Return type:
RichTextBlock
CREATE_PARAGRAPH - @classmethod

Create a paragraph block

Parameters:
NameTypeDefault valueDescription
id_str
textstr
Return type:
RichTextBlock
CREATE_RICH_TEXT_DTO - @classmethod
Parameters:
NameTypeDefault valueDescription
blocksList
Return type:
RichTextDTO
CREATE_TIMESTAMP - @classmethod

Create a timestamp block

Parameters:
NameTypeDefault valueDescription
id_str
dataRichTextTimestampData
Return type:
RichTextBlock
DESERIALIZE - @classmethod

Deserialize the object from a json object. For SerializableRField, this method is called when the RField is loaded.

Parameters:
NameTypeDefault valueDescription
datadict Json object generated by the serialize method union[dict, list, str, bool, float]
Return type:
RichText