Skip to content

Commit 461368f

Browse files
committed
feat(BlockEditor): Rename ProseMirror functions and add new block editor Twig templates
1 parent 511bbaa commit 461368f

9 files changed

Lines changed: 12 additions & 12 deletions

File tree

examples/dotcms-symfony/src/Twig/DotCMSExtension.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function getFunctions(): array
2323
new TwigFunction('getGridClass', [$this, 'getGridClass']),
2424
new TwigFunction('generateHtmlBasedOnProperty', [$this, 'generateHtmlBasedOnProperty'], ['is_safe' => ['html']]),
2525
new TwigFunction('htmlAttr', [$this, 'htmlAttr'], ['is_safe' => ['html']]),
26-
new TwigFunction('renderProseMirrorContent', [$this, 'renderProseMirrorContent'], ['is_safe' => ['html']])
26+
new TwigFunction('renderBlockEditorField', [$this, 'renderBlockEditorField'], ['is_safe' => ['html']])
2727
];
2828
}
2929

@@ -77,24 +77,24 @@ public function getContainersData(array $containers, array $containerRef): array
7777
return $containerData;
7878
}
7979

80-
public function renderProseMirrorContent($content): string
80+
public function renderBlockEditorField($content): string
8181
{
8282
if (empty($content) || !isset($content['content'])) {
8383
return '';
8484
}
8585

8686
$html = '';
8787
foreach ($content['content'] as $block) {
88-
$html .= $this->renderProseMirrorBlock($block);
88+
$html .= $this->renderBlockEditorBlock($block);
8989
}
9090

9191
return $html;
9292
}
9393

94-
private function renderProseMirrorBlock(array $block): string
94+
private function renderBlockEditorBlock(array $block): string
9595
{
9696
$type = $block['type'] ?? '';
97-
$template = 'dotcms/prosemirror/' . $type . '.twig';
97+
$template = 'dotcms/block-editor-field/' . $type . '.twig';
9898

9999
if ($this->twig->getLoader()->exists($template)) {
100100
return $this->twig->render($template, ['block' => $block]);
@@ -131,7 +131,7 @@ private function renderBulletList(array $block): string
131131
$items = '';
132132
if (isset($block['content'])) {
133133
foreach ($block['content'] as $item) {
134-
$items .= $this->renderProseMirrorBlock($item);
134+
$items .= $this->renderBlockEditorBlock($item);
135135
}
136136
}
137137
return $items ? "<ul>{$items}</ul>" : '';
@@ -142,7 +142,7 @@ private function renderListItem(array $block): string
142142
$content = '';
143143
if (isset($block['content'])) {
144144
foreach ($block['content'] as $item) {
145-
$content .= $this->renderProseMirrorBlock($item);
145+
$content .= $this->renderBlockEditorBlock($item);
146146
}
147147
}
148148
return $content ? "<li>{$content}</li>" : '';

examples/dotcms-symfony/templates/blog-detail.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
{% if pageAsset.urlContentMap.blogContent is defined %}
1515
<div class="blog-content">
16-
{{ renderProseMirrorContent(pageAsset.urlContentMap.blogContent) }}
16+
{{ renderBlockEditorField(pageAsset.urlContentMap.blogContent) }}
1717
</div>
1818
{% endif %}
1919
</article>

examples/dotcms-symfony/templates/dotcms/prosemirror/blockquote.twig renamed to examples/dotcms-symfony/templates/dotcms/block-editor-field/blockquote.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{%- if block.content is defined -%}
22
<blockquote>
33
{%- for item in block.content -%}
4-
{{ renderProseMirrorContent({'content': [item]}) }}
4+
{{ renderBlockEditorField({'content': [item]}) }}
55
{%- endfor -%}
66
</blockquote>
77
{%- endif -%}

examples/dotcms-symfony/templates/dotcms/prosemirror/bulletList.twig renamed to examples/dotcms-symfony/templates/dotcms/block-editor-field/bulletList.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{%- if block.content is defined -%}
22
<ul>
33
{%- for item in block.content -%}
4-
{{ renderProseMirrorContent({'content': [item]}) }}
4+
{{ renderBlockEditorField({'content': [item]}) }}
55
{%- endfor -%}
66
</ul>
77
{%- endif -%}

examples/dotcms-symfony/templates/dotcms/prosemirror/codeBlock.twig renamed to examples/dotcms-symfony/templates/dotcms/block-editor-field/codeBlock.twig

File renamed without changes.

examples/dotcms-symfony/templates/dotcms/prosemirror/heading.twig renamed to examples/dotcms-symfony/templates/dotcms/block-editor-field/heading.twig

File renamed without changes.

examples/dotcms-symfony/templates/dotcms/prosemirror/listItem.twig renamed to examples/dotcms-symfony/templates/dotcms/block-editor-field/listItem.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{%- endif -%}
1414
{{ content }}
1515
{%- else -%}
16-
{{ renderProseMirrorContent({'content': [item]}) }}
16+
{{ renderBlockEditorField({'content': [item]}) }}
1717
{%- endif -%}
1818
{%- endfor -%}
1919
</li>

examples/dotcms-symfony/templates/dotcms/prosemirror/orderedList.twig renamed to examples/dotcms-symfony/templates/dotcms/block-editor-field/orderedList.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{%- if block.content is defined -%}
22
<ol>
33
{%- for item in block.content -%}
4-
{{ renderProseMirrorContent({'content': [item]}) }}
4+
{{ renderBlockEditorField({'content': [item]}) }}
55
{%- endfor -%}
66
</ol>
77
{%- endif -%}

examples/dotcms-symfony/templates/dotcms/prosemirror/paragraph.twig renamed to examples/dotcms-symfony/templates/dotcms/block-editor-field/paragraph.twig

File renamed without changes.

0 commit comments

Comments
 (0)