diff --git a/README.md b/README.md index 3ecd909..8b889c7 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,10 @@ PointlineJS is an SVG based JS library for drawing tree diagrams. It relies on Treant-JS, Raphael for handling SVG and animations, JQuery. +# Build status + +[![Node.js Package](https://github.com/egor-progger/pointlinejs/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/egor-progger/pointlinejs/actions/workflows/npm-publish.yml) + # Quick start 1. clone repository with command: diff --git a/package-lock.json b/package-lock.json index 22a9371..8648424 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pointlinejs", - "version": "1.0.5", + "version": "1.0.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "pointlinejs", - "version": "1.0.5", + "version": "1.0.6", "license": "MIT", "dependencies": { "@material/dialog": "^14.0.0", diff --git a/package.json b/package.json index 2efc321..fcd9455 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pointlinejs", - "version": "1.0.5", + "version": "1.0.6", "description": "JavaScipt library for visualization of tree diagrams", "directories": { "example": "examples" diff --git a/src/pointlinejs/components/button-callback.ts b/src/pointlinejs/components/button-callback.ts index 3c35e84..96c3bed 100644 --- a/src/pointlinejs/components/button-callback.ts +++ b/src/pointlinejs/components/button-callback.ts @@ -1,25 +1,28 @@ import { PointlineJS } from "@pointlinejs/pointlinejs"; export enum BUTTON_TYPE { - ADD_BUTTON = 'ADD_BUTTON' + ADD_BUTTON = 'ADD_BUTTON', + EXPORT_TO_JSON_BUTTON = 'EXPORT_TO_JSON_BUTTON', } export const BUTTON_CALLBACK = { ADD_BUTTON: addBtnClickEvent, + EXPORT_TO_JSON_BUTTON: exportToJSONBtnClickEvent } function addBtnClickEvent(pointlineJS: PointlineJS, selectedEl: HTMLElement) { - console.log('addBtnClickEvent'); const tree = pointlineJS.getTree(); const nodeDb = tree.getNodeDb().db; - console.log(tree); for (var key in nodeDb) { var nodeTree = nodeDb[key]; if (nodeTree.text.name == selectedEl.textContent) { const selectedNodeTree = nodeTree; - tree.addNode(selectedNodeTree, { text: { name: 'test' } }) - // $('#modalWin').dialog("open"); + tree.addNode(selectedNodeTree, { text: { name: 'test' } }); break; } } +} + +function exportToJSONBtnClickEvent(pointlineJS: PointlineJS) { + return JSON.stringify(pointlineJS.exportTreeToJSON()); } \ No newline at end of file diff --git a/src/pointlinejs/components/add-node-dialog.ts b/src/pointlinejs/components/dialog-template.ts similarity index 83% rename from src/pointlinejs/components/add-node-dialog.ts rename to src/pointlinejs/components/dialog-template.ts index 9ff3811..1f6a01b 100644 --- a/src/pointlinejs/components/add-node-dialog.ts +++ b/src/pointlinejs/components/dialog-template.ts @@ -1,4 +1,4 @@ -export const AddNodeDialogTemplate = `