@sikka/hawa 0.0.235 → 0.0.236
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/styles.css +3 -0
- package/docs/documentation/iframe.html +1 -1
- package/docs/documentation/main.44fbaf91.iframe.bundle.js +1 -0
- package/docs/documentation/project.json +1 -1
- package/es/elements/FloatingComment.d.ts +27 -1
- package/es/index.es.js +1 -1
- package/lib/elements/FloatingComment.d.ts +27 -1
- package/lib/index.js +2 -2
- package/package.json +1 -1
- package/src/elements/FloatingComment.tsx +53 -13
- package/src/styles.css +3 -0
- package/docs/documentation/main.fb64f936.iframe.bundle.js +0 -1
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import clsx from "clsx"
|
|
|
4
4
|
const Property = (props) => {
|
|
5
5
|
return (
|
|
6
6
|
<div
|
|
7
|
-
className="border-box mr-[
|
|
7
|
+
className="border-box mr-[10px] flex h-[32px] w-[32px] items-center justify-center rounded bg-gray-300 p-2"
|
|
8
8
|
onMouseDown={props.onMouseDown}
|
|
9
9
|
>
|
|
10
10
|
{props.name}
|
|
@@ -13,14 +13,18 @@ const Property = (props) => {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
type ComponentTypes = {
|
|
16
|
-
|
|
16
|
+
rtl?: "enabled" | "disabled" | "auto"
|
|
17
|
+
onSubmit?: (
|
|
18
|
+
content: string,
|
|
19
|
+
stylings: { type: keyof typeof stylers; start: number; finish: number }[]
|
|
20
|
+
) => void
|
|
17
21
|
}
|
|
18
22
|
|
|
19
|
-
const
|
|
20
|
-
bold: "font-bold",
|
|
21
|
-
italic: "italic",
|
|
22
|
-
under: "underline",
|
|
23
|
-
strike: "line-through",
|
|
23
|
+
const stylers = {
|
|
24
|
+
bold: { css: "font-bold", content: "B" },
|
|
25
|
+
italic: { id: "italic", css: "italic", content: "I" },
|
|
26
|
+
under: { id: "under", css: "underline", content: "U" },
|
|
27
|
+
strike: { id: "strike", css: "line-through", content: "S" },
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
// FIXME: Highlighting a part of styled text with a bit on the left with an overall length not equal to clipboard copied text will result in paste issues
|
|
@@ -847,7 +851,7 @@ export const FloatingComment: React.FunctionComponent<ComponentTypes> = (
|
|
|
847
851
|
// console.log(data)
|
|
848
852
|
// console.log(stylings)
|
|
849
853
|
return `<span class="${stylings
|
|
850
|
-
.map((styling) =>
|
|
854
|
+
.map((styling) => stylers[styling.type].css)
|
|
851
855
|
.join(" ")}" data-child-index="${index}">${data}</span>`
|
|
852
856
|
})
|
|
853
857
|
.join("")
|
|
@@ -855,10 +859,36 @@ export const FloatingComment: React.FunctionComponent<ComponentTypes> = (
|
|
|
855
859
|
field.current.innerHTML = html
|
|
856
860
|
}, [text.content, text.stylings, text.revert])
|
|
857
861
|
|
|
862
|
+
const getTextDirection = () => {
|
|
863
|
+
let value = props.rtl || "disabled"
|
|
864
|
+
|
|
865
|
+
switch (value) {
|
|
866
|
+
case "enabled":
|
|
867
|
+
return "rtl"
|
|
868
|
+
case "disabled":
|
|
869
|
+
return "ltr"
|
|
870
|
+
case "auto":
|
|
871
|
+
return "ltr"
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
|
|
858
875
|
return (
|
|
859
|
-
<div className="align-center box-border flex h-min w-[400px] flex-col items-center justify-center rounded
|
|
876
|
+
<div className="align-center box-border flex h-min w-[400px] flex-col items-center justify-center rounded shadow-md">
|
|
860
877
|
<div className={clsx("flex w-full flex-row justify-start p-2")}>
|
|
861
|
-
|
|
878
|
+
{Object.entries(stylers).map(([id, data]) => {
|
|
879
|
+
return (
|
|
880
|
+
<Property
|
|
881
|
+
name={data.content}
|
|
882
|
+
key={`property-${id}`}
|
|
883
|
+
onMouseDown={(event) => {
|
|
884
|
+
event.preventDefault()
|
|
885
|
+
perform(id)
|
|
886
|
+
}}
|
|
887
|
+
/>
|
|
888
|
+
)
|
|
889
|
+
})}
|
|
890
|
+
|
|
891
|
+
{/* <Property
|
|
862
892
|
name="B"
|
|
863
893
|
onMouseDown={(event) => {
|
|
864
894
|
event.preventDefault() // This does not take focus away from field which allows the function to retrieve the current selection data
|
|
@@ -885,14 +915,17 @@ export const FloatingComment: React.FunctionComponent<ComponentTypes> = (
|
|
|
885
915
|
event.preventDefault()
|
|
886
916
|
perform("strike")
|
|
887
917
|
}}
|
|
888
|
-
/>
|
|
918
|
+
/> */}
|
|
889
919
|
</div>
|
|
890
920
|
<div className="h-[1px] w-full bg-slate-600"> </div>
|
|
891
921
|
<div className="w-full">
|
|
892
922
|
<div
|
|
893
923
|
ref={field}
|
|
894
924
|
contentEditable="true"
|
|
895
|
-
className="h-[150px] w-full resize-none overflow-auto overflow-x-hidden border-none p-2 outline-none"
|
|
925
|
+
className="rtl h-[150px] w-full resize-none overflow-auto overflow-x-hidden border-none p-2 outline-none"
|
|
926
|
+
style={{
|
|
927
|
+
direction: getTextDirection(),
|
|
928
|
+
}}
|
|
896
929
|
onPaste={(event) => {
|
|
897
930
|
// pastes all copied text from the content editable as plain text
|
|
898
931
|
event.preventDefault()
|
|
@@ -980,7 +1013,14 @@ export const FloatingComment: React.FunctionComponent<ComponentTypes> = (
|
|
|
980
1013
|
></div>
|
|
981
1014
|
</div>
|
|
982
1015
|
<div className="h-[1px] w-full bg-slate-600"> </div>
|
|
983
|
-
<button
|
|
1016
|
+
<button
|
|
1017
|
+
className="my-1 rounded bg-cyan-800 p-2 py-1 text-white"
|
|
1018
|
+
onClick={() => {
|
|
1019
|
+
let onSubmit = props.onSubmit || (() => {})
|
|
1020
|
+
|
|
1021
|
+
onSubmit(text.content, text.stylings)
|
|
1022
|
+
}}
|
|
1023
|
+
>
|
|
984
1024
|
Submit
|
|
985
1025
|
</button>
|
|
986
1026
|
</div>
|