@@ -330,7 +326,6 @@ const BlockifyLink = (props: {
let { editorState } = props;
let rep = useReplicache();
let smoker = useSmoker();
- let isLocked = useEntity(props.entityID, "block/is-locked");
let focused = useUIState((s) => s.focusedEntity?.entityID === props.entityID);
let isBlueskyPost =
@@ -340,7 +335,6 @@ const BlockifyLink = (props: {
// if its bluesky, change text to embed post
if (
- !isLocked &&
focused &&
editorState &&
betterIsUrl(editorState.doc.textContent) &&
diff --git a/components/Blocks/index.tsx b/components/Blocks/index.tsx
index 6a7414b6..f5d49802 100644
--- a/components/Blocks/index.tsx
+++ b/components/Blocks/index.tsx
@@ -181,11 +181,9 @@ function NewBlockButton(props: { lastBlock: Block | null; entityID: string }) {
: null,
);
- let isLocked = useEntity(props.lastBlock?.value || null, "block/is-locked");
if (!entity_set.permissions.write) return null;
if (
- ((props.lastBlock?.type === "text" && !isLocked?.data.value) ||
- props.lastBlock?.type === "heading") &&
+ (props.lastBlock?.type === "text" || props.lastBlock?.type === "heading") &&
(!editorState?.editor || editorState.editor.doc.content.size <= 2)
)
return null;
diff --git a/components/Blocks/useBlockKeyboardHandlers.ts b/components/Blocks/useBlockKeyboardHandlers.ts
index 38f678a0..6ffb977e 100644
--- a/components/Blocks/useBlockKeyboardHandlers.ts
+++ b/components/Blocks/useBlockKeyboardHandlers.ts
@@ -23,7 +23,6 @@ export function useBlockKeyboardHandlers(
) {
let { rep, undoManager } = useReplicache();
let entity_set = useEntitySetContext();
- let isLocked = !!useEntity(props.entityID, "block/is-locked")?.data.value;
let isSelected = useUIState((s) => {
let selectedBlocks = s.selectedBlocks;
@@ -70,18 +69,16 @@ export function useBlockKeyboardHandlers(
entity_set,
areYouSure,
setAreYouSure,
- isLocked,
});
undoManager.endGroup();
};
window.addEventListener("keydown", listener);
return () => window.removeEventListener("keydown", listener);
- }, [entity_set, isSelected, props, rep, areYouSure, setAreYouSure, isLocked]);
+ }, [entity_set, isSelected, props, rep, areYouSure, setAreYouSure]);
}
type Args = {
e: KeyboardEvent;
- isLocked: boolean;
props: BlockProps;
rep: Replicache
;
entity_set: { set: string };
@@ -133,16 +130,8 @@ function ArrowUp({ e, props }: Args) {
}
let debounced: null | number = null;
-async function Backspace({
- e,
- props,
- rep,
- areYouSure,
- setAreYouSure,
- isLocked,
-}: Args) {
+async function Backspace({ e, props, rep, areYouSure, setAreYouSure }: Args) {
// if this is a textBlock, let the textBlock/keymap handle the backspace
- if (isLocked) return;
// if its an input, label, or teatarea with content, do nothing (do the broswer default instead)
let el = e.target as HTMLElement;
if (
diff --git a/components/Toolbar/LockBlockButton.tsx b/components/Toolbar/LockBlockButton.tsx
deleted file mode 100644
index 3fdaa497..00000000
--- a/components/Toolbar/LockBlockButton.tsx
+++ /dev/null
@@ -1,103 +0,0 @@
-import { useUIState } from "src/useUIState";
-import { ToolbarButton } from ".";
-import { useEntity, useReplicache } from "src/replicache";
-
-import { focusBlock } from "src/utils/focusBlock";
-import { Props } from "components/Icons/Props";
-
-export function LockBlockButton() {
- let focusedBlock = useUIState((s) => s.focusedEntity);
- let selectedBlocks = useUIState((s) => s.selectedBlocks);
- let type = useEntity(focusedBlock?.entityID || null, "block/type");
- let locked = useEntity(focusedBlock?.entityID || null, "block/is-locked");
- let { rep } = useReplicache();
- if (focusedBlock?.entityType !== "block") return;
- return (
- {
- if (!locked?.data.value) {
- await rep?.mutate.assertFact({
- entity: focusedBlock.entityID,
- attribute: "block/is-locked",
- data: { value: true, type: "boolean" },
- });
- if (selectedBlocks.length > 1) {
- for (let block of selectedBlocks) {
- await rep?.mutate.assertFact({
- attribute: "block/is-locked",
- entity: block.value,
- data: { value: true, type: "boolean" },
- });
- }
- }
- } else {
- await rep?.mutate.retractFact({ factID: locked.id });
- if (selectedBlocks.length > 1) {
- for (let block of selectedBlocks) {
- await rep?.mutate.retractAttribute({
- attribute: "block/is-locked",
- entity: block.value,
- });
- }
- } else {
- type &&
- focusBlock(
- {
- type: type.data.value,
- parent: focusedBlock.parent,
- value: focusedBlock.entityID,
- },
- { type: "end" },
- );
- }
- }
- }}
- tooltipContent={
- {!locked?.data.value ? "Lock Editing" : " Unlock to Edit"}
- }
- >
- {!locked?.data.value ? : }
-
- );
-}
-
-const LockSmall = (props: Props) => {
- return (
-
-
-
- );
-};
-
-const UnlockSmall = (props: Props) => {
- return (
-
-
-
- );
-};
diff --git a/components/Toolbar/MultiSelectToolbar.tsx b/components/Toolbar/MultiSelectToolbar.tsx
index affb41d2..ef2aa833 100644
--- a/components/Toolbar/MultiSelectToolbar.tsx
+++ b/components/Toolbar/MultiSelectToolbar.tsx
@@ -3,14 +3,12 @@ import { ReplicacheMutators, useReplicache } from "src/replicache";
import { ToolbarButton } from "./index";
import { copySelection } from "src/utils/copySelection";
import { useSmoker, useToaster } from "components/Toast";
-import { getBlocksWithType } from "src/hooks/queries/useBlocks";
-import { Replicache } from "replicache";
-import { LockBlockButton } from "./LockBlockButton";
+
import { Props } from "components/Icons/Props";
import { TextAlignmentButton } from "./TextAlignmentToolbar";
import { getSortedSelection } from "components/SelectionManager/selectionState";
import { deleteBlock } from "src/utils/deleteBlock";
-import { ShortcutKey } from "components/Layout";
+import { Separator, ShortcutKey } from "components/Layout";
export const MultiselectToolbar = (props: {
setToolbarState: (state: "multiselect" | "text-alignment") => void;
@@ -69,7 +67,7 @@ export const MultiselectToolbar = (props: {
-
+
);
diff --git a/components/Toolbar/TextToolbar.tsx b/components/Toolbar/TextToolbar.tsx
index fb663732..b6663dd5 100644
--- a/components/Toolbar/TextToolbar.tsx
+++ b/components/Toolbar/TextToolbar.tsx
@@ -8,7 +8,6 @@ import { HighlightButton } from "./HighlightToolbar";
import { ToolbarTypes } from ".";
import { schema } from "components/Blocks/TextBlock/schema";
import { TextAlignmentButton } from "./TextAlignmentToolbar";
-import { LockBlockButton } from "./LockBlockButton";
import { Props } from "components/Icons/Props";
import { isMac } from "src/utils/isDevice";
@@ -81,8 +80,6 @@ export const TextToolbar = (props: {