packages/rich-text: fix tests
This commit is contained in:
parent
4fe03486eb
commit
2ea2444e84
|
@ -24,8 +24,8 @@ export type RichTextFormatList = Array<RichTextFormat>;
|
||||||
*/
|
*/
|
||||||
export interface RichTextValue {
|
export interface RichTextValue {
|
||||||
text: string;
|
text: string;
|
||||||
formats: Array< RichTextFormatList >;
|
formats: Array<RichTextFormatList>;
|
||||||
replacements: Array< RichTextFormatList>;
|
replacements: Array<RichTextFormatList>;
|
||||||
activeFormats?: RichTextFormatList;
|
activeFormats?: RichTextFormatList;
|
||||||
start?: number;
|
start?: number;
|
||||||
end?: number;
|
end?: number;
|
||||||
|
@ -64,6 +64,7 @@ export interface RichTextFormat {
|
||||||
formatType?: RichTextFormatType;
|
formatType?: RichTextFormatType;
|
||||||
attributes?: Record<string, any>;
|
attributes?: Record<string, any>;
|
||||||
unregisteredAttributes?: Record<string, any>;
|
unregisteredAttributes?: Record<string, any>;
|
||||||
|
innerHTML?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SimpleRange {
|
export interface SimpleRange {
|
||||||
|
|
|
@ -31,16 +31,22 @@ export function useFormatTypes(): FormatTypeStore {
|
||||||
|
|
||||||
formatTypes.value = formatTypes.value.filter(({ name }) => {
|
formatTypes.value = formatTypes.value.filter(({ name }) => {
|
||||||
if (isArray) {
|
if (isArray) {
|
||||||
return !!typesToRemove.find((type) => type === name);
|
return !typesToRemove.find((type) => type === name);
|
||||||
} else {
|
} else {
|
||||||
return name === typesToRemove;
|
return name !== typesToRemove;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const findFormatType = (fn: (f:RichTextFormatType) => boolean) => formatTypes.value.find(type => fn(type));
|
const findFormatType = (fn: (f:RichTextFormatType) => boolean) => formatTypes.value.find(type => fn(type));
|
||||||
const getFormatTypeByName = (name: string) => formatTypes.value.find(type => type.name === name);
|
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);
|
const getFormatTypeForBareElement = (name: string) => formatTypes.value.find(type => type.tagName === name);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue