@yoopta/code
Advanced tools
Changelog
[4.9.0] - 2024-10-27
editor.on('change', changeHandler);
// before
editor.on('change', (value: YooptaChildrenValue) => {
setValue(value);
});
// now
editor.on('change', (options: YooptaEventChangePayload) => {
const { value, operations } = options;
setValue(value);
});
// [!!!But I highly recommend start to use new `onChange` prop in <YooptaEditor value={value} onChange={newValue => setValue(newValue)} />;
Undo/redo now available!
editor.undo: ({ scroll?: boolean }?: UndoRedoOptions) => void
editor.redo: ({ scroll?: boolean }?: UndoRedoOptions) => void
editor.historyStack: Record
editor.withoutSavingHistory: (fn: () => void): void
editor.withSavingHistory: (fn: () => void): void
editor.isSavingHistory: (): boolean | undefined
editor.withoutMergingHistory: (fn: () => void): void
editor.withMergingHistory: (fn: () => void): void
editor.isMergingHistory: (): boolean | undefined
New powerful
editor.applyTransforms
method andoperations API.
Now, every time the content is changed, the corresponding operation is called, which passes through theeditor.applyTransforms
editor.path: YooptaPath
editor.setPath: (path: YooptaPath) => void;
Blocks.getBlock: (editor: YooEditor, options: GetBlockOptions) => YooptaBlockData
Blocks.getBlockSlate: (editor: YooEditor, options: GetBlockSlateOptions) => SlateEditor
Blocks.buildBlockData: (block?: BuildBlockDataOptions) => YooptaBlockData
Blocks.mergeBlock: () => void
export type YooptaPath = {
current: YooptaPathIndex, // current selected block
selected?: number[] | null, // array of selected blocks
};
editor.toggleBlock
-fixed toggling between complex block elementseditor.splitBlock
- fixed split between complex block elementsonChange
now does not fire during initializationeditor.duplicateBlock
- fixed for Code blockActionMenu
editor.applyChanges
- removededitor.selection
- removed (changed to editor.path
)editor.setSelection
- removed (changed to editor.setPath
)editor.setBlockSelected
- removed (changed to editor.setPath
)editor.insertBlocks
- removededitor.deleteBlocks
- removededitor.createBlock
- removed. Use editor.insertBlock
insteadoperations
APIundo/redo