@uipath/apollo-react 3.66.1 → 3.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/components/StickyNoteNode/FormattingToolbar.cjs +149 -0
- package/dist/canvas/components/StickyNoteNode/FormattingToolbar.d.ts +12 -0
- package/dist/canvas/components/StickyNoteNode/FormattingToolbar.d.ts.map +1 -0
- package/dist/canvas/components/StickyNoteNode/FormattingToolbar.js +115 -0
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.cjs +75 -12
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.d.ts.map +1 -1
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.js +75 -12
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.styles.cjs +54 -7
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.styles.d.ts +16 -0
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.styles.d.ts.map +1 -1
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.styles.js +40 -2
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.types.d.ts +6 -0
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.types.d.ts.map +1 -1
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.utils.cjs +8 -0
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.utils.d.ts +2 -0
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.utils.d.ts.map +1 -1
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.utils.js +3 -1
- package/dist/canvas/components/StickyNoteNode/markdown-formatting/detectActiveFormats.cjs +69 -0
- package/dist/canvas/components/StickyNoteNode/markdown-formatting/detectActiveFormats.d.ts +11 -0
- package/dist/canvas/components/StickyNoteNode/markdown-formatting/detectActiveFormats.d.ts.map +1 -0
- package/dist/canvas/components/StickyNoteNode/markdown-formatting/detectActiveFormats.js +32 -0
- package/dist/canvas/components/StickyNoteNode/markdown-formatting/index.cjs +68 -0
- package/dist/canvas/components/StickyNoteNode/markdown-formatting/index.d.ts +4 -0
- package/dist/canvas/components/StickyNoteNode/markdown-formatting/index.d.ts.map +1 -0
- package/dist/canvas/components/StickyNoteNode/markdown-formatting/index.js +4 -0
- package/dist/canvas/components/StickyNoteNode/markdown-formatting/inlineFormatting.cjs +173 -0
- package/dist/canvas/components/StickyNoteNode/markdown-formatting/inlineFormatting.d.ts +5 -0
- package/dist/canvas/components/StickyNoteNode/markdown-formatting/inlineFormatting.d.ts.map +1 -0
- package/dist/canvas/components/StickyNoteNode/markdown-formatting/inlineFormatting.js +133 -0
- package/dist/canvas/components/StickyNoteNode/markdown-formatting/listFormatting.cjs +175 -0
- package/dist/canvas/components/StickyNoteNode/markdown-formatting/listFormatting.d.ts +8 -0
- package/dist/canvas/components/StickyNoteNode/markdown-formatting/listFormatting.d.ts.map +1 -0
- package/dist/canvas/components/StickyNoteNode/markdown-formatting/listFormatting.js +126 -0
- package/dist/canvas/components/StickyNoteNode/useMarkdownShortcuts.cjs +62 -0
- package/dist/canvas/components/StickyNoteNode/useMarkdownShortcuts.d.ts +4 -0
- package/dist/canvas/components/StickyNoteNode/useMarkdownShortcuts.d.ts.map +1 -0
- package/dist/canvas/components/StickyNoteNode/useMarkdownShortcuts.js +28 -0
- package/package.json +1 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
FormattingToolbar: ()=>FormattingToolbar
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const external_index_cjs_namespaceObject = require("../../index.cjs");
|
|
31
|
+
const index_cjs_namespaceObject = require("../../../material/components/index.cjs");
|
|
32
|
+
const external_react_namespaceObject = require("react");
|
|
33
|
+
const external_markdown_formatting_index_cjs_namespaceObject = require("./markdown-formatting/index.cjs");
|
|
34
|
+
const external_StickyNoteNode_styles_cjs_namespaceObject = require("./StickyNoteNode.styles.cjs");
|
|
35
|
+
const external_StickyNoteNode_utils_cjs_namespaceObject = require("./StickyNoteNode.utils.cjs");
|
|
36
|
+
const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, onFormat })=>{
|
|
37
|
+
const applyFormat = (0, external_react_namespaceObject.useCallback)((formatFn)=>{
|
|
38
|
+
const textarea = textAreaRef.current;
|
|
39
|
+
if (!textarea) return;
|
|
40
|
+
const input = {
|
|
41
|
+
value: textarea.value,
|
|
42
|
+
selectionStart: textarea.selectionStart,
|
|
43
|
+
selectionEnd: textarea.selectionEnd
|
|
44
|
+
};
|
|
45
|
+
onFormat(formatFn(input));
|
|
46
|
+
textarea.focus();
|
|
47
|
+
}, [
|
|
48
|
+
textAreaRef,
|
|
49
|
+
onFormat
|
|
50
|
+
]);
|
|
51
|
+
const handleBold = (0, external_react_namespaceObject.useCallback)(()=>applyFormat(external_markdown_formatting_index_cjs_namespaceObject.toggleBold), [
|
|
52
|
+
applyFormat
|
|
53
|
+
]);
|
|
54
|
+
const handleItalic = (0, external_react_namespaceObject.useCallback)(()=>applyFormat(external_markdown_formatting_index_cjs_namespaceObject.toggleItalic), [
|
|
55
|
+
applyFormat
|
|
56
|
+
]);
|
|
57
|
+
const handleStrikethrough = (0, external_react_namespaceObject.useCallback)(()=>applyFormat(external_markdown_formatting_index_cjs_namespaceObject.toggleStrikethrough), [
|
|
58
|
+
applyFormat
|
|
59
|
+
]);
|
|
60
|
+
const handleBulletList = (0, external_react_namespaceObject.useCallback)(()=>applyFormat(external_markdown_formatting_index_cjs_namespaceObject.toggleBulletList), [
|
|
61
|
+
applyFormat
|
|
62
|
+
]);
|
|
63
|
+
const handleNumberedList = (0, external_react_namespaceObject.useCallback)(()=>applyFormat(external_markdown_formatting_index_cjs_namespaceObject.toggleNumberedList), [
|
|
64
|
+
applyFormat
|
|
65
|
+
]);
|
|
66
|
+
const mod = (0, external_StickyNoteNode_utils_cjs_namespaceObject.getModifierKey)();
|
|
67
|
+
const shift = (0, external_StickyNoteNode_utils_cjs_namespaceObject.isMac)() ? '⇧' : '+Shift+';
|
|
68
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingToolbarContainer, {
|
|
69
|
+
borderColor: borderColor,
|
|
70
|
+
onMouseDown: (e)=>e.preventDefault(),
|
|
71
|
+
className: "nodrag nowheel",
|
|
72
|
+
children: [
|
|
73
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_cjs_namespaceObject.ApTooltip, {
|
|
74
|
+
content: `Bold (${mod}+B)`,
|
|
75
|
+
placement: "top",
|
|
76
|
+
delay: true,
|
|
77
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingButton, {
|
|
78
|
+
isActive: activeFormats.bold,
|
|
79
|
+
onClick: handleBold,
|
|
80
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.NodeIcon, {
|
|
81
|
+
icon: "bold",
|
|
82
|
+
size: 14
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
}),
|
|
86
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_cjs_namespaceObject.ApTooltip, {
|
|
87
|
+
content: `Italic (${mod}+I)`,
|
|
88
|
+
placement: "top",
|
|
89
|
+
delay: true,
|
|
90
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingButton, {
|
|
91
|
+
isActive: activeFormats.italic,
|
|
92
|
+
onClick: handleItalic,
|
|
93
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.NodeIcon, {
|
|
94
|
+
icon: "italic",
|
|
95
|
+
size: 14
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
}),
|
|
99
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_cjs_namespaceObject.ApTooltip, {
|
|
100
|
+
content: `Strikethrough (${mod}${shift}X)`,
|
|
101
|
+
placement: "top",
|
|
102
|
+
delay: true,
|
|
103
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingButton, {
|
|
104
|
+
isActive: activeFormats.strikethrough,
|
|
105
|
+
onClick: handleStrikethrough,
|
|
106
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.NodeIcon, {
|
|
107
|
+
icon: "strikethrough",
|
|
108
|
+
size: 14
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
}),
|
|
112
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.ToolbarSeparator, {}),
|
|
113
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_cjs_namespaceObject.ApTooltip, {
|
|
114
|
+
content: "Bullet list",
|
|
115
|
+
placement: "top",
|
|
116
|
+
delay: true,
|
|
117
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingButton, {
|
|
118
|
+
isActive: activeFormats.bulletList,
|
|
119
|
+
onClick: handleBulletList,
|
|
120
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.NodeIcon, {
|
|
121
|
+
icon: "list",
|
|
122
|
+
size: 14
|
|
123
|
+
})
|
|
124
|
+
})
|
|
125
|
+
}),
|
|
126
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_cjs_namespaceObject.ApTooltip, {
|
|
127
|
+
content: "Numbered list",
|
|
128
|
+
placement: "top",
|
|
129
|
+
delay: true,
|
|
130
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingButton, {
|
|
131
|
+
isActive: activeFormats.numberedList,
|
|
132
|
+
onClick: handleNumberedList,
|
|
133
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.NodeIcon, {
|
|
134
|
+
icon: "list-ordered",
|
|
135
|
+
size: 14
|
|
136
|
+
})
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
]
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
const FormattingToolbar = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(FormattingToolbarComponent);
|
|
143
|
+
exports.FormattingToolbar = __webpack_exports__.FormattingToolbar;
|
|
144
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
145
|
+
"FormattingToolbar"
|
|
146
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
147
|
+
Object.defineProperty(exports, '__esModule', {
|
|
148
|
+
value: true
|
|
149
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import type { ActiveFormats } from './markdown-formatting';
|
|
3
|
+
import type { TextSelection } from './StickyNoteNode.types';
|
|
4
|
+
interface FormattingToolbarProps {
|
|
5
|
+
textAreaRef: RefObject<HTMLTextAreaElement | null>;
|
|
6
|
+
borderColor: string;
|
|
7
|
+
activeFormats: ActiveFormats;
|
|
8
|
+
onFormat: (result: TextSelection) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const FormattingToolbar: import("react").MemoExoticComponent<({ textAreaRef, borderColor, activeFormats, onFormat, }: FormattingToolbarProps) => import("react/jsx-runtime").JSX.Element>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=FormattingToolbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormattingToolbar.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/FormattingToolbar.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAQ,KAAK,SAAS,EAAe,MAAM,OAAO,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAa3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAG5D,UAAU,sBAAsB;IAC9B,WAAW,EAAE,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,aAAa,CAAC;IAC7B,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;CAC3C;AAwED,eAAO,MAAM,iBAAiB,+FAjE3B,sBAAsB,6CAiEwC,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { NodeIcon } from "../../index.js";
|
|
3
|
+
import { ApTooltip } from "../../../material/components/index.js";
|
|
4
|
+
import { memo, useCallback } from "react";
|
|
5
|
+
import { toggleBold, toggleBulletList, toggleItalic, toggleNumberedList, toggleStrikethrough } from "./markdown-formatting/index.js";
|
|
6
|
+
import { FormattingButton, FormattingToolbarContainer, ToolbarSeparator } from "./StickyNoteNode.styles.js";
|
|
7
|
+
import { getModifierKey, isMac } from "./StickyNoteNode.utils.js";
|
|
8
|
+
const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, onFormat })=>{
|
|
9
|
+
const applyFormat = useCallback((formatFn)=>{
|
|
10
|
+
const textarea = textAreaRef.current;
|
|
11
|
+
if (!textarea) return;
|
|
12
|
+
const input = {
|
|
13
|
+
value: textarea.value,
|
|
14
|
+
selectionStart: textarea.selectionStart,
|
|
15
|
+
selectionEnd: textarea.selectionEnd
|
|
16
|
+
};
|
|
17
|
+
onFormat(formatFn(input));
|
|
18
|
+
textarea.focus();
|
|
19
|
+
}, [
|
|
20
|
+
textAreaRef,
|
|
21
|
+
onFormat
|
|
22
|
+
]);
|
|
23
|
+
const handleBold = useCallback(()=>applyFormat(toggleBold), [
|
|
24
|
+
applyFormat
|
|
25
|
+
]);
|
|
26
|
+
const handleItalic = useCallback(()=>applyFormat(toggleItalic), [
|
|
27
|
+
applyFormat
|
|
28
|
+
]);
|
|
29
|
+
const handleStrikethrough = useCallback(()=>applyFormat(toggleStrikethrough), [
|
|
30
|
+
applyFormat
|
|
31
|
+
]);
|
|
32
|
+
const handleBulletList = useCallback(()=>applyFormat(toggleBulletList), [
|
|
33
|
+
applyFormat
|
|
34
|
+
]);
|
|
35
|
+
const handleNumberedList = useCallback(()=>applyFormat(toggleNumberedList), [
|
|
36
|
+
applyFormat
|
|
37
|
+
]);
|
|
38
|
+
const mod = getModifierKey();
|
|
39
|
+
const shift = isMac() ? '⇧' : '+Shift+';
|
|
40
|
+
return /*#__PURE__*/ jsxs(FormattingToolbarContainer, {
|
|
41
|
+
borderColor: borderColor,
|
|
42
|
+
onMouseDown: (e)=>e.preventDefault(),
|
|
43
|
+
className: "nodrag nowheel",
|
|
44
|
+
children: [
|
|
45
|
+
/*#__PURE__*/ jsx(ApTooltip, {
|
|
46
|
+
content: `Bold (${mod}+B)`,
|
|
47
|
+
placement: "top",
|
|
48
|
+
delay: true,
|
|
49
|
+
children: /*#__PURE__*/ jsx(FormattingButton, {
|
|
50
|
+
isActive: activeFormats.bold,
|
|
51
|
+
onClick: handleBold,
|
|
52
|
+
children: /*#__PURE__*/ jsx(NodeIcon, {
|
|
53
|
+
icon: "bold",
|
|
54
|
+
size: 14
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
}),
|
|
58
|
+
/*#__PURE__*/ jsx(ApTooltip, {
|
|
59
|
+
content: `Italic (${mod}+I)`,
|
|
60
|
+
placement: "top",
|
|
61
|
+
delay: true,
|
|
62
|
+
children: /*#__PURE__*/ jsx(FormattingButton, {
|
|
63
|
+
isActive: activeFormats.italic,
|
|
64
|
+
onClick: handleItalic,
|
|
65
|
+
children: /*#__PURE__*/ jsx(NodeIcon, {
|
|
66
|
+
icon: "italic",
|
|
67
|
+
size: 14
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
}),
|
|
71
|
+
/*#__PURE__*/ jsx(ApTooltip, {
|
|
72
|
+
content: `Strikethrough (${mod}${shift}X)`,
|
|
73
|
+
placement: "top",
|
|
74
|
+
delay: true,
|
|
75
|
+
children: /*#__PURE__*/ jsx(FormattingButton, {
|
|
76
|
+
isActive: activeFormats.strikethrough,
|
|
77
|
+
onClick: handleStrikethrough,
|
|
78
|
+
children: /*#__PURE__*/ jsx(NodeIcon, {
|
|
79
|
+
icon: "strikethrough",
|
|
80
|
+
size: 14
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
}),
|
|
84
|
+
/*#__PURE__*/ jsx(ToolbarSeparator, {}),
|
|
85
|
+
/*#__PURE__*/ jsx(ApTooltip, {
|
|
86
|
+
content: "Bullet list",
|
|
87
|
+
placement: "top",
|
|
88
|
+
delay: true,
|
|
89
|
+
children: /*#__PURE__*/ jsx(FormattingButton, {
|
|
90
|
+
isActive: activeFormats.bulletList,
|
|
91
|
+
onClick: handleBulletList,
|
|
92
|
+
children: /*#__PURE__*/ jsx(NodeIcon, {
|
|
93
|
+
icon: "list",
|
|
94
|
+
size: 14
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
}),
|
|
98
|
+
/*#__PURE__*/ jsx(ApTooltip, {
|
|
99
|
+
content: "Numbered list",
|
|
100
|
+
placement: "top",
|
|
101
|
+
delay: true,
|
|
102
|
+
children: /*#__PURE__*/ jsx(FormattingButton, {
|
|
103
|
+
isActive: activeFormats.numberedList,
|
|
104
|
+
onClick: handleNumberedList,
|
|
105
|
+
children: /*#__PURE__*/ jsx(NodeIcon, {
|
|
106
|
+
icon: "list-ordered",
|
|
107
|
+
size: 14
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
]
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
const FormattingToolbar = /*#__PURE__*/ memo(FormattingToolbarComponent);
|
|
115
|
+
export { FormattingToolbar };
|
|
@@ -47,9 +47,12 @@ const external_remark_gfm_namespaceObject = require("remark-gfm");
|
|
|
47
47
|
var external_remark_gfm_default = /*#__PURE__*/ __webpack_require__.n(external_remark_gfm_namespaceObject);
|
|
48
48
|
const external_constants_cjs_namespaceObject = require("../../constants.cjs");
|
|
49
49
|
const index_cjs_namespaceObject = require("../Toolbar/index.cjs");
|
|
50
|
+
const external_FormattingToolbar_cjs_namespaceObject = require("./FormattingToolbar.cjs");
|
|
51
|
+
const external_markdown_formatting_index_cjs_namespaceObject = require("./markdown-formatting/index.cjs");
|
|
50
52
|
const external_StickyNoteNode_styles_cjs_namespaceObject = require("./StickyNoteNode.styles.cjs");
|
|
51
53
|
const external_StickyNoteNode_types_cjs_namespaceObject = require("./StickyNoteNode.types.cjs");
|
|
52
54
|
const external_StickyNoteNode_utils_cjs_namespaceObject = require("./StickyNoteNode.utils.cjs");
|
|
55
|
+
const external_useMarkdownShortcuts_cjs_namespaceObject = require("./useMarkdownShortcuts.cjs");
|
|
53
56
|
const minWidth = 8 * external_constants_cjs_namespaceObject.GRID_SPACING;
|
|
54
57
|
const minHeight = 8 * external_constants_cjs_namespaceObject.GRID_SPACING;
|
|
55
58
|
const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = 'Add text', renderPlaceholderOnSelect = false })=>{
|
|
@@ -60,6 +63,13 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
60
63
|
const [localContent, setLocalContent] = (0, external_react_namespaceObject.useState)(data.content || '');
|
|
61
64
|
const textAreaRef = (0, external_react_namespaceObject.useRef)(null);
|
|
62
65
|
const colorButtonRef = (0, external_react_namespaceObject.useRef)(null);
|
|
66
|
+
const [activeFormats, setActiveFormats] = (0, external_react_namespaceObject.useState)({
|
|
67
|
+
bold: false,
|
|
68
|
+
italic: false,
|
|
69
|
+
strikethrough: false,
|
|
70
|
+
bulletList: false,
|
|
71
|
+
numberedList: false
|
|
72
|
+
});
|
|
63
73
|
const colorKey = data.color || 'yellow';
|
|
64
74
|
const color = external_StickyNoteNode_types_cjs_namespaceObject.STICKY_NOTE_COLORS[colorKey] ?? external_StickyNoteNode_types_cjs_namespaceObject.STICKY_NOTE_COLORS.yellow;
|
|
65
75
|
const colorWithAlpha = (0, external_StickyNoteNode_types_cjs_namespaceObject.withAlpha)(color);
|
|
@@ -89,6 +99,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
89
99
|
isResizing
|
|
90
100
|
]);
|
|
91
101
|
const handleDoubleClick = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
102
|
+
if (isEditing) return;
|
|
92
103
|
setIsEditing(true);
|
|
93
104
|
setTimeout(()=>{
|
|
94
105
|
if (textAreaRef.current) {
|
|
@@ -96,7 +107,9 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
96
107
|
textAreaRef.current.select();
|
|
97
108
|
}
|
|
98
109
|
}, 0);
|
|
99
|
-
}, [
|
|
110
|
+
}, [
|
|
111
|
+
isEditing
|
|
112
|
+
]);
|
|
100
113
|
const handleBlur = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
101
114
|
setIsEditing(false);
|
|
102
115
|
if (localContent !== data.content) updateNodeData(id, {
|
|
@@ -111,14 +124,53 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
111
124
|
const handleChange = (0, external_react_namespaceObject.useCallback)((e)=>{
|
|
112
125
|
setLocalContent(e.target.value);
|
|
113
126
|
}, []);
|
|
127
|
+
const handleFormat = (0, external_react_namespaceObject.useCallback)((result)=>{
|
|
128
|
+
setLocalContent(result.value);
|
|
129
|
+
setActiveFormats((0, external_markdown_formatting_index_cjs_namespaceObject.detectActiveFormats)(result));
|
|
130
|
+
requestAnimationFrame(()=>{
|
|
131
|
+
if (textAreaRef.current) {
|
|
132
|
+
textAreaRef.current.selectionStart = result.selectionStart;
|
|
133
|
+
textAreaRef.current.selectionEnd = result.selectionEnd;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}, []);
|
|
137
|
+
const updateActiveFormats = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
138
|
+
if (!textAreaRef.current) return;
|
|
139
|
+
const next = (0, external_markdown_formatting_index_cjs_namespaceObject.detectActiveFormats)({
|
|
140
|
+
value: textAreaRef.current.value,
|
|
141
|
+
selectionStart: textAreaRef.current.selectionStart,
|
|
142
|
+
selectionEnd: textAreaRef.current.selectionEnd
|
|
143
|
+
});
|
|
144
|
+
setActiveFormats((prev)=>(0, external_markdown_formatting_index_cjs_namespaceObject.activeFormatsEqual)(prev, next) ? prev : next);
|
|
145
|
+
}, []);
|
|
146
|
+
const shortcutKeyDown = (0, external_useMarkdownShortcuts_cjs_namespaceObject.useMarkdownShortcuts)(textAreaRef, handleFormat);
|
|
114
147
|
const handleKeyDown = (0, external_react_namespaceObject.useCallback)((e)=>{
|
|
115
148
|
if ('Escape' === e.key) {
|
|
116
149
|
setIsEditing(false);
|
|
117
150
|
setLocalContent(data.content || '');
|
|
118
151
|
textAreaRef.current?.blur();
|
|
152
|
+
return;
|
|
119
153
|
}
|
|
154
|
+
if ('Enter' === e.key && !e.shiftKey && !e.metaKey && !e.ctrlKey) {
|
|
155
|
+
const textarea = textAreaRef.current;
|
|
156
|
+
if (textarea) {
|
|
157
|
+
const result = (0, external_markdown_formatting_index_cjs_namespaceObject.continueListOnEnter)({
|
|
158
|
+
value: textarea.value,
|
|
159
|
+
selectionStart: textarea.selectionStart,
|
|
160
|
+
selectionEnd: textarea.selectionEnd
|
|
161
|
+
});
|
|
162
|
+
if (result) {
|
|
163
|
+
e.preventDefault();
|
|
164
|
+
handleFormat(result);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
shortcutKeyDown(e);
|
|
120
170
|
}, [
|
|
121
|
-
data.content
|
|
171
|
+
data.content,
|
|
172
|
+
shortcutKeyDown,
|
|
173
|
+
handleFormat
|
|
122
174
|
]);
|
|
123
175
|
const handleResizeStart = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
124
176
|
setIsResizing(true);
|
|
@@ -310,16 +362,27 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
310
362
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.BottomCornerIndicators, {
|
|
311
363
|
selected: selected
|
|
312
364
|
}),
|
|
313
|
-
isEditing ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
365
|
+
isEditing ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
366
|
+
children: [
|
|
367
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_FormattingToolbar_cjs_namespaceObject.FormattingToolbar, {
|
|
368
|
+
textAreaRef: textAreaRef,
|
|
369
|
+
borderColor: color,
|
|
370
|
+
activeFormats: activeFormats,
|
|
371
|
+
onFormat: handleFormat
|
|
372
|
+
}),
|
|
373
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.StickyNoteTextArea, {
|
|
374
|
+
ref: textAreaRef,
|
|
375
|
+
value: localContent,
|
|
376
|
+
onChange: handleChange,
|
|
377
|
+
onBlur: handleBlur,
|
|
378
|
+
onKeyDown: handleKeyDown,
|
|
379
|
+
onSelect: updateActiveFormats,
|
|
380
|
+
onKeyUp: updateActiveFormats,
|
|
381
|
+
placeholder: placeholder,
|
|
382
|
+
isEditing: isEditing,
|
|
383
|
+
className: "nodrag nowheel"
|
|
384
|
+
})
|
|
385
|
+
]
|
|
323
386
|
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.StickyNoteMarkdown, {
|
|
324
387
|
children: localContent ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_markdown_default(), {
|
|
325
388
|
remarkPlugins: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StickyNoteNode.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/StickyNoteNode.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"StickyNoteNode.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/StickyNoteNode.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AA6B1E,OAAO,KAAK,EAAmB,cAAc,EAAiB,MAAM,wBAAwB,CAAC;AAK7F,MAAM,WAAW,mBAAoB,SAAQ,SAAS;IACpD,IAAI,EAAE,cAAc,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC;AAsXD,eAAO,MAAM,cAAc,kHA1WxB,mBAAmB,6CA0WqC,CAAC"}
|
|
@@ -8,9 +8,12 @@ import react_markdown from "react-markdown";
|
|
|
8
8
|
import remark_gfm from "remark-gfm";
|
|
9
9
|
import { GRID_SPACING } from "../../constants.js";
|
|
10
10
|
import { NodeToolbar } from "../Toolbar/index.js";
|
|
11
|
+
import { FormattingToolbar } from "./FormattingToolbar.js";
|
|
12
|
+
import { activeFormatsEqual, continueListOnEnter, detectActiveFormats } from "./markdown-formatting/index.js";
|
|
11
13
|
import { BottomCornerIndicators, ColorOption, ColorPickerPanel, RESIZE_CONTROL_Z_INDEX, ResizeHandle, StickyNoteContainer, StickyNoteMarkdown, StickyNoteTextArea, StickyNoteWrapper, TopCornerIndicators, stickyNoteGlobalStyles } from "./StickyNoteNode.styles.js";
|
|
12
14
|
import { STICKY_NOTE_COLORS, withAlpha } from "./StickyNoteNode.types.js";
|
|
13
15
|
import { preserveNewlines } from "./StickyNoteNode.utils.js";
|
|
16
|
+
import { useMarkdownShortcuts } from "./useMarkdownShortcuts.js";
|
|
14
17
|
const minWidth = 8 * GRID_SPACING;
|
|
15
18
|
const minHeight = 8 * GRID_SPACING;
|
|
16
19
|
const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = 'Add text', renderPlaceholderOnSelect = false })=>{
|
|
@@ -21,6 +24,13 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
21
24
|
const [localContent, setLocalContent] = useState(data.content || '');
|
|
22
25
|
const textAreaRef = useRef(null);
|
|
23
26
|
const colorButtonRef = useRef(null);
|
|
27
|
+
const [activeFormats, setActiveFormats] = useState({
|
|
28
|
+
bold: false,
|
|
29
|
+
italic: false,
|
|
30
|
+
strikethrough: false,
|
|
31
|
+
bulletList: false,
|
|
32
|
+
numberedList: false
|
|
33
|
+
});
|
|
24
34
|
const colorKey = data.color || 'yellow';
|
|
25
35
|
const color = STICKY_NOTE_COLORS[colorKey] ?? STICKY_NOTE_COLORS.yellow;
|
|
26
36
|
const colorWithAlpha = withAlpha(color);
|
|
@@ -50,6 +60,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
50
60
|
isResizing
|
|
51
61
|
]);
|
|
52
62
|
const handleDoubleClick = useCallback(()=>{
|
|
63
|
+
if (isEditing) return;
|
|
53
64
|
setIsEditing(true);
|
|
54
65
|
setTimeout(()=>{
|
|
55
66
|
if (textAreaRef.current) {
|
|
@@ -57,7 +68,9 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
57
68
|
textAreaRef.current.select();
|
|
58
69
|
}
|
|
59
70
|
}, 0);
|
|
60
|
-
}, [
|
|
71
|
+
}, [
|
|
72
|
+
isEditing
|
|
73
|
+
]);
|
|
61
74
|
const handleBlur = useCallback(()=>{
|
|
62
75
|
setIsEditing(false);
|
|
63
76
|
if (localContent !== data.content) updateNodeData(id, {
|
|
@@ -72,14 +85,53 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
72
85
|
const handleChange = useCallback((e)=>{
|
|
73
86
|
setLocalContent(e.target.value);
|
|
74
87
|
}, []);
|
|
88
|
+
const handleFormat = useCallback((result)=>{
|
|
89
|
+
setLocalContent(result.value);
|
|
90
|
+
setActiveFormats(detectActiveFormats(result));
|
|
91
|
+
requestAnimationFrame(()=>{
|
|
92
|
+
if (textAreaRef.current) {
|
|
93
|
+
textAreaRef.current.selectionStart = result.selectionStart;
|
|
94
|
+
textAreaRef.current.selectionEnd = result.selectionEnd;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}, []);
|
|
98
|
+
const updateActiveFormats = useCallback(()=>{
|
|
99
|
+
if (!textAreaRef.current) return;
|
|
100
|
+
const next = detectActiveFormats({
|
|
101
|
+
value: textAreaRef.current.value,
|
|
102
|
+
selectionStart: textAreaRef.current.selectionStart,
|
|
103
|
+
selectionEnd: textAreaRef.current.selectionEnd
|
|
104
|
+
});
|
|
105
|
+
setActiveFormats((prev)=>activeFormatsEqual(prev, next) ? prev : next);
|
|
106
|
+
}, []);
|
|
107
|
+
const shortcutKeyDown = useMarkdownShortcuts(textAreaRef, handleFormat);
|
|
75
108
|
const handleKeyDown = useCallback((e)=>{
|
|
76
109
|
if ('Escape' === e.key) {
|
|
77
110
|
setIsEditing(false);
|
|
78
111
|
setLocalContent(data.content || '');
|
|
79
112
|
textAreaRef.current?.blur();
|
|
113
|
+
return;
|
|
80
114
|
}
|
|
115
|
+
if ('Enter' === e.key && !e.shiftKey && !e.metaKey && !e.ctrlKey) {
|
|
116
|
+
const textarea = textAreaRef.current;
|
|
117
|
+
if (textarea) {
|
|
118
|
+
const result = continueListOnEnter({
|
|
119
|
+
value: textarea.value,
|
|
120
|
+
selectionStart: textarea.selectionStart,
|
|
121
|
+
selectionEnd: textarea.selectionEnd
|
|
122
|
+
});
|
|
123
|
+
if (result) {
|
|
124
|
+
e.preventDefault();
|
|
125
|
+
handleFormat(result);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
shortcutKeyDown(e);
|
|
81
131
|
}, [
|
|
82
|
-
data.content
|
|
132
|
+
data.content,
|
|
133
|
+
shortcutKeyDown,
|
|
134
|
+
handleFormat
|
|
83
135
|
]);
|
|
84
136
|
const handleResizeStart = useCallback(()=>{
|
|
85
137
|
setIsResizing(true);
|
|
@@ -271,16 +323,27 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
271
323
|
/*#__PURE__*/ jsx(BottomCornerIndicators, {
|
|
272
324
|
selected: selected
|
|
273
325
|
}),
|
|
274
|
-
isEditing ? /*#__PURE__*/
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
326
|
+
isEditing ? /*#__PURE__*/ jsxs(Fragment, {
|
|
327
|
+
children: [
|
|
328
|
+
/*#__PURE__*/ jsx(FormattingToolbar, {
|
|
329
|
+
textAreaRef: textAreaRef,
|
|
330
|
+
borderColor: color,
|
|
331
|
+
activeFormats: activeFormats,
|
|
332
|
+
onFormat: handleFormat
|
|
333
|
+
}),
|
|
334
|
+
/*#__PURE__*/ jsx(StickyNoteTextArea, {
|
|
335
|
+
ref: textAreaRef,
|
|
336
|
+
value: localContent,
|
|
337
|
+
onChange: handleChange,
|
|
338
|
+
onBlur: handleBlur,
|
|
339
|
+
onKeyDown: handleKeyDown,
|
|
340
|
+
onSelect: updateActiveFormats,
|
|
341
|
+
onKeyUp: updateActiveFormats,
|
|
342
|
+
placeholder: placeholder,
|
|
343
|
+
isEditing: isEditing,
|
|
344
|
+
className: "nodrag nowheel"
|
|
345
|
+
})
|
|
346
|
+
]
|
|
284
347
|
}) : /*#__PURE__*/ jsx(StickyNoteMarkdown, {
|
|
285
348
|
children: localContent ? /*#__PURE__*/ jsx(react_markdown, {
|
|
286
349
|
remarkPlugins: [
|