WriteopiaManager

class WriteopiaManager(stepsNormalizer: UnitsNormalizationMap = StepsMapNormalizationBuilder.reduceNormalizations { defaultNormalizers() }, movementHandler: MovementHandler = MovementHandler(), contentHandler: ContentHandler = ContentHandler( stepsNormalizer = stepsNormalizer ), focusHandler: FocusHandler = FocusHandler(), spanHandler: SpansHandler = SpansHandler, aiClient: AiClient? = null)

Constructors

Link copied to clipboard
constructor(stepsNormalizer: UnitsNormalizationMap = StepsMapNormalizationBuilder.reduceNormalizations { defaultNormalizers() }, movementHandler: MovementHandler = MovementHandler(), contentHandler: ContentHandler = ContentHandler( stepsNormalizer = stepsNormalizer ), focusHandler: FocusHandler = FocusHandler(), spanHandler: SpansHandler = SpansHandler, aiClient: AiClient? = null)

Functions

Link copied to clipboard
fun addAtPosition(storyState: StoryState, storyStep: StoryStep, position: Int): StoryState

Adds a story in a position. Useful to add stories that were not created by the end user, but by an API call or different event.

Link copied to clipboard
fun addDocumentLink(storyState: StoryState, position: Int, documentId: String, text: String): StoryState
Link copied to clipboard
fun addSpan(storyState: StoryState, position: Int, spanInfo: SpanInfo): StoryState

Adds a Span like, Bold, Italic, Underline to a story.

Link copied to clipboard
fun addSpanToStories(storyState: StoryState, positions: Set<Int>, span: Span): StoryState
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun bulkDelete(positions: Iterable<Int>, stories: Map<Int, StoryStep>): Pair<Map<Int, StoryStep>, Map<Int, StoryStep>>

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

Link copied to clipboard

Changes the state of a story step based of the stateChange

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

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
fun collapseItem(storyState: StoryState, position: Int): StoryState
Link copied to clipboard
fun expandItem(storyState: StoryState, position: Int): StoryState
Link copied to clipboard
suspend fun generateSuggestionsList(storyState: () -> StoryState, storyType: StoryType, position: Int, context: String, userId: String): StoryState
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
fun moveRequest(move: Action.Move, storyState: StoryState): StoryState

A request to move a content to a position.

Link copied to clipboard
fun newDocument(documentId: String = GenerateId.generate(), userId: String = "", title: String = "", parentFolder: String = "root"): Pair<DocumentInfo, StoryState>
Link copied to clipboard
fun nextFocus(position: Int, cursor: Int, storyState: StoryState): StoryState

Moves the focus to the next available StoryStep if it can't find a step to focus, it creates a new StoryStep at the end of the document.

Link copied to clipboard
fun onDelete(deleteStory: Action.DeleteStory, storyState: StoryState): StoryState?

Deletes a StoryStep

Link copied to clipboard
fun onErase(deleteStory: Action.EraseStory, storyState: StoryState): StoryState

Erases a StoryStep

Link copied to clipboard
fun onLineBreak(lineBreak: Action.LineBreak, storyState: StoryState): Pair<Int, StoryState>

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
fun previousTextStory(storyMap: Map<Int, StoryStep>, position: Int): Pair<StoryStep, Int>?
Link copied to clipboard
fun removeAtPosition(storyState: StoryState, position: Int): StoryState
Link copied to clipboard
fun removeBy(storyState: StoryState, predicate: (StoryStep) -> Boolean): StoryState
Link copied to clipboard
fun removeTags(position: Int, storyState: StoryState): StoryState

Removes all tags from a story step