Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: do not insert table on clicking cell

ammarahm-edf3db2937a633
diff --git a/packages/editor/dist/es/toolbar/popups/tablepopup.js b/packages/editor/dist/es/toolbar/popups/tablepopup.js
index 830001055..85169f143 100644
--- a/packages/editor/dist/es/toolbar/popups/tablepopup.js
+++ b/packages/editor/dist/es/toolbar/popups/tablepopup.js
@@ -15,11 +15,11 @@ export function TablePopup(props) {
const { onInsertTable } = props;
const [cellLocation, setCellLocation] = useState({
column: 0,
- row: 0,
+ row: 0
});
const [tableSize, setTableSize] = useState({
columns: MIN_COLUMNS,
- rows: MIN_ROWS,
+ rows: MIN_ROWS
});
useEffect(() => {
if (!autoExpand)
@@ -36,7 +36,7 @@ export function TablePopup(props) {
: Math.min(old.columns + columnFactor, MAX_COLUMNS),
rows: isDecrease
? Math.max(row + rowFactor, MIN_ROWS)
- : Math.min(old.rows + rowFactor, MAX_ROWS),
+ : Math.min(old.rows + rowFactor, MAX_ROWS)
};
});
}, [cellLocation, autoExpand]);
@@ -47,14 +47,14 @@ export function TablePopup(props) {
disabled: !cellLocation.column || !cellLocation.row,
onClick: () => onInsertTable({
columns: cellLocation.column,
- rows: cellLocation.row,
- }),
+ rows: cellLocation.row
+ })
} }, { children: _jsxs(Flex, Object.assign({ sx: { px: 1, pt: 1, flexDirection: "column", alignItems: "center" } }, { children: [_jsx(Box, Object.assign({ sx: {
display: "grid",
gridTemplateColumns: `repeat(${tableSize.columns}, minmax(${cellSize}px, 1fr))`,
gap: "small",
bg: "background",
- width: "100%",
+ width: "100%"
}, onTouchMove: (e) => {
const touch = e.touches.item(0);
const element = document.elementFromPoint(touch.pageX, touch.pageY);
@@ -71,21 +71,23 @@ export function TablePopup(props) {
borderRadius: "small",
bg: isCellHighlighted(index, cellLocation, tableSize)
? "disabled"
- : "transparent",
+ : "transparent"
}, onTouchStart: () => {
setCellLocation(getCellLocation(index, tableSize));
}, onMouseEnter: () => {
setCellLocation(getCellLocation(index, tableSize));
+ }, onTouchEnd: (e) => {
+ e.preventDefault();
}, onClick: () => {
onInsertTable({
columns: cellLocation.column,
- rows: cellLocation.row,
+ rows: cellLocation.row
});
} }, index))) })), _jsxs(Flex, Object.assign({ sx: {
display: ["flex", "none", "none"],
mt: 1,
alignItems: "center",
- justifyContent: "center",
+ justifyContent: "center"
} }, { children: [_jsx(InlineInput, { containerProps: { sx: { mr: 1 } }, label: "columns", placeholder: `${cellLocation.column} columns`, type: "number", value: cellLocation.column, onChange: (e) => {
setCellLocation((l) => (Object.assign(Object.assign({}, l), { column: e.target.valueAsNumber || 0 })));
} }), _jsx(InlineInput, { label: "rows", placeholder: `${cellLocation.row} rows`, type: "number", value: cellLocation.row, onChange: (e) => {
diff --git a/packages/editor/src/toolbar/popups/table-popup.tsx b/packages/editor/src/toolbar/popups/table-popup.tsx
index 6ef278eea..858613973 100644
--- a/packages/editor/src/toolbar/popups/table-popup.tsx
+++ b/packages/editor/src/toolbar/popups/table-popup.tsx
@@ -26,11 +26,11 @@ export function TablePopup(props: TablePopupProps) {
const { onInsertTable } = props;
const [cellLocation, setCellLocation] = useState<CellLocation>({
column: 0,
- row: 0,
+ row: 0
});
const [tableSize, setTableSize] = useState<TableSize>({
columns: MIN_COLUMNS,
- rows: MIN_ROWS,
+ rows: MIN_ROWS
});
useEffect(() => {
@@ -50,7 +50,7 @@ export function TablePopup(props: TablePopupProps) {
: Math.min(old.columns + columnFactor, MAX_COLUMNS),
rows: isDecrease
? Math.max(row + rowFactor, MIN_ROWS)
- : Math.min(old.rows + rowFactor, MAX_ROWS),
+ : Math.min(old.rows + rowFactor, MAX_ROWS)
};
});
}, [cellLocation, autoExpand]);
@@ -66,8 +66,8 @@ export function TablePopup(props: TablePopupProps) {
onClick: () =>
onInsertTable({
columns: cellLocation.column,
- rows: cellLocation.row,
- }),
+ rows: cellLocation.row
+ })
}}
>
<Flex
@@ -79,7 +79,7 @@ export function TablePopup(props: TablePopupProps) {
gridTemplateColumns: `repeat(${tableSize.columns}, minmax(${cellSize}px, 1fr))`, // "1fr ".repeat(tableSize.columns),
gap: "small",
bg: "background",
- width: "100%",
+ width: "100%"
}}
onTouchMove={(e) => {
const touch = e.touches.item(0);
@@ -105,7 +105,7 @@ export function TablePopup(props: TablePopupProps) {
borderRadius: "small",
bg: isCellHighlighted(index, cellLocation, tableSize)
? "disabled"
- : "transparent",
+ : "transparent"
}}
onTouchStart={() => {
setCellLocation(getCellLocation(index, tableSize));
@@ -113,10 +113,13 @@ export function TablePopup(props: TablePopupProps) {
onMouseEnter={() => {
setCellLocation(getCellLocation(index, tableSize));
}}
+ onTouchEnd={(e) => {
+ e.preventDefault();
+ }}
onClick={() => {
onInsertTable({
columns: cellLocation.column,
- rows: cellLocation.row,
+ rows: cellLocation.row
});
}}
/>
@@ -127,7 +130,7 @@ export function TablePopup(props: TablePopupProps) {
display: ["flex", "none", "none"],
mt: 1,
alignItems: "center",
- justifyContent: "center",
+ justifyContent: "center"
}}
>
<InlineInput
@@ -139,7 +142,7 @@ export function TablePopup(props: TablePopupProps) {
onChange={(e) => {
setCellLocation((l) => ({
...l,
- column: e.target.valueAsNumber || 0,
+ column: e.target.valueAsNumber || 0
}));
}}
/>
@@ -151,7 +154,7 @@ export function TablePopup(props: TablePopupProps) {
onChange={(e) => {
setCellLocation((l) => ({
...l,
- row: e.target.valueAsNumber || 0,
+ row: e.target.valueAsNumber || 0
}));
}}
/>