UNPKG

@craftercms/studio-ui

Version:

Services, components, models & utils to build CrafterCMS authoring extensions.

112 lines (110 loc) 4.3 kB
/* * Copyright (C) 2007-2022 Crafter Software Corporation. All Rights Reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 3 as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import { ParsedQuery } from 'query-string'; import { DetailedItem, PasteItem } from '../models/Item'; import LookupTable from '../models/LookupTable'; import ContentType from '../models/ContentType'; import { SystemType } from '../models'; export declare function getPathFromPreviewURL(previewURL: string): string; /** * Computes and returns the preview URL from a path. Notice non-previewable paths will not be transformed. * @param path {string} The path to compute the preview URL from * @returns {string} The preview URL */ export declare function getPreviewURLFromPath(path: string): string; export declare function getFileNameFromPath(path: string): string; export declare function getQueryVariable(query: string, variable: string): string | string[]; export declare function parseQueryString(): ParsedQuery; export declare function withoutIndex(path: string): string; export declare function withIndex(path: string): string; /** * Takes in a path and if it ends with a file, strips the file off the path (returns the parent * path of the file). Returns same path if not file is present in the path. **/ export declare function withoutFile(path: string): string; /** * Takes in a path (or file name) and extracts its extension (e.g. "/files/names.txt" => "txt") **/ export declare function getFileExtension(path: string): string; export declare function hasExtension(path: string): boolean; export declare function removeExtension(name: string): string; export declare function getParentPath(path: string): string; export declare function isRootPath(path: string): boolean; export declare function getRootPath(path: string): string; export declare function getParentsFromPath(path: string, rootPath: string): string[]; export declare function getIndividualPaths(path: string, rootPath?: string): string[]; export declare function getPasteItemFromPath(path: string, paths: string[]): PasteItem; export declare function isValidCopyPastePath(targetPath: string, sourcePath: string): boolean; export declare function isValidCutPastePath(targetPath: string, sourcePath: string): boolean; export declare function getEditFormSrc({ path, selectedFields, site, authoringBase, readonly, isHidden, modelId, changeTemplate, contentTypeId, isNewContent, iceGroupId, newEmbedded, canEdit, fieldsIndexes }: { path: string; selectedFields?: string; site: string; authoringBase: string; readonly?: boolean; isHidden?: boolean; modelId?: string; changeTemplate?: string; contentTypeId?: string; isNewContent?: boolean; iceGroupId?: string; newEmbedded?: string; canEdit?: boolean; fieldsIndexes?: string; }): string; export declare function getCodeEditorSrc({ path, site, type, contentType, authoringBase, readonly }: { path: string; site: string; type: string; contentType?: string; authoringBase: string; readonly: boolean; }): string; export declare function stripDuplicateSlashes(str: string): string; export declare function getItemGroovyPath(item: DetailedItem): string; export declare function getItemTemplatePath(item: DetailedItem, contentTypes: LookupTable<ContentType>): string; export declare function getControllerPath(type: SystemType): string; export declare function processPathMacros(dependencies: { path: string; objectId: string; objectGroupId?: string; useUUID?: boolean; fullParentPath?: string; }): string; export declare const pickExtensionForItemType: (systemType: string, name?: string) => string; export declare const getFileNameWithExtensionForItemType: (type: string, name: string) => string;