import { Editor } from 'roosterjs-editor-core' ; import { getFormatState } from 'roosterjs-editor-api' ; import { DocumentCommand , Indentation , QueryScope } from 'roosterjs-editor-types' ; function execCommand ( editor , command , addUndoSnapshotWhenCollapsed ? ) { editor . focus ( ) ; const formatter = ( ) => editor . getDocument ( ) . execCommand ( command , false , null ) ; const range = editor . getSelectionRange ( ) ; if ( range && range . collapsed && ! addUndoSnapshotWhenCollapsed ) { formatter ( ) ; } else { editor . addUndoSnapshot ( formatter ) ; } } param editor export function toggleNonCompatNumbering ( editor ) { execCommand ( editor , DocumentCommand . InsertOrderedList , true ) ; } param editor export function toggleNonCompatBullet ( editor ) { execCommand ( editor , DocumentCommand . InsertUnorderedList , true ) ; } param editor param indentation export function setNonCompatIndentation ( editor , indentation ) { editor . focus ( ) ; const command = indentation == Indentation . Increase ? 'indent' : 'outdent' ; editor . addUndoSnapshot ( ( ) => { const format = getFormatState ( editor ) ; editor . getDocument ( ) . execCommand ( command , false , null ) ; if ( ! format . isBullet && ! format . isNumbering ) { editor . queryElements ( 'blockquote' , QueryScope . OnSelection , node => { node . style . marginTop = '0' ; node . style . marginBottom = '0' ; } ) ; } } ) ; }