ProsemirrorEx.Transform.Transform (prosemirror_ex v0.3.0)

Copy Markdown View Source

Abstraction to build up and track an array of steps representing a document transformation.

Functions pattern-match on map keys rather than the %Transform{} struct so that a future Transaction struct can reuse them.

Ports Transform from prosemirror-transform/src/transform.ts.

Summary

Functions

Add a mark to inline content between from and to.

The starting document (before any steps were applied).

Return a single range, in post-transform document positions, that covers all content changed by this transform. Returns nil if no replacements are made. Note that this will ignore changes that add/remove marks without replacing the underlying content.

Removes all marks and nodes from the content of the node at pos that don't match the given new parent node type.

Delete content between from and to.

Smart delete that expands to cover parent nodes when appropriate.

True when the document has been changed (when there are any steps).

Insert content at pos.

Join the blocks around the given position.

Lift the content in the given range to the given target depth.

Try to apply a step in this transformation, ignoring it if it fails. Returns {updated_tr, step_result}.

Create a new Transform starting with the given document.

Remove marks from inline nodes between from and to. When mark is a single mark, remove precisely that mark. When it is a mark type, remove all marks of that type. When it is nil, remove all marks of any type.

Replace a range of the document with a slice.

WYSIWYG-aware replace across a range.

WYSIWYG-aware replace with a single node.

Replace a range of the document with a node or list of nodes.

Set the type of all textblocks (partly) between from and to.

Set a document-level attribute.

Set a single attribute on the node at pos.

Change the type, attributes, and/or marks of the node at pos.

Split the node at the given position.

Apply a new step in this transform, saving the result. Raises a TransformError when the step fails.

Wrap the content in the given range in the given wrapper nodes.

Types

t()

@type t() :: %ProsemirrorEx.Transform.Transform{
  doc: ProsemirrorEx.Model.Node.t(),
  docs: [ProsemirrorEx.Model.Node.t()],
  mapping: ProsemirrorEx.Transform.Mapping.t(),
  steps: [term()]
}

Functions

add_mark(tr, from, to, mark)

Add a mark to inline content between from and to.

before(map)

The starting document (before any steps were applied).

changed_range(map)

Return a single range, in post-transform document positions, that covers all content changed by this transform. Returns nil if no replacements are made. Note that this will ignore changes that add/remove marks without replacing the underlying content.

clear_incompatible(tr, pos, parent_type, match \\ nil, clear_newlines \\ true)

Removes all marks and nodes from the content of the node at pos that don't match the given new parent node type.

delete(tr, from, to)

Delete content between from and to.

delete_range(tr, from, to)

Smart delete that expands to cover parent nodes when appropriate.

doc_changed?(map)

True when the document has been changed (when there are any steps).

insert(tr, pos, content)

Insert content at pos.

join(tr, pos, depth \\ 1)

Join the blocks around the given position.

lift(tr, range, target)

Lift the content in the given range to the given target depth.

maybe_step(tr, step_struct)

Try to apply a step in this transformation, ignoring it if it fails. Returns {updated_tr, step_result}.

new(doc)

Create a new Transform starting with the given document.

remove_mark(tr, from, to, mark \\ nil)

Remove marks from inline nodes between from and to. When mark is a single mark, remove precisely that mark. When it is a mark type, remove all marks of that type. When it is nil, remove all marks of any type.

replace(tr, from, to \\ nil, slice \\ nil)

Replace a range of the document with a slice.

replace_range(tr, from, to, slice)

WYSIWYG-aware replace across a range.

replace_range_with(tr, from, to, node)

WYSIWYG-aware replace with a single node.

replace_with(tr, from, to, content)

Replace a range of the document with a node or list of nodes.

set_block_type(tr, from, to \\ nil, type, attrs \\ nil)

Set the type of all textblocks (partly) between from and to.

set_doc_attribute(tr, attr, value)

Set a document-level attribute.

set_node_attribute(tr, pos, attr, value)

Set a single attribute on the node at pos.

set_node_markup(tr, pos, type \\ nil, attrs \\ nil, marks \\ nil)

Change the type, attributes, and/or marks of the node at pos.

split(tr, pos, depth \\ 1, types_after \\ nil)

Split the node at the given position.

step(tr, step_struct)

Apply a new step in this transform, saving the result. Raises a TransformError when the step fails.

wrap(tr, range, wrappers)

Wrap the content in the given range in the given wrapper nodes.