-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
chore(TS): Text SVG export mixin #8486
Merged
Merged
Changes from 6 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
9246306
transform
ShaMan123 55f6a98
migrate
ShaMan123 b8e8305
Update itext.class.ts
ShaMan123 b5a4fa1
init
ShaMan123 3b7055a
fix imports
ShaMan123 cb7404f
rename file
ShaMan123 3bed0ab
Revert "rename file"
ShaMan123 e1f6c03
refactor/rename
ShaMan123 e3ed93d
extract type `SVGReviver`
ShaMan123 af55d8d
Update CHANGELOG.md
ShaMan123 ebbbffd
rename file
ShaMan123 dca534a
hadle in #8488
ShaMan123 d02b4a8
Update svgParsing.ts
ShaMan123 d42d517
Merge branch 'master' into ts-itext-svg
ShaMan123 f127fc9
imports fix
ShaMan123 d38c7af
Merge branch 'master' into ts-itext-svg
ShaMan123 c3dd07a
Merge branch 'master' into ts-itext-svg
ShaMan123 bba513d
saved conflicts
asturur 57e188e
saved conflicts
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 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 was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
|
@@ -5,11 +5,18 @@ import { uid } from '../util/internals/uid'; | |
import { matrixToSVG } from '../util/misc/svgParsing'; | ||
import { toFixed } from '../util/misc/toFixed'; | ||
|
||
type SVGReviver = (markup: string) => string; | ||
export type SVGReviver = (markup: string) => string; | ||
|
||
/* _TO_SVG_START_ */ | ||
|
||
function getSvgColorString(prop: string, value?: any) { | ||
/** | ||
* Adobe Illustrator (at least CS5) is unable to render rgba()-based fill values | ||
* we work around it by "moving" alpha channel into opacity attribute and setting fill's alpha to 1 | ||
* @param prop | ||
* @param value | ||
* @returns | ||
*/ | ||
export function getSvgColorString(prop: string, value?: any) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. now used by Text instead of |
||
if (!value) { | ||
return `${prop}: none; `; | ||
} else if (value.toLive) { | ||
|
@@ -170,25 +177,6 @@ export class FabricObjectSVGExportMixin { | |
return `${svgTransform}${additionalTransform}" `; | ||
} | ||
|
||
_setSVGBg(textBgRects: string[]) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. used by text, refactored into text svg export mixin |
||
if (this.backgroundColor) { | ||
const NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS; | ||
textBgRects.push( | ||
'\t\t<rect ', | ||
this._getFillAttributes(this.backgroundColor), | ||
' x="', | ||
toFixed(-this.width / 2, NUM_FRACTION_DIGITS), | ||
'" y="', | ||
toFixed(-this.height / 2, NUM_FRACTION_DIGITS), | ||
'" width="', | ||
toFixed(this.width, NUM_FRACTION_DIGITS), | ||
'" height="', | ||
toFixed(this.height, NUM_FRACTION_DIGITS), | ||
'"></rect>\n' | ||
); | ||
} | ||
} | ||
|
||
/** | ||
* Returns svg representation of an instance | ||
* @param {SVGReviver} [reviver] Method for further parsing of svg representation. | ||
|
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extracted to util and renamed to
colorPropToSVG