diff --git a/packages/rich-text/lib/types.ts b/packages/rich-text/lib/types.ts index 719cb27..3976d37 100644 --- a/packages/rich-text/lib/types.ts +++ b/packages/rich-text/lib/types.ts @@ -24,8 +24,8 @@ export type RichTextFormatList = Array; */ export interface RichTextValue { text: string; - formats: Array< RichTextFormatList >; - replacements: Array< RichTextFormatList>; + formats: Array; + replacements: Array; activeFormats?: RichTextFormatList; start?: number; end?: number; @@ -64,6 +64,7 @@ export interface RichTextFormat { formatType?: RichTextFormatType; attributes?: Record; unregisteredAttributes?: Record; + innerHTML?: string; } export interface SimpleRange { diff --git a/packages/rich-text/lib/use-format-types.ts b/packages/rich-text/lib/use-format-types.ts index 815ddf6..4b07367 100644 --- a/packages/rich-text/lib/use-format-types.ts +++ b/packages/rich-text/lib/use-format-types.ts @@ -31,16 +31,22 @@ export function useFormatTypes(): FormatTypeStore { formatTypes.value = formatTypes.value.filter(({ name }) => { if (isArray) { - return !!typesToRemove.find((type) => type === name); + return !typesToRemove.find((type) => type === name); } else { - return name === typesToRemove; + return name !== typesToRemove; } }); }; const findFormatType = (fn: (f:RichTextFormatType) => boolean) => formatTypes.value.find(type => fn(type)); const getFormatTypeByName = (name: string) => formatTypes.value.find(type => type.name === name); - const getFormatTypeForClassName = (name: string) => formatTypes.value.find(type => type.className === name); + const getFormatTypeForClassName = (name: string) => formatTypes.value.find(type => { + if ( type.className === null ) { + return false; + } + + return ` ${ name } `.indexOf( ` ${ type.className } ` ) >= 0; + } ); const getFormatTypeForBareElement = (name: string) => formatTypes.value.find(type => type.tagName === name); return {