diff --git a/package.json b/package.json
index eaf12dd..6e9fd66 100644
--- a/package.json
+++ b/package.json
@@ -7,6 +7,7 @@
"@material-ui/core": "^3.9.2",
"@material-ui/icons": "^3.0.2",
"@svgr/webpack": "4.1.0",
+ "axios": "^0.19.0",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "9.0.0",
"babel-jest": "23.6.0",
diff --git a/src/App.js b/src/App.js
index 60af774..6e56572 100755
--- a/src/App.js
+++ b/src/App.js
@@ -92,7 +92,8 @@ const styles = theme => ({
width: contentWidth + "mm",
height: contentHeight + "mm",
background: "white",
- overflow: "auto"
+ overflow: "auto",
+ wordBreak: "break-all"
},
navbar: {
width: "100%",
diff --git a/src/components/Button/Picture.js b/src/components/Button/Picture.js
index d750c09..74735fe 100644
--- a/src/components/Button/Picture.js
+++ b/src/components/Button/Picture.js
@@ -4,30 +4,61 @@ import PropTypes from "prop-types";
import { withStyles } from "@material-ui/core/styles";
import Tooltip from "@material-ui/core/Tooltip";
import Button from "@material-ui/core/Button";
+import axios from "axios";
import picture from "../../icons/picture.svg";
-import { ENTER_DELAY, LEAVE_DELAY, DATA_MARKDOWN } from "../../utils/constant";
+import {
+ ENTER_DELAY,
+ LEAVE_DELAY,
+ DATA_MARKDOWN,
+ DATA_ORIGIN,
+ SM_MS_PROXY
+} from "../../utils/constant";
import { observer, inject } from "mobx-react";
@inject("navbar")
@inject("resume")
+@inject("hint")
@observer
class Picture extends Component {
/**
- * 更新markdown样式
+ * 上传图片
*/
- updateStyle = flag => event => {
- event.stopPropagation();
- const id = this.props.resume.choosenKey;
- const element = document.getElementById(id);
- let content = element.getAttribute(DATA_MARKDOWN);
- content = "- " + content;
+ uploadPicture = async ({ target }) => {
+ const file = document.getElementById("uploadImage");
+ const formData = new FormData();
+ formData.append("smfile", file.files[0]);
- // 更新markdown内容
- element.childNodes[0].innerText = content;
- element.setAttribute(DATA_MARKDOWN, content);
+ const result = await axios.post(SM_MS_PROXY, formData);
+ if (result.data.message === "Image upload repeated limit.") {
+ this.props.hint.setError({
+ isOpen: true,
+ message: "同一张图片无法上传多次"
+ });
+ } else {
+ const id = this.props.resume.choosenKey;
+ console.log(id);
+ const element = document.getElementById(id);
+
+ const { isMarkdownMode } = this.props.navbar;
+ let content;
+ if (isMarkdownMode) {
+ content = ``;
+ element.childNodes[0].innerText = content;
+ element.setAttribute(DATA_MARKDOWN, content);
+ } else {
+ content = `
\n`
+ element.childNodes[0].innerHTML = content;
+ element.setAttribute(DATA_ORIGIN, content);
+ }
+
+ }
+ };
+
+ stopPropagation = event => {
+ event.stopPropagation();
};
render() {
@@ -44,6 +75,7 @@ class Picture extends Component {
-