How to create a plugin

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.

Branches

Get branch by id:

const branch = ioctopus.getBranchById(ID);

Get selected branches:

const selectedBranches = ioctopus.getSelectedBranches();

Get text of a branch:

let branchText = branch.getText();

Set text to a branch:

branch.setText("<span>You can use html</span>");

Add a child branch:

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.

Delete branch button:

branch.removeButton('buttonName')

On branches data change

ioctopus.$on('branch-map-data', ({ $branch, mapData }) => {
	// ...
});

Selection

Count of selected elements:

ioctopus.selectedCount

Selected elements

let selectedElementsArray = ioctopus.getSelected();

Picking

To give your users possibility to pick a branch use next:

Start picking:

ioctopus.startPicking($branch => {
	ioctopus.stopPicking();
	console.log('$branch', $branch);
});

Stop picking:

ioctopus.stopPicking();

Dialogs

Open dialog:

ioctopus.openDialog({
	header: 'Header of dialog',

	// Vue Component
	component: {
		template: `<p>Content</p>`,
	}

}).then(dialog => {
	//...
});

Close dialog

dialog.close();

Disable shortcodes within input

After focus an input use:

ioctopus.onFocus();

After blur an input use:

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">`,
	}

});

Save file changes

ioctopus.save();

Lodash

ioctopus._

Do you want more functionality?

Email us at roman@ioctopus.online.