Skip to content

Commit 0d23e04

Browse files
committed
feat: migrate to Umbraco.RichText and data-content-key
1 parent 088c9cb commit 0d23e04

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/packages/block/block-rte/tiptap-extension/block.extension.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { UMB_DATA_CONTENT_UDI, type UmbBlockRteLayoutModel } from '../types.js';
1+
import { UMB_DATA_CONTENT_KEY, type UmbBlockRteLayoutModel } from '../types.js';
22
import { UMB_BLOCK_RTE_MANAGER_CONTEXT } from '../context/index.js';
33
import { UmbTiptapExtensionApiBase } from '@umbraco-cms/backoffice/tiptap';
44
import { Node } from '@umbraco-cms/backoffice/external/tiptap';
@@ -28,7 +28,7 @@ const umbRteBlock = Node.create({
2828

2929
addAttributes() {
3030
return {
31-
[UMB_DATA_CONTENT_UDI]: {
31+
[UMB_DATA_CONTENT_KEY]: {
3232
isRequired: true,
3333
},
3434
};
@@ -47,7 +47,7 @@ const umbRteBlock = Node.create({
4747
setBlock:
4848
(options) =>
4949
({ commands }) => {
50-
const attrs = { [UMB_DATA_CONTENT_UDI]: options.contentUdi };
50+
const attrs = { [UMB_DATA_CONTENT_KEY]: options.contentUdi };
5151
return commands.insertContent({
5252
type: this.name,
5353
attrs,
@@ -75,7 +75,7 @@ const umbRteBlockInline = umbRteBlock.extend({
7575
setBlockInline:
7676
(options) =>
7777
({ commands }) => {
78-
const attrs = { [UMB_DATA_CONTENT_UDI]: options.contentUdi };
78+
const attrs = { [UMB_DATA_CONTENT_KEY]: options.contentUdi };
7979
return commands.insertContent({
8080
type: this.name,
8181
attrs,
@@ -111,7 +111,7 @@ export default class UmbTiptapBlockElementApi extends UmbTiptapExtensionApiBase
111111
if (!editor) return;
112112

113113
const existingBlocks = Array.from(editor.view.dom.querySelectorAll('umb-rte-block, umb-rte-block-inline')).map(
114-
(x) => x.getAttribute(UMB_DATA_CONTENT_UDI),
114+
(x) => x.getAttribute(UMB_DATA_CONTENT_KEY),
115115
);
116116
const newBlocks = blocks.filter((x) => !existingBlocks.find((contentUdi) => contentUdi === x.udi));
117117

src/packages/block/block-rte/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ import type { UmbBlockLayoutBaseModel, UmbBlockValueType } from '@umbraco-cms/ba
33

44
export const UMB_BLOCK_RTE_TYPE = 'block-rte-type';
55
export const UMB_BLOCK_RTE = 'block-rte';
6+
/**
7+
* The attribute where the block content key is stored.
8+
* @deprecated Use {@link UMB_DATA_CONTENT_KEY} instead
9+
*/
610
export const UMB_DATA_CONTENT_UDI = 'data-content-udi';
11+
/**
12+
* The attribute where the block content key is stored.
13+
*/
14+
export const UMB_DATA_CONTENT_KEY = 'data-content-key';
715

816
export interface UmbBlockRteTypeModel extends UmbBlockTypeBaseModel {
917
displayInline: boolean;

src/packages/rte/components/rte-base.element.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface UmbRichTextEditorValueType {
1818
blocks: UmbBlockValueType<UmbBlockRteLayoutModel>;
1919
}
2020

21-
export const UMB_BLOCK_RTE_BLOCK_LAYOUT_ALIAS = 'Umbraco.TinyMCE';
21+
export const UMB_BLOCK_RTE_BLOCK_LAYOUT_ALIAS = 'Umbraco.RichText';
2222

2323
export abstract class UmbRteBaseElement extends UmbLitElement implements UmbPropertyEditorUiElement {
2424
public set config(config: UmbPropertyEditorConfigCollection | undefined) {

0 commit comments

Comments
 (0)