New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

useblocks-dev

Package Overview
Dependencies
Maintainers
1
Versions
119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

useblocks-dev

Run this code in the command prompt:

latest
npmnpm
Version
1.0.104-alpha.4
Version published
Weekly downloads
6
-53.85%
Maintainers
1
Weekly downloads
 
Created
Source

Installation

Run this code in the command prompt:

$ npm i useblocks@1.0.104-alpha.4 -save

Add the Blocks plugin to your App config.

For the Webpack module bundler

Package import:

const useblocksPlugin = require('useblocks/webpack')

Defining the package in the app:

module.exports = {
	plugins: [
		new UseblocksWebpackPlugin(),
	]
}

For the Vite module bundler

Package import:

import useblocksPlugin from 'useblocks/vite'

Defining the package in the app:

export default defineConfig({
	plugins: [useblocksPlugin()],
})

Initialization

Import the Blocks plugin into your component:

import * as useblocks from "useblocks"

The Plugin configuration contains a parameter named getAuthToken. For authorization, you must pass the application's OAuth token to its value. For debugging purposes, the dev version of the plugin supports a mechanism for obtaining a token from the front of the application. To use this mechanism you need first to define auth-proxy in AppConfig:

Fetching the OAuth token on the backend

curl --location 'https://api.useblocks.io/oauth/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=*******' \
--data-urlencode 'client_secret=*******' \
--data-urlencode 'grant_type=client_credentials'

Creating the Blocks plugin entity

useblocks.init({
	getAuthToken: getAuthToken,
	element: "#test",
	content: {
		title: "Email subject",
		html: "EMAIL_CODE",
	},
	config: { }
}).then(instance => {  })

You can get the EMAIL_CODE from our example or paste the HTML code of your own email

Configuration

Plugin configuration is JSON with several nesting levels. In the config you can set the appearance, content, and the logic the plugin will work with.

Element

You can send the element line into the plugin configuration. It is a DOM element selector and you need to initiate the plugin inside of it. If the element is not defined, the app will run in the background mode.

Content

The content section contains parameters of an email that must be displayed in the editor. This is what can be sent to this parameter:

{string}

HTML code of an email.

{object} email options

{
	id?: string; // A unique ID of a project in your system.
	html?: string; // HTML code of an email.
	subject?: string; // Email subject line.
	preheader?: string; // Email preheader.
}

{object} full description

{
	temlateId?: string; // Email template ID in Blocks.
	email?: object; // email options.
	blocks?: []; // Additional blocks.
	comments?: []; // Comments in an email.
}

You can change the content at any moment after the initialization with the help of the instance.show(content) method.

Config

This section is dedicated to setting the appearance and settings of the editor. You can change the configuration of this section after the initialization with the help of useblocks.setConfig or useblocks.updateConfig.

The list of parameters of the config section
ParameterDescriptionDefault
themePlugin theme: light, dark.light
autosaveTimeoutDelay before autosave, ms.10000
mergeTagsJSON with the list of dynamic variables.undefined
stylesString with styles in CSS format.''
headerShowShow header.true
headerArrowBackVisibleShow “Back” arrow.true
headerTitleVisibleShow “Subject” field.true
headerPreheaderVisibleShow “Preheader” field.true
historyEnabledShow “Version history” button.true
codeEnabledShow “Code mode” button.true
codeModeDirectionDefault code editor display modenone
codeSideEnabledShow “Code mode” button when desktop/mobile toggle is available.true
previewIconEnabledShow “Preview” button.true
previewModeEnabledLink to Preview.true
livePreviewEnabledShow “Email client testing” button.true
sendTestEnabledShow “Send test” button.true
sharePreviewEnabledShow “Share” button.true
webversionEnabledShow link to web version.true
commonStylesEnabledShow content styles.true
emailResponsiveControlEnabledShow email responsiveness toggle.true
templateNotEmAlertShowShow alert that template is not from EM.true
emailDropdownMenuEnabledShow email menu.true
emailDropdownMenuCloneShow “Clone” item.true
emailDropdownMenuImportShow “Import” item.true
emailDropdownMenuImportButtonShow “Import” as a button.true
emailDropdownMenuLockShow “Lock” item.true
emailDropdownMenuRemoveShow “Delete” item.true
emailExportEnabledShow “Export” button.true
exportHtmlEnabledExport to HTML.true
exportZipEnabledExport to ZIP.true
exportClipboardEnabledExport to clipboard.true
exportWebHookEnabledExport to webhook.true
exportOutlookEnabledExport to Outlook.true
exportPdfEnabledExport to PDF.true
exportPngEnabledExport to PNG.true
nextButtonEnabledShow secondary button.false
nextButtonTextText on secondary button.''
saveButtonEnabledShow primary button.true
saveButtonTextText on primary button.true
commandButtonsEnabledShow primary and secondary buttons.true
sidePanelFloatingFloating side panel.true
desktopMobileSwitchRuleModes switch bar.true
desktopMobileSwitchPanelModes switch panel.false
onlyCodeModeInMobileShow only code on mobile.false
pathEnabledShow breadcrumbs.true
copyPasteEnabledShow copy–paste block in iframe.true
saveBlockEnabledShow save block button.true
editImageControlEnabledShow image editing button.true
menuDirectionSide panel position.'right'
defaultBuildPanelDefault opened tab setting.''/'empty'/'project'/'common'/'template'
commentsEnabledShow “Comments” button.true
aiAssistentEnabledShow “AI assistant”.true
optimizeEnabledShow “Optimization” button.true
optimizeLinksEnabledShow links check.true
optimizeImagesEnabledShow images check.true
optimizeSpamAssassinEnabledShow SpamAssassin check.true
optimizeCheckCodeEnabledShow code check.true
settingsEnabledShow “Settings” button.true
UTMEnabledShow UTM tags tab.true
descriptionEnabledShow “Description” field in settings.true
tagsEnabledShow “Tags” field in settings.true
switchDesktopMobilePropsEnabledShow mobile properties toggle.true
stepToOtherElementEnabledShow buttons to jump to other elements.true
deleteButtonEnabledShow delete element button.true
toggleSidePanelAllow collapsing side panel.true
blocksSectionsShowShow blocks menu.true
blocksEmptyEnabledShow empty blocks.true
blocksSavedEnabledShow saved blocks.true
blocksCommonEnabledShow common blocks.true
blocksTemplateEnabledShow template blocks.true
blocksSearchEnabledShow blocks search.true
blocksAddPanelEnabledShow add block panel in visual editor.true
imagePathDropdownEnabledShow dropdown with image path.true
formFieldImageTitleEnabledShow title field in image form.true
formFieldBorderEnabledShow border controls.true
formFieldBorderRadiusEnabledShow border radius controls.true
formFieldBoxShadowEnabledShow shadow controls.true
formFieldVisibilityEnabledShow element visibility controls.true
formFieldExportAsPictureEnabledShow “export as image” toggle.true
formButtonFieldInsertImageEnabledShow “insert image into text” button for button.true
formButtonFieldVerticalAlignEnabledShow vertical alignment controls for button.true
formButtonFieldTextAlignEnabledShow text alignment controls for button.true
formButtonFieldBackgroundImageEnabledShow background image controls for button.true
formButtonFieldPaddingsEnabledShow padding controls for button.true
formButtonFieldReplacerEnabledShow replacer for button.true
formCellFieldVerticalAlignEnabledShow vertical alignment controls for cell.true
formCellFieldBackgroundImageEnabledShow background image controls for cell.true
formCellFieldPaddingsEnabledShow padding controls for cell.true
formCellFieldSizeEnabledShow width and height controls.true
formImageFieldVerticalAlignEnabledShow vertical alignment controls for image.true
formImageFieldReplacerEnabledShow replacer for image.true
formImageFieldHeightEnabledShow height field for image.true
formTableFieldBackgroundImageEnabledShow background image controls for table.true
formDivFieldBackgroundImageEnabledShow background image controls for container.true
formEmailFieldBackgroundImageEnabledShow background image controls for email.true
formTextFieldTypografEnabledShow typograph button.true
formTextFieldReplacerEnabledShow replacer button.true
elementImageEnabledElement Image.true
elementTextEnabledElement Text.true
elementHeaderEnabledElement Heading.true
elementButtonEnabledElement Button.true
elementListULEnabledElement List UL.true
elementListOLEnabledElement List OL.true
elementDividerEnabledElement Divider.true
elementSpacerEnabledElement Spacer.true
elementSocialEnabledElement Social.true
elementTableEnabledElement Table.true
elementCountdownEnabledElement Countdown.true
elementVideoEnabledElement Video.true
elementAIimageEnabledElement AI image.true
elementAItextEnabledElement AI text.true
elementCarouselEnabledElement AMP carousel.true
elementAccordionEnabledElement AMP accordion.true
elementFormEnabledElement AMP form.true
imageCenterStockEnabledStock photos tab.true
imageCenterGifEnabledStock GIFs tab.true
imageCenterEditorEnabledImage editor tab.true
compressMaxSizeMax image size after optimization, MB.true
compressMaxWidthOrHeightMax image width after optimization, px.true

Events

Events can be sent to configurations or added to them later while working with the instance of the plugin. All event subscribers can be asynchronous features.

Example

useblocks.init({
	....,
	// Subscription to events in the initialization.
	handleReadEmail: (e) => {},
	handleSaveEmail: async (e) => {}
}).then((instance) => {
	// Subscription to events after the initialization.
	const dispose = instance.handleReadEmail(e => {});
	const dispose = instance.handleSaveEmail(async (e) => {});
});

By sending the asynchronous feature you can implement the asynchronous data load.

Example

useblocks.init({
	element: "#test",
	content: {
		id: "1"
	}
	handleReadEmail: async (id) => {
		return await  fetchData(id); // Your data fetch feature.
	}
}).then((instance) => { 
	setTimeout(() => instance.show({ id: "2" }), 1000)
});

Events

NameDescription
handleReadEmailRead email
handleSaveEmailSave / update email
handleReadEmailRevisionsRead autosave list
handleEmailAutosaveAutosave
handleReadBlocksRead project blocks list
handleSaveBlockSave / update project block
handleRemoveBlockDelete project block
handleReadCommentsRead email comments list
handleSaveCommentSave / update comment
handleRemoveCommentDelete email comment
handleSaveButtonClickEmail save button click
handleNextButtonClickNext button click
handlePreviousButtonClickBack button click
handleEmailChangedAny email parameter changed
handleHtmlChangedEmail HTML changed
handleDestroyPlugin destroy
handleLoadPlugin instance initialization completed
handleLoadImageLoad images
handleNotifyNotification
handleErrorError notification
handleSuccessSuccess notification
handleTestEmailSendTest email send
handleTestEmailModalOpen test email modal window

Methods

Method nameDescription
initInitialization (async)
showUpdate content after initialization
destroyDestroy instance
resetReset all configuration
getEmailGet current email
getConfigGet configuration
getBlocksGet project blocks
getCommentsGet email comments
getEmailRevisionsGet version control list
setConfigSet new config parameters
updateConfigAdd to config parameters
notifyShow notifications
getElementGet initialization element
saveSave email
compileEmailGet compiled email

📂 File Manager

To enable the file manager, you need to specify the following configuration during initialization:

emailmaker.init({
  storageProvider: ..., // implementation of the StorageProvider interface
  config: {
    imageCenterFileManagerView: true
  }
});

The fileManager section controls the features of the file manager. All fields are optional; if omitted or set to false, the corresponding feature is disabled.

Basic Operations

  • enableTrash — enables trash functionality for deleted files. When enabled, files are moved to trash instead of permanent deletion. Default: true
  • enableRenameFolder — allows renaming folders. Default is true
  • enableRenameFile — allows renaming files. Default is true
  • enableUpdateFile — allows updating file content or metadata. Default is true
  • enableEdit — allows editing files (changing content or properties). Default is true
  • enableMoveFile — allows moving files between folders. Default is true
  • enableMoveFolder — allows moving folders. Default is true
  • enableCopyFile — allows copying files. Default is true
  • enableCopyFolder — allows copying folders. Default is true
  • enableDelete — allows deleting files and folders. When the recycle bin is enabled, files are moved there instead of being permanently deleted. Default is true
  • multiSelect — allows multiple selection of files and folders for batch operations. Default is true
  • defaultFolderName — default folder name

Pagination & Display

  • enablePagination — enables paginated navigation. If disabled, all items are loaded at once. Default: true

Client-Side Processing

  • clientSideSorting — client-side file sorting.

    • If true, applies standard sorting (by name ascending).
    • If a function is provided, it receives the current file array, optional sortBy and sortOrder, and returns a sorted array.
  • clientSidePaging — client-side file pagination.

    • If true, applies standard array slicing based on page and limit.
    • If a function is provided, it receives the file array, page and limit, and returns an array for the specific page only.
  • clientSideFilter — client-side file filtering.

    • If true, applies standard filtering by search text.
    • If a function is provided, it receives the file array and optional search, and returns a filtered array.

Cache Strategy

  • cacheStrategy — caching strategy for performance optimization.
    • ttl — cache time-to-live in milliseconds. Default: 300000 (5 minutes)
    • errorTtl — cache TTL for errors in milliseconds. Default: 60000 (1 minute)
    • allowSortedInsert — allows inserting elements into sorted arrays without full cache invalidation. Default: false
    • allowSearchInsert — allows inserting elements into filtered arrays without full cache invalidation. Default: false
    • invalidateOnPaginationFull — marks cache as stale when inserting into a full paginated page. Default: true
    • comparator — comparison function for sorting two files. Default: name-based comparison
    • filterMatch — function to check if a file passes current filters. Default: name-based search

Interface StorageProvider

Properties

PropertyTypeDescriptionDefault
pathModebooleanUse path as identifier for folders-
rootIdstringCustom identifier for root folder''
trashPathstringPath to trash/recycle bin folder-
tempPathstringPath to temporary folder for uploads-
useSoftDeletebooleanEnable client-side soft deletefalse
ensureFolderTrailingSlashbooleanAdd a trailing slash to folder pathstrue
validateDuplicatesbooleanClient-side check for existing files or folders-

Methods

Core Methods
MethodParametersReturnsDescription
getItemsoptions:
- folderId?: string
- search?: string
- sortBy?: string
- sortOrder?: 'asc'|'desc'
- page?: number
- limit?: number
- itemType: 'all'|'file'|'folder'
{ items: FileSystemItem[], pagination?: Partial<ApiPaginationResponse> }Retrieve files/folders with filtering, sorting, pagination
createFoldername: string, parentid?: stringFileSystemItemCreate new folder
uploadFilefile:
- name: string
- size: number
- type: string
- folderId?: string
- data: Blob | string
- thumbnail?: string
- dimensions?: string
- aspectRatio?: string
- extension?: string
FileSystemItemUpdateUpload file with metadata
uploadFilesrequest:
- items: { requestId?: string, name: string, size: number, type: string, folderId?: string | null, data: Blob | string, extension?: string }[]
- folderId?: string | null
BatchResult<UploadFileResultData>Upload multiple files. The order of items matters — if requestId is not provided, results are matched by index
uploadFileByUrlurl: string, folderId?: stringFileSystemItemUpload file from URL (check for existing files)
findItemByPathpath: stringFileSystemItem | undefinedFind system files/folders by path
setControllercontroller: StorageProviderControllervoidSet cache management controller
getFileDatafile: FileSystemItemBlobGet file content as blob
getUrlfile: FileSystemItemstringGet file access URL
getThumbnailUrlfile: FileSystemItemstringGet thumbnail URL
renameItemitem: FileSystemItem, newName: stringFileSystemItemUpdateRename file/folder
deleteItemitem: FileSystemItemvoidDelete single item (moves to trash if soft delete enabled)
deleteItemsitems: FileSystemItem[]BatchResult<never>Delete multiple items
moveItemitem: FileSystemItem, targetFolderId?: stringFileSystemItemUpdateMove single item
moveItemsitems: FileSystemItem[], targetFolderId?: stringBatchResult<FileSystemItemUpdate>Move multiple items
copyItemitem: FileSystemItem, targetFolderId?: stringFileSystemItemUpdateCopy single item
copyItemsitems: FileSystemItem[], targetFolderId?: stringBatchResult<FileSystemItemUpdate>Copy multiple items
updateFilefile: FileSystemItem, updates: metadata objectFileSystemItemUpdateUpdate file metadata/content
Type Definitions
  • MayBePromise<T>: T | Promise<T>
  • FileSystemItem: File or folder object
  • FileSystemItemUpdate: Item with changed fields
  • BatchResult<T>: Result with success/failure details
  • ApiPaginationResponse: Pagination metadata
Important Notes
  • Soft Delete: When useSoftDelete=true, delete operations move items to trashPath
  • Root Folder: Use rootId or empty string for root operations
  • Path Resolution: trashPath and tempPath are resolved to actual folder IDs
  • URL Upload: Should check if file already exists on current server
  • Cache Control: Use setController for cache invalidation requests

Keywords

none

FAQs

Package last updated on 10 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts