diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 0ad30524d0f..00000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -name: Bug report -about: Create a report with a reproducible test case in a JSFIDDLE, For anything else use the github DISCUSSIONS feature. Anything different than a bug report will be closed automatically. ---- - - - - - - - -## Version - -5.0.0 - - - - -## Test Case - -- [ ] [Browser Issue Template](https://jsfiddle.net/Lcp2h3nv/) -- [ ] [Node Issue Template](https://codesandbox.io/s/exciting-browser-ytb701) - -## Information about environment - -Nodejs or browser? -Which browsers? - -## Steps To Reproduce - -1. - -
Error Message & Stack Trace

- -```txt - -``` - -

- -## Expected Behavior - -## Actual Behavior - - diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 00000000000..8f96b113366 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,128 @@ +name: 🐛 Bug Report +description: File a bug report +title: '[Bug]: ' +body: + - type: markdown + attributes: + value: | + Thank you for wanting to create an issue in this repository. + Before you do, please ensure you are filing the issue in the right place. + + * If you have a question or if an issue is not right for what you mean to file use [Discussions](https://github.com/fabricjs/fabric.js/discussions). + + - type: checkboxes + id: terms + attributes: + label: CheckList + description: >- + By submitting this issue, you agree to follow our [Code of + Conduct](https://github.com/fabricjs/fabric.js/CODE_OF_CONDUCT.md) + options: + - label: I agree to follow this project's Code of Conduct + required: true + - label: >- + I have read and followed the [Contributing + Guide](https://github.com/fabricjs/fabric.js/CONTRIBUTING.md) + required: true + - label: >- + I have read and followed the [Issue Tracker + Guide](https://github.com/fabricjs/fabric.js/CONTRIBUTING.md#%EF%B8%8F-issue-tracker) + required: true + - label: I have searched and referenced existing issues and discussions + required: true + - label: >- + I am filing a **BUG** report. + required: true + - label: >- + I have managed to reproduce the bug **after** upgrading to the + **latest** version + required: true + - label: I have created an accurate and minimal reproduction + required: true + - type: dropdown + id: version + attributes: + label: version + description: >- + If you are working on a version below latest you should upgrade to + latest before filing a bug report, your issue might have been resolved + already. + options: + - 5.2.4 + validations: + required: true + - type: dropdown + id: environments + attributes: + label: In What environments are you experiencing the problem? + description: >- + checkout the [supported + browsers](/README.md#supported-browsersenvironments) + multiple: true + options: + - Firefox + - Chrome + - Safari + - Opera + - Microsoft Edge + - Node.js + - type: input + id: node_version + attributes: + label: Node Version (if applicable) + validations: + required: false + - type: input + id: reproduction_link + attributes: + label: Link To Reproduction + description: > + A good reproduction helps us UNDERSTAND your issue, find the bug and fix + it quickly. + + Take the time and put effort into making your reproduction accurate and + minimal. + + Use the following reproduction templates. + + + - [Browser reproduction template](https://jsfiddle.net/Lcp2h3nv/) + + - [Node reproduction + template](https://codesandbox.io/s/exciting-browser-ytb701) + + + ⛔ No reproduction === closed issue ⛔ + validations: + required: true + - type: textarea + id: steps + attributes: + label: Steps To Reproduce + value: | + 1. + 2. + 3. + validations: + required: true + - type: textarea + id: expected + attributes: + label: Expected Behavior + validations: + required: true + - type: textarea + id: actual + attributes: + label: Actual Behavior + description: Provide screenshots/screencasts if relevant + validations: + required: true + - type: textarea + id: error + attributes: + label: Error Message & Stack Trace + description: Provide logging outputs/errors if relevant + render: bash + validations: + required: false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000000..dffe48d76f2 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,53 @@ +--- +name: Pull Request +about: Creating a PR +--- + + + + + +## Motivation + + + + +## Description + + + +## Changes + + + +## Gist + + + +## In Action + + + diff --git a/GOTCHAS.md b/GOTCHAS.md new file mode 100644 index 00000000000..3a372aca9f0 --- /dev/null +++ b/GOTCHAS.md @@ -0,0 +1,45 @@ +- **Crazy DOM**\ +`new fabric.Canvas('foo')` wraps `` element with a `
` one, and adds another (absolutely positioned) canvas element on top of the existing canvas (the one with id="foo"). This only happens for dynamic canvases (`fabric.Canvas`), not static ones (`fabric.StaticCanvas`).\ +See [[How fabric canvas layering works]]. + +- **Crazier fabric**\ +Make sure you are not sharing an object (such as a `clipPath`) between render agents. In other words, keep the object tree simple and strict. + +- **Object is NOT selectable**: `setCoords()`\ +An object has a visual state and an coordinate state. Both can become stale.\ +When the visual state is stale it is visible making it simple to catch. This is a bit different.\ +When an object or its controls aren't interactive or don't match their visual position, it means the coordinate state is stale. This happens after changing a property that affects position. +Calling `object.setCoords()` should fix it. + +- **Visuals NOT updating**: [Object Caching](http://fabricjs.com/fabric-object-caching)\ +Consider marking the object as `dirty` before rendering. + +- **Wrong position after loading from JSON**: increase `NUM_FRACTION_DIGITS`\ +When dealing with serialization, floats can blows up the string size with unnecessary decimals. `NUM_FRACTION_DIGITS` controls the fraction digits in exporting methods (`toObject`, `toSVG`) + +- **Mouse/Touch position is off**: `canvas.calcOffset()`\ +This usually happens once the canvas' position in the `document` is changed **after** it had been initialized. + +- **0.5 pixel position offset**: `strokeWidth`\ +Most Objects have a transparent stroke of width 1 that shift them by 0.5 pixel horizontally and vertically. +Take this under consideration when positioning objects at an exact position. +This is to comply with SVG behavior. +You can always set `strokeWidth` to `0`. + +- **Blurry visuals**: retina scaling\ +Objects need a reference to `Canvas` for proper rendering. +Without the reference objects can't access the retina scaling value ([device pixel ratio](https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio#correcting_resolution_in_a_canvas)), resulting in bad resolution. +This usually happens when an object is a child of a custom object. Fix it by propagating `canvas` to the object in the parent's `_set` method **OR** better off, use `Group`, it is designed especially for building custom objects. + +- **Object position in Group**\ +An object in a group will relate to the group's center as (0, 0). +Read more about `Group` + +- **Vanishing Object**\ +It is likely you are misusing `Group` and the object tree because the vanished object thinks it is not within the canvas' visible viewport, indicating a severe **bug** in coordinate calculation. If you want to hack your way around it use `canvas.skipOffscreen` (recommended for triaging **ONLY**) with a significant performance hit. + +- **Text BBOX is off**\ +Make sure fonts have loaded before you create the `Text` object. Fabric needs the font to calculate the position and bounding box of the characters. Doing so prior to loading the font will lead to a bad calculation using a fallback font. + +- **Editing Textbox on Mobile**: `dblclick`\ + When trying to edit a textbox on mobile, users need to double-tap the same spot to enter edit mode - otherwise it just moves it around. diff --git a/scripts/updateBugReportVersion.mjs b/scripts/updateBugReportVersion.mjs new file mode 100644 index 00000000000..0de1244b7a6 --- /dev/null +++ b/scripts/updateBugReportVersion.mjs @@ -0,0 +1,15 @@ +import fs from 'fs'; +import cp from 'node:child_process'; +import { fileURLToPath } from 'node:url'; +import path from 'path'; +import YAML from 'js-yaml'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const file = path.resolve(__dirname, '..', '.github/ISSUE_TEMPLATE/bug_report.yml'); +const id = 'version'; +const packageName = 'fabric'; +const content = YAML.load(fs.readFileSync(file).toString()); +const found = content.body.find(entry => entry.id === id && entry.type === 'dropdown'); +const tags = JSON.parse(cp.execSync(`npm view ${packageName} versions --json`).toString()).reverse(); +found.attributes.options = tags; +fs.writeFileSync(file, YAML.dump(content)); diff --git a/src/LICENSE.md b/src/LICENSE.md new file mode 100644 index 00000000000..cf89a9a20e4 --- /dev/null +++ b/src/LICENSE.md @@ -0,0 +1,17 @@ + +Copyright (c) 2008-2015 Printio (Juriy Zaytsev, Maxim Chernyak) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file