Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/netlify-cms-locales/src/en/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,17 @@ const en = {
},
image: {
choose: 'Choose an image',
chooseUrl: 'Insert from URL',
replaceUrl: 'Replace with URL',
promptUrl: 'Enter the URL of the image',
chooseDifferent: 'Choose different image',
remove: 'Remove image',
},
file: {
choose: 'Choose a file',
chooseUrl: 'Insert from URL',
replaceUrl: 'Replace with URL',
promptUrl: 'Enter the URL of the file',
chooseDifferent: 'Choose different file',
remove: 'Remove file',
},
Expand Down
24 changes: 20 additions & 4 deletions packages/netlify-cms-widget-file/src/withFileControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ const FileLinkList = styled.ul`
const FileWidgetButton = styled.button`
${buttons.button};
${components.badge};
margin-bottom: 12px;
`;

const FileWidgetButtonRemove = styled.button`
${buttons.button};
${components.badgeDanger};
margin-top: 12px;
`;

function isMultiple(value) {
Expand Down Expand Up @@ -174,6 +174,14 @@ export default function withFileControl({ forImage } = {}) {
});
};

handleUrl = subject => e => {
e.preventDefault();

const url = window.prompt(this.props.t(`editor.editorWidgets.${subject}.promptUrl`));

return this.props.onChange(url);
};

handleRemove = e => {
e.preventDefault();
this.props.onClearMediaControl(this.controlID);
Expand Down Expand Up @@ -255,6 +263,9 @@ export default function withFileControl({ forImage } = {}) {
<FileWidgetButton onClick={this.handleChange}>
{t(`editor.editorWidgets.${subject}.chooseDifferent`)}
</FileWidgetButton>
<FileWidgetButton onClick={this.handleUrl(subject)}>
{t(`editor.editorWidgets.${subject}.replaceUrl`)}
</FileWidgetButton>
<FileWidgetButtonRemove onClick={this.handleRemove}>
{t(`editor.editorWidgets.${subject}.remove`)}
</FileWidgetButtonRemove>
Expand All @@ -266,9 +277,14 @@ export default function withFileControl({ forImage } = {}) {
renderNoSelection = subject => {
const { t } = this.props;
return (
<FileWidgetButton onClick={this.handleChange}>
{t(`editor.editorWidgets.${subject}.choose`)}
</FileWidgetButton>
<>
<FileWidgetButton onClick={this.handleChange}>
{t(`editor.editorWidgets.${subject}.choose`)}
</FileWidgetButton>
<FileWidgetButton onClick={this.handleUrl(subject)}>
{t(`editor.editorWidgets.${subject}.chooseUrl`)}
</FileWidgetButton>
</>
);
};

Expand Down