1. Create a file script-name.vue
.
2. Add content to the file like below:
<!--
PluginName: __SCRIPT_NAME__
PluginUrl: __URL_WHERE_OTHER_USERS_CAN_DOWNLOAD_THE_SCRIPT__
-->
<!-- Libraries (if need) -->
<script src="__URL_OF_LIBRARY_JS_FILE__"></script>
<!-- Main Script -->
<script>
// On Key Down
ioctopus.$on("keydown", e => {
// Alt + Shift + N
if (e.altKey && e.shiftKey && e.code === "KeyN") {
// Get Selected Branches
const selectedBranches = ioctopus.getSelectedBranches();
// Each branches
for (let branch of selectedBranches) {
// Change the branch content
let text = branch.getText();
// Change the text as you want
// (you can use html)...
text = `<span class="my-style">${text}</span>`;
branch.setText(text);
}
}
});
</script>
<!-- Styles -->
<style>
.my-style {
color: green;
}
</style>
ioctopus
- is the main object of the mind map
Main Events
ioctopus.$on('EVENT_NAME', callback);
Available events:
keydown
keypress
keyup
context-menu
branch-map-data
(on branch data change)
Context Menu
// On Context Menu
ioctopus.$on('context-menu', contextMenu => {
// Add to the Context Menu new Button
contextMenu.add({
label: "Button text", // Button Text
icon: "fas fa-list-ul", // Button Icon
keycode: "Alt+Shift+L", // Dysplayed prompt
click: () => { // Button action
// Code running on click
},
href: "https://...", // Button url (when no Button action)
target: "_blank", // Open Button url in new window (tab)
});
});
Where can I get icons?
From fontawesome.com.
For example, copy this code from this page.
Get branch by id:
const branch = ioctopus.getBranchById(ID);
Get selected branches:
const selectedBranches = ioctopus.getSelectedBranches();
branch.addChild({
content: {
text: "My new branch",
}
});
Show/hide branch "Loading..."
branch.loading();
branch.loadingStop();
Add button to branch:
branch.addButton('buttonName', {
icon: 'fa-equals fas',
title: 'Title on hover',
label: 'Button label',
click: () => {
console.log('Button pressed')
},
})
Where can I get icons?
From fontawesome.com.
For example, copy this code from this page.
branch.removeButton('buttonName')
ioctopus.$on('branch-map-data', ({ $branch, mapData }) => {
// ...
});
Selection
Count of selected elements:
ioctopus.selectedCount
Selected elements
let selectedElementsArray = ioctopus.getSelected();
Choose elements
To give your users possibility to pick a branch use next:
ioctopus.startPicking($branch => {
ioctopus.stopPicking();
console.log('$branch', $branch);
});
Stop picking:
ioctopus.stopPicking();
Menubar
How to add a button to the menubar:
// Menubar
ioctopus.addButtonToMenubar({
to: 'tools',
button: {
label: 'Button label',
icon: 'fas fa-calendar-alt', // Font Awesome
click() {
// ...
},
},
});
Dialogs
Open dialog:
ioctopus.openDialog({
header: 'Header of dialog',
// Vue Component
component: {
template: `<p>Content</p>`,
}
}).then(dialog => {
//...
});
Close dialog
dialog.close();
Disable Shortcodes on Text Input
After focus an input:
ioctopus.onFocus();
After blur an input:
ioctopus.onBlur();
Example:
ioctopus.openDialog({
header: 'Header of dialog',
// Vue Component
component: {
methods: {
onFocus() {
ioctopus.onFocus();
},
onBlur() {
ioctopus.onBlur();
},
},
template: `<input @focus="onFocus" @blur="onBlur">`,
}
});
ioctopus.save();
Do you want more functionality?
Email us at roman@ioctopus.online.