({ sticker, config }: { sticker: StickerType; config: StickerTermConfig })
| 54 | } |
| 55 | |
| 56 | function TermSticker({ sticker, config }: { sticker: StickerType; config: StickerTermConfig }) { |
| 57 | const style: React.CSSProperties = { |
| 58 | position: sticker.position, |
| 59 | top: convertHeightDimToPx(sticker.top, config), |
| 60 | left: convertWidthDimToPx(sticker.left, config), |
| 61 | right: convertWidthDimToPx(sticker.right, config), |
| 62 | bottom: convertHeightDimToPx(sticker.bottom, config), |
| 63 | width: convertWidthDimToPx(sticker.width, config), |
| 64 | height: convertHeightDimToPx(sticker.height, config), |
| 65 | color: sticker.color, |
| 66 | fontSize: sticker.fontsize, |
| 67 | transform: sticker.transform, |
| 68 | opacity: sticker.opacity, |
| 69 | fill: sticker.color, |
| 70 | stroke: sticker.color, |
| 71 | }; |
| 72 | if (sticker.pointerevents) { |
| 73 | style.pointerEvents = "auto"; |
| 74 | } |
| 75 | if (style.width != null) { |
| 76 | style.overflowX = "hidden"; |
| 77 | } |
| 78 | if (style.height != null) { |
| 79 | style.overflowY = "hidden"; |
| 80 | } |
| 81 | let clickHandler = null; |
| 82 | if (sticker.pointerevents && (sticker.clickcmd || sticker.clickblockdef)) { |
| 83 | style.cursor = "pointer"; |
| 84 | clickHandler = () => { |
| 85 | console.log("clickHandler", sticker.clickcmd, sticker.clickblockdef); |
| 86 | if (sticker.clickcmd) { |
| 87 | const b64data = stringToBase64(sticker.clickcmd); |
| 88 | RpcApi.ControllerInputCommand(TabRpcClient, { blockid: config.blockId, inputdata64: b64data }); |
| 89 | } |
| 90 | if (sticker.clickblockdef) { |
| 91 | createBlock(sticker.clickblockdef); |
| 92 | } |
| 93 | }; |
| 94 | } |
| 95 | if (sticker.stickertype == "icon") { |
| 96 | return ( |
| 97 | <div className="term-sticker" style={style} onClick={clickHandler}> |
| 98 | <i className={clsx("fa", "fa-" + sticker.icon)} /> |
| 99 | </div> |
| 100 | ); |
| 101 | } |
| 102 | if (sticker.stickertype == "image") { |
| 103 | if (sticker.imgsrc == null) { |
| 104 | return null; |
| 105 | } |
| 106 | const streamingUrl = |
| 107 | getWebServerEndpoint() + "/wave/stream-local-file?path=" + encodeURIComponent(sticker.imgsrc); |
| 108 | return ( |
| 109 | <div className="term-sticker term-sticker-image" style={style} onClick={clickHandler}> |
| 110 | <img src={streamingUrl} /> |
| 111 | </div> |
| 112 | ); |
| 113 | } |
nothing calls this directly
no test coverage detected