Skip to content

Commit 41a728a

Browse files
committed
Merge branch 'release-2.15.9' into release
2 parents e1ab16d + 38349c1 commit 41a728a

20 files changed

+16495
-22907
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// resolveUtils.unit.test.jsx
2+
3+
import resolvePathsForElementsWithAttribute from '../../../../../server/utils/resolveUtils';
4+
import { resolvePathToFile } from '../../../../../server/utils/filePath';
5+
6+
// Mock the dependencies
7+
jest.mock('../../../../../server/utils/filePath', () => ({
8+
resolvePathToFile: jest.fn()
9+
}));
10+
11+
jest.mock('../../../../../server/utils/fileUtils', () => ({
12+
MEDIA_FILE_REGEX: /\.(png|jpg|jpeg|gif|svg)$/i
13+
}));
14+
15+
describe('resolvePathsForElementsWithAttribute', () => {
16+
let mockSketchDoc;
17+
let mockFiles;
18+
19+
beforeEach(() => {
20+
jest.clearAllMocks();
21+
22+
// Create a mock DOM environment
23+
mockSketchDoc = document.implementation.createHTMLDocument();
24+
mockFiles = {
25+
'image.png': { url: 'https://example.com/image.png' },
26+
'missing.jpg': { url: null }
27+
};
28+
29+
resolvePathToFile.mockImplementation((fileName, files) => files[fileName]);
30+
});
31+
32+
it('should update the attribute when the file is resolved successfully', () => {
33+
const element = mockSketchDoc.createElement('img');
34+
element.setAttribute('src', 'image.png');
35+
mockSketchDoc.body.appendChild(element);
36+
37+
resolvePathsForElementsWithAttribute('src', mockSketchDoc, mockFiles);
38+
39+
expect(element.getAttribute('src')).toBe('https://example.com/image.png');
40+
});
41+
42+
it('should not update the attribute when the file resolution fails', () => {
43+
const element = mockSketchDoc.createElement('img');
44+
element.setAttribute('src', 'missing.jpg');
45+
mockSketchDoc.body.appendChild(element);
46+
47+
resolvePathsForElementsWithAttribute('src', mockSketchDoc, mockFiles);
48+
49+
expect(element.getAttribute('src')).toBe('missing.jpg');
50+
});
51+
52+
it('should not update the attribute when the value does not match MEDIA_FILE_REGEX', () => {
53+
const element = mockSketchDoc.createElement('img');
54+
element.setAttribute('src', 'document.pdf');
55+
mockSketchDoc.body.appendChild(element);
56+
57+
resolvePathsForElementsWithAttribute('src', mockSketchDoc, mockFiles);
58+
59+
expect(element.getAttribute('src')).toBe('document.pdf');
60+
});
61+
62+
it('should do nothing when no elements with the specified attribute are found', () => {
63+
resolvePathsForElementsWithAttribute('src', mockSketchDoc, mockFiles);
64+
65+
expect(mockSketchDoc.querySelectorAll('[src]').length).toBe(0);
66+
});
67+
});

client/modules/Preview/EmbedFrame.jsx

+1-14
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import decomment from 'decomment';
88
import { resolvePathToFile } from '../../../server/utils/filePath';
99
import getConfig from '../../utils/getConfig';
1010
import {
11-
MEDIA_FILE_REGEX,
1211
MEDIA_FILE_QUOTED_REGEX,
1312
STRING_REGEX,
1413
PLAINTEXT_FILE_REGEX,
@@ -18,6 +17,7 @@ import {
1817
import { getAllScriptOffsets } from '../../utils/consoleUtils';
1918
import { registerFrame } from '../../utils/dispatcher';
2019
import { createBlobUrl } from './filesReducer';
20+
import resolvePathsForElementsWithAttribute from '../../../server/utils/resolveUtils';
2121

2222
let objectUrls = {};
2323
let objectPaths = {};
@@ -34,19 +34,6 @@ const Frame = styled.iframe`
3434
`}
3535
`;
3636

37-
function resolvePathsForElementsWithAttribute(attr, sketchDoc, files) {
38-
const elements = sketchDoc.querySelectorAll(`[${attr}]`);
39-
const elementsArray = Array.prototype.slice.call(elements);
40-
elementsArray.forEach((element) => {
41-
if (element.getAttribute(attr).match(MEDIA_FILE_REGEX)) {
42-
const resolvedFile = resolvePathToFile(element.getAttribute(attr), files);
43-
if (resolvedFile && resolvedFile.url) {
44-
element.setAttribute(attr, resolvedFile.url);
45-
}
46-
}
47-
});
48-
}
49-
5037
function resolveCSSLinksInString(content, files) {
5138
let newContent = content;
5239
let cssFileStrings = content.match(STRING_REGEX);

client/modules/User/components/LoginForm.jsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ function LoginForm() {
101101
)}
102102
</Field>
103103
{submitError && !modifiedSinceLastSubmit && (
104-
<span className="form-error">{submitError}</span>
104+
<span className="form-error">
105+
{t('LoginForm.Errors.invalidCredentials')}
106+
</span>
105107
)}
106108
<Button type="submit" disabled={submitting}>
107109
{t('LoginForm.Submit')}

client/modules/User/components/SignupForm.jsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,14 @@ function SignupForm() {
7070
setShowConfirmPassword(!showConfirmPassword);
7171

7272
function onSubmit(formProps) {
73-
console.log("it's happening");
7473
return dispatch(validateAndSignUpUser(formProps));
7574
}
7675

7776
return (
7877
<Form
7978
fields={['username', 'email', 'password', 'confirmPassword']}
8079
validate={validateSignup}
81-
onSubmit={(values) => {
82-
console.log('Form onSubmit triggered', values);
83-
return onSubmit(values);
84-
}}
80+
onSubmit={onSubmit}
8581
>
8682
{({ handleSubmit, pristine, submitting, invalid, form }) => {
8783
formRef.current = form;

client/styles/components/_console.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
@extend %link;
9090
color: getThemifyVariable('secondary-text-color');
9191
&:hover {
92-
color: getThemifyVariable('heavy-text-color');
92+
color: getThemifyVariable('logo-color');
9393
}
9494
}
9595
background: transparent;

client/styles/components/_p5-contrast-codemirror-theme.scss

+6-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ $p5-contrast-pink: #FFA9D9;
2525

2626
$p5-contrast-gutter: #454545;
2727
$p5-contrast-number: #FDFDFD;
28-
$p5-contrast-selected: rgba(45, 123, 182, 25);
28+
$p5-contrast-selected: $middle-dark;
2929
$p5-contrast-activeline: #999999;
3030

3131
.cm-s-p5-contrast {
@@ -81,8 +81,11 @@ $p5-contrast-activeline: #999999;
8181
color: $p5-contrast-number;
8282
}
8383

84-
.cm-s-p5-contrast div .CodeMirror-selected {
85-
background-color: $p5-contrast-selected;
84+
.cm-s-p5-contrast {
85+
.CodeMirror-selected { background: $p5-contrast-selected; }
86+
.CodeMirror-focused .CodeMirror-selected { background: $p5-contrast-selected; }
87+
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: $p5-contrast-selected; }
88+
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: $p5-contrast-selected; }
8689
}
8790

8891
.cm-s-p5-contrast .CodeMirror-activeline-background {

client/styles/components/_p5-dark-codemirror-theme.scss

+6-8
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ $p5-dark-goldbrown: #b58318;
2626

2727
$p5-dark-gutter: #f4f4f4;
2828
$p5-dark-number: #b5b5b5;
29-
$p5-dark-selected: rgba(45, 123, 182, 25);
29+
$p5-dark-selected: $medium-dark;
3030
$p5-dark-activeline: rgb(207, 207, 207);
3131

3232
$p5-dark-error: #df3a3d;
@@ -84,8 +84,11 @@ $p5-dark-error: #df3a3d;
8484
color: $p5-dark-number;
8585
}
8686

87-
.cm-s-p5-dark div.CodeMirror-selected {
88-
background-color: $p5-dark-selected;
87+
.cm-s-p5-dark {
88+
.CodeMirror-selected { background: $p5-dark-selected; }
89+
.CodeMirror-focused .CodeMirror-selected { background: $p5-dark-selected; }
90+
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: $p5-dark-selected; }
91+
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: $p5-dark-selected; }
8992
}
9093

9194
.cm-s-p5-dark .CodeMirror-activeline-background {
@@ -146,8 +149,3 @@ $p5-dark-error: #df3a3d;
146149
.cm-s-p5-dark .cm-searching {
147150
background-color: $p5js-pink-opacity;
148151
}
149-
150-
.cm-s-p5-dark .CodeMirror-selectedtext {
151-
background-color: $medium-dark;
152-
}
153-

client/styles/components/_p5-light-codemirror-theme.scss

+6-7
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ $p5-light-green: #47820A;
2323

2424
$p5-light-gutter: #f4f4f4;
2525
$p5-light-number: #b5b5b5;
26-
$p5-light-selected: rgba(45, 123, 182, 25);
26+
$p5-light-selected: $medium-light;
2727
$p5-light-activeline: rgb(207, 207, 207);
2828

2929
.cm-s-p5-light {
@@ -79,8 +79,11 @@ $p5-light-activeline: rgb(207, 207, 207);
7979
color: $p5-light-number;
8080
}
8181

82-
.cm-s-p5-light div .CodeMirror-selected {
83-
background-color: $p5-light-selected;
82+
.cm-s-p5-light {
83+
.CodeMirror-selected { background: $p5-light-selected; }
84+
.CodeMirror-focused .CodeMirror-selected { background: $p5-light-selected; }
85+
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: $p5-light-selected; }
86+
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: $p5-light-selected; }
8487
}
8588

8689
.cm-s-p5-light .CodeMirror-activeline-background {
@@ -139,7 +142,3 @@ $p5-light-activeline: rgb(207, 207, 207);
139142
.cm-s-p5-light .cm-searching {
140143
background-color: $p5js-pink-opacity;
141144
}
142-
143-
.cm-s-p5-light .CodeMirror-selectedtext {
144-
background-color: $medium-light;
145-
}

0 commit comments

Comments
 (0)