-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix(Textbox) Textbox inputs with new lines #9192
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f01de95
fix regression
asturur 0e195b5
update CHANGELOG.md
github-actions[bot] acf8d46
a test
asturur af8ee71
Merge branch 'fix-textbox-regression' of github.com:fabricjs/fabric.j…
asturur f95c613
cover both cases
asturur 6b75654
no changes to sandbox
asturur a0d13b1
more tolerance
asturur dd8278c
more tolerance
asturur 4803a19
suggestion
ShaMan123 95115c0
Update e2e/tests/text/adding-text/index.spec.ts
asturur 0dbc933
Revert "Update e2e/tests/text/adding-text/index.spec.ts"
asturur c416dbe
remove the unnecessary double type
asturur 5f7eef8
more removals
asturur 6e351f8
changelog
asturur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| import { CanvasUtil } from '../../../utils/CanvasUtil'; | ||
| import { expect, test } from '@playwright/test'; | ||
| import { ObjectUtil } from '../../../utils/ObjectUtil'; | ||
| import type { Textbox } from 'fabric'; | ||
| import '../../../setup'; | ||
|
|
||
| [false, true].forEach((splitByGrapheme) => { | ||
| test(`adding new lines and copy paste - splitByGrapheme: ${splitByGrapheme}`, async ({ | ||
| page, | ||
| context, | ||
| }) => { | ||
| await context.grantPermissions(['clipboard-read', 'clipboard-write']); | ||
| const canvasUtil = new CanvasUtil(page); | ||
| const textBoxutil = new ObjectUtil(page, 'text'); | ||
|
|
||
| await textBoxutil.executeInBrowser( | ||
| (textbox: Textbox, context) => { | ||
| textbox.splitByGrapheme = context.splitByGrapheme; | ||
| textbox.set('dirty', true); | ||
| textbox.initDimensions(); | ||
| textbox.canvas.renderAll(); | ||
| }, | ||
| { splitByGrapheme } | ||
| ); | ||
|
|
||
| await expect(await canvasUtil.screenshot()).toMatchSnapshot({ | ||
| name: `1-initial-splitByGrapheme-${splitByGrapheme}.png`, | ||
| }); | ||
| await canvasUtil.click({ | ||
| position: { | ||
| x: 50, | ||
| y: 65, | ||
| }, | ||
| delay: 200, | ||
| }); | ||
| await canvasUtil.click({ | ||
| position: { | ||
| x: 50, | ||
| y: 65, | ||
| }, | ||
| delay: 200, | ||
| }); | ||
| await page.mouse.down(); | ||
| await page.mouse.move(65, 120, { steps: 15 }); | ||
| await page.mouse.up(); | ||
| await canvasUtil.ctrlC(); | ||
| await canvasUtil.click({ | ||
| position: { | ||
| x: 176, | ||
| y: 65, | ||
| }, | ||
| delay: 200, | ||
| }); | ||
| await canvasUtil.press('Enter'); | ||
| await canvasUtil.press('Enter'); | ||
| await canvasUtil.press('a'); | ||
| await canvasUtil.press('b'); | ||
| await canvasUtil.press('c'); | ||
| await canvasUtil.press('Enter'); | ||
| await canvasUtil.press('Enter'); | ||
| await expect(await canvasUtil.screenshot()).toMatchSnapshot({ | ||
| name: `2-before-pasting-splitByGrapheme-${splitByGrapheme}.png`, | ||
| }); | ||
| await canvasUtil.ctrlV(); | ||
| await expect(await canvasUtil.screenshot()).toMatchSnapshot({ | ||
| name: `3-after-pasting-splitByGrapheme-${splitByGrapheme}.png`, | ||
| maxDiffPixelRatio: 0.03, | ||
| }); | ||
| // NOTE: Here is clear that there style bug of #9028 is visible splitbygrapheme true only | ||
| // to be triggered the copy paste has to happen across lines | ||
| await canvasUtil.click({ | ||
| position: { | ||
| x: 176, | ||
| y: 152, | ||
| }, | ||
| delay: 200, | ||
| }); | ||
| await canvasUtil.press('Enter'); | ||
| await canvasUtil.press('Enter'); | ||
| await expect(await canvasUtil.screenshot()).toMatchSnapshot({ | ||
| name: `4-after-adding-more-lines-splitByGrapheme-${splitByGrapheme}.png`, | ||
| maxDiffPixelRatio: 0.03, | ||
| }); | ||
| }); | ||
| }); | ||
Binary file added
BIN
+11.3 KB
...ts/text/adding-text/index.spec.ts-snapshots/1-initial-splitByGrapheme-false.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.5 KB
...sts/text/adding-text/index.spec.ts-snapshots/1-initial-splitByGrapheme-true.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.6 KB
.../adding-text/index.spec.ts-snapshots/2-before-pasting-splitByGrapheme-false.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.7 KB
...t/adding-text/index.spec.ts-snapshots/2-before-pasting-splitByGrapheme-true.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+20.1 KB
...t/adding-text/index.spec.ts-snapshots/3-after-pasting-splitByGrapheme-false.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.6 KB
...xt/adding-text/index.spec.ts-snapshots/3-after-pasting-splitByGrapheme-true.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+20.1 KB
...ext/index.spec.ts-snapshots/4-after-adding-more-lines-splitByGrapheme-false.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.6 KB
...text/index.spec.ts-snapshots/4-after-adding-more-lines-splitByGrapheme-true.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { Textbox, util } from 'fabric'; | ||
| import { beforeAll } from '../../test'; | ||
|
|
||
| beforeAll( | ||
| (canvas) => { | ||
| const textValue = 'fabric.js sandbox'; | ||
| const text = new Textbox(textValue, { | ||
| originX: 'center', | ||
| objectCaching: false, | ||
| splitByGrapheme: true, | ||
| width: 200, | ||
| top: 20, | ||
| styles: util.stylesFromArray( | ||
| [ | ||
| { | ||
| style: { | ||
| fontWeight: 'bold', | ||
| fontSize: 64, | ||
| }, | ||
| start: 0, | ||
| end: 9, | ||
| }, | ||
| ], | ||
| textValue | ||
| ), | ||
| }); | ||
| canvas.add(text); | ||
| canvas.centerObjectH(text); | ||
| return { text }; | ||
| }, | ||
| { width: 300, height: 700 } | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.