| 1 |
import { createBlock } from '@wordpress/blocks'; |
| 2 |
import { |
| 3 |
__UNSTABLE_LINE_SEPARATOR, |
| 4 |
create, |
| 5 |
split, |
| 6 |
toHTMLString, |
| 7 |
} from '@wordpress/rich-text'; |
| 8 |
|
| 9 |
export default { |
| 10 |
from: [ |
| 11 |
{ |
| 12 |
type: 'block', |
| 13 |
blocks: ['core/quote', 'core/pullquote'], |
| 14 |
transform(attrs) { |
| 15 |
const paragraphs = split( |
| 16 |
create({ |
| 17 |
html: attrs.value, |
| 18 |
multilineTag: 'p', |
| 19 |
}), |
| 20 |
__UNSTABLE_LINE_SEPARATOR |
| 21 |
); |
| 22 |
|
| 23 |
return createBlock( |
| 24 |
'ghostkit/testimonial', |
| 25 |
{ |
| 26 |
source: attrs.citation || '', |
| 27 |
}, |
| 28 |
paragraphs.map((piece) => |
| 29 |
createBlock('core/paragraph', { |
| 30 |
content: toHTMLString({ value: piece }), |
| 31 |
}) |
| 32 |
) |
| 33 |
); |
| 34 |
}, |
| 35 |
}, |
| 36 |
], |
| 37 |
}; |
| 38 |
|