From 0563a00771e4e6b5bfe481536e9060c4782f5dae Mon Sep 17 00:00:00 2001 From: Aylie Chou Date: Thu, 27 Jun 2024 14:14:58 +0800 Subject: [PATCH] feat: add `embededOnly` options for HTML type --- fields/types/html/HtmlField.js | 8 ++++---- fields/types/html/HtmlType.js | 3 ++- fields/types/html/editor/entities.js | 6 ++++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/fields/types/html/HtmlField.js b/fields/types/html/HtmlField.js index e343a0bbf5..17a7a17343 100644 --- a/fields/types/html/HtmlField.js +++ b/fields/types/html/HtmlField.js @@ -16,7 +16,7 @@ import { InlineStyleButtons, } from './editor/editor-buttons'; import { Button, FormInput } from 'elemental'; -import { ENTITY, ENTITY_SIMPLE } from './editor/entities'; +import { ENTITY, ENTITY_SIMPLE, ENTITY_EMBEDEDONLY } from './editor/entities'; import AtomicBlockSwitcher from './editor/base/atomic-block-switcher'; import BlockModifier from './editor/modifiers/index'; import DraftConverter from './editor/draft-converter'; @@ -345,9 +345,9 @@ module.exports = Field.create({ expandBtnClass = ' expanded'; } - const blockGroup = this.props.simple ? BLOCK_TYPES_SIMPLE : BLOCK_TYPES - const inlineGroup = this.props.simple ? INLINE_STYLES_SIMPLE : INLINE_STYLES - const entityGroup = this.props.simple ? ENTITY_SIMPLE : ENTITY + const blockGroup = this.props.embededOnly ? [] : (this.props.simple ? BLOCK_TYPES_SIMPLE : BLOCK_TYPES); + const inlineGroup = this.props.embededOnly ? [] : (this.props.simple ? INLINE_STYLES_SIMPLE : INLINE_STYLES); + const entityGroup = this.props.embededOnly ? ENTITY_EMBEDEDONLY : (this.props.simple ? ENTITY_SIMPLE : ENTITY); return (
diff --git a/fields/types/html/HtmlType.js b/fields/types/html/HtmlType.js index fc2a727553..42b19fc4e9 100644 --- a/fields/types/html/HtmlType.js +++ b/fields/types/html/HtmlType.js @@ -13,7 +13,8 @@ function html(list, path, options) { this.wysiwyg = options.wysiwyg || false; this.height = options.height || 180; this.simple = options.simple ? true : false; - this._properties = ['wysiwyg', 'height', 'simple']; + this.embededOnly = options.embededOnly ? true : false; + this._properties = ['wysiwyg', 'height', 'simple', 'embededOnly']; html.super_.call(this, list, path, options); } util.inherits(html, FieldType); diff --git a/fields/types/html/editor/entities.js b/fields/types/html/editor/entities.js index a0594dee96..be72c55cc3 100644 --- a/fields/types/html/editor/entities.js +++ b/fields/types/html/editor/entities.js @@ -52,5 +52,11 @@ export const ENTITY_SIMPLE = { }, }; +export const ENTITY_EMBEDEDONLY = { + EMBEDDEDCODE: { + type: 'EMBEDDEDCODE', + }, +}; + export default ENTITY;