diff --git a/.changeset/core copy.md b/.changeset/core copy.md new file mode 100644 index 0000000000..dccfc654e7 --- /dev/null +++ b/.changeset/core copy.md @@ -0,0 +1,9 @@ +--- +'@udecode/plate-caption': patch +'@udecode/plate-utils': patch +'@udecode/plate-resizable': patch +'@udecode/plate-selection': patch +'@udecode/plate-tabbable': patch +--- + +Use `editor.findPath` diff --git a/.changeset/core.md b/.changeset/core.md new file mode 100644 index 0000000000..cd94d72482 --- /dev/null +++ b/.changeset/core.md @@ -0,0 +1,5 @@ +--- +'@udecode/plate-core': patch +--- + +- `withPlate` overrides `editor.findPath` with `ReactEditor.findPath` (memo). We now **recommend to always use** `editor.findPath` over `findNodePath` / `findPath`. diff --git a/.changeset/table-m.md b/.changeset/table-m.md index 9233fe33e0..639203dd9c 100644 --- a/.changeset/table-m.md +++ b/.changeset/table-m.md @@ -4,8 +4,21 @@ - `TablePlugin` merging is now enabled by default: - Rename `enableMerging` to `disableMerge` - - Migration: + - **Migration**: - `enableMerging: true` -> remove the option - else -> `TablePlugin.configure({ options: { disableMerge: true } })` - Rename `unmergeTableCells` to `splitTableCell` +- Rename `editor.api.create.cell` to `editor.api.create.tableCell` - `useTableMergeState` return: rename `canUnmerge` to `canSplit` +- `insertTableRow`, `insertTableColumn`: remove `disableSelect` in favor of `select`. **Migration**: Replace by the opposite boolean +- `getTableCellBorders`: params `(element, options)` -> `(editor, options)`. Remove `isFirstCell`, `isFirstRow` options +- Merged `useTableCellElementState` into `useTableCellElement`: + - Remove parameter + - Remove `hovered`, `hoveredLeft` returned values in favor of CSS + - Rename `rowSize` return to `minHeight` + - Computes column sizes and add `width` return +- Merged `useTableCellElementResizableState` into `useTableCellElementResizable`: + - Remove `onHover`, `onHoverEnd` props in favor of CSS +- Merged `useTableElementState` into `useTableElement`: + - Remove parameter + - Does not compute and return `colSizes`, `minColumnWidth`, `colGroupProps` anymore. diff --git a/.changeset/table-mi.md b/.changeset/table-mi.md new file mode 100644 index 0000000000..775d1a27f2 --- /dev/null +++ b/.changeset/table-mi.md @@ -0,0 +1,41 @@ +--- +'@udecode/plate-table': minor +--- + +- `TablePlugin` new api and transforms: + +```ts +type TableApi = { + create: { + table: OmitFirst; + /** Cell node factory used each time a cell is created. */ + tableCell: OmitFirst; + tableRow: OmitFirst; + }; + table: { + getCellBorders: OmitFirst; + getCellSize: OmitFirst; + getColSpan: typeof getColSpan; + getRowSpan: typeof getRowSpan; + }; +}; + +type TableTransforms = { + insert: { + table: OmitFirst; + }; + remove: { + table: OmitFirst; + tableColumn: OmitFirst; + tableRow: OmitFirst; + }; + table: { + merge: OmitFirst; + split: OmitFirst; + }; +}; +``` + +- `insertTableColumn` add `before` option to insert a column before the current column. +- `insertTableRow` add `before` option to insert a row before the current row. +- `insertTable` now supports inserting a table after the current table. diff --git a/apps/www/content/docs/components/changelog.mdx b/apps/www/content/docs/components/changelog.mdx index cfb6453e0f..c2b2afb2ad 100644 --- a/apps/www/content/docs/components/changelog.mdx +++ b/apps/www/content/docs/components/changelog.mdx @@ -12,10 +12,15 @@ Use the [CLI](https://platejs.org/docs/components/cli) to install the latest ver ### December 25 #17.6 -- `table-element` - - v42 +v42 + +- `table-element`, `table-element-static` - Move icons to `table-icons` - Remove `colgroup`, col width is now set in `table-cell-element` +- `table-row-element`: remove `hideBorder` prop +- `table-cell-element`, `table-cell-element-static`: column hover/resizing state is now using Tailwind instead of JS +- `table-dropdown-menu`: add more actions +- `tooltip`: add `TooltipButton` ### December 23 #17.5 diff --git a/apps/www/src/app/api/ai/command/route.ts b/apps/www/src/app/api/ai/command/route.ts deleted file mode 100644 index 76175403d4..0000000000 --- a/apps/www/src/app/api/ai/command/route.ts +++ /dev/null @@ -1,41 +0,0 @@ -import type { NextRequest } from 'next/server'; - -import { createOpenAI } from '@ai-sdk/openai'; -import { convertToCoreMessages, streamText } from 'ai'; -import { NextResponse } from 'next/server'; - -export async function POST(req: NextRequest) { - const { - apiKey: key, - messages, - model = 'gpt-4o-mini', - system, - } = await req.json(); - - const apiKey = key || process.env.OPENAI_API_KEY; - - if (!apiKey) { - return NextResponse.json( - { error: 'Missing OpenAI API key.' }, - { status: 401 } - ); - } - - const openai = createOpenAI({ apiKey }); - - try { - const result = await streamText({ - maxTokens: 2048, - messages: convertToCoreMessages(messages), - model: openai(model), - system: system, - }); - - return result.toDataStreamResponse(); - } catch { - return NextResponse.json( - { error: 'Failed to process AI request' }, - { status: 500 } - ); - } -} diff --git a/apps/www/src/app/api/ai/copilot/route.ts b/apps/www/src/app/api/ai/copilot/route.ts deleted file mode 100644 index 2439860d26..0000000000 --- a/apps/www/src/app/api/ai/copilot/route.ts +++ /dev/null @@ -1,47 +0,0 @@ -import type { NextRequest } from 'next/server'; - -import { createOpenAI } from '@ai-sdk/openai'; -import { generateText } from 'ai'; -import { NextResponse } from 'next/server'; - -export async function POST(req: NextRequest) { - const { - apiKey: key, - model = 'gpt-4o-mini', - prompt, - system, - } = await req.json(); - - const apiKey = key || process.env.OPENAI_API_KEY; - - if (!apiKey) { - return NextResponse.json( - { error: 'Missing OpenAI API key.' }, - { status: 401 } - ); - } - - const openai = createOpenAI({ apiKey }); - - try { - const result = await generateText({ - abortSignal: req.signal, - maxTokens: 50, - model: openai(model), - prompt: prompt, - system, - temperature: 0.7, - }); - - return NextResponse.json(result); - } catch (error: any) { - if (error.name === 'AbortError') { - return NextResponse.json(null, { status: 408 }); - } - - return NextResponse.json( - { error: 'Failed to process AI request' }, - { status: 500 } - ); - } -}