add setting diable/enable smart guide
This commit is contained in:
@@ -39,6 +39,7 @@ const EditorCanvas = ({ catalogSize }: EditorCanvasProps) => {
|
|||||||
tool,
|
tool,
|
||||||
objects,
|
objects,
|
||||||
guides,
|
guides,
|
||||||
|
documentSettings,
|
||||||
pages,
|
pages,
|
||||||
currentPageId,
|
currentPageId,
|
||||||
selectedObjectId,
|
selectedObjectId,
|
||||||
@@ -50,6 +51,7 @@ const EditorCanvas = ({ catalogSize }: EditorCanvasProps) => {
|
|||||||
setGuides,
|
setGuides,
|
||||||
zoom,
|
zoom,
|
||||||
} = useEditorStore();
|
} = useEditorStore();
|
||||||
|
const isSmartGuideEnabled = documentSettings.smartGuide;
|
||||||
const currentPage = pages.find((page) => page.id === currentPageId);
|
const currentPage = pages.find((page) => page.id === currentPageId);
|
||||||
|
|
||||||
const bgColor =
|
const bgColor =
|
||||||
@@ -307,6 +309,11 @@ const EditorCanvas = ({ catalogSize }: EditorCanvasProps) => {
|
|||||||
const handleDragMove = (e: Konva.KonvaEventObject<DragEvent>) => {
|
const handleDragMove = (e: Konva.KonvaEventObject<DragEvent>) => {
|
||||||
const node = e.target;
|
const node = e.target;
|
||||||
if (!node || node.name() === "guide-line") return;
|
if (!node || node.name() === "guide-line") return;
|
||||||
|
if (!isSmartGuideEnabled) {
|
||||||
|
updateActiveGuides([]);
|
||||||
|
clearSmartGuides(smartGuidesLayerRef.current);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const snapped = getSnappedPosition(node, guides, finalScale);
|
const snapped = getSnappedPosition(node, guides, finalScale);
|
||||||
|
|
||||||
@@ -338,6 +345,12 @@ const EditorCanvas = ({ catalogSize }: EditorCanvasProps) => {
|
|||||||
clearSmartGuides(smartGuidesLayerRef.current);
|
clearSmartGuides(smartGuidesLayerRef.current);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isSmartGuideEnabled) return;
|
||||||
|
updateActiveGuides([]);
|
||||||
|
clearSmartGuides(smartGuidesLayerRef.current);
|
||||||
|
}, [isSmartGuideEnabled]);
|
||||||
|
|
||||||
const handleStageMouseDownWithGuideReset = (e: Konva.KonvaEventObject<MouseEvent>) => {
|
const handleStageMouseDownWithGuideReset = (e: Konva.KonvaEventObject<MouseEvent>) => {
|
||||||
if (e.target?.name() !== "guide-line") {
|
if (e.target?.name() !== "guide-line") {
|
||||||
setSelectedGuideId(null);
|
setSelectedGuideId(null);
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ const SettingsPanel = () => {
|
|||||||
displayStyle,
|
displayStyle,
|
||||||
autoPlay,
|
autoPlay,
|
||||||
pageFlipSound,
|
pageFlipSound,
|
||||||
|
smartGuide,
|
||||||
// leftToRightFlip,
|
// leftToRightFlip,
|
||||||
} = documentSettings
|
} = documentSettings
|
||||||
|
|
||||||
@@ -142,6 +143,19 @@ const SettingsPanel = () => {
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section className="p-4 border-b border-border">
|
||||||
|
<div className="flex items-center gap-2 mb-4">
|
||||||
|
<h3 className="text-sm font-semibold text-gray-800">تنظیمات ویرایشگر</h3>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-col gap-3">
|
||||||
|
<CheckboxRow
|
||||||
|
label="راهنمای هوشمند"
|
||||||
|
checked={smartGuide}
|
||||||
|
onChange={(v) => updateDocumentSettings({ smartGuide: v })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
{/* ─── پس زمینه ─── */}
|
{/* ─── پس زمینه ─── */}
|
||||||
<section className="p-4">
|
<section className="p-4">
|
||||||
<h3 className="text-sm font-semibold text-gray-800 mb-4">پس زمینه</h3>
|
<h3 className="text-sm font-semibold text-gray-800 mb-4">پس زمینه</h3>
|
||||||
|
|||||||
@@ -189,6 +189,7 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
|||||||
autoPlay: false,
|
autoPlay: false,
|
||||||
pageFlipSound: true,
|
pageFlipSound: true,
|
||||||
leftToRightFlip: false,
|
leftToRightFlip: false,
|
||||||
|
smartGuide: true,
|
||||||
backgroundType: 'color',
|
backgroundType: 'color',
|
||||||
backgroundColor: '#ffffff',
|
backgroundColor: '#ffffff',
|
||||||
backgroundGradient: {
|
backgroundGradient: {
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ export type DocumentSettings = {
|
|||||||
autoPlay: boolean;
|
autoPlay: boolean;
|
||||||
pageFlipSound: boolean;
|
pageFlipSound: boolean;
|
||||||
leftToRightFlip: boolean;
|
leftToRightFlip: boolean;
|
||||||
|
smartGuide: boolean;
|
||||||
backgroundType: BackgroundType;
|
backgroundType: BackgroundType;
|
||||||
backgroundColor: string;
|
backgroundColor: string;
|
||||||
backgroundGradient?: LinearGradient;
|
backgroundGradient?: LinearGradient;
|
||||||
|
|||||||
Reference in New Issue
Block a user