Skip to content

Commit 21426d4

Browse files
committed
ui: added copy paste TB links
1 parent 196de38 commit 21426d4

13 files changed

Lines changed: 313 additions & 163 deletions

File tree

frontend/src/languages/english.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,12 @@ const en = {
708708
select: "Select a picture from the gallery or upload a custom picture"
709709
},
710710

711+
clipboard: {
712+
copy: "Copy link",
713+
copied: "Link copied",
714+
paste: "Paste link"
715+
},
716+
711717
language: {
712718
english: "English",
713719
french: "French",

frontend/src/languages/french.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,12 @@ const fr = {
718718
select: "Sélectionner ou télécharger une image personnalisée"
719719
},
720720

721+
clipboard: {
722+
copy: "Copy link",
723+
copied: "Link copied",
724+
paste: "Paste link"
725+
},
726+
721727
language: {
722728
english: "Anglais",
723729
french: "Français",

frontend/src/languages/georgian.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,12 @@ const ka = {
710710
select: "აირჩიეთ სურათი გალერეიდან ან ატვირთეთ მორგებული სურათი."
711711
},
712712

713+
clipboard: {
714+
copy: "Copy link",
715+
copied: "Link copied",
716+
paste: "Paste link"
717+
},
718+
713719
language: {
714720
english: "ინგლისური",
715721
french: "ფრანგული",

frontend/src/languages/german.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,12 @@ const de = {
710710
select: "Wählen Sie ein Bild aus oder laden Sie ein eigenes hoch"
711711
},
712712

713+
clipboard: {
714+
copy: "Copy link",
715+
copied: "Link copied",
716+
paste: "Paste link"
717+
},
718+
713719
language: {
714720
english: "Englisch",
715721
french: "Französisch",

frontend/src/languages/portuguese.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,12 @@ const pt = {
712712
select: "Selecione ou faça o upload de uma imagem personalizada"
713713
},
714714

715+
clipboard: {
716+
copy: "Copy link",
717+
copied: "Link copied",
718+
paste: "Paste link"
719+
},
720+
715721
language: {
716722
english: "English",
717723
french: "Français",

frontend/src/pages/Common/Markdown.js

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,60 @@ import React from "react";
22
import {
33
BoldItalicUnderlineToggles,
44
CreateLink,
5+
headingsPlugin,
56
linkDialogPlugin,
67
linkPlugin,
78
listsPlugin,
89
ListsToggle,
910
MDXEditor,
11+
quotePlugin,
1012
toolbarPlugin,
1113
UndoRedo
1214
} from "@mdxeditor/editor";
1315

16+
import strings from "../../localizeStrings";
17+
1418
import "@mdxeditor/editor/style.css";
1519

16-
const Markdown = ({ text, onChangeFunc }) => {
20+
const Markdown = ({ text, onChangeFunc, readOnly, paste, clipboard }) => {
21+
const ref = React.useRef(null);
1722
return (
18-
<MDXEditor
19-
markdown={text || ""}
20-
onChange={onChangeFunc}
21-
plugins={[
22-
toolbarPlugin({
23-
toolbarContents: () => (
24-
<>
25-
{" "}
26-
<UndoRedo />
27-
<BoldItalicUnderlineToggles />
28-
<ListsToggle />
29-
<CreateLink />
30-
</>
31-
)
32-
}),
33-
linkDialogPlugin(),
34-
listsPlugin(),
35-
linkPlugin()
36-
]}
37-
/>
23+
<>
24+
{clipboard ? (
25+
<button
26+
onClick={() => {
27+
ref.current?.focus(() => ref.current?.insertMarkdown(clipboard));
28+
paste();
29+
}}
30+
>
31+
{strings.clipboard.paste}
32+
</button>
33+
) : null}
34+
<MDXEditor
35+
ref={ref}
36+
markdown={text || ""}
37+
onChange={onChangeFunc}
38+
readOnly={readOnly}
39+
plugins={[
40+
headingsPlugin(),
41+
listsPlugin(),
42+
linkDialogPlugin(),
43+
linkPlugin(),
44+
quotePlugin(),
45+
toolbarPlugin({
46+
toolbarContents: () => (
47+
<>
48+
{" "}
49+
<UndoRedo />
50+
<BoldItalicUnderlineToggles />
51+
<ListsToggle />
52+
<CreateLink />
53+
</>
54+
)
55+
})
56+
]}
57+
/>
58+
</>
3859
);
3960
};
4061

frontend/src/pages/Navbar/actions.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ export const SAVE_EMAIL_ADDRESS_SUCCESS = "SAVE_EMAIL_ADDRESS_SUCCESS";
3636
export const SAVE_EMAIL_ADDRESS_FAILED = "SAVE_EMAIL_ADDRESS_FAILED";
3737
export const SET_VALID_EMAIL_ADDRESS_INPUT = "SET_VALID_EMAIL_ADDRESS_INPUT";
3838

39+
export const CLIPBOARD_COPY = "CLIPBOARD_COPY";
40+
export const CLIPBOARD_PASTE = "CLIPBOARD_PASTE";
41+
3942
export function toggleSidebar() {
4043
return {
4144
type: TOGGLE_SIDEBAR
@@ -144,3 +147,16 @@ export function setValidEmailAddressInput(valid) {
144147
valid
145148
};
146149
}
150+
151+
export function clipboardCopy(text) {
152+
return {
153+
type: CLIPBOARD_COPY,
154+
text
155+
};
156+
}
157+
158+
export function clipboardPaste() {
159+
return {
160+
type: CLIPBOARD_PASTE
161+
};
162+
}

frontend/src/pages/Navbar/reducer.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
import { FETCH_ALL_SUBPROJECT_DETAILS_SUCCESS } from "../Workflows/actions";
1111

1212
import {
13+
CLIPBOARD_COPY,
14+
CLIPBOARD_PASTE,
1315
DISABLE_USER_PROFILE_EDIT,
1416
ENABLE_USER_PROFILE_EDIT,
1517
FETCH_ACTIVE_PEERS_SUCCESS,
@@ -40,7 +42,8 @@ const defaultState = fromJS({
4042
userProfileOpen: false,
4143
userProfileEdit: false,
4244
tempEmailAddress: "",
43-
isEmailAddressInputValid: true
45+
isEmailAddressInputValid: true,
46+
clipboard: null
4447
});
4548

4649
export default function navbarReducer(state = defaultState, action) {
@@ -100,6 +103,12 @@ export default function navbarReducer(state = defaultState, action) {
100103
searchTerm: defaultState.get("searchTerm"),
101104
searchBarDisplayed: defaultState.get("searchBarDisplayed")
102105
});
106+
case CLIPBOARD_COPY: {
107+
return state.set("clipboard", action.text || "");
108+
}
109+
case CLIPBOARD_PASTE: {
110+
return state.set("clipboard", null);
111+
}
103112
default:
104113
return state;
105114
}

frontend/src/pages/Overview/ProjectDialogContainer.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { connect } from "react-redux";
33

44
import { toJS } from "../../helper";
55
import withInitialLoading from "../Loading/withInitialLoading";
6+
import { clipboardPaste } from "../Navbar/actions";
67
import { storeSnackbarMessage } from "../Notifications/actions";
78

89
import {
@@ -38,7 +39,8 @@ const mapStateToProps = (state) => {
3839
currentStep: state.getIn(["overview", "currentStep"]),
3940
projectToAdd: state.getIn(["overview", "projectToAdd"]),
4041
dialogTitle: state.getIn(["overview", "dialogTitle"]),
41-
allowedIntents: state.getIn(["login", "allowedIntents"])
42+
allowedIntents: state.getIn(["login", "allowedIntents"]),
43+
clipboard: state.getIn(["navbar", "clipboard"])
4244
};
4345
};
4446

@@ -61,7 +63,8 @@ const mapDispatchToProps = (dispatch) => {
6163
addProjectTag: (tag) => dispatch(addProjectTag(tag)),
6264
removeProjectTag: (tag) => dispatch(removeProjectTag(tag)),
6365
addCustomImage: (imageBase64) => dispatch(addCustomImage(imageBase64)),
64-
removeCustomImage: (imageBase64) => dispatch(removeCustomImage(imageBase64))
66+
removeCustomImage: (imageBase64) => dispatch(removeCustomImage(imageBase64)),
67+
pasteClipboard: () => dispatch(clipboardPaste())
6568
};
6669
};
6770

frontend/src/pages/Overview/ProjectDialogContent.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ const ProjectDialogContent = (props) => {
5555
<Divider />
5656
<div>
5757
<Typography variant="subtitle2">{strings.project.markdown}</Typography>
58-
<Markdown onChangeFunc={props.storeProjectMarkdown} text={props.projectToAdd.markdown} />
58+
<Markdown
59+
onChangeFunc={props.storeProjectMarkdown}
60+
text={props.projectToAdd.markdown}
61+
clipboard={props.clipboard}
62+
paste={props.pasteClipboard}
63+
readOnly={false}
64+
/>
5965
</div>
6066
</div>
6167
);

0 commit comments

Comments
 (0)