Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 现在粘贴base64格式的图片的时候会先把base64的图片先上传到指定服务器后在执行粘贴指令。 #91

Merged
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
8 changes: 8 additions & 0 deletions packages/cw/cw_text_power_library/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## 1.1.6

Associated Task: [#278603](https://projectmanage.netease-official.lcap.163yun.com/dashboard/TaskDetail?id=2786032954278656)

### ✨Features

- [60094da](https://github.com/vusion/cloud-ui-materials/commit/60094dad3f3ad4538558d691aa9331ef4a636b63) Thanks [ncqwer](https://github.com/ncqwer) ! - 现在粘贴base64格式的图片的时候会先把base64的图片先上传到指定服务器后在执行粘贴指令。

Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,77 @@

```vue
<template>
<div>
{{ value }}
<cw-wang-editor :value.sync="value"></cw-wang-editor>
</div>
<div>
{{ value }}
<cw-wang-editor :value.sync="value" ref="editor"></cw-wang-editor>
<u-button
@click="handleClick"
:style="{
backgroundImage: `url(${base64})`,
backgroundSize: 'cover',
}">
hhh
</u-button>
</div>
</template>
<script>
export default {
data() {
return {
readOnly: true,
value: "",
};
},
mounted() {
setTimeout(() => {
this.value = "123";
}, 2000);
},
methods: {
handleReadOnly() {
this.readOnly = !this.readOnly;
data() {
return {
readOnly: true,
value: '',
base64: undefined,
};
},
mounted() {
setTimeout(() => {
this.value = '123';
}, 2000);
},
methods: {
handleReadOnly() {
this.readOnly = !this.readOnly;
},
async handleClick() {
const [fileHandle] = await window.showOpenFilePicker();
const file = await fileHandle.getFile();
const dataURL = await new Promise((res) => {
const reader = new FileReader();
reader.onload = (e) => res(e.target.result);
reader.readAsDataURL(file);
});
this.base64 = dataURL;
navigator.clipboard.write([
new ClipboardItem({
'text/html': new Blob(
[
`<img src="${dataURL}"></img><div style="background-image: url(${dataURL}); background-size:cover">hhh</div>`,
],
{
type: 'text/html',
}
),
'text/plain': new Blob([dataURL], {
type: 'text/plain',
}),
}),
]);
},
async handleClick1() {
const src = this.$refs.editor.getMockData();
navigator.clipboard.write([
new ClipboardItem({
'text/html': new Blob([src], {
type: 'text/html',
}),
'text/plain': new Blob([src], {
type: 'text/plain',
}),
}),
]);
this.$refs.editor.exportToDocx();
},
},
},
};
</script>
```
Expand All @@ -33,9 +81,8 @@ export default {

```html
<cw-wang-editor
value="<p>hello</p><img src='https://p3-passport.byteimg.com/img/user-avatar/834687b5e4137f4d998a95be7330f543~180x180.awebp'"
uploadImgServer="/upload/test"
></cw-wang-editor>
value="<p>hello</p><img src='https://p3-passport.byteimg.com/img/user-avatar/834687b5e4137f4d998a95be7330f543~180x180.awebp'"
uploadImgServer="/upload/test"></cw-wang-editor>
```

### 只读模式
Expand All @@ -44,27 +91,26 @@ export default {

```vue
<template>
<div>
<cw-wang-editor
:readOnly="readOnly"
value="<p>hello</p><img src='https://p3-passport.byteimg.com/img/user-avatar/834687b5e4137f4d998a95be7330f543~180x180.awebp'>"
></cw-wang-editor>
<u-button @click="handleReadOnly">切换</u-button>
</div>
<div>
<cw-wang-editor
:readOnly="readOnly"
value="<p>hello</p><img src='https://p3-passport.byteimg.com/img/user-avatar/834687b5e4137f4d998a95be7330f543~180x180.awebp'>"></cw-wang-editor>
<u-button @click="handleReadOnly">切换</u-button>
</div>
</template>

<script>
export default {
data() {
return {
readOnly: true,
};
},
methods: {
handleReadOnly() {
this.readOnly = !this.readOnly;
data() {
return {
readOnly: true,
};
},
methods: {
handleReadOnly() {
this.readOnly = !this.readOnly;
},
},
},
};
</script>
```
Expand All @@ -73,42 +119,40 @@ export default {

```vue
<template>
<u-form ref="form" gap="large">
<u-form-item
:required="true"
layout="block"
rules="required"
label="业务口径"
>
<cw-wang-editor
:value.sync="value"
:editorStyle="editorStyle"
></cw-wang-editor>
</u-form-item>
<u-form-item layout="block">
<u-button @click="onClick">验证</u-button>
</u-form-item>
</u-form>
<u-form ref="form" gap="large">
<u-form-item
:required="true"
layout="block"
rules="required"
label="业务口径">
<cw-wang-editor
:value.sync="value"
:editorStyle="editorStyle"></cw-wang-editor>
</u-form-item>
<u-form-item layout="block">
<u-button @click="onClick">验证</u-button>
</u-form-item>
</u-form>
</template>

<script>
export default {
data() {
return {
value: "",
editorStyle: "height: 300px",
};
},
mounted() {
setTimeout(() => {
this.value = "我有内容了";
}, 1000);
},
methods: {
async onClick() {
const valid = await this.$refs.form.validate();
data() {
return {
value: '',
editorStyle: 'height: 300px',
};
},
mounted() {
setTimeout(() => {
this.value = '我有内容了';
}, 1000);
},
methods: {
async onClick() {
const valid = await this.$refs.form.validate();
},
},
},
};
</script>
```
Loading
Loading