Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kie-issues#1164: Cut/Copy/Paste Functionality Issues in DRD View: DMN Editor Extension for VSCode (macOS) #2883

Merged
merged 6 commits into from
Jan 31, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
kie-issues#1164: Cut/Copy/Paste Functionality Issues in DRD View: DMN…
… Editor Extension for VSCode (macOS)
danielzhe committed Dec 18, 2024
commit 84941e37760ee3ab2608f8b144ca2792e80c889e
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@ import {
BeeTableSelectionContextProvider,
SELECTION_MIN_ACTIVE_DEPTH,
SelectionPart,
useBeeTableSelection,
useBeeTableSelectionDispatch,
} from "../../selection/BeeTableSelectionContext";
import { BeeTableCellWidthsToFitDataContextProvider } from "../../resizing/BeeTableCellWidthToFitDataContext";
@@ -111,6 +112,8 @@ export function BeeTableInternal<R extends object>({
const tableComposableRef = useRef<HTMLTableElement>(null);
const { currentlyOpenContextMenu } = useBoxedExpressionEditor();

const { selectionStart, selectionEnd } = useBeeTableSelection();

const tableRef = React.useRef<HTMLDivElement>(null);

const hasAdditionalRow = useMemo(() => {
@@ -325,6 +328,10 @@ export function BeeTableInternal<R extends object>({

const onKeyDown = useCallback(
(e: React.KeyboardEvent) => {
if (selectionStart?.isEditing || selectionEnd?.isEditing) {
return;
}

if (!enableKeyboardNavigation) {
return;
}
@@ -504,20 +511,22 @@ export function BeeTableInternal<R extends object>({
}
},
[
selectionStart?.isEditing,
selectionEnd?.isEditing,
enableKeyboardNavigation,
currentlyOpenContextMenu,
isReadOnly,
setCurrentDepth,
mutateSelection,
getColumnCount,
rowCount,
reactTableInstance.allColumns.length,
reactTableInstance.rows.length,
getColumnCount,
reactTableInstance.allColumns.length,
erase,
resetSelectionAt,
copy,
cut,
paste,
isReadOnly,
]
);

Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { NavigationKeysUtils } from "../../keysUtils/keyUtils";
import { useBoxedExpressionEditor } from "../../BoxedExpressionEditorContext";
import "./BeeTableEditableCellContent.css";
import { getOperatingSystem, OperatingSystem } from "@kie-tools-core/operating-system";

const CELL_LINE_HEIGHT = 20;

@@ -183,7 +184,7 @@ export function BeeTableEditableCellContent({
(e) => {
// When inside FEEL Input, all keyboard events should be kept inside it.
// Exceptions to this strategy are handled on `onFeelKeyDown`.
if (isEditing) {
if (isEditing && !(getOperatingSystem() === OperatingSystem.MACOS && e.metaKey)) {
e.stopPropagation();
}

Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ import {
} from "../../selection/BeeTableSelectionContext";
import { useBoxedExpressionEditor } from "../../BoxedExpressionEditorContext";
import { InsertRowColumnsDirection } from "../../api";
import { getOperatingSystem, OperatingSystem } from "@kie-tools-core/operating-system";

export interface BeeTableThProps<R extends object> {
groupType: string | undefined;
@@ -85,7 +86,9 @@ export function BeeTableTh<R extends object>({

const onAddColumnButtonClick = useCallback(
(e: React.MouseEvent) => {
e.stopPropagation();
if (!(getOperatingSystem() === OperatingSystem.MACOS && e.metaKey)) {
e.stopPropagation();
}

if (!hoverInfo.isHovered) {
return;
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@ import { NodeLabelPosition } from "./NodeSvgs";
import { State } from "../../store/Store";
import "./EditableNodeLabel.css";
import { useSettings } from "../../settings/DmnEditorSettingsContext";
import { getOperatingSystem, OperatingSystem } from "@kie-tools-core/operating-system";

export type OnEditableNodeLabelChange = (value: string | undefined) => void;

@@ -161,7 +162,9 @@ export function EditableNodeLabel({
// Finish editing on `Enter` pressed.
const onKeyDown = useCallback(
(e: React.KeyboardEvent) => {
e.stopPropagation();
if (!(getOperatingSystem() === OperatingSystem.MACOS && e.metaKey)) {
e.stopPropagation();
}

if (e.key === "Enter") {
if (!isValid) {
5 changes: 4 additions & 1 deletion packages/dmn-editor/src/feel/InlineFeelNameInput.tsx
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ import { DMN15_SPEC, UniqueNameIndex } from "@kie-tools/dmn-marshaller/dist/sche
import { useFocusableElement } from "../focus/useFocusableElement";
import { State } from "../store/Store";
import { useDmnEditorStoreApi } from "../store/StoreContext";
import { getOperatingSystem, OperatingSystem } from "@kie-tools-core/operating-system";

export type OnInlineFeelNameRenamed = (newName: string) => void;

@@ -127,7 +128,9 @@ export function InlineFeelNameInput({
}}
onKeyDown={(e) => {
onKeyDown?.(e);
e.stopPropagation();
if (!(getOperatingSystem() === OperatingSystem.MACOS && e.metaKey)) {
e.stopPropagation();
}

if (e.key === "Enter") {
e.preventDefault();
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ import { useDmnEditorStore, useDmnEditorStoreApi } from "../store/StoreContext";
import { useMemo } from "react";
import { SingleNodeProperties } from "./SingleNodeProperties";
import { useExternalModels } from "../includedModels/DmnEditorDependenciesContext";
import { getOperatingSystem, OperatingSystem } from "@kie-tools-core/operating-system";

export function BeePropertiesPanel() {
const dmnEditorStoreApi = useDmnEditorStoreApi();
@@ -55,7 +56,11 @@ export function BeePropertiesPanel() {
isResizable={true}
minSize={"300px"}
defaultSize={"500px"}
onKeyDown={(e) => e.stopPropagation()} // Prevent ReactFlow KeyboardShortcuts from triggering when editing stuff on Properties Panel
onKeyDown={(e) => {
if (!(getOperatingSystem() === OperatingSystem.MACOS && e.metaKey)) {
e.stopPropagation();
}
}}
>
<DrawerHead>
{shouldDisplayDecisionOrBkmProps && <SingleNodeProperties nodeId={node.id} />}
Original file line number Diff line number Diff line change
@@ -53,6 +53,7 @@ import { useExternalModels } from "../includedModels/DmnEditorDependenciesContex
import { drgElementToBoxedExpression } from "../boxedExpressions/BoxedExpressionScreen";
import { IteratorVariableCell } from "./BoxedExpressionPropertiesPanelComponents/IteratorVariableCell";
import { useSettings } from "../settings/DmnEditorSettingsContext";
import { getOperatingSystem, OperatingSystem } from "@kie-tools-core/operating-system";

export function BoxedExpressionPropertiesPanel() {
const dmnEditorStoreApi = useDmnEditorStoreApi();
@@ -109,7 +110,11 @@ export function BoxedExpressionPropertiesPanel() {
isResizable={true}
minSize={"300px"}
defaultSize={"500px"}
onKeyDown={(e) => e.stopPropagation()} // Prevent ReactFlow KeyboardShortcuts from triggering when editing stuff on Properties Panel
onKeyDown={(e) => {
if (!(getOperatingSystem() === OperatingSystem.MACOS && e.metaKey)) {
e.stopPropagation();
}
}}
>
<DrawerHead>
{shouldDisplayDecisionOrBkmProps && <SingleNodeProperties nodeId={node.id} />}
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ import { MultipleNodeProperties } from "./MultipleNodeProperties";
import { useDmnEditorStore } from "../store/StoreContext";
import { useExternalModels } from "../includedModels/DmnEditorDependenciesContext";
import "./DiagramPropertiesPanel.css";
import { getOperatingSystem, OperatingSystem } from "@kie-tools-core/operating-system";

export function DiagramPropertiesPanel() {
const { externalModelsByNamespace } = useExternalModels();
@@ -39,7 +40,11 @@ export function DiagramPropertiesPanel() {
isResizable={true}
minSize={"300px"}
defaultSize={"500px"}
onKeyDown={(e) => e.stopPropagation()} // Prevent ReactFlow KeyboardShortcuts from triggering when editing stuff on Properties Panel
onKeyDown={(e) => {
if (!(getOperatingSystem() === OperatingSystem.MACOS && e.metaKey)) {
e.stopPropagation();
}
}}
>
<DrawerHead>
{selectedNodesById.size <= 0 && <GlobalDiagramProperties />}