@onlyoffice/docspace-sdk-js
Version:
Simple integration JavaScript SDK for ONLYOFFICE DocSpace
66 lines (65 loc) • 3.27 kB
TypeScript
/**
* (c) Copyright Ascensio System SIA 2025
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @license
*/
import type { TFrameConfig } from "../types";
/**
* Converts an object with string, number, or boolean values into `URLSearchParams`.
*
* @param data - An object where the keys are strings and the values are either strings, numbers, or booleans.
* @returns A new instance of `URLSearchParams` initialized with the provided object.
*/
export declare const customUrlSearchParams: (data: Record<string, string | number | boolean | undefined | null>) => string;
/**
* Validates the Content Security Policy (CSP) of the target source.
*
* @param targetSrc - The target source URL to validate against the current origin.
* @returns A promise that resolves if the CSP validation passes, otherwise it throws an error.
*
* @throws Will throw an error if the current origin is not included in the allowed domains from the target source's CSP.
*/
export declare const validateCSP: (targetSrc: string) => Promise<void>;
export declare const getCSPErrorBody: (src: string) => string;
export declare const getLoaderStyle: (className: string) => string;
/**
* Retrieves the configuration from the URL parameters of the current script element.
*
* This function extracts the `src` attribute from the current script element,
* decodes it, and parses the query parameters to construct a configuration object.
* The configuration is based on the `defaultConfig` object and overrides its properties
* with the parsed parameters.
*
* @returns {TFrameConfig | null} The parsed configuration object or null if the `src` attribute is empty.
*/
export declare const getConfigFromParams: () => TFrameConfig | null;
/**
* Generates a URL path based on the provided configuration.
*
* @param config - The configuration object for generating the frame path.
* @returns The generated URL path as a string.
*
* @remarks
* The function handles different modes specified in the `config.mode` property:
* - `SDKMode.Manager`: Generates a path for the manager mode, including optional request tokens and filters.
* - `SDKMode.PublicRoom`: Generates a path for the public room mode, including request tokens and filters.
* - `SDKMode.RoomSelector`: Returns a fixed path for the room selector.
* - `SDKMode.FileSelector`: Returns a path for the file selector with the specified selector type.
* - `SDKMode.System`: Returns a fixed path for the system mode.
* - `SDKMode.Editor`: Generates a path for the editor mode, including customization and event handling.
* - `SDKMode.Viewer`: Generates a path for the viewer mode, similar to the editor mode but with view action.
*
*/
export declare const getFramePath: (config: TFrameConfig) => string;