1- import { addIcon } from "obsidian"
21import { Canvas , CanvasNode } from "src/@types/Canvas"
32import AdvancedCanvasPlugin from "src/main"
43import * as CanvasHelper from "src/utils/canvas-helper"
@@ -7,86 +6,54 @@ import { CanvasEvent } from "src/events/events"
76interface Shape {
87 id : string | null
98 menuName : string
10- icon : ( ) => string
9+ icon : string
1110}
1211
1312const SHAPES : Shape [ ] = [
1413 {
1514 id : null ,
1615 menuName : 'Default' ,
17- icon : ( ) => 'circle-off'
16+ icon : 'circle-off'
1817 } ,
1918 {
2019 id : 'oval' ,
2120 menuName : 'Oval' ,
22- icon : ( ) => {
23- addIcon ( 'oval' , `
24- <rect rx="31.25" height="62.5" width="93.75" y="18.75" x="3.125" stroke-width="8.333" stroke="currentColor" fill="transparent"/>
25- ` )
26- return 'oval'
27- }
21+ icon : 'oval'
2822 } ,
2923 {
3024 id : 'centered-rectangle' ,
3125 menuName : 'Rectangle' ,
32- icon : ( ) => 'rectangle-horizontal'
26+ icon : 'rectangle-horizontal'
3327 } ,
3428 {
3529 id : 'diamond' ,
3630 menuName : 'Diamond' ,
37- icon : ( ) => 'diamond'
31+ icon : 'diamond'
3832 } ,
3933 {
4034 id : 'parallelogram' ,
4135 menuName : 'Parallelogram' ,
42- icon : ( ) => {
43- addIcon ( 'parallelogram' , `
44- <rect transform="skewX(-20)" rx="5" height="50" width="70" y="25" x="35" stroke-width="8.333" stroke="currentColor" fill="transparent"/>
45- ` )
46- return 'parallelogram'
47- }
36+ icon : 'parallelogram'
4837 } ,
4938 {
5039 id : 'circle' ,
5140 menuName : 'Circle' ,
52- icon : ( ) => 'circle'
41+ icon : 'circle'
5342 } ,
5443 {
5544 id : 'predefined-process' ,
5645 menuName : 'Predefined process' ,
57- icon : ( ) => {
58- addIcon ( 'predefined-process' , `
59- <g stroke-width="2" stroke="currentColor" fill="none" transform="matrix(4.166667,0,0,4.166667,0,0)">
60- <path d="M 4.999687 3 L 19.000312 3 C 20.104688 3 21 3.895312 21 4.999687 L 21 19.000312 C 21 20.104688 20.104688 21 19.000312 21 L 4.999687 21 C 3.895312 21 3 20.104688 3 19.000312 L 3 4.999687 C 3 3.895312 3.895312 3 4.999687 3 Z M 4.999687 3 "/>
61- <path d="M 7 3 L 7 21 "/>
62- <path d="M 17 3 L 17 21 "/>
63- </g>
64- ` )
65- return 'predefined-process'
66- }
46+ icon : 'predefined-process'
6747 } ,
6848 {
6949 id : 'document' ,
7050 menuName : 'Document' ,
71- icon : ( ) => {
72- addIcon ( 'document' , `
73- <path transform="translate(0, 5)" stroke="currentColor" fill="none" stroke-width="8.333" d="M83.75 25C85.82 25 87.5 26.68 87.5 28.75L87.5 64.375Q68.75 54.25 50 64.375 31.25 74.5 12.5 64.375L12.5 30.625 12.5 28.75C12.5 26.68 14.18 25 16.25 25Z"/>
74- ` )
75- return 'document'
76- }
51+ icon : 'document'
7752 } ,
7853 {
7954 id : 'database' ,
8055 menuName : 'Database' ,
81- icon : ( ) => {
82- addIcon ( 'database-shape' , `
83- <g transform="translate(20, 20)" stroke-width="8.333" stroke="currentColor" fill="none">
84- <path d="M 1 51 L 1 11 C 1 5.48 14.43 1 31 1 C 47.57 1 61 5.48 61 11 L 61 51 C 61 56.52 47.57 61 31 61 C 14.43 61 1 56.52 1 51 Z"/>
85- <path d="M 1 11 C 1 16.52 14.43 21 31 21 C 47.57 21 61 16.52 61 11"/>
86- </g>
87- ` )
88- return 'database-shape'
89- }
56+ icon : 'database-shape'
9057 }
9158]
9259
@@ -126,7 +93,7 @@ export default class ShapesCanvasExtension {
12693 const shapeButton = CanvasHelper . createPopupMenuOption (
12794 '' ,
12895 shape . menuName ,
129- shape . icon ( ) ,
96+ shape . icon ,
13097 ( ) => this . setShapeForSelection ( canvas , shape )
13198 )
13299
0 commit comments