devexpress-reporting
Version:
DevExpress Reporting provides the capability to develop a reporting application to create and customize reports.
88 lines (87 loc) • 4.46 kB
JavaScript
/**
* DevExpress HTML/JS Reporting (designer\controls\xrRichTextSurface.js)
* Version: 25.1.3
* Build date: Jun 26, 2025
* Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED
* License: https://www.devexpress.com/Support/EULAs/universal.xml
*/
import { NotifyAboutWarning } from '@devexpress/analytics-core/analytics-internal';
import * as ko from 'knockout';
import { ReportRenderingService } from '../services/_reportRenderingService';
import { XRControlSurface } from './xrControl';
export class XRRichSurface extends XRControlSurface {
_sendCallback(propertyName = null) {
if (!this._innerUpdate()) {
if (this._primaryProperties.includes(this._lastRequestedProperty)) {
this._secondaryPropertiesChangedRequest = propertyName;
return;
}
this._lastRequestedProperty = propertyName;
const selfControl = this._control;
this.isLoading(true);
ReportRenderingService.getRichImage(this, propertyName)
.done((result) => {
this.isLoading(false);
if (propertyName === this._lastRequestedProperty) {
this._lastRequestedProperty = null;
selfControl.root && selfControl.root['_update'] && selfControl.root['_update'](true);
if (propertyName !== 'height' && propertyName !== 'width') {
this._innerUpdate(true);
if (propertyName !== 'textRtf') {
selfControl.textRtf(result.Text);
}
selfControl._rtf(result.Rtf);
selfControl.serializableRtfString(result.SerializableRtfString);
this._innerUpdate(false);
}
this.imageSrc('data:image/x;base64,' + result.Img);
selfControl.root && selfControl.root['_update'] && selfControl.root['_update'](false);
if (this._secondaryPropertiesChangedRequest) {
this._sendCallback(this._secondaryPropertiesChangedRequest);
this._secondaryPropertiesChangedRequest = null;
}
}
})
.fail((jqXHR) => {
this.isLoading(false);
this._lastRequestedProperty = null;
this._secondaryPropertiesChangedRequest = null;
NotifyAboutWarning('It is impossible to get richText');
});
}
}
constructor(control, context) {
super(control, context);
this._primaryProperties = ['textRtf', 'base64rtf', 'rtf'];
this._secondaryPropertiesChangedRequest = null;
this._lastRequestedProperty = null;
this._innerUpdate = ko.observable(false);
this.imageSrc = ko.observable('');
this.isLoading = ko.observable(false);
this.dragDropFileEnabled = ko.observable(true);
this.template = 'dxrd-shape';
this.contenttemplate = 'dxrd-server-rendered-control-content';
const handleNewData = (newVal) => {
if (newVal && newVal.content && newVal.contentType === 'base64') {
control.serializableRtfString(newVal.content);
}
else {
control.serializableRtfString(null);
}
};
this._disposables.push(control._newDocumentData.subscribe(handleNewData));
this._disposables.push(control.textRtf.subscribe((newVal) => { this._sendCallback('textRtf'); }));
this._disposables.push(control._rtf.subscribe(() => { this._sendCallback('rtf'); }));
this._disposables.push(control.font.subscribe(() => { this._sendCallback('font'); }));
this._disposables.push(control.foreColor.subscribe(() => { this._sendCallback('foreColor'); }));
this._disposables.push(this['position']['width'].subscribe((newValue) => { this._sendCallback('width'); }));
this._disposables.push(this['position']['height'].subscribe((newValue) => { this._sendCallback('height'); }));
this._disposables.push(control.serializableRtfString.subscribe((newVal) => { this._sendCallback(newVal ? 'base64rtf' : undefined); }));
if (control._newDocumentData()) {
handleNewData(control._newDocumentData());
}
else {
this._sendCallback();
}
}
}