| @@ -1,23 +1,24 @@ | ||
| 1 | 1 | import { createBlock } from '@wordpress/blocks'; |
| 2 | 2 | import { escapeHTML } from '@wordpress/escape-html'; |
| 3 | 3 | import blockConfig from '../block.json'; |
| 4 | -import type { Attributes, Lang } from '../types'; | |
| 4 | +import { Attributes, Lang } from '../types'; | |
| 5 | 5 | import { getMainAlias } from '../util/languages'; |
| 6 | 6 | |
| 7 | +// eslint-disable-next-line @typescript-eslint/no-explicit-any | |
| 7 | 8 | export const transformToCBP = (attrs: any) => { |
| 8 | - const { content, language } = attrs; | |
| 9 | - const decode = (value: string) => { | |
| 10 | - const txt = document.createElement('textarea'); | |
| 11 | - txt.innerHTML = value; | |
| 12 | - return txt.value; | |
| 13 | - }; | |
| 14 | - return createBlock(blockConfig.name, { | |
| 15 | - code: content ? escapeHTML(decode(content)) : undefined, | |
| 16 | - language: getMainAlias(language) as Lang, | |
| 17 | - }); | |
| 9 | + const { content, language } = attrs; | |
| 10 | + const decode = (value: string) => { | |
| 11 | + const txt = document.createElement('textarea'); | |
| 12 | + txt.innerHTML = value; | |
| 13 | + return txt.value; | |
| 14 | + }; | |
| 15 | + return createBlock(blockConfig.name, { | |
| 16 | + code: content ? escapeHTML(decode(content)) : undefined, | |
| 17 | + language: getMainAlias(language) as Lang, | |
| 18 | + }); | |
| 18 | 19 | }; |
| 19 | 20 | |
| 20 | 21 | export const transformFromCBP = (attrs: Attributes) => { |
| 21 | - const { code: content } = attrs; | |
| 22 | - return createBlock('core/code', { content }); | |
| 22 | + const { code: content } = attrs; | |
| 23 | + return createBlock('core/code', { content }); | |
| 23 | 24 | }; |