associateFileType IO
¶
associateFileType API is used to register filetype association with your plugin callback handler. This handler will be triggered every time this file type is loaded in INK editor. This will also allow users to select the associated file types in open file dialog.
Syntax¶
associateFileType(triggerCB: function, extension: String)
Example¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import INKAPI from './inkapi.js'
INKAPI.ready(async () => {
const IO = INKAPI.io;
const docxFileHandler = (data) => {
console.log(data);
}
//Associating docx filetype with this plugin handler
IO.associateFileType(docxFileHandler, "docx");
/*
Console Output when associated file is triggered:
[
{
path: "C:\Users\Me\sample.docx",
filename: : "sample.docx",
data: Uint8Array(11434) [ ... ]
}
]
*/
});
|
Parameters¶
Name |
Type |
Description |
---|---|---|
triggerCB |
|
Required. Callback to trigger when associated file type gets loaded in INK editor. |
extension |
|
Required. Extension to associate with. |