Skip to content

Commit

Permalink
rename.
Browse files Browse the repository at this point in the history
  • Loading branch information
b4rtaz committed Oct 15, 2023
1 parent 1d214d2 commit ac4b4e4
Show file tree
Hide file tree
Showing 51 changed files with 117 additions and 40 deletions.
Binary file added .github/cover.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
![Mini Canvas Editor](.github/cover.png)

# Mini Canvas Editor

Canvas editor component for JavaScript application. Works with any front-end framework. Easy to integrate and use. Well-known graphical interface. Edit images, draw shapes, add texts and more. Gzipped size less than 60 KB. Uses Fabric.js internally.
[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fb4rtaz%2Fmini-canvas-editor%2Fbadge%3Fref%3Dmain&style=flat-square)](https://actions-badge.atrox.dev/b4rtaz/mini-canvas-editor/goto?ref=main) [![License: MIT](https://img.shields.io/badge/license-MIT-green?style=flat-square)](/LICENSE) [![View this project on NPM](https://img.shields.io/npm/v/mini-canvas-editor.svg?style=flat-square)](https://npmjs.org/package/mini-canvas-editor)

Canvas editor component for JavaScript application. Works with any front-end framework. Easy to integrate and use. Well-known graphical interface. Edit images, draw shapes, add texts and more. Gzipped size less than 100 KB. Uses Fabric.js internally.

Main use cases:

Expand All @@ -11,8 +15,29 @@ Main use cases:

Online Examples:

* [🎨 Inpainting Mask](demos/webpack-app/public/inpainting-mask.html)
* [🎬 Template Creator](demos/webpack-app/public/template-creator.html)
* [🎬 Template Creator](https://b4rtaz.github.io/mini-canvas-editor/webpack-app/public/template-creator.html)
* [🎨 Inpainting Mask](https://b4rtaz.github.io/mini-canvas-editor/webpack-app/public/inpainting-mask.html)

## 🚀 Installation

To use the editor you should add JS/TS files and CSS files to your project.

### CDN

Add the below code to your head section in HTML document.

```html
<head>
...
<link href="https://cdn.jsdelivr.net/npm/[email protected]/css/editor.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.umd.min.js"></script>
```

Call the designer by:

```js
miniCanvasEditor.Editor.createBlank(placeholder, 200, 300, {});
```

## 💡 License

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion canvas/package.json → core/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "mini-canvas",
"name": "mini-canvas-core",
"description": "Core library for Mini Canvas Editor.",
"version": "0.0.1",
"license": "MIT",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion demos/svelte-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dependencies": {
"mini-canvas-editor": "^0.0.1",
"mini-canvas": "^0.0.1",
"mini-canvas-core": "^0.0.1",
"fabric": "6.0.0-beta13",
"canvas": "^2.11.2"
},
Expand Down
2 changes: 1 addition & 1 deletion demos/svelte-app/src/routes/backend/+server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MceStaticCanvas, type MceImageJSON } from 'mini-canvas/node';
import { MceStaticCanvas, type MceImageJSON } from 'mini-canvas-core/node';

export async function POST({ request }: { request: Request }) {
const json = (await request.json()) as MceImageJSON;
Expand Down
2 changes: 1 addition & 1 deletion demos/webpack-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dependencies": {
"mini-canvas-editor": "^0.0.1",
"mini-canvas": "^0.0.1"
"mini-canvas-core": "^0.0.1"
},
"devDependencies": {
"ts-loader": "^9.4.2",
Expand Down
2 changes: 1 addition & 1 deletion demos/webpack-app/src/inpainting-mask.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Editor, EditorMode } from 'mini-canvas-editor';
import { MceImage } from 'mini-canvas';
import { MceImage } from 'mini-canvas-core';

import 'mini-canvas-editor/css/editor.css';

Expand Down
2 changes: 1 addition & 1 deletion demos/webpack-app/src/template-creator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Editor } from 'mini-canvas-editor';
import { MceRect, MceTextbox } from 'mini-canvas';
import { MceRect, MceTextbox } from 'mini-canvas-core';

import 'mini-canvas-editor/css/editor.css';

Expand Down
5 changes: 2 additions & 3 deletions editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"type": "module",
"main": "./lib/esm/index.js",
"types": "./lib/index.d.ts",
"private": true,
"exports": {
".": {
"types": {
Expand Down Expand Up @@ -51,10 +50,10 @@
"prettier:fix": "prettier --write ./src ./css"
},
"dependencies": {
"mini-canvas": "^0.0.1"
"mini-canvas-core": "^0.0.1"
},
"peerDependencies": {
"mini-canvas": "^0.0.1"
"mini-canvas-core": "^0.0.1"
},
"devDependencies": {
"tslib": "^2.6.2",
Expand Down
2 changes: 1 addition & 1 deletion editor/src/editor-state.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FabricObject, MceCanvas, Point } from 'mini-canvas';
import { FabricObject, MceCanvas, Point } from 'mini-canvas-core';
import { SimpleEvent } from './core/simple-event';
import { BrushModeConfiguration, EditorConfiguration, EditorMode, RectModeConfiguration } from './editor-configuration';

Expand Down
2 changes: 1 addition & 1 deletion editor/src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { EditorConfiguration } from './editor-configuration';
import { Toolbox } from './toolbox/toolbox';
import { SimpleEvent } from './core/simple-event';
import { EditorState } from './editor-state';
import { FabricObject, MceImage, MceImageJSON, MceStaticCanvas, Point } from 'mini-canvas';
import { FabricObject, MceImage, MceImageJSON, MceStaticCanvas, Point } from 'mini-canvas-core';
import { LayoutController } from './layout-controller';
import { Toolbar } from './toolbar/toolbar';

Expand Down
2 changes: 1 addition & 1 deletion editor/src/sidebar/layers/layer-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Component } from '../../components/component';
import { IconButtonComponent, iconButtonComponent } from '../../components/icon-button-component';
import { Html } from '../../core/html';
import { Icons } from '../../core/icons';
import { FabricObject } from 'mini-canvas';
import { FabricObject } from 'mini-canvas-core';

export class LayerItem implements Component {
public static create(state: EditorState, object: FabricObject, isFirst: boolean, isLast: boolean) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Html } from '../../../core/html';
import { DestroyableComponent } from '../../../components/component';
import { simplePropertyEditor } from './simple-property-editor';
import { TFiller } from 'mini-canvas';
import { TFiller } from 'mini-canvas-core';
import { PropertyAccessor } from '../property-accessor';

type FillType = string | TFiller | null;
Expand Down
2 changes: 1 addition & 1 deletion editor/src/sidebar/properties/object-properties-editor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FabricObject, ObjectEvents } from 'mini-canvas';
import { FabricObject, ObjectEvents } from 'mini-canvas-core';
import { DestroyableComponent } from '../../components/component';
import { Html } from '../../core/html';
import { EditorState } from '../../editor-state';
Expand Down
2 changes: 1 addition & 1 deletion editor/src/sidebar/properties/root-properties-editor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CanvasEvents, MceCanvas } from 'mini-canvas/.';
import { CanvasEvents, MceCanvas } from 'mini-canvas-core';
import { DestroyableComponent } from '../../components/component';
import { EditorState } from '../../editor-state';
import { numberPropertyEditor } from './editors/number-property-editor';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { UpdateManager } from '../update-manager';
import { DestroyableComponent } from '../../../components/component';
import { commonShapeEditor } from './common-shape-editor';
import { Circle } from 'mini-canvas';
import { Circle } from 'mini-canvas-core';

export function circleShapeEditor(manager: UpdateManager<Circle>): DestroyableComponent {
return commonShapeEditor(manager, []);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FabricObject } from 'mini-canvas/.';
import { FabricObject } from 'mini-canvas-core';
import { DestroyableComponent } from '../../../components/component';
import { numberPropertyEditor } from '../editors/number-property-editor';
import { propertyEditorRow } from '../layout/property-editor-row';
Expand Down
2 changes: 1 addition & 1 deletion editor/src/sidebar/properties/shapes/image-shape-editor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { UpdateManager } from '../update-manager';
import { DestroyableComponent } from '../../../components/component';
import { commonShapeEditor } from './common-shape-editor';
import { MceImage } from 'mini-canvas';
import { MceImage } from 'mini-canvas-core';
import { propertyEditorRow } from '../layout/property-editor-row';
import { numberPropertyEditor } from '../editors/number-property-editor';

Expand Down
2 changes: 1 addition & 1 deletion editor/src/sidebar/properties/shapes/rect-shape-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { numberPropertyEditor } from '../editors/number-property-editor';
import { DestroyableComponent } from '../../../components/component';
import { commonShapeEditor } from './common-shape-editor';
import { colorPropertyEditor } from '../editors/color-property-editor';
import { MceRect } from 'mini-canvas';
import { MceRect } from 'mini-canvas-core';

export function rectShapeEditor(manager: UpdateManager<MceRect>): DestroyableComponent {
const row1 = propertyEditorRow([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { rectShapeEditor } from './rect-shape-editor';
import { circleShapeEditor } from './circle-shape-editor';
import { imageShapeEditor } from './image-shape-editor';
import { unknownShapeEditor } from './unknown-shape-editor';
import { Circle, FabricObject, MceImage, MceRect, MceTextbox, ObjectEvents } from 'mini-canvas';
import { Circle, FabricObject, MceImage, MceRect, MceTextbox, ObjectEvents } from 'mini-canvas-core';

export class ShapeEditorFactory {
public static create(type: string, manager: UpdateManager<FabricObject, ObjectEvents>): DestroyableComponent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { propertyEditorRow } from '../layout/property-editor-row';
import { numberPropertyEditor } from '../editors/number-property-editor';
import { choicePropertyEditor } from '../editors/choice-property-editor';
import { colorPropertyEditor } from '../editors/color-property-editor';
import { MceTextbox, MceVerticalAlign } from 'mini-canvas';
import { MceTextbox, MceVerticalAlign } from 'mini-canvas-core';

export function textShapeEditor(manager: UpdateManager<MceTextbox>): DestroyableComponent {
const row1 = propertyEditorRow([
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { UpdateManager } from '../update-manager';
import { DestroyableComponent } from '../../../components/component';
import { commonShapeEditor } from './common-shape-editor';
import { FabricObject } from 'mini-canvas';
import { FabricObject } from 'mini-canvas-core';

export function unknownShapeEditor(manager: UpdateManager<FabricObject>): DestroyableComponent {
return commonShapeEditor(manager, []);
Expand Down
2 changes: 1 addition & 1 deletion editor/src/sidebar/properties/update-manager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EditorState } from '../../editor-state';
import { SimpleEvent } from '../../core/simple-event';
import { Observable } from 'mini-canvas';
import { Observable } from 'mini-canvas-core';
import { PropertyAccessor } from './property-accessor';

export class UpdateManager<Obj extends Observable<EventSpec>, EventSpec = unknown> {
Expand Down
2 changes: 1 addition & 1 deletion editor/src/toolbox/actions/open-image-action.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MceImage } from 'mini-canvas';
import { MceImage } from 'mini-canvas-core';
import { EditorState } from '../../editor-state';
import { openImageFile } from './open-image-file';

Expand Down
2 changes: 1 addition & 1 deletion editor/src/workspace/modes/box-painter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FabricObject, TPointerEvent, TPointerEventInfo } from 'mini-canvas';
import { FabricObject, TPointerEvent, TPointerEventInfo } from 'mini-canvas-core';
import { SimpleEvent } from '../../core/simple-event';
import { SelectionReverter, EditorState } from '../../editor-state';

Expand Down
2 changes: 1 addition & 1 deletion editor/src/workspace/modes/brush-workspace-mode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { McePath, Path, PencilBrush } from 'mini-canvas';
import { McePath, Path, PencilBrush } from 'mini-canvas-core';
import { EditorState } from '../../editor-state';
import { WorkspaceMode } from './workspace-mode';

Expand Down
2 changes: 1 addition & 1 deletion editor/src/workspace/modes/rect-workspace-mode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MceRect } from 'mini-canvas';
import { MceRect } from 'mini-canvas-core';
import { EditorState } from '../../editor-state';
import { BoxPainter } from './box-painter';
import { WorkspaceMode } from './workspace-mode';
Expand Down
2 changes: 1 addition & 1 deletion editor/src/workspace/modes/textbox-workspace-mode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MceTextbox, Rect } from 'mini-canvas';
import { MceTextbox, Rect } from 'mini-canvas-core';
import { EditorState } from '../../editor-state';
import { BoxPainter } from './box-painter';
import { WorkspaceMode } from './workspace-mode';
Expand Down
2 changes: 1 addition & 1 deletion editor/src/workspace/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { EditorConfiguration, EditorMode } from '../editor-configuration';
import { WorkspaceMode } from './modes/workspace-mode';
import { EditorState } from '../editor-state';
import { WorkspaceModeFactory } from './modes/workspace-mode-factory';
import { MceCanvas, Point, TPointerEventInfo } from 'mini-canvas';
import { MceCanvas, Point, TPointerEventInfo } from 'mini-canvas-core';

export class Workspace implements Component {
public static create(workspaceWidth: number, workspaceHeight: number, configuration: EditorConfiguration) {
Expand Down
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
packages:
- './canvas'
- './core'
- './editor'
- './demos/svelte-app'
- './demos/webpack-app'
11 changes: 11 additions & 0 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

cd "$(dirname "${BASH_SOURCE[0]}")"

cd ../cavas
pnpm build
npm publish

cd ../editor
pnpm build
npm publish
42 changes: 42 additions & 0 deletions scripts/set-version.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const fs = require('fs');
const path = require('path');

const version = process.argv[2];
if (!version || !(/^\d+\.\d+\.\d+$/.test(version))) {
console.log('Usage: node set-version.js 1.2.3');
return;
}

const dependencies = [
'sequential-workflow-editor-model',
'sequential-workflow-editor'
];

function updateDependencies(deps) {
if (!deps) {
return;
}
for (const name in deps) {
if (dependencies.includes(name)) {
deps[name] = `^${version}`;
}
}
}

function updatePackage(filePath, setVersion) {
filePath = path.join(__dirname, '..', filePath);
const json = JSON.parse(fs.readFileSync(filePath, 'utf-8'));

if (setVersion) {
json['version'] = version;
}
updateDependencies(json['dependencies']);
updateDependencies(json['peerDependencies']);
updateDependencies(json['devDependencies']);

fs.writeFileSync(filePath, JSON.stringify(json, null, '\t'), 'utf-8');
}

updatePackage('model/package.json', true);
updatePackage('editor/package.json', true);
updatePackage('demos/webpack-app/package.json', false);

0 comments on commit ac4b4e4

Please sign in to comment.