WriteopiaStateManager

class WriteopiaStateManager(stepsNormalizer: UnitsNormalizationMap = StepsMapNormalizationBuilder.reduceNormalizations { defaultNormalizers() }, dispatcher: CoroutineDispatcher, coroutineScope: CoroutineScope = CoroutineScope(EmptyCoroutineContext), backStackManager: BackstackManager, userId: suspend () -> String = { "no_user_id_provided" }, writeopiaManager: WriteopiaManager, val selectionState: StateFlow<Boolean>, keyboardEventFlow: Flow<KeyboardEvent>, drawStateModify: (List<DrawStory>, Int) -> List<DrawStory> = StepsModifier::modify) : BackstackHandler, BackstackInform

This is the entry class of the framework. It follows the Controller pattern, redirecting all the call to another class responsible for the part of the SDK requested.

Constructors

Link copied to clipboard
constructor(stepsNormalizer: UnitsNormalizationMap = StepsMapNormalizationBuilder.reduceNormalizations { defaultNormalizers() }, dispatcher: CoroutineDispatcher, coroutineScope: CoroutineScope = CoroutineScope(EmptyCoroutineContext), backStackManager: BackstackManager, userId: suspend () -> String = { "no_user_id_provided" }, writeopiaManager: WriteopiaManager, selectionState: StateFlow<Boolean>, keyboardEventFlow: Flow<KeyboardEvent>, drawStateModify: (List<DrawStory>, Int) -> List<DrawStory> = StepsModifier::modify)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val canRedo: StateFlow<Boolean>

Notifies if it is possible to redo an action.

Link copied to clipboard
open override val canUndo: StateFlow<Boolean>

Notifies if it is possible to undo an action.

Link copied to clipboard
val currentDocument: StateFlow<Document?>
Link copied to clipboard
val currentStory: StateFlow<StoryState>
Link copied to clipboard
val documentInfo: StateFlow<DocumentInfo>
Link copied to clipboard
val onEditPositions: StateFlow<Set<Int>>
Link copied to clipboard
val scrollToPosition: StateFlow<Int?>
Link copied to clipboard
val selectionState: StateFlow<Boolean>
Link copied to clipboard
val toDraw: Flow<DrawState>

Functions

Link copied to clipboard

Cancels the current selection.

Link copied to clipboard

At the moment it is only possible to check items not inside groups. Todo: Fix it!

Link copied to clipboard
fun changeStoryType(position: Int, typeInfo: TypeInfo, commandInfo: CommandInfo?)

Changes the story type. The type of a messages changes without changing the content of it. Commands normally change the type of a message. From a message to a unordered list item, for example.

Link copied to clipboard

A click at the end of the document. The focus should be moved to the first StoryStep that can receive the focus, from last to first.

Link copied to clipboard

Deletes the whole selection. All StoryStep in the selection will be deleted.

Link copied to clipboard
fun handleTextInput(input: TextInput, position: Int, lineBreakByContent: Boolean)
Link copied to clipboard
Link copied to clipboard
fun liveSync(sharedEditionManager: SharedEditionManager)
Link copied to clipboard
fun loadDocument(document: Document)

Initializes a document passed as a parameter. This method should be used when you would like to load a document from a database and start editing it, instead of creating something new.

Link copied to clipboard

Merges two StoryStep into a group. This can be used to merge two images into a message group or any other kind of group.

Link copied to clipboard

A request to move a content to a position.

Link copied to clipboard
fun moveToNext(cursor: Int, positions: Int = 1)
Link copied to clipboard
fun moveToPrevious(cursor: Int, positions: Int = 1)
Link copied to clipboard
fun newStory(documentId: String = GenerateId.generate(), title: String = "", parentFolder: String = "root", forceRestart: Boolean = false)

Creates a new story. Use this when you wouldn't like to load a documented previously saved.

Link copied to clipboard

Click lister when user clicks in the menu to add a check item

Link copied to clipboard
fun onClear()

Clears the WriteopiaStateManager. Use this in the onCleared of your ViewModel.

Link copied to clipboard

Click lister when user clicks in the menu to add a code block

Link copied to clipboard
fun onDelete(deleteStory: Action.DeleteStory)

Deletes a StoryStep

Link copied to clipboard
fun onDragHover(position: Int)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun onErase(eraseStory: Action.EraseStory)
Link copied to clipboard
fun onFocusChange(position: Int, hasFocus: Boolean)
Link copied to clipboard
Link copied to clipboard

Creates a line break. When a line break happens, the line it divided into two StorySteps of the same, if possible, or the next line will be a Message.

Link copied to clipboard

Click lister when user clicks in the menu to add a list item

Link copied to clipboard
fun onSelected(isSelected: Boolean, position: Int)

Add a StoryStep of a position into the selection list. Selected content can be used to perform bulk actions, like bulk edition and bulk deletion.

Link copied to clipboard
open override fun redo()

Redo the last undone action.

Link copied to clipboard
fun removeTags(position: Int)
Link copied to clipboard
fun saveOnStoryChanges(documentTracker: DocumentTracker)

Saves the document automatically as it is changed. It uses the DocumentTracker passed in the constructor of WriteopiaStateManager

Link copied to clipboard
fun toggleCollapseItem(position: Int)
Link copied to clipboard
fun toggleSelection(position: Int)
Link copied to clipboard
fun toggleTagForPosition(position: Int, tag: TagInfo, commandInfo: CommandInfo? = null)
Link copied to clipboard
open override fun undo()

Undo the last action.