富文本修复,index问题修复
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import {_t} from '@web/core/l10n/translation';
|
||||
import {Component, onWillStart, onMounted, onPatched, onWillUnmount, useEffect} from '@odoo/owl';
|
||||
import {standardFieldProps} from '@web/views/fields/standard_field_props';
|
||||
import {registry} from '@web/core/registry';
|
||||
import {TranslationButton} from '@web/views/fields/translation_button';
|
||||
import {loadJS} from '@web/core/assets';
|
||||
import {cookie} from '@web/core/browser/cookie';
|
||||
import { _t } from '@web/core/l10n/translation';
|
||||
import { Component, onWillStart, onMounted, onPatched, onWillUnmount, useEffect } from '@odoo/owl';
|
||||
import { standardFieldProps } from '@web/views/fields/standard_field_props';
|
||||
import { registry } from '@web/core/registry';
|
||||
import { TranslationButton } from '@web/views/fields/translation_button';
|
||||
import { loadJS } from '@web/core/assets';
|
||||
import { cookie } from '@web/core/browser/cookie';
|
||||
|
||||
export class FieldTinyMCE extends Component {
|
||||
static template = 'web_editor_tinymce.TinyMCE';
|
||||
@@ -15,9 +15,9 @@ export class FieldTinyMCE extends Component {
|
||||
};
|
||||
static props = {
|
||||
...standardFieldProps,
|
||||
placeholder: {type: String, optional: true},
|
||||
dynamicPlaceholder: {type: Boolean, optional: true},
|
||||
dynamicPlaceholderModelReferenceField: {type: String, optional: true},
|
||||
placeholder: { type: String, optional: true },
|
||||
dynamicPlaceholder: { type: Boolean, optional: true },
|
||||
dynamicPlaceholderModelReferenceField: { type: String, optional: true },
|
||||
};
|
||||
static defaultProps = {
|
||||
dynamicPlaceholder: false,
|
||||
@@ -32,7 +32,7 @@ export class FieldTinyMCE extends Component {
|
||||
plugins: 'autoresize preview importcss searchreplace autolink directionality code visualblocks visualchars fullscreen image link media codesample table charmap pagebreak nonbreaking anchor insertdatetime advlist lists wordcount help charmap quickbars emoticons accordion',
|
||||
editimage_cors_hosts: ['picsum.photos'],
|
||||
image_advtab: true,
|
||||
language:"zh_CN",
|
||||
language: "zh_CN",
|
||||
importcss_append: true,
|
||||
height: 'auto',
|
||||
image_caption: true,
|
||||
@@ -50,9 +50,13 @@ export class FieldTinyMCE extends Component {
|
||||
});
|
||||
onMounted(async () => {
|
||||
await this.initEditor();
|
||||
this.updateReadonly();
|
||||
})
|
||||
useEffect(() => {
|
||||
this.updateEditor();
|
||||
if (this.editor) {
|
||||
this.updateReadonly();
|
||||
}
|
||||
})
|
||||
onWillUnmount(async () => {
|
||||
this.removeEditor()
|
||||
@@ -86,7 +90,7 @@ export class FieldTinyMCE extends Component {
|
||||
editor.on('change', e => {
|
||||
const value = tinymce.activeEditor.getContent();
|
||||
if (value !== this.value) {
|
||||
this.props.record.update({[this.props.name]: value})
|
||||
this.props.record.update({ [this.props.name]: value })
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -113,14 +117,22 @@ export class FieldTinyMCE extends Component {
|
||||
}
|
||||
this.editor.setContent(this.value);
|
||||
}
|
||||
|
||||
updateReadonly() {
|
||||
if (this.editor) {
|
||||
if (this.props.readonly) {
|
||||
this.editor.mode.set("readonly");
|
||||
} else {
|
||||
this.editor.mode.set("design");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const fieldTinyMCE = {
|
||||
component: FieldTinyMCE,
|
||||
displayName: _t('TinyMCE'),
|
||||
supportedTypes: ['html', 'text'],
|
||||
extractProps: ({attrs, options}) => ({
|
||||
extractProps: ({ attrs, options }) => ({
|
||||
placeholder: attrs.placeholder,
|
||||
dynamicPlaceholder: options?.dynamic_placeholder || false,
|
||||
dynamicPlaceholderModelReferenceField:
|
||||
|
||||
Reference in New Issue
Block a user