Skip to content

Commit

Permalink
Merge branch 'main' into feat/jotai-factory
Browse files Browse the repository at this point in the history
  • Loading branch information
12joan committed Dec 6, 2023
2 parents 7a363f9 + b807c40 commit 55aeeb0
Show file tree
Hide file tree
Showing 24 changed files with 105 additions and 38 deletions.
4 changes: 3 additions & 1 deletion apps/www/content/docs/link.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ import { createLinkPlugin } from '@udecode/plate-link';

const plugins = [
// ...otherPlugins,
createLinkPlugin(),
createLinkPlugin({
renderAfterEditable: LinkFloatingToolbar
}),
];
```

Expand Down
6 changes: 6 additions & 0 deletions packages/floating/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @udecode/plate-floating

## 26.0.4

### Patch Changes

- [#2777](https://github.com/udecode/plate/pull/2777) by [@zbeyens](https://github.com/zbeyens) – Vendor: remove radix-ui package

## 25.0.1

## 25.0.0
Expand Down
3 changes: 1 addition & 2 deletions packages/floating/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@udecode/plate-floating",
"version": "25.0.1",
"version": "26.0.4",
"description": "Floating UI for Plate",
"license": "MIT",
"homepage": "https://platejs.org",
Expand Down Expand Up @@ -41,7 +41,6 @@
"dependencies": {
"@floating-ui/core": "^1.3.1",
"@floating-ui/react": "^0.22.3",
"@radix-ui/react-dropdown-menu": "^2.0.5",
"@udecode/plate-common": "25.0.1"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/floating/src/libs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
*/

export * from './floating-ui';
export * from './radix-ui';
1 change: 0 additions & 1 deletion packages/floating/src/libs/radix-ui.ts

This file was deleted.

2 changes: 2 additions & 0 deletions packages/link/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# @udecode/plate-link

## 26.0.4

## 25.0.1

## 25.0.0
Expand Down
4 changes: 2 additions & 2 deletions packages/link/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@udecode/plate-link",
"version": "25.0.1",
"version": "26.0.4",
"description": "Link plugin for Plate",
"license": "MIT",
"homepage": "https://platejs.org",
Expand Down Expand Up @@ -40,7 +40,7 @@
},
"dependencies": {
"@udecode/plate-common": "25.0.1",
"@udecode/plate-floating": "25.0.1",
"@udecode/plate-floating": "26.0.4",
"@udecode/plate-normalizers": "25.0.1"
},
"peerDependencies": {
Expand Down
4 changes: 4 additions & 0 deletions packages/plate/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# @udecode/plate

## 26.0.5

## 26.0.4

## 26.0.3

## 26.0.2
Expand Down
16 changes: 8 additions & 8 deletions packages/plate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@udecode/plate",
"version": "26.0.3",
"version": "26.0.5",
"description": "Plate – a plugin system for slate",
"license": "MIT",
"homepage": "https://platejs.org",
Expand Down Expand Up @@ -53,7 +53,7 @@
"@udecode/plate-comments": "26.0.0",
"@udecode/plate-common": "25.0.1",
"@udecode/plate-find-replace": "25.0.1",
"@udecode/plate-floating": "25.0.1",
"@udecode/plate-floating": "26.0.4",
"@udecode/plate-font": "25.0.1",
"@udecode/plate-heading": "25.0.1",
"@udecode/plate-highlight": "25.0.1",
Expand All @@ -62,23 +62,23 @@
"@udecode/plate-indent-list": "25.0.1",
"@udecode/plate-kbd": "25.0.1",
"@udecode/plate-line-height": "25.0.1",
"@udecode/plate-link": "25.0.1",
"@udecode/plate-link": "26.0.4",
"@udecode/plate-list": "25.0.1",
"@udecode/plate-media": "25.0.1",
"@udecode/plate-mention": "25.0.1",
"@udecode/plate-node-id": "25.0.1",
"@udecode/plate-normalizers": "25.0.1",
"@udecode/plate-paragraph": "25.0.1",
"@udecode/plate-reset-node": "25.0.1",
"@udecode/plate-resizable": "25.0.1",
"@udecode/plate-resizable": "26.0.5",
"@udecode/plate-select": "25.0.1",
"@udecode/plate-serializer-csv": "26.0.3",
"@udecode/plate-serializer-docx": "26.0.3",
"@udecode/plate-serializer-csv": "26.0.5",
"@udecode/plate-serializer-docx": "26.0.5",
"@udecode/plate-serializer-html": "26.0.0",
"@udecode/plate-serializer-md": "25.0.1",
"@udecode/plate-serializer-md": "26.0.4",
"@udecode/plate-suggestion": "25.0.1",
"@udecode/plate-tabbable": "25.0.1",
"@udecode/plate-table": "26.0.3",
"@udecode/plate-table": "26.0.5",
"@udecode/plate-trailing-block": "25.0.1"
},
"peerDependencies": {
Expand Down
6 changes: 6 additions & 0 deletions packages/resizable/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @udecode/plate-resizable

## 26.0.5

### Patch Changes

- [#2781](https://github.com/udecode/plate/pull/2781) by [@dimaanj](https://github.com/dimaanj) – Add initial size for resize handle

## 25.0.1

## 25.0.0
Expand Down
2 changes: 1 addition & 1 deletion packages/resizable/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@udecode/plate-resizable",
"version": "25.0.1",
"version": "26.0.5",
"description": "Resize components",
"license": "MIT",
"homepage": "https://platejs.org",
Expand Down
4 changes: 4 additions & 0 deletions packages/serializer-csv/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# @udecode/plate-serializer-csv

## 26.0.5

## 26.0.4

## 26.0.3

## 26.0.2
Expand Down
4 changes: 2 additions & 2 deletions packages/serializer-csv/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@udecode/plate-serializer-csv",
"version": "26.0.3",
"version": "26.0.5",
"description": "CSV serializer plugin for Plate",
"license": "MIT",
"homepage": "https://platejs.org",
Expand Down Expand Up @@ -40,7 +40,7 @@
},
"dependencies": {
"@udecode/plate-common": "25.0.1",
"@udecode/plate-table": "26.0.3",
"@udecode/plate-table": "26.0.5",
"papaparse": "^5.4.1"
},
"peerDependencies": {
Expand Down
4 changes: 4 additions & 0 deletions packages/serializer-docx/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# @udecode/plate-docx-serializer

## 26.0.5

## 26.0.4

## 26.0.3

## 26.0.2
Expand Down
4 changes: 2 additions & 2 deletions packages/serializer-docx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@udecode/plate-serializer-docx",
"version": "26.0.3",
"version": "26.0.5",
"description": "Docx serializer plugin for Plate",
"license": "MIT",
"homepage": "https://platejs.org",
Expand Down Expand Up @@ -45,7 +45,7 @@
"@udecode/plate-indent-list": "25.0.1",
"@udecode/plate-media": "25.0.1",
"@udecode/plate-paragraph": "25.0.1",
"@udecode/plate-table": "26.0.3",
"@udecode/plate-table": "26.0.5",
"validator": "^13.9.0"
},
"peerDependencies": {
Expand Down
2 changes: 2 additions & 0 deletions packages/serializer-md/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# @udecode/plate-md-serializer

## 26.0.4

## 25.0.1

## 25.0.0
Expand Down
4 changes: 2 additions & 2 deletions packages/serializer-md/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@udecode/plate-serializer-md",
"version": "25.0.1",
"version": "26.0.4",
"description": "Markdown serializer plugin for Plate",
"license": "MIT",
"homepage": "https://platejs.org",
Expand Down Expand Up @@ -45,7 +45,7 @@
"@udecode/plate-common": "25.0.1",
"@udecode/plate-heading": "25.0.1",
"@udecode/plate-horizontal-rule": "25.0.1",
"@udecode/plate-link": "25.0.1",
"@udecode/plate-link": "26.0.4",
"@udecode/plate-list": "25.0.1",
"@udecode/plate-media": "25.0.1",
"@udecode/plate-paragraph": "25.0.1",
Expand Down
8 changes: 8 additions & 0 deletions packages/table/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @udecode/plate-table

## 26.0.5

## 26.0.4

### Patch Changes

- [#2776](https://github.com/udecode/plate/pull/2776) by [@dimaanj](https://github.com/dimaanj) – Fix unmerging a single column

## 26.0.3

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/table/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@udecode/plate-table",
"version": "26.0.3",
"version": "26.0.5",
"description": "Table plugin for Plate",
"license": "MIT",
"homepage": "https://platejs.org",
Expand Down Expand Up @@ -40,7 +40,7 @@
},
"dependencies": {
"@udecode/plate-common": "25.0.1",
"@udecode/plate-resizable": "25.0.1",
"@udecode/plate-resizable": "26.0.5",
"lodash": "^4.17.21"
},
"peerDependencies": {
Expand Down
8 changes: 5 additions & 3 deletions packages/table/src/merge/computeCellIndices.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getPluginOptions, PlateEditor, Value } from '@udecode/plate-common';

import { ELEMENT_TABLE } from '../createTablePlugin';
import { getRowSpan } from '../queries/getRowSpan';
import {
TablePlugin,
TTableCellElement,
Expand Down Expand Up @@ -40,15 +41,16 @@ export function computeCellIndices<V extends Value>(
prevRow.children.forEach((pC) => {
const prevCell = pC as TTableCellElement;
const prevIndices = options?._cellIndices?.get(prevCell);
const _rowSpan = getRowSpan(prevCell);
if (prevIndices) {
const { col: prevColIndex } = prevIndices;
if (
// colIndex affects
prevColIndex <= colIndex &&
// rowSpan affects
prevCell.rowSpan &&
prevCell.rowSpan > 1 &&
rowIndex - _rowIndex < prevCell.rowSpan
_rowSpan &&
_rowSpan > 1 &&
rowIndex - _rowIndex < _rowSpan
) {
colIndex += prevCell.colSpan || 1;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/table/src/merge/isTableRectangular.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getRowSpan } from '../queries/getRowSpan';
import { TTableCellElement, TTableElement, TTableRowElement } from '../types';

const allEqual = (arr: number[]) => arr.every((val) => val === arr[0]);
Expand All @@ -14,7 +15,7 @@ export const isTableRectangular = (table?: TTableElement) => {
const cellElem = cell as TTableCellElement;

Array.from({
length: cellElem?.rowSpan || 1,
length: getRowSpan(cellElem) || 1,
} as ArrayLike<number>).forEach((_, i) => {
if (!arr[rI + i]) {
arr[rI + i] = 0;
Expand Down
42 changes: 35 additions & 7 deletions packages/table/src/merge/unmergeTableCells.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import { ELEMENT_TABLE, ELEMENT_TR } from '../createTablePlugin';
import { getTableGridAbove } from '../queries';
import { getColSpan } from '../queries/getColSpan';
import { getRowSpan } from '../queries/getRowSpan';
import { TablePlugin, TTableCellElement, TTableRowElement } from '../types';
import { getEmptyCellNode } from '../utils';
import { getCellIndices } from './getCellIndices';
Expand Down Expand Up @@ -45,8 +46,8 @@ export const unmergeTableCells = <V extends Value = Value>(

const cellPath = path.slice(-2);
const [rowPath, colPath] = cellPath;
const colSpan = cellElem.colSpan as number;
const rowSpan = cellElem.rowSpan as number;
const colSpan = getColSpan(cellElem as TTableCellElement);
const rowSpan = getRowSpan(cellElem as TTableCellElement);

// Generate an array of column paths from the colspan
const colPaths: number[] = [];
Expand All @@ -69,8 +70,12 @@ export const unmergeTableCells = <V extends Value = Value>(
at: [...tablePath, row],
match: { type: getPluginType(editor, ELEMENT_TR) },
})!; // TODO: improve typing
const rowEl = rowEntry[0] as TTableRowElement;

if (!rowEntry) {
return newColPath;
}

const rowEl = rowEntry[0] as TTableRowElement;
for (const item of rowEl.children) {
const { col: c } = getCellIndices(
cellIndices!,
Expand All @@ -93,16 +98,39 @@ export const unmergeTableCells = <V extends Value = Value>(
for (let i = 0; i < rowSpan; i++) {
const currentRowPath = rowPath + i;
const pathForNextRows = getColPathForRow(currentRowPath);
for (let j = 0; j < colPaths.length; j++) {
const currentColPath = i === 0 ? colPaths[j] : pathForNextRows;
const newRowChildren = [];
const _rowPath = [...tablePath, currentRowPath];
const rowEntry = findNode(editor, {
at: _rowPath,
match: { type: getPluginType(editor, ELEMENT_TABLE) },
});

const pathForNewCell = [...tablePath, currentRowPath, currentColPath];
for (let j = 0; j < colPaths.length; j++) {
const cellToInsert =
i === 0 && j === 0
? createEmptyCell(cellElem.children)
: createEmptyCell();

insertElements(editor, cellToInsert, { at: pathForNewCell });
// if row exists, insert into it, otherwise insert row
if (rowEntry) {
const currentColPath = i === 0 ? colPaths[j] : pathForNextRows;
const pathForNewCell = [...tablePath, currentRowPath, currentColPath];

insertElements(editor, cellToInsert, { at: pathForNewCell });
} else {
newRowChildren.push(cellToInsert);
}
}

if (!rowEntry) {
insertElements(
editor,
{
type: getPluginType(editor, ELEMENT_TR),
children: newRowChildren,
},
{ at: _rowPath }
);
}
}
});
Expand Down
6 changes: 4 additions & 2 deletions packages/table/src/merge/useTableMergeState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { useReadOnly, useSelected } from 'slate-react';

import { ELEMENT_TABLE } from '../createTablePlugin';
import { getTableGridAbove } from '../queries';
import { getColSpan } from '../queries/getColSpan';
import { getRowSpan } from '../queries/getRowSpan';
import { useTableStore } from '../stores';
import { TablePlugin } from '../types';
import { isTableRectangular } from './isTableRectangular';
Expand Down Expand Up @@ -56,8 +58,8 @@ export const useTableMergeState = () => {
collapsed &&
selectedCellEntries &&
selectedCellEntries.length === 1 &&
((selectedCellEntries[0][0] as any)?.colSpan > 1 ||
(selectedCellEntries[0][0] as any)?.rowSpan > 1);
(getColSpan(selectedCellEntries[0][0] as any) > 1 ||
getRowSpan(selectedCellEntries[0][0] as any) > 1);

return { canMerge, canUnmerge };
};
Loading

0 comments on commit 55aeeb0

Please sign in to comment.