-
-
Notifications
You must be signed in to change notification settings - Fork 755
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3644 from udecode/ai-release
Ai packages
- Loading branch information
Showing
93 changed files
with
2,417 additions
and
1,342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@udecode/plate-markdown': patch | ||
--- | ||
|
||
New `deserializeInlineMd` `serializeInlineMd` `stripMarkdownBlocks` `stripMarkdownInline` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@udecode/plate-selection': patch | ||
--- | ||
|
||
BlockSelectionPlugin: New `tf.setBlockSelectionIndent` `tf.insertBlocksAndSelect` | ||
|
||
BlockMenuPlugin: Now when the left mouse button is clicked and the menu is open, the default event will not be prevented. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@udecode/plate-math': patch | ||
--- | ||
|
||
New `editor.tf.insert.equation` `editor.tf.insert.inlineEquation` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@udecode/plate-callout': patch | ||
--- | ||
|
||
New `editor.tf.insert.callout` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@udecode/plate-media': patch | ||
--- | ||
|
||
New `editor.tf.insert.audioPlaceholder` `editor.tf.insert.filePlaceholder` `editor.tf.insert.imagePlaceholder` `editor.tf.insert.videoPlaceholder` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@udecode/plate-ai': patch | ||
--- | ||
|
||
`CopilotPlugin`, `AIPlugin` is ready from this version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
WIP | ||
# Plate ai | ||
|
||
Visit https://platejs.org/docs/ai to view the documentation. | ||
|
||
## License | ||
|
||
[MIT](../../LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,47 @@ | ||
import type { TriggerComboboxPluginOptions } from '@udecode/plate-combobox'; | ||
|
||
import { | ||
type OmitFirst, | ||
type PluginConfig, | ||
type SlateEditor, | ||
type TNodeEntry, | ||
bindFirst, | ||
createTSlatePlugin, | ||
} from '@udecode/plate-common'; | ||
|
||
import { withTriggerAIMenu } from './withTriggerAIMenu'; | ||
import { removeAIMarks } from './transforms'; | ||
import { insertAINodes } from './transforms/insertAINodes'; | ||
import { removeAINodes } from './transforms/removeAINodes'; | ||
|
||
export type BaseAIOptions = { | ||
onOpenAI?: (editor: SlateEditor, nodeEntry: TNodeEntry) => void; | ||
} & TriggerComboboxPluginOptions; | ||
type BaseAIOptions = {}; | ||
type BaseAITransforms = { | ||
insertNodes: OmitFirst<typeof insertAINodes>; | ||
removeMarks: OmitFirst<typeof removeAIMarks>; | ||
removeNodes: OmitFirst<typeof removeAINodes>; | ||
}; | ||
|
||
export type BaseAIPluginConfig = PluginConfig<'ai', BaseAIOptions>; | ||
export type BaseAIPluginConfig = PluginConfig< | ||
'ai', | ||
BaseAIOptions, | ||
{}, | ||
{ ai: BaseAITransforms } | ||
>; | ||
|
||
export const BaseAIPlugin = createTSlatePlugin({ | ||
key: 'ai', | ||
extendEditor: withTriggerAIMenu, | ||
options: { | ||
scrollContainerSelector: '#scroll_container', | ||
trigger: ' ', | ||
triggerPreviousCharPattern: /^\s?$/, | ||
}, | ||
}); | ||
node: { isLeaf: true }, | ||
}) | ||
.extendTransforms(({ editor }) => ({ | ||
insertNodes: bindFirst(insertAINodes, editor), | ||
removeMarks: bindFirst(removeAIMarks, editor), | ||
removeNodes: bindFirst(removeAINodes, editor), | ||
})) | ||
.extend({ | ||
extendEditor: ({ editor }) => { | ||
const { apply } = editor; | ||
|
||
editor.apply = (op) => { | ||
// console.log('🚀 ~ editor.apply= ~ op:', op); | ||
// console.log('history', editor.history.undos); | ||
apply(op); | ||
}; | ||
|
||
return editor; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
*/ | ||
|
||
export * from './BaseAIPlugin'; | ||
export * from './withTriggerAIMenu'; | ||
export * from './transforms/index'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* @file Automatically generated by barrelsby. | ||
*/ | ||
|
||
export * from './insertAINodes'; | ||
export * from './removeAIMarks'; | ||
export * from './removeAINodes'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import type { Path } from 'slate'; | ||
|
||
import { | ||
type SlateEditor, | ||
type TDescendant, | ||
collapseSelection, | ||
getEndPoint, | ||
insertNodes, | ||
withNewBatch, | ||
} from '@udecode/plate-common'; | ||
|
||
import { AIPlugin } from '../../react/ai/AIPlugin'; | ||
|
||
export const insertAINodes = ( | ||
editor: SlateEditor, | ||
nodes: TDescendant[], | ||
{ | ||
splitHistory = false, | ||
target, | ||
}: { | ||
splitHistory?: boolean; | ||
target?: Path; | ||
} = {} | ||
) => { | ||
if (!target && !editor.selection?.focus.path) return; | ||
|
||
const insert = () => { | ||
const aiNodes = nodes.map((node) => ({ | ||
...node, | ||
[AIPlugin.key]: true, | ||
})); | ||
|
||
insertNodes(editor, aiNodes, { | ||
at: getEndPoint(editor, target || editor.selection!.focus.path), | ||
select: true, | ||
}); | ||
collapseSelection(editor, { edge: 'end' }); | ||
}; | ||
|
||
if (splitHistory) { | ||
withNewBatch(editor, insert); | ||
} else { | ||
insert(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { Location } from 'slate'; | ||
|
||
import { type SlateEditor, getRange, removeMark } from '@udecode/plate-common'; | ||
|
||
import { AIPlugin } from '../../react/ai/AIPlugin'; | ||
|
||
export const removeAIMarks = ( | ||
editor: SlateEditor, | ||
{ at = [] }: { at?: Location } = {} | ||
) => { | ||
removeMark(editor, { | ||
key: AIPlugin.key, | ||
at: getRange(editor, at), | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { Path } from 'slate'; | ||
|
||
import { type SlateEditor, isText, removeNodes } from '@udecode/plate-common'; | ||
|
||
import { AIPlugin } from '../../react/ai/AIPlugin'; | ||
|
||
export const removeAINodes = ( | ||
editor: SlateEditor, | ||
{ at = [] }: { at?: Path } = {} | ||
) => { | ||
removeNodes(editor, { | ||
at, | ||
match: (n) => isText(n) && !!n[AIPlugin.key], | ||
}); | ||
}; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.