dev: editor extensions feature flagging (#5279)

This commit is contained in:
Aaryan Khandelwal 2024-08-07 20:06:15 +05:30 committed by GitHub
parent 520938ab5c
commit 943dd593fa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 51 additions and 22 deletions

View file

@ -1,10 +1,14 @@
import { Extensions } from "@tiptap/core";
import { SlashCommand } from "@/extensions";
// hooks
import { TFileHandler } from "@/hooks/use-editor";
// plane editor types
import { TIssueEmbedConfig } from "@/plane-editor/types";
// types
import { TExtensions } from "@/types";
type Props = {
disabledExtensions?: TExtensions[];
fileHandler: TFileHandler;
issueEmbedConfig: TIssueEmbedConfig | undefined;
};
@ -12,7 +16,7 @@ type Props = {
export const DocumentEditorAdditionalExtensions = (props: Props) => {
const { fileHandler } = props;
const extensions = [SlashCommand(fileHandler.upload)];
const extensions: Extensions = [SlashCommand(fileHandler.upload)];
return extensions;
};

View file

@ -9,10 +9,11 @@ import { TFileHandler } from "@/hooks/use-editor";
// plane editor types
import { TEmbedConfig } from "@/plane-editor/types";
// types
import { EditorRefApi, IMentionHighlight, IMentionSuggestion } from "@/types";
import { EditorRefApi, IMentionHighlight, IMentionSuggestion, TExtensions } from "@/types";
interface IDocumentEditor {
containerClassName?: string;
disabledExtensions?: TExtensions[];
editorClassName?: string;
embedHandler: TEmbedConfig;
fileHandler: TFileHandler;
@ -32,6 +33,7 @@ interface IDocumentEditor {
const DocumentEditor = (props: IDocumentEditor) => {
const {
containerClassName,
disabledExtensions,
editorClassName = "",
embedHandler,
fileHandler,
@ -54,6 +56,7 @@ const DocumentEditor = (props: IDocumentEditor) => {
// use document editor
const { editor, isIndexedDbSynced } = useDocumentEditor({
disabledExtensions,
id,
editorClassName,
embedHandler,

View file

@ -19,11 +19,7 @@ const RichTextEditor = (props: IRichTextEditor) => {
};
const getExtensions = useCallback(() => {
const extensions = [
SlashCommand(fileHandler.upload),
// TODO; add the extension conditionally for forms that don't require it
// EnterKeyExtension(onEnterKeyPress),
];
const extensions = [SlashCommand(fileHandler.upload)];
if (dragDropEnabled) extensions.push(DragAndDrop(setHideDragHandleFunction));

View file

@ -13,9 +13,10 @@ import { CollaborationProvider } from "@/plane-editor/providers";
// plane editor types
import { TEmbedConfig } from "@/plane-editor/types";
// types
import { EditorRefApi, IMentionHighlight, IMentionSuggestion } from "@/types";
import { EditorRefApi, IMentionHighlight, IMentionSuggestion, TExtensions } from "@/types";
type DocumentEditorProps = {
disabledExtensions?: TExtensions[];
editorClassName: string;
editorProps?: EditorProps;
embedHandler?: TEmbedConfig;
@ -36,6 +37,7 @@ type DocumentEditorProps = {
export const useDocumentEditor = (props: DocumentEditorProps) => {
const {
disabledExtensions,
editorClassName,
editorProps = {},
embedHandler,
@ -102,6 +104,7 @@ export const useDocumentEditor = (props: DocumentEditorProps) => {
document: provider.document,
}),
...DocumentEditorAdditionalExtensions({
disabledExtensions,
fileHandler,
issueEmbedConfig: embedHandler?.issue,
}),
@ -111,5 +114,8 @@ export const useDocumentEditor = (props: DocumentEditorProps) => {
tabIndex,
});
return { editor, isIndexedDbSynced };
return {
editor,
isIndexedDbSynced,
};
};

View file

@ -0,0 +1 @@
export type TExtensions = "issue-embed";

View file

@ -1,5 +1,6 @@
export * from "./editor";
export * from "./embed";
export * from "./extensions";
export * from "./image";
export * from "./mention-suggestion";
export * from "./slash-commands-suggestion";

View file

@ -20,7 +20,8 @@ export type TEditorCommands =
| "code"
| "table"
| "image"
| "divider";
| "divider"
| "issue-embed";
export type CommandProps = {
editor: Editor;