Skip to content

Commit

Permalink
Merge pull request #252 from Aylie-Chou/5-feat-add-html-embededOnly
Browse files Browse the repository at this point in the history
feat: add `embededOnly` options for HTML type
  • Loading branch information
Aylie-Chou authored Jul 8, 2024
2 parents 9695e96 + 0563a00 commit aaa46de
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
8 changes: 4 additions & 4 deletions fields/types/html/HtmlField.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 (
<div className={outerClassName}>
Expand Down
3 changes: 2 additions & 1 deletion fields/types/html/HtmlType.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions fields/types/html/editor/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,11 @@ export const ENTITY_SIMPLE = {
},
};

export const ENTITY_EMBEDEDONLY = {
EMBEDDEDCODE: {
type: 'EMBEDDEDCODE',
},
};


export default ENTITY;

0 comments on commit aaa46de

Please sign in to comment.