Skip to content

Commit f405206

Browse files
committed
0.3.1.
1 parent 40a9a84 commit f405206

File tree

9 files changed

+28
-20
lines changed

9 files changed

+28
-20
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.1
2+
3+
Added a new fill mode to the replaceRectToImage method in the MceCanvasReplacer class (credit: [@seven7seven](https://github.com/seven7seven)).
4+
15
## 0.3.0
26

37
This version changed the license to MIT.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ Add the below code to your head section in HTML document.
5555
```html
5656
<head>
5757
...
58-
<link href="https://cdn.jsdelivr.net/npm/mini-canvas-editor@0.3.0/css/editor.css" rel="stylesheet">
59-
<script src="https://cdn.jsdelivr.net/npm/mini-canvas-core@0.3.0/dist/index.umd.js"></script>
60-
<script src="https://cdn.jsdelivr.net/npm/mini-canvas-editor@0.3.0/dist/index.umd.js"></script>
58+
<link href="https://cdn.jsdelivr.net/npm/mini-canvas-editor@0.3.1/css/editor.css" rel="stylesheet">
59+
<script src="https://cdn.jsdelivr.net/npm/mini-canvas-core@0.3.1/dist/index.umd.js"></script>
60+
<script src="https://cdn.jsdelivr.net/npm/mini-canvas-editor@0.3.1/dist/index.umd.js"></script>
6161
```
6262

6363
Create the editor by:

core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mini-canvas-core",
33
"description": "Core library for Mini Canvas Editor.",
4-
"version": "0.3.0",
4+
"version": "0.3.1",
55
"license": "SEE LICENSE IN LICENSE",
66
"type": "module",
77
"main": "./lib/cjs/index.browser.cjs",

core/src/replacer/fill-image.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ export function fillImage(rect: MceRect, sourceImage: HTMLImageElement): MceImag
44
const scale = Math.min(rect.width / sourceImage.width, rect.height / sourceImage.height);
55
const cropWidth = rect.width / scale;
66
const cropHeight = rect.height / scale;
7-
7+
88
// Center the crop area
99
const cropY = Math.max(0, (sourceImage.height - cropHeight) / 2);
1010
const cropX = Math.max(0, (sourceImage.width - cropWidth) / 2);
11-
11+
1212
// Center the image in the rect
1313
const left = rect.left + (rect.width - sourceImage.width * scale) / 2;
1414
const top = rect.top + (rect.height - sourceImage.height * scale) / 2;

core/src/replacer/mce-canvas-replacer.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ export class MceCanvasReplacer {
3737
* @param mode Mode of fitting image to the rectangle.
3838
* @returns Promise that resolves when the rect is replaced.
3939
*/
40-
public async replaceRectToImage(layer: MceLayer, sourceImage: HTMLImageElement | string, mode: 'stretch' | 'fit' | 'fill'): Promise<void> {
40+
public async replaceRectToImage(
41+
layer: MceLayer,
42+
sourceImage: HTMLImageElement | string,
43+
mode: 'stretch' | 'fit' | 'fill'
44+
): Promise<void> {
4145
const rect = this.objects[layer.realIndex] as MceRect;
4246
if (!rect.visible) {
4347
// If the layer is hidden, do nothing.

demos/svelte-app/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"prettier:fix": "prettier --write ./src"
1515
},
1616
"dependencies": {
17-
"mini-canvas-editor": "workspace:*",
18-
"mini-canvas-core": "workspace:*",
17+
"mini-canvas-editor": "^0.3.1",
18+
"mini-canvas-core": "^0.3.1",
1919
"fabric": "6.0.0-beta13",
2020
"canvas": "^2.11.2"
2121
},
@@ -30,4 +30,4 @@
3030
"prettier": "^3.0.3"
3131
},
3232
"type": "module"
33-
}
33+
}

demos/webpack-app/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"prettier:fix": "prettier --write ./src ./public/**/*.html ./public/**/*.css"
1515
},
1616
"dependencies": {
17-
"mini-canvas-editor": "workspace:*",
18-
"mini-canvas-core": "workspace:*"
17+
"mini-canvas-editor": "^0.3.1",
18+
"mini-canvas-core": "^0.3.1"
1919
},
2020
"devDependencies": {
2121
"ts-loader": "^9.4.2",
@@ -29,4 +29,4 @@
2929
"@typescript-eslint/parser": "^6.7.5",
3030
"eslint": "^8.51.0"
3131
}
32-
}
32+
}

demos/webpack-app/public/vanilla-javascript.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ <h1>📦 Vanilla JavaScript Example</h1>
4141
const isLocalhost = ['localhost', '127.0.0.1'].includes(location.hostname);
4242
const cssUrl = isLocalhost
4343
? '../../../editor/css/editor.css'
44-
: 'https://cdn.jsdelivr.net/npm/mini-canvas-editor@0.3.0/css/editor.css';
44+
: 'https://cdn.jsdelivr.net/npm/mini-canvas-editor@0.3.1/css/editor.css';
4545
const coreUrl = isLocalhost
4646
? '../../../core/dist/index.umd.js'
47-
: 'https://cdn.jsdelivr.net/npm/mini-canvas-core@0.3.0/dist/index.umd.js';
47+
: 'https://cdn.jsdelivr.net/npm/mini-canvas-core@0.3.1/dist/index.umd.js';
4848
const editorUrl = isLocalhost
4949
? '../../../editor/dist/index.umd.js'
50-
: 'https://cdn.jsdelivr.net/npm/mini-canvas-editor@0.3.0/dist/index.umd.js';
50+
: 'https://cdn.jsdelivr.net/npm/mini-canvas-editor@0.3.1/dist/index.umd.js';
5151

5252
document.write('<link href="' + cssUrl + '" rel="stylesheet" \/>');
5353
document.write('<script src="' + coreUrl + '"><\/script>');

editor/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mini-canvas-editor",
33
"description": "Canvas editor component for JavaScript application. Easy to integrate and use.",
4-
"version": "0.3.0",
4+
"version": "0.3.1",
55
"type": "module",
66
"main": "./lib/esm/index.js",
77
"types": "./lib/index.d.ts",
@@ -50,10 +50,10 @@
5050
"prettier:fix": "prettier --write ./src ./css"
5151
},
5252
"dependencies": {
53-
"mini-canvas-core": "workspace:*"
53+
"mini-canvas-core": "^0.3.1"
5454
},
5555
"peerDependencies": {
56-
"mini-canvas-core": "^0.3.0"
56+
"mini-canvas-core": "^0.3.1"
5757
},
5858
"devDependencies": {
5959
"tslib": "^2.6.2",
@@ -88,4 +88,4 @@
8888
"image resize",
8989
"inpainting"
9090
]
91-
}
91+
}

0 commit comments

Comments
 (0)