gws_core

Introduction
Getting Started
Developer guide
Release
Architecture
CLI
Technical documentations
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.

rich_text_dto : Optional
target_version : int
add_figure

Add a figure to the rich text content

figure_data : RichTextFigureData
parameter_name : str
Return type : RichTextBlock
add_file

Add a file to the rich text content

file_data : RichTextFileData
parameter_name : str
Return type : RichTextBlock
add_file_view

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

file_view : RichTextViewFileData
view to add
parameter_name : str
name of the parameter where to insert the block. If None, the block is appended
Return type : RichTextBlock
add_formula

Add a math formula to the rich text content

formula : str
parameter_name : str
name of the parameter where to insert the block. If None, the block is appended
Return type : RichTextBlock
add_header

Add a header to the rich text content

text : str
level : RichTextParagraphHeaderLevel
Return type : RichTextBlock
add_list

Add a list to the rich text content

data : RichTextParagraphListData
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

resource_view : RichTextNoteResourceViewData
view to add
parameter_name : str
name of the parameter where to insert the block. If None, the block is appended
Return type : RichTextBlock
add_paragraph

Add a paragraph to the rich text content

text : str
Return type : RichTextBlock
add_resource_view
resource_view : RichTextResourceViewData
parameter_name : str
Return type : RichTextBlock
add_timestamp

Add a timestamp to the rich text content

timestamp_data : RichTextTimestampData
parameter_name : str
Return type : RichTextBlock
append_block

Append a block to the rich text content

block : RichTextBlock
block to add
Return type : int
append_rich_text
rich_text : RichText
generate_id
Return type : str
get_associated_resources
Return type : Set
get_block_at_index

Get the block at the given index

index : int
Return type : RichTextBlock
get_block_by_id

Get the block by its id

block_id : str
id of the block
Return type : Optional
get_block_index_by_id

Get the block index by its id

block_id : str
id of the block
Return type : int
get_blocks
Return type : List
get_blocks_by_type

Get the blocks of the given type

block_type : RichTextBlockType
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

view_config_id : str
Return type : bool
insert_block_at_index

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

index : int
block : RichTextBlock
is_empty
Return type : bool
replace_block_at_index

Replace a block at the given index

index : int
block : RichTextBlock
replace_block_by_id

Replace a block by its id

block_id : str
block : RichTextBlock
replace_block_data_by_id

Replace the data of a block by its id

block_id : str
data : Any
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

parameter_name : str
value : str
replace_block : bool - False
to_dto
Return type : RichTextDTO
to_dto_json_dict
Return type : dict
create_block @classmethod

Create a block

id_ : str
block_type : RichTextBlockType
data : Any
Return type : RichTextBlock
create_formula @classmethod

summary

id_ : str
id of the block
formula : str
math formula using the KaTeX syntax
Return type : RichTextBlock
create_header @classmethod

Create a paragraph block

id_ : str
text : str
level : RichTextParagraphHeaderLevel
Return type : RichTextBlock
create_list @classmethod

Create a list block

id_ : str
data : RichTextParagraphListData
Return type : RichTextBlock
create_paragraph @classmethod

Create a paragraph block

id_ : str
text : str
Return type : RichTextBlock
create_rich_text_dto @classmethod
blocks : List
Return type : RichTextDTO
create_timestamp @classmethod

Create a timestamp block

id_ : str
data : RichTextTimestampData
Return type : RichTextBlock
deserialize @classmethod

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

data : dict
json object generated by the serialize method
Return type : RichText
from_json @classmethod
data : dict
Return type : RichText