import {StyloMenu} from '../types/menu';
const imageSvg = ({width, height}: {width: number; height: number}): string => ``;
const setImageWith = ({
size,
paragraph
}: {
size: '25%' | '50%' | '75%' | '100%';
paragraph: HTMLElement;
}) => paragraph.style.setProperty('width', size);
export const imgMenu: StyloMenu = {
match: ({paragraph}: {paragraph: HTMLElement}) => paragraph.nodeName.toLowerCase() === 'img',
actions: [
{
text: 'img_width_original',
icon: imageSvg({width: 20, height: 20}),
action: async ({paragraph}: {paragraph: HTMLElement}) =>
setImageWith({paragraph, size: '100%'})
},
{
text: 'img_width_large',
icon: imageSvg({width: 18, height: 18}),
action: async ({paragraph}: {paragraph: HTMLElement}) =>
setImageWith({paragraph, size: '75%'})
},
{
text: 'img_width_medium',
icon: imageSvg({width: 14, height: 14}),
action: async ({paragraph}: {paragraph: HTMLElement}) =>
setImageWith({paragraph, size: '50%'})
},
{
text: 'img_width_small',
icon: imageSvg({width: 10, height: 10}),
action: async ({paragraph}: {paragraph: HTMLElement}) =>
setImageWith({paragraph, size: '25%'})
},
{
text: 'img_delete',
icon: ``,
action: async ({paragraph}: {paragraph: HTMLElement}) => {
paragraph.parentElement.removeChild(paragraph);
}
}
]
};