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

fix(Tinymce): Read only status upload button can also be used #718

Merged
merged 1 commit into from
Jun 7, 2021
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 src/components/Tinymce/src/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@done="handleDone"
v-if="showImageUpload"
v-show="editorRef"
:disabled="disabled"
/>
<textarea :id="tinymceId" ref="elRef" :style="{ visibility: 'hidden' }"></textarea>
</div>
Expand Down Expand Up @@ -170,6 +171,12 @@
};
});

const disabled = computed(() => {
const { options } = props;
const getdDisabled = options && Reflect.get(options, 'readonly');
return getdDisabled ?? false;
});

watch(
() => attrs.disabled,
() => {
Expand Down Expand Up @@ -301,6 +308,7 @@
handleDone,
editorRef,
fullscreen,
disabled,
};
},
});
Expand Down
18 changes: 15 additions & 3 deletions src/components/Tinymce/src/ImgUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
:showUploadList="false"
accept=".jpg,.jpeg,.gif,.png,.webp"
>
<a-button type="primary">
<a-button type="primary" v-bind="{ ...getButtonProps }">
{{ t('component.upload.imgUpload') }}
</a-button>
</Upload>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { defineComponent, computed } from 'vue';

import { Upload } from 'ant-design-vue';
import { useDesign } from '/@/hooks/web/useDesign';
Expand All @@ -29,15 +29,26 @@
fullscreen: {
type: Boolean,
},
disabled: {
type: Boolean,
default: false,
},
},
emits: ['uploading', 'done', 'error'],
setup(_, { emit }) {
setup(props, { emit }) {
let uploading = false;

const { uploadUrl } = useGlobSetting();
const { t } = useI18n();
const { prefixCls } = useDesign('tinymce-img-upload');

const getButtonProps = computed(() => {
const { disabled } = props;
return {
disabled,
};
});

function handleChange(info: Recordable) {
const file = info.file;
const status = file?.status;
Expand All @@ -63,6 +74,7 @@
handleChange,
uploadUrl,
t,
getButtonProps,
};
},
});
Expand Down