PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.26.7
Code Block Pro – Beautiful Syntax Highlighting v1.26.7
1.27.1 1.27.2 1.27.3 1.27.4 1.27.5 1.27.6 1.27.7 1.28.0 1.3.0 1.4.0 1.5.0 1.5.1 1.5.2 1.6.0 1.7.0 1.8.0 1.9.0 1.9.1 1.9.2 1.9.3 trunk 1.1.0 1.10.0 1.11.0 1.11.1 All 63 releases
← All changes | src/editor/transforms.ts +14 -13 trunk1.26.7 View file →
@@ -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 };