[PE-232] chore: management of disabled extensions (#6317)

* chore: added mobile editor required changes

* fix: turbo.json

---------

Co-authored-by: Lakhan <Lakhanbaheti9@gmail.com>
This commit is contained in:
M. Palanikannan 2025-01-15 20:23:09 +05:30 committed by GitHub
parent 79fff4744a
commit a908bf9edd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 27 additions and 22 deletions

View file

@ -1,5 +1,6 @@
import { HocuspocusProvider } from "@hocuspocus/provider"; import { HocuspocusProvider } from "@hocuspocus/provider";
import { Extensions } from "@tiptap/core"; import { Extensions } from "@tiptap/core";
import { AnyExtension } from "@tiptap/core";
import { SlashCommands } from "@/extensions"; import { SlashCommands } from "@/extensions";
// plane editor types // plane editor types
import { TIssueEmbedConfig } from "@/plane-editor/types"; import { TIssueEmbedConfig } from "@/plane-editor/types";
@ -13,15 +14,24 @@ type Props = {
userDetails: TUserDetails; userDetails: TUserDetails;
}; };
export const DocumentEditorAdditionalExtensions = (_props: Props) => { type ExtensionConfig = {
const { disabledExtensions } = _props; isEnabled: (disabledExtensions: TExtensions[]) => boolean;
const extensions: Extensions = disabledExtensions?.includes("slash-commands") getExtension: (props: Props) => AnyExtension;
? [] };
: [
SlashCommands({ const extensionRegistry: ExtensionConfig[] = [
disabledExtensions, {
}), isEnabled: (disabledExtensions) => !disabledExtensions.includes("slash-commands"),
]; getExtension: () => SlashCommands({}),
},
return extensions; ];
export const DocumentEditorAdditionalExtensions = (_props: Props) => {
const { disabledExtensions = [] } = _props;
const documentExtensions = extensionRegistry
.filter((config) => config.isEnabled(disabledExtensions))
.map((config) => config.getExtension(_props));
return documentExtensions;
}; };

View file

@ -4,7 +4,7 @@ import { TSlashCommandAdditionalOption } from "@/extensions";
import { TExtensions } from "@/types"; import { TExtensions } from "@/types";
type Props = { type Props = {
disabledExtensions: TExtensions[]; disabledExtensions?: TExtensions[];
}; };
export const coreEditorAdditionalSlashCommandOptions = (props: Props): TSlashCommandAdditionalOption[] => { export const coreEditorAdditionalSlashCommandOptions = (props: Props): TSlashCommandAdditionalOption[] => {

View file

@ -39,11 +39,11 @@ import {
setText, setText,
} from "@/helpers/editor-commands"; } from "@/helpers/editor-commands";
// types // types
import { CommandProps, ISlashCommandItem, TExtensions, TSlashCommandSectionKeys } from "@/types"; import { CommandProps, ISlashCommandItem, TSlashCommandSectionKeys } from "@/types";
// plane editor extensions // plane editor extensions
import { coreEditorAdditionalSlashCommandOptions } from "@/plane-editor/extensions"; import { coreEditorAdditionalSlashCommandOptions } from "@/plane-editor/extensions";
// local types // local types
import { TSlashCommandAdditionalOption } from "./root"; import { TExtensionProps } from "./root";
export type TSlashCommandSection = { export type TSlashCommandSection = {
key: TSlashCommandSectionKeys; key: TSlashCommandSectionKeys;
@ -51,13 +51,8 @@ export type TSlashCommandSection = {
items: ISlashCommandItem[]; items: ISlashCommandItem[];
}; };
type TArgs = {
additionalOptions?: TSlashCommandAdditionalOption[];
disabledExtensions: TExtensions[];
};
export const getSlashCommandFilteredSections = export const getSlashCommandFilteredSections =
(args: TArgs) => (args: TExtensionProps) =>
({ query }: { query: string }): TSlashCommandSection[] => { ({ query }: { query: string }): TSlashCommandSection[] => {
const { additionalOptions, disabledExtensions } = args; const { additionalOptions, disabledExtensions } = args;
const SLASH_COMMAND_SECTIONS: TSlashCommandSection[] = [ const SLASH_COMMAND_SECTIONS: TSlashCommandSection[] = [

View file

@ -103,9 +103,9 @@ const renderItems = () => {
}; };
}; };
type TExtensionProps = { export type TExtensionProps = {
additionalOptions?: TSlashCommandAdditionalOption[]; additionalOptions?: TSlashCommandAdditionalOption[];
disabledExtensions: TExtensions[]; disabledExtensions?: TExtensions[];
}; };
export const SlashCommands = (props: TExtensionProps) => export const SlashCommands = (props: TExtensionProps) =>