* feat: Support hypelinks * dont show edit when link not present * auto submit on blur * Add link button in sidebar and do it react way * add key to hyperlink to remount when element selection changes * autofocus input * remove click handler and use pointerup/down to show /hide popup * add keydown and support enter/escape to submit * show extrrnal link icon when element has link * use icons and open link in new tab * dnt submit unless link updated * renamed ffiles * remove unnecessary changes * update snap * hide link popup once user starts interacting with element and show again only if clicked outside and clicked on element again * render link icon outside the element * fix hit testing * rewrite implementation to render hyperlinks outside elements and hide when element selected * remove * remove * tweak icon position and size * rotate link icon when element rotated, handle zooming and render exactly where ne resize handle is rendered * no need to create a new reference anymore for element when link added/updated * rotate the link image as well when rotating element * calculate hitbox of link icon and show pointer when hovering over link icon * open link when clicked on link icon * show tooltip when hovering over link icon * show link action only when single element selected * support other protocols * add shortcut cmd/ctrl+k to edit/update link * don't hide popup after submit * renderes decreased woo * Add context mneu label to add/edit link * fix tests * remove tick and show trash when in edit mode * show edit view when element contains link * fix snap * horizontally center the hyperlink container with respect to elemnt * fix padding * remove checkcircle * show popup on hover of selected element and dismiss when outside hitbox * check if element has link before setting popup state * move logic of auto hide to hyperlink and dnt hide when editing * hide popover when drag/resize/rotate * unmount during autohide * autohide after 500ms * fix regression * prevent cmd/ctrl+k when inside link editor * submit when input not updated * allow custom urls * fix centering of popup when zoomed * fix hitbox during zoom * fix * tweak link normalization * touch hyperlink tooltip DOM only if needed * consider 0 if no offsetY * reduce hitbox of link icon and make sure link icon doesn't show on top of higher z-index elements * show link tooltip only if element has higher z-index * dnt show hyperlink popup when selection changes from element with link to element with no link and also hide popover when element type changes from selection to something else * lint: EOL * fix link icon tooltip positioning * open the link only when last pointer down and last pointer up hit the link hitbox * render tooltip after 300ms delay * ensure link popup and editor input have same height * wip: cache the link icon canvas * fix the image quality after caching using device pixel ratio yay * some cleanup * remove unused selectedElementIds from renderConfig * Update src/renderer/renderElement.ts * fix `opener` vulnerability * tweak styling * decrease padding * open local links in the same tab * fix caching * code style refactor * remove unnecessary save & restore * show link shortcut in help dialog * submit on cmd/ctrl+k * merge state props * Add title for link * update editview if prop changes * tweak link action logic * make `Hyperlink` compo editor state fully controlled * dont show popup when context menu open * show in contextMenu only for single selection & change pos * set button `selected` state * set contextMenuOpen on pointerdown * set contextMenyOpen to false when action triggered * don't render link icons on export * fix tests * fix buttons wrap * move focus states to input top-level rule * fix elements sharing `Hyperlink` state * fix hitbox for link icon in case of rect * Early return if hitting link icon Co-authored-by: dwelle <luzar.david@gmail.com>
331 lines
6.3 KiB
Plaintext
331 lines
6.3 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`restoreElements should restore arrow element correctly 1`] = `
|
|
Object {
|
|
"angle": 0,
|
|
"backgroundColor": "transparent",
|
|
"boundElements": Array [],
|
|
"endArrowhead": null,
|
|
"endBinding": null,
|
|
"fillStyle": "hachure",
|
|
"groupIds": Array [],
|
|
"height": 0,
|
|
"id": "id-arrow01",
|
|
"isDeleted": false,
|
|
"lastCommittedPoint": null,
|
|
"link": null,
|
|
"opacity": 100,
|
|
"points": Array [
|
|
Array [
|
|
0,
|
|
0,
|
|
],
|
|
Array [
|
|
0,
|
|
0,
|
|
],
|
|
],
|
|
"roughness": 1,
|
|
"seed": Any<Number>,
|
|
"startArrowhead": null,
|
|
"startBinding": null,
|
|
"strokeColor": "#000000",
|
|
"strokeSharpness": "sharp",
|
|
"strokeStyle": "solid",
|
|
"strokeWidth": 1,
|
|
"type": "arrow",
|
|
"updated": 1,
|
|
"version": 1,
|
|
"versionNonce": 0,
|
|
"width": 0,
|
|
"x": 0,
|
|
"y": 0,
|
|
}
|
|
`;
|
|
|
|
exports[`restoreElements should restore correctly with rectangle, ellipse and diamond elements 1`] = `
|
|
Object {
|
|
"angle": 0,
|
|
"backgroundColor": "blue",
|
|
"boundElements": Array [],
|
|
"fillStyle": "cross-hatch",
|
|
"groupIds": Array [
|
|
"1",
|
|
"2",
|
|
"3",
|
|
],
|
|
"height": 200,
|
|
"id": "1",
|
|
"isDeleted": false,
|
|
"link": null,
|
|
"opacity": 10,
|
|
"roughness": 2,
|
|
"seed": Any<Number>,
|
|
"strokeColor": "red",
|
|
"strokeSharpness": "round",
|
|
"strokeStyle": "dashed",
|
|
"strokeWidth": 2,
|
|
"type": "rectangle",
|
|
"updated": 1,
|
|
"version": 1,
|
|
"versionNonce": 0,
|
|
"width": 100,
|
|
"x": 10,
|
|
"y": 20,
|
|
}
|
|
`;
|
|
|
|
exports[`restoreElements should restore correctly with rectangle, ellipse and diamond elements 2`] = `
|
|
Object {
|
|
"angle": 0,
|
|
"backgroundColor": "blue",
|
|
"boundElements": Array [],
|
|
"fillStyle": "cross-hatch",
|
|
"groupIds": Array [
|
|
"1",
|
|
"2",
|
|
"3",
|
|
],
|
|
"height": 200,
|
|
"id": "2",
|
|
"isDeleted": false,
|
|
"link": null,
|
|
"opacity": 10,
|
|
"roughness": 2,
|
|
"seed": Any<Number>,
|
|
"strokeColor": "red",
|
|
"strokeSharpness": "round",
|
|
"strokeStyle": "dashed",
|
|
"strokeWidth": 2,
|
|
"type": "ellipse",
|
|
"updated": 1,
|
|
"version": 1,
|
|
"versionNonce": 0,
|
|
"width": 100,
|
|
"x": 10,
|
|
"y": 20,
|
|
}
|
|
`;
|
|
|
|
exports[`restoreElements should restore correctly with rectangle, ellipse and diamond elements 3`] = `
|
|
Object {
|
|
"angle": 0,
|
|
"backgroundColor": "blue",
|
|
"boundElements": Array [],
|
|
"fillStyle": "cross-hatch",
|
|
"groupIds": Array [
|
|
"1",
|
|
"2",
|
|
"3",
|
|
],
|
|
"height": 200,
|
|
"id": "3",
|
|
"isDeleted": false,
|
|
"link": null,
|
|
"opacity": 10,
|
|
"roughness": 2,
|
|
"seed": Any<Number>,
|
|
"strokeColor": "red",
|
|
"strokeSharpness": "round",
|
|
"strokeStyle": "dashed",
|
|
"strokeWidth": 2,
|
|
"type": "diamond",
|
|
"updated": 1,
|
|
"version": 1,
|
|
"versionNonce": 0,
|
|
"width": 100,
|
|
"x": 10,
|
|
"y": 20,
|
|
}
|
|
`;
|
|
|
|
exports[`restoreElements should restore freedraw element correctly 1`] = `
|
|
Object {
|
|
"angle": 0,
|
|
"backgroundColor": "transparent",
|
|
"boundElements": Array [],
|
|
"fillStyle": "hachure",
|
|
"groupIds": Array [],
|
|
"height": 0,
|
|
"id": "id-freedraw01",
|
|
"isDeleted": false,
|
|
"lastCommittedPoint": null,
|
|
"link": null,
|
|
"opacity": 100,
|
|
"points": Array [],
|
|
"pressures": Array [],
|
|
"roughness": 1,
|
|
"seed": Any<Number>,
|
|
"simulatePressure": true,
|
|
"strokeColor": "#000000",
|
|
"strokeSharpness": "sharp",
|
|
"strokeStyle": "solid",
|
|
"strokeWidth": 1,
|
|
"type": "freedraw",
|
|
"updated": 1,
|
|
"version": 1,
|
|
"versionNonce": 0,
|
|
"width": 0,
|
|
"x": 0,
|
|
"y": 0,
|
|
}
|
|
`;
|
|
|
|
exports[`restoreElements should restore line and draw elements correctly 1`] = `
|
|
Object {
|
|
"angle": 0,
|
|
"backgroundColor": "transparent",
|
|
"boundElements": Array [],
|
|
"endArrowhead": null,
|
|
"endBinding": null,
|
|
"fillStyle": "hachure",
|
|
"groupIds": Array [],
|
|
"height": 0,
|
|
"id": "id-line01",
|
|
"isDeleted": false,
|
|
"lastCommittedPoint": null,
|
|
"link": null,
|
|
"opacity": 100,
|
|
"points": Array [
|
|
Array [
|
|
0,
|
|
0,
|
|
],
|
|
Array [
|
|
0,
|
|
0,
|
|
],
|
|
],
|
|
"roughness": 1,
|
|
"seed": Any<Number>,
|
|
"startArrowhead": null,
|
|
"startBinding": null,
|
|
"strokeColor": "#000000",
|
|
"strokeSharpness": "sharp",
|
|
"strokeStyle": "solid",
|
|
"strokeWidth": 1,
|
|
"type": "line",
|
|
"updated": 1,
|
|
"version": 1,
|
|
"versionNonce": 0,
|
|
"width": 0,
|
|
"x": 0,
|
|
"y": 0,
|
|
}
|
|
`;
|
|
|
|
exports[`restoreElements should restore line and draw elements correctly 2`] = `
|
|
Object {
|
|
"angle": 0,
|
|
"backgroundColor": "transparent",
|
|
"boundElements": Array [],
|
|
"endArrowhead": null,
|
|
"endBinding": null,
|
|
"fillStyle": "hachure",
|
|
"groupIds": Array [],
|
|
"height": 0,
|
|
"id": "id-draw01",
|
|
"isDeleted": false,
|
|
"lastCommittedPoint": null,
|
|
"link": null,
|
|
"opacity": 100,
|
|
"points": Array [
|
|
Array [
|
|
0,
|
|
0,
|
|
],
|
|
Array [
|
|
0,
|
|
0,
|
|
],
|
|
],
|
|
"roughness": 1,
|
|
"seed": Any<Number>,
|
|
"startArrowhead": null,
|
|
"startBinding": null,
|
|
"strokeColor": "#000000",
|
|
"strokeSharpness": "sharp",
|
|
"strokeStyle": "solid",
|
|
"strokeWidth": 1,
|
|
"type": "line",
|
|
"updated": 1,
|
|
"version": 1,
|
|
"versionNonce": 0,
|
|
"width": 0,
|
|
"x": 0,
|
|
"y": 0,
|
|
}
|
|
`;
|
|
|
|
exports[`restoreElements should restore text element correctly passing value for each attribute 1`] = `
|
|
Object {
|
|
"angle": 0,
|
|
"backgroundColor": "transparent",
|
|
"baseline": 0,
|
|
"boundElements": Array [],
|
|
"containerId": null,
|
|
"fillStyle": "hachure",
|
|
"fontFamily": 1,
|
|
"fontSize": 14,
|
|
"groupIds": Array [],
|
|
"height": 100,
|
|
"id": "id-text01",
|
|
"isDeleted": false,
|
|
"link": null,
|
|
"opacity": 100,
|
|
"originalText": "text",
|
|
"roughness": 1,
|
|
"seed": Any<Number>,
|
|
"strokeColor": "#000000",
|
|
"strokeSharpness": "sharp",
|
|
"strokeStyle": "solid",
|
|
"strokeWidth": 1,
|
|
"text": "text",
|
|
"textAlign": "center",
|
|
"type": "text",
|
|
"updated": 1,
|
|
"version": 1,
|
|
"versionNonce": 0,
|
|
"verticalAlign": "middle",
|
|
"width": 100,
|
|
"x": 0,
|
|
"y": 0,
|
|
}
|
|
`;
|
|
|
|
exports[`restoreElements should restore text element correctly with unknown font family, null text and undefined alignment 1`] = `
|
|
Object {
|
|
"angle": 0,
|
|
"backgroundColor": "transparent",
|
|
"baseline": 0,
|
|
"boundElements": Array [],
|
|
"containerId": null,
|
|
"fillStyle": "hachure",
|
|
"fontFamily": 1,
|
|
"fontSize": 10,
|
|
"groupIds": Array [],
|
|
"height": 100,
|
|
"id": "id-text01",
|
|
"isDeleted": false,
|
|
"link": null,
|
|
"opacity": 100,
|
|
"originalText": "test",
|
|
"roughness": 1,
|
|
"seed": Any<Number>,
|
|
"strokeColor": "#000000",
|
|
"strokeSharpness": "sharp",
|
|
"strokeStyle": "solid",
|
|
"strokeWidth": 1,
|
|
"text": "",
|
|
"textAlign": "left",
|
|
"type": "text",
|
|
"updated": 1,
|
|
"version": 1,
|
|
"versionNonce": 0,
|
|
"verticalAlign": "top",
|
|
"width": 100,
|
|
"x": 0,
|
|
"y": 0,
|
|
}
|
|
`;
|