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

Cursor Overlay plugin #3744

Merged
merged 38 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions .changeset/ai.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@udecode/plate-ai': patch
---

- `CopilotPlugin`: reset on mouse down
- `CopilotPlugin`: auto trigger only on selection change
10 changes: 10 additions & 0 deletions .changeset/column.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@udecode/plate-layout': minor
---

- `ColumnPlugin`:
- unwrap columns when there is only one column
- remove column group when it has no column children
- remove column when it has no children
- Add `insertColumnGroup`
- Add `toggleColumnGroup`
6 changes: 6 additions & 0 deletions .changeset/core-major.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@udecode/plate-slate-react': major
---

- Add `slate-dom` as a peer dependency
- Update `slate-react` peer dependency to `>=0.111.0`
19 changes: 19 additions & 0 deletions .changeset/core.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
'@udecode/plate-core': patch
---

- `Plate` store: add `containerRef`. This is used by some plugins like `CursorOverlay`.
- Add `useEditorContainerRef` selector hook. You can pass the returned ref to your editor scroll container.
- `usePlateEditor` options: `value` can now be a callback function to get the value from the editor
- `editor.key` is now using `nanoid()`
- `editor.uid`: new property added by `Plate` to uniquely identify the editor. The difference with `editor.key` is that `uid` supports SSR hydration. This can be passed to the editor container as `id` prop.
- `Plate` now warns if multiple instances of `@udecode/plate-core` are detected. Use `suppressInstanceWarning` to suppress the warning.
- `render.aboveNodes` and `render.belowNodes` now support `useElement`
- `PlatePlugin.inject` new properties:
- `excludePlugins?: string[]`
- `excludeBelowPlugins?: string[]`
- `maxLevel?: number`
- `isLeaf?: boolean`
- `isBlock?: boolean`
- `isElement?: boolean`
- Add `getInjectMatch(editor, plugin)` to get a plugin inject match function.
5 changes: 5 additions & 0 deletions .changeset/cursor copy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@udecode/plate-cursor': patch
---

Deprecated, use `@udecode/plate-selection` instead.
9 changes: 9 additions & 0 deletions .changeset/cursor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@udecode/plate-selection': minor
---

- New plugin `CursorOverlayPlugin`
- `useCursorOverlay` now supports collapsed selection using `minSelectionWidth = 1`
- selectable depends now on `data-block-id` instead of `data-key`
- Fix a bug when deleting selected blocks without id
- Fix `useBlockSelected`: use `id` parameter if defined
6 changes: 6 additions & 0 deletions .changeset/dnd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@udecode/plate-dnd': minor
---

- Dragging `dropEffect` is now `move` instead of `copy`
- Fix drag bug when dragging an element without id
6 changes: 6 additions & 0 deletions .changeset/heading.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@udecode/plate-heading': major
'@udecode/plate-ai': major
---

- Remove `scrollContainerSelector` option in favor of `useEditorContainerRef`
5 changes: 5 additions & 0 deletions .changeset/html.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@udecode/plate-html': patch
---

Sync with `@udecode/plate-core`
6 changes: 6 additions & 0 deletions .changeset/hyper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@udecode/plate-test-utils': patch
---

- Strip (potentially injected by the compiler) attributes starting with `__`.
- Remove internal functions from exports.
11 changes: 11 additions & 0 deletions .changeset/id.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@udecode/plate-node-id': minor
---

- `idCreator` default is now `nanoid(10)`
- New option `filterInline` to filter inline elements. Default is `true`.
- `NodeIdPlugin`:
- add `normalizeInitialValue` that set node ids when missing, called before mount
- default behavior will normalize only the first and last node if missing id to avoid traversing the entire document
- you can disable it with `NodeIdPlugin.configure({ normalizeInitialValue: null })`
- you can force check all nodes with `NodeIdPlugin.configure({ options: { normalizeInitialValue: true } })`
6 changes: 6 additions & 0 deletions .changeset/layout-major.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@udecode/plate-layout': major
---

- Remove `toggleColumns` in favor of `toggleColumnGroup`
- Remove `insertEmptyColumn` in favor of `insertColumn`
6 changes: 6 additions & 0 deletions .changeset/md.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@udecode/plate-markdown': minor
---

- `api.markdown.deserialize`: add second argument option: `processor?: (processor: Processor) => Processor`. You could use this to add other remark plugins like `remark-gfm`.
- Add `delete` text rule. This does not add support for strikethrough yet.
7 changes: 7 additions & 0 deletions .changeset/misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@udecode/plate-line-height': patch
'@udecode/plate-alignment': patch
'@udecode/plate-indent': patch
---

Use `getInjectMatch(editor, plugin)`
5 changes: 5 additions & 0 deletions .changeset/table.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@udecode/plate-table': patch
---

Fix: remove tables without any rows
5 changes: 5 additions & 0 deletions .changeset/utils.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@udecode/plate-utils': patch
---

- `PlateElement` add `data-block-id` if `element.id` is defined, after editor mount to support SSR hydration.
16 changes: 0 additions & 16 deletions apps/www/content/docs/ai.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ const plugins = [
? PROMPT_TEMPLATES.userSelecting
: PROMPT_TEMPLATES.userDefault;
},
scrollContainerSelector: '#scroll_container',
systemTemplate: ({ isBlockSelecting, isSelecting }) => {
return isBlockSelecting
? PROMPT_TEMPLATES.systemBlockSelecting
Expand All @@ -183,18 +182,11 @@ const plugins = [
},
render: { afterEditable: () => <AIMenu /> },
}),
SelectionOverlayPlugin,
];
```

- [AIMenu](/docs/components/ai-menu)

The [SelectionOverlayPlugin](https://pro.platejs.org/docs/components/cursor-overlay):

- Maintains selection highlight when editor loses focus
- Essential for AI menu and other external input interactions
- Prevents double selection with `data-plate-prevent-overlay` attribute

### AI SDK

This plugin is depending on the [ai](https://npmjs.com/package/ai) package:
Expand Down Expand Up @@ -278,14 +270,6 @@ Template for generating prompts. Supports placeholders:

</APIItem>

<APIItem name="scrollContainerSelector" type="string" optional>

CSS selector for scrollable container.

- **Default:** `'#scroll_container'`

</APIItem>

<APIItem name="systemTemplate" type="(props: EditorPromptParams) => string | void" optional>

Template for system messages. Supports same placeholders as `promptTemplate`.
Expand Down
22 changes: 22 additions & 0 deletions apps/www/content/docs/api/core/plate-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,28 @@ Defines how the plugin injects functionality into other plugins or the editor.
<APISubListItem parent="inject" name="nodeProps" type="InjectNodeProps<WithAnyKey<C>>" optional>
Properties used by Plate to inject props into any node component.
</APISubListItem>


<APISubListItem parent="inject" name="excludePlugins" type="string[]" optional>
An array of plugin keys to exclude from node prop injection.
</APISubListItem>

<APISubListItem parent="inject" name="excludeBelowPlugins" type="string[]" optional>
An array of plugin keys. Node prop injection will be excluded for any nodes that are descendants of elements with these plugin types.
</APISubListItem>
<APISubListItem parent="inject" name="isBlock" type="boolean" optional>
If true, only matches block elements. Used to restrict prop injection to block-level nodes.
</APISubListItem>

<APISubListItem parent="inject" name="isElement" type="boolean" optional>
If true, only matches element nodes. Used to restrict prop injection to element nodes.
</APISubListItem>
<APISubListItem parent="inject" name="isLeaf" type="boolean" optional>
If true, only matches leaf nodes. Used to restrict prop injection to leaf nodes.
</APISubListItem>
<APISubListItem parent="inject" name="maxLevel" type="number" optional>
Maximum nesting level for node prop injection. Nodes deeper than this level will not receive injected props.
</APISubListItem>
<APISubListItem parent="inject" name="plugins" type="Record<string, Partial<EditorPlatePlugin<AnyPluginConfig>>>" optional>
Property that can be used by a plugin to allow other plugins to inject code.
</APISubListItem>
Expand Down
4 changes: 4 additions & 0 deletions apps/www/content/docs/api/core/store.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ A unique ID used as a provider scope. Use it if you have multiple `Plate` in the
- **Default:** random id
</APIItem>

<APIItem name="containerRef" type="React.RefObject<HTMLDivElement>">
A reference to the editor container element.
</APIItem>

<APIItem name="decorate" type="function" optional>
Function used to decorate ranges in the editor.

Expand Down
6 changes: 1 addition & 5 deletions apps/www/content/docs/block-menu.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ docs:

---

<ComponentPreview name="playground-demo" id="blockmenu" />
<ComponentPreview name="playground-demo" id="block-menu" />

<PackageInfo>

Expand Down Expand Up @@ -52,10 +52,6 @@ const plugins = [
},
startThreshold: 10,
},
boundaries: '#scroll_container',
container: '#scroll_container',
selectables: '#scroll_container .slate-selectable',
selectionAreaClass: 'slate-selection-area',
},
enableContextMenu: true,
},
Expand Down
Loading
Loading