Skip to content

Commit ed8baca

Browse files
committed
replace toggleDecorations with appendChild
1 parent ff958ea commit ed8baca

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/features/decorators.tsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ export const toggleDecorations = (flag: boolean) => {
559559
newInput.onchange = async (e) => {
560560
const target = e.target as HTMLInputElement;
561561
const newColor = target.value;
562+
const colorString = newColor.replace("#", "");
562563
const uid = getBlockUidFromTarget(target);
563564
const blockText = getTextByBlockUid(uid);
564565
const newText = blockText.replace(
@@ -568,10 +569,15 @@ export const toggleDecorations = (flag: boolean) => {
568569
await window.roamAlphaAPI.updateBlock({
569570
block: { uid, string: newText },
570571
});
571-
target.value = newColor;
572-
toggleDecorations(false);
572+
const parent = renderedRef.closest(`.roam-block`);
573573
setTimeout(() => {
574-
toggleDecorations(true);
574+
const afterChangeInput = parent?.querySelector(
575+
`[data-tag="${colorString}"]`
576+
);
577+
afterChangeInput?.appendChild(newInput);
578+
if (colorString === "ffffff")
579+
newInput.style.boxShadow =
580+
"inset 0 0 0 1px hsla(0,0%,0%,.2)";
575581
}, 100);
576582
};
577583
});

0 commit comments

Comments
 (0)