1- import { StyloMenu } from '@papyrs/stylo' ;
21import { popoverController } from '@ionic/core' ;
32
3+ import { StyloMenu } from '@papyrs/stylo' ;
4+
5+ import { SelectedTarget } from '../types/editor/selected-target' ;
6+
7+ import { SelectedElementUtils } from '../utils/editor/selected-element.utils' ;
8+
49export const codeMenu : StyloMenu = {
510 match : ( { paragraph} : { paragraph : HTMLElement } ) => paragraph ?. nodeName . toLowerCase ( ) === 'deckgo-highlight-code' ,
611 actions : [
712 {
813 text : 'edit_code' ,
9- icon : `<svg xmlns=' http://www.w3.org/2000/svg' width='20' height='20' viewBox=' 0 0 512 512' >
10- <polygon points='364.13 125.25 87 403 64 448 108.99 425 386.75 147.87 364.13 125.25' style=' fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width:32px' />
11- <path d='M420.69,68.69,398.07,91.31l22.62,22.63,22.62-22.63a16,16,0,0,0,0 -22.62h0A16,16,0,0,0,420.69,68.69Z' style='fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px' />
12- </svg>` ,
14+ icon : `<svg xmlns=" http://www.w3.org/2000/svg" width='20' height='20' viewBox=" 0 0 512 512" >
15+ <path d="M384 224v184a40 40 0 01-40 40H104a40 40 0 01-40-40V168a40 40 0 0140-40h167.48" fill=" none" stroke=" currentColor" stroke-linecap=" round" stroke-linejoin=" round" stroke-width="32" />
16+ <path d="M459.94 53.25a16.06 16.06 0 00-23.22-.56L424.35 65a8 8 0 000 11.31l11.34 11.32a8 8 0 0011.34 0l12.06-12c6.1-6.09 6.67-16.01.85 -22.38zM399.34 90L218.82 270.2a9 9 0 00-2.31 3.93L208.16 299a3.91 3.91 0 004.86 4.86l24.85-8.35a9 9 0 003.93-2.31L422 112.66a9 9 0 000-12.66l-9.95-10a9 9 0 00-12.71 0z" />
17+ </svg>` ,
1318 action : async ( { paragraph} : { paragraph : HTMLElement } ) => {
1419 const editCode : CustomEvent < void > = new CustomEvent < void > ( 'editCode' , {
1520 bubbles : true
@@ -18,6 +23,29 @@ export const codeMenu: StyloMenu = {
1823 paragraph . dispatchEvent ( editCode ) ;
1924 }
2025 } ,
26+ {
27+ text : 'style' ,
28+ icon : `<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 512 512'>
29+ <path d='M452.37,59.63h0a40.49,40.49,0,0,0-57.26,0L184,294.74c23.08,4.7,46.12,27.29,49.26,49.26L452.37,116.89A40.49,40.49,0,0,0,452.37,59.63Z' style='fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px'/>
30+ <path d='M138,336c-29.88,0-54,24.5-54,54.86,0,23.95-20.88,36.57-36,36.57C64.56,449.74,92.82,464,120,464c39.78,0,72-32.73,72-73.14C192,360.5,167.88,336,138,336Z' style='fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px'/>
31+ </svg>` ,
32+ action : async ( { paragraph} : { paragraph : HTMLElement } ) => {
33+ const popover : HTMLIonPopoverElement = await popoverController . create ( {
34+ component : 'app-element-style' ,
35+ componentProps : {
36+ selectedTarget : {
37+ target : paragraph ,
38+ ...( SelectedElementUtils . initDescription ( paragraph ) as SelectedTarget )
39+ }
40+ } ,
41+ mode : 'ios' ,
42+ showBackdrop : false ,
43+ cssClass : 'popover-menu'
44+ } ) ;
45+
46+ await popover . present ( ) ;
47+ }
48+ } ,
2149 {
2250 text : 'options' ,
2351 icon : `<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 512 512'>
0 commit comments