Skip to content

Commit b7a18ba

Browse files
committed
Adjustments after #1323 merge. Revert content as parameter to load font (To address #923).
1 parent 94fec7d commit b7a18ba

7 files changed

Lines changed: 19 additions & 19 deletions

File tree

assets/src/edit-story/app/font/actions/useLoadFontFiles.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ function useLoadFontFiles() {
5555
font: { family, service, variants },
5656
fontWeight,
5757
isItalic,
58+
content,
5859
}) => {
5960
if (!family || service !== 'fonts.google.com') {
6061
return null;
@@ -89,8 +90,8 @@ function useLoadFontFiles() {
8990

9091
const ensureFontLoaded = async () => {
9192
if (document?.fonts) {
92-
await document.fonts.load(fontFaceSet);
93-
return document.fonts.check(fontFaceSet);
93+
await document.fonts.load(fontFaceSet, content || '');
94+
return document.fonts.check(fontFaceSet, content || '');
9495
} else {
9596
return null;
9697
}

assets/src/edit-story/app/font/test/actions/useLoadFontFiles.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ const DEFAULT_FONT = {
3030
service: 'fonts.google.com',
3131
},
3232
fontWeight: 400,
33-
fontStyle: 'normal',
33+
isItalic: true,
34+
content: 'Fill in some text',
3435
};
3536

3637
describe('useLoadFontFiles', () => {

assets/src/edit-story/components/library/text/fontPreview.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,7 @@ const Text = styled.span`
5353
color: ${({ theme }) => theme.colors.fg.v1};
5454
`;
5555

56-
function FontPreview({
57-
title,
58-
font,
59-
fontSize,
60-
fontWeight,
61-
fontStyle,
62-
onClick,
63-
}) {
56+
function FontPreview({ title, font, fontSize, fontWeight, content, onClick }) {
6457
const {
6558
actions: { maybeEnqueueFontStyle },
6659
} = useFont();
@@ -70,10 +63,10 @@ function FontPreview({
7063
{
7164
font,
7265
fontWeight,
73-
fontStyle,
66+
content,
7467
},
7568
]);
76-
}, [font, fontWeight, fontStyle, maybeEnqueueFontStyle]);
69+
}, [font, fontWeight, content, maybeEnqueueFontStyle]);
7770

7871
return (
7972
<Preview onClick={onClick}>
@@ -93,7 +86,7 @@ FontPreview.propTypes = {
9386
font: FontPropType,
9487
fontSize: PropTypes.number,
9588
fontWeight: PropTypes.number,
96-
fontStyle: PropTypes.string,
89+
content: PropTypes.string,
9790
onClick: PropTypes.func,
9891
};
9992

assets/src/edit-story/components/panels/textStyle/font.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,11 @@ function FontControls({ selectedElements, pushUpdate }) {
9090
};
9191

9292
await maybeEnqueueFontStyle(
93-
selectedElements.map(() => ({
93+
selectedElements.map(({ content }) => ({
9494
font: newFont,
9595
isItalic,
9696
fontWeight,
97+
content,
9798
}))
9899
);
99100

@@ -118,10 +119,11 @@ function FontControls({ selectedElements, pushUpdate }) {
118119
value={fontWeight}
119120
onChange={async (value) => {
120121
await maybeEnqueueFontStyle(
121-
selectedElements.map(({ font }) => ({
122+
selectedElements.map(({ font, content }) => ({
122123
font,
123124
isItalic,
124125
fontWeight: parseInt(value),
126+
content,
125127
}))
126128
);
127129
handleSelectFontWeight(value);

assets/src/edit-story/components/panels/textStyle/textStyle.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,11 @@ function StylePanel({ selectedElements, pushUpdate }) {
143143
iconHeight={10}
144144
onChange={async (value) => {
145145
await maybeEnqueueFontStyle(
146-
selectedElements.map(({ font }) => ({
146+
selectedElements.map(({ font, content }) => ({
147147
font,
148148
isItalic: value,
149149
fontWeight,
150+
content,
150151
}))
151152
);
152153
handleClickItalic(value);

assets/src/edit-story/elements/text/display.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,10 @@ function TextDisplay({
125125
font,
126126
fontWeight,
127127
isItalic,
128+
content,
128129
},
129130
]);
130-
}, [font, fontWeight, isItalic, maybeEnqueueFontStyle]);
131+
}, [font, fontWeight, isItalic, content, maybeEnqueueFontStyle]);
131132

132133
useTransformHandler(id, (transform) => {
133134
const target = ref.current;

assets/src/edit-story/elements/text/edit.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,10 @@ function TextEdit({
214214
font,
215215
fontWeight,
216216
isItalic,
217+
content,
217218
},
218219
]);
219-
}, [font, fontWeight, isItalic, maybeEnqueueFontStyle]);
220+
}, [font, fontWeight, isItalic, content, maybeEnqueueFontStyle]);
220221

221222
return (
222223
<Wrapper ref={wrapperRef} onClick={onClick}>

0 commit comments

Comments
 (0)