editorShape
Description
Optional. This is an array of objects that lets you control how the Kanban editor looks and works.
Usage
editorShape?: [
{
// common parameters for all types
type: string,
key: string,
label?: string,
// for the "dateRange" type only
key: {
start: string,
end: string
},
config?: {
align?: "start" | "center" | "end",
editable?: boolean | function,
buttons?: boolean,
css?: string,
disabled?: boolean,
done?: boolean,
error?: boolean,
format?: string,
months?: number,
placeholder?: string,
title?: string,
width?: string
},
// for the "date" type only
config?: {
align?: "start" | "center" | "end",
editable?: boolean | function,
buttons?: boolean,
css?: string,
disabled?: boolean,
error?: boolean,
format?: string,
placeholder?: string,
title?: string,
width?: string
},
// for the "color" type only
values?: array,
config?: {
clear?: boolean,
disabled?: boolean,
error?: boolean,
placeholder?: string,
title?: string
},
// for "combo", "select", and "multiselect" types only
values?: [
{
id: string | number,
label: string,
avatar?: string // for a "multiselect" type only
},
{...} // other options
],
config?: {
clear?: boolean, // for "combo" and "color" types
label?: string, // for a "select" type only
checkboxes?: boolean, // for a "multiselect" type only
// common parameters
disabled?: boolean,
error?: boolean,
placeholder?: string,
textField?: string,
title?: string
},
// for a "text" type only
config?: {
css?: string,
disabled?: boolean,
error?: boolean,
focus?: boolean,
icon?: string,
inputStyle?: string,
placeholder?: string,
readonly?: boolean,
select?: boolean,
title?: string,
type?: string
},
// for a "textarea" type only
config? {
disabled?: boolean,
error?: boolean,
placeholder?: string,
title?: string,
readonly?: boolean
},
// for a "progress" type only
config?: {
disabled?: boolean,
label?: string,
max?: number,
min?: number,
step?: number,
title?: string,
width?: number
},
// for a "files" type only
uploadURL?: string | function,
config?: {
accept?: string,
disabled?: boolean,
multiple?: boolean,
folder?: boolean,
},
// for a "comments" type only
config?: {
format?: string,
placement?: "page" | "editor",
html?: boolean,
confirmDeletion?: boolean
},
// for a "links" type only
config?: {
confirmDeletion?: boolean
},
}, { /* other control settings */ }
];
Parameters
These are the parameters you can use to set up the editor's look and behavior:
- Common parameters for all types
type- (required) specifies the editor field type.
The editor supports these field types: dateRange, date, combo, select, multiselect, color, text, textarea, progress, files, comments, and links.
key- (required) the editor field key. This should match the value used in thecardShapeproperty. Here's an example:
// card appearance settings
const cardShape = {
...kanban.defaultCardShape,
headerFields: [
{ // custom field
label: "Custom field",
css: "custom_style",
key: "custom_key"
}
]
};
// editor appearance settings
const editorShape = [
{
label: "Custom field",
type: "text",
key: "custom_key"
}
];
label- (optional) the label for the editor field.
- Parameters for a "dateRange" type
key- (required) an object defining keys for the editor field:start- (required) the key for the start dateend- (required) the key for the end date
These keys should match those used in the cardShape property.
config- (optional) configuration options for the "dateRange" field:align- (optional) controls how the calendar popup aligns relative to the Date Range controleditable- (optional) controls if the date picker can be edited and optionally sets a custom date formatbuttons- (optional) toggles visibility of Today and Clear buttons in the calendar popupcss- (optional) adjusts the icon position in the Date Range controldisabled- (optional) disables the Date Range control when truedone- (optional) shows or hides the Done buttonerror- (optional) applies error styling if trueformat- (optional) sets the date format; see here for available formatsmonths- (optional) sets how many calendars appear in the Date Range controlplaceholder- (optional) placeholder text for the controltitle- (optional) a title with extra info for the controlwidth- (optional) width of the calendar popup
- Parameters for a "date" type
config- (optional) configuration options for the "date" field:align- (optional) controls popup alignment relative to the Date controleditable- (optional) controls editability and custom date formatbuttons- (optional) toggles Today and Clear buttons in the popupcss- (optional) changes icon positiondisabled- (optional) disables the controlerror- (optional) applies error stylingformat- (optional) sets date format, with options listed hereplaceholder- (optional) placeholder texttitle- (optional) additional info titlewidth- (optional) popup width
- Parameters for a "color" type
values- (optional) an array of valid HEX color codesconfig- (optional) configuration options for the "color" field:placeholder- (optional) placeholder textclear- (optional) shows or hides a clear icondisabled- (optional) disables the controlerror- (optional) applies error stylingtitle- (optional) extra info title
- Parameters for "combo", "select" and "multiselect" types
values- (optional) an array of option objects, each with:id- (required) option IDlabel- (required) option labelavatar- (optional) path to an image (only for "multiselect")
To assign a single user, use "select" or "combo" types. To assign multiple users, use "multiselect".
config- (optional) configuration options for these types:clear- (optional) adds a Clear button (only for "combo" and "color")label- (optional) binds options to the input field by this key (only for "select")checkboxes- (optional) shows checkboxes next to options (only for "multiselect")textField- (optional) binds combo options to input by this key (for "combo" and "multiselect")disabled- (optional) disables the controlerror- (optional) applies error stylingplaceholder- (optional) placeholder texttitle- (optional) extra info title
- Parameters for a "text" type
config- (optional) configuration options for the "text" field:css- (optional) icon position in the controldisabled- (optional) disables the controlerror- (optional) applies error stylingfocus- (optional) sets focus on the controlicon- (optional) adds an icon inside the controlinputStyle- (optional) custom style for the controlplaceholder- (optional) placeholder textreadonly- (optional) makes the control read-onlyselect- (optional) selects the control's contenttitle- (optional) extra info titletype- (optional) sets the input type
- Parameters for a "textarea" type
config- (optional) configuration options for the "textarea" field:disabled- (optional) disables the controlerror- (optional) applies error stylingplaceholder- (optional) placeholder texttitle- (optional) extra info titlereadonly- (optional) makes the control read-only
- Parameters for a "progress" type
config- (optional) configuration options for the "progress" field:disabled- (optional) disables the controllabel- (optional) label displayed above the controlmax- (optional) maximum valuemin- (optional) minimum valuestep- (optional) value incrementstitle- (optional) extra info titlewidth- (optional) control width
- Parameters for a "files" type
uploadURL- (optional) URL or function for file uploading; details below
Details
The uploadURL can be a string or a function. Here’s an example using a function:
uploadURL: rec => {
const formData = new FormData();
formData.append("upload", rec.file);
const config = {
method: "POST",
body: formData,
headers: {
'Authorization': 'Bearer ' + token // include token or other headers here
}
};
return fetch(url + "/uploads", config) // specify URL here
.then(res => res.json())
.then(
data => {
rec.id = data.id;
return data;
},
() => ({ id: rec.id, status: "error" })
)
.catch();
}
The rec parameter is an extended PointerEvent object with these extra properties:
interface UploadEvent extends PointerEvent {
id: number;
status: "client" | "server" | "error"; // indicates upload status: "not sent yet", "sent successfully", or "error"
name: string; // file name
file: string | Blob; // the file itself
}
config- (optional) configuration options for the "files" field:accept- (optional) file types allowed (e.g., "image/*", "video/*", "audio/*" and others)disabled- (optional) disables uploadingmultiple- (optional) enables uploading multiple files at oncefolder- (optional) enables uploading folders
- Parameters for a "comments" type
config- (optional) configuration options for the "comments" field:format- (optional) date format for comments; see available options hereplacement- (optional) where comments appear:"editor"— inside the editor"page"— in a separate panel
html- (optional) allows HTML markup in commentsconfirmDeletion- (optional) shows a confirmation dialog before deleting comments
- Parameters for a "links" type
config- (optional) configuration options for the "links" field:confirmDeletion- (optional) shows a confirmation dialog before deleting links
If you don’t set editor options via the editorShape property, the widget will use the defaultEditorShape settings.
Default config
const defaultPriorities = [
{ id: 1, color: "#FE6158", label: "High" },
{ id: 2, color: "#F1B941", label: "Medium" },
{ id: 3, color: "#77D257", label: "Low" }
];
const defaultColors = ["#33B0B4", "#0096FA", "#F1B941"];
const defaultEditorShape = [
{
key: "label",
type: "text",
label: "Label"
},
{
key: "description",
type: "textarea",
label: "Description"
},
{
type: "combo",
label: "Priority",
key: "priority",
config: {
clear: true
}
},
{
type: "color",
label: "Color",
key: "color"
},
{
type: "progress",
key: "progress",
label: "Progress"
},
{
type: "date",
key: "start_date",
label: "Start date"
},
{
type: "date",
key: "end_date",
label: "End date"
},
{
type: "multiselect",
key: "users",
label: "Users"
}
];
Example
const users = [ // user data
{ id: 1, label: "John Smith", avatar: "../assets/user.jpg" },
{ id: 2, label: "Aaron Short" }
];
const editorShape = [ // editor settings
...kanban.defaultEditorShape, // include the default settings
{ // add custom fields
type: "multiselect",
key: "users",
label: "Users",
values: users
},
{
type: "comments",
key: "comments",
label: "Comments",
config: {
format: "%M %d",
placement: "page",
html: true,
confirmDeletion: true
}
},
{
type: "links",
key:"links",
label: "Links",
config: {
confirmDeletion: true
}
}
];
new kanban.Kanban("#root", {
cards,
columns,
editorShape,
// other parameters
});
Change log:
- The dateRange type was introduced in v1.3
- The comments and links editor types, along with the format parameter, were added in v1.4
- The clearButton parameter was renamed to clear
Related articles: Configuration