Як створити плагін

1. Створіть файл script-name.vue.

2. Додайте вміст до файлу як нижче:

<!--
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 - це основний об'єкт карти мислення

Основні події

ioctopus.$on('EVENT_NAME', callback);

Доступні події:

  • keydown
  • keypress
  • keyup
  • context-menu
  • branch-map-data (при зміні даних гілки)

Контекстне меню

// 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)
	});
});

Де можна отримати іконки?

З fontawesome.com.
Наприклад, копіюйте цей код з цієї сторінки.

Філії

Отримати гілку по id:

const branch = ioctopus.getBranchById(ID);

Отримати вибрані гілки:

const selectedBranches = ioctopus.getSelectedBranches();

Отримати текст вітки: Встановлення тексту вітки: Додати дочірню вітку:
branch.addChild({
	content: {
		text: "My new branch",
	}
});

Показати/приховати гілку "Завантаження..."

branch.loading();
branch.loadingStop();

Додати кнопку у гілку:

branch.addButton('buttonName', {
	icon: 'fa-equals fas',
	title: 'Title on hover',
	label: 'Button label',
	click: () => {
		console.log('Button pressed')
	},
})

Звідки можна отримати іконки?

З fontawesome.com.
Наприклад, скопіюйте цей код з цієї сторінки.

Видалити кнопку

branch.removeButton('buttonName')

Коли дані гілок змінено

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

Вибір

Кількість вибраних елементів:

ioctopus.selectedCount

Обрані елементи

let selectedElementsArray = ioctopus.getSelected();

Вибір елементів

Щоб надати користувачам можливість вибрати вітку, використовуйте наступне:

Запустіть режим вибору:

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

Зупиніть вибір:

ioctopus.stopPicking();

Меню

Як додати кнопку до меню:

// Menubar
ioctopus.addButtonToMenubar({
	to: 'tools',
	button: {
		label: 'Button label',
		icon: 'fas fa-calendar-alt', // Font Awesome
		click() {
			// ...
		},
	},
});

Діалоги

Відкрити діалог:

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

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

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

Закрити діалог

dialog.close();

Відключити короткі коди під час введення тексту

Після наведення фокусу на поле введення:

ioctopus.onFocus();

Після зняття фокусу з поля введення:

ioctopus.onBlur();

Приклад:

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

	// Vue Component
	component: {
		methods: {
			
			onFocus() {
				ioctopus.onFocus();
			},


			onBlur() {
				ioctopus.onBlur();
			},
		},
		template: `<input @focus="onFocus" @blur="onBlur">`,
	}

});

Зберегти файл

ioctopus.save();

Ви хочете більше функціональності?

Надішліть нам електронного листа на info@mind-map-online.ru.

Коментарі