34 lines
968 B
TypeScript
34 lines
968 B
TypeScript
![]() |
import { blockNames, EditorBlock } from 'editor/types/blocks'
|
||
|
|
||
|
function makeParentBlock (tag: string, create: EditorBlock["create"]): EditorBlock {
|
||
|
return {
|
||
|
selector: tag,
|
||
|
allowedChildren: blockNames,
|
||
|
handleEmpty: 'remove',
|
||
|
create: create,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// TODO: añadir blockquote
|
||
|
// XXX: si agregás algo acá, probablemente le quieras hacer un botón
|
||
|
// en app/views/posts/attributes/_content.haml
|
||
|
export const parentBlocks: { [propName: string]: EditorBlock } = {
|
||
|
left: makeParentBlock('div[data-align=left]', () => {
|
||
|
const el = document.createElement('div')
|
||
|
el.dataset.align = 'left'
|
||
|
return el
|
||
|
}),
|
||
|
center: makeParentBlock('div[data-align=center]', () => {
|
||
|
const el = document.createElement('div')
|
||
|
el.dataset.align = 'center'
|
||
|
return el
|
||
|
}),
|
||
|
right: makeParentBlock('div[data-align=right]', () => {
|
||
|
const el = document.createElement('div')
|
||
|
el.dataset.align = 'right'
|
||
|
return el
|
||
|
}),
|
||
|
}
|
||
|
|
||
|
export const parentBlockNames = Object.keys(parentBlocks)
|