Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Custom properties and custom method add in Class #10391

Closed
4 tasks done
vijaygurjar opened this issue Jan 8, 2025 · 4 comments
Closed
4 tasks done

[Feature]: Custom properties and custom method add in Class #10391

vijaygurjar opened this issue Jan 8, 2025 · 4 comments

Comments

@vijaygurjar
Copy link

CheckList

  • I agree to follow this project's Code of Conduct
  • I have read and followed the Contributing Guide
  • I have searched and referenced existing issues, feature requests and discussions
  • I am filing a FEATURE request.

Description

New Method and properties add and override

Current State

Based on the documents properties and method will be add but when i am trying to add it gives an error.

Documents:

// declare the methods for typescript
declare module "fabric" {
// to have the properties recognized on the instance and in the constructor
interface Rect {
getText: () => string;
}
// to have the properties typed in the exported object
interface Text {
getText: () => string;
}
}

// then add the methods to the classes:
Rect.prototype.getText = function() { return 'none'; }
Text.prototype.getText = function() { return this.text; }

compile time error shown getText in available in Text and Rect class

please give me a solution if it is available in fabricjs
i am using Angular 17

Additional Context

No response

@vijaygurjar
Copy link
Author

now got the solution add custom properties and method but not able to find how to assign default values to that properties

@vijaygurjar
Copy link
Author

Also got the solution for set defaults

@asturur
Copy link
Member

asturur commented Jan 8, 2025

https://fabricjs.com/docs/using-custom-properties/

@vijaygurjar
Copy link
Author

Thanks @asturur got the solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants