Merge pull request #6 from edoardocarmignani/issue5
Patch prototype instead of instance
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
[tool.bumpversion]
|
||||
current_version = "1.0.1"
|
||||
current_version = "1.0.2"
|
||||
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
||||
serialize = ["{major}.{minor}.{patch}"]
|
||||
search = "{current_version}"
|
||||
|
||||
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
---
|
||||
|
||||
## [1.0.2] - 2025-09-26
|
||||
|
||||
### Fixed
|
||||
|
||||
- Change patched method from `app.canvas.linkRenderer.pathRenderer.drawLinkPath` to `app.canvas.linkRenderer.pathRenderer.constructor.prototype.drawLinkPath` in order to patch each instance instead of just the first one. ([#5](https://github.com/edoardocarmignani/extralinks/issues/5))
|
||||
- Store original prototype method to restore them when needed.
|
||||
|
||||
---
|
||||
|
||||
## [1.0.1] - 2025-09-23
|
||||
|
||||
### Fixed
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
|
||||
__author__ = 'Edoardo Carmignani'
|
||||
__email__ = 'edoardo.carmignani@gmail.com'
|
||||
__version__ = '1.0.1'
|
||||
__version__ = '1.0.2'
|
||||
|
||||
WEB_DIRECTORY = './web'
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "extralinks"
|
||||
version = "1.0.1"
|
||||
version = "1.0.2"
|
||||
description = "More connection links."
|
||||
authors = [
|
||||
{name = "Edoardo Carmignani", email = "edoardo.carmignani@gmail.com"}
|
||||
|
||||
@@ -95,14 +95,15 @@ export class ExtraLinks {
|
||||
patchDrawLinkPath() {
|
||||
|
||||
const pathRenderer = app.canvas.linkRenderer.pathRenderer;
|
||||
const pathRendererConstructor = pathRenderer.constructor;
|
||||
const _originalDrawLinkPath = pathRenderer.drawLinkPath;
|
||||
const _originalCalculateCenterPoint = pathRenderer.calculateCenterPoint;
|
||||
|
||||
pathRenderer.drawLinkPath = function drawLinkPath(ctx, path, link2, context, lineWidth, color2) {
|
||||
pathRendererConstructor.prototype.drawLinkPath = function drawLinkPath(ctx, path, link2, context, lineWidth, color2) {
|
||||
|
||||
if (!app.extensionManager.setting.get("Extra Links.General.Enable")) {
|
||||
pathRenderer.drawLinkPath = _originalDrawLinkPath;
|
||||
pathRenderer.calculateCenterPoint = _originalCalculateCenterPoint;
|
||||
pathRendererConstructor.prototype.drawLinkPath = _originalDrawLinkPath;
|
||||
pathRendererConstructor.prototype.calculateCenterPoint = _originalCalculateCenterPoint;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -141,7 +142,7 @@ export class ExtraLinks {
|
||||
|
||||
ctx.stroke(path);
|
||||
|
||||
pathRenderer.calculateCenterPoint = (...args) => {
|
||||
pathRendererConstructor.prototype.calculateCenterPoint = (...args) => {
|
||||
return link2.centerPos = {x: pos[0], y: pos[1]}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ app.registerExtension({
|
||||
},
|
||||
{
|
||||
id: "Extra Links.ExtraLinks",
|
||||
name: "Version 1.0.1",
|
||||
name: "Version 1.0.2",
|
||||
type: () => {
|
||||
const container = document.createElement("span");
|
||||
const btn = document.createElement("button");
|
||||
|
||||
Reference in New Issue
Block a user