部分控件变量取值默认不走 html 转义
This commit is contained in:
parent
c66f37f4a9
commit
1240887eb2
|
@ -96,7 +96,7 @@ export class DiffEditor extends React.Component<DiffEditorProps, any>{
|
|||
|
||||
if (this.originalEditor && diffValue && (diffValue !== prevProps.diffValue || data !== prevProps.data)) {
|
||||
this.originalEditor.getModel().setValue(/^\$(?:([a-z0-9_.]+)|{.+})$/.test(diffValue as string)
|
||||
? filter(normalizeValue(diffValue || ''), data) : normalizeValue(diffValue));
|
||||
? filter(normalizeValue(diffValue || ''), data, '| raw') : normalizeValue(diffValue));
|
||||
}
|
||||
|
||||
if (this.modifiedEditor && value && value !== prevProps.value && !this.state.focused) {
|
||||
|
@ -127,7 +127,7 @@ export class DiffEditor extends React.Component<DiffEditorProps, any>{
|
|||
|
||||
this.editor.setModel({
|
||||
original: this.monaco.editor.createModel(/^\$(?:([a-z0-9_.]+)|{.+})$/.test(diffValue as string)
|
||||
? filter(normalizeValue(diffValue || ''), data) : normalizeValue(diffValue), language),
|
||||
? filter(normalizeValue(diffValue || ''), data, '| raw') : normalizeValue(diffValue), language),
|
||||
modified: this.monaco.editor.createModel(normalizeValue(value), language)
|
||||
});
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ export class ImageField extends React.Component<ImageProps, object> {
|
|||
src,
|
||||
} = this.props;
|
||||
|
||||
const finnalSrc = src ? filter(src, data) : '';
|
||||
const finnalSrc = src ? filter(src, data, '| raw') : '';
|
||||
let value = this.props.value;
|
||||
|
||||
return (
|
||||
|
|
|
@ -39,7 +39,7 @@ export default class QRCode extends React.Component<QRCodeProps, any> {
|
|||
<div className={cx(`${ns}QrCode`, className)}>
|
||||
{value ? (
|
||||
<QrCode
|
||||
value={filter(value, data)}
|
||||
value={filter(value, data, '| raw')}
|
||||
size={codeSize}
|
||||
bgColor={backgroundColor}
|
||||
fgColor={foregroundColor}
|
||||
|
|
|
@ -402,7 +402,7 @@ export default class Video extends React.Component<VideoProps, VideoState> {
|
|||
let source = this.props.src || (name && data && (data as any)[name]) || (amisConfig && amisConfig.value);
|
||||
const videoState = this.state.videoState;
|
||||
let highlight = videoState.duration && minVideoDuration && videoState.duration < minVideoDuration;
|
||||
let src = filter(source, data);
|
||||
let src = filter(source, data, '| raw');
|
||||
let sourceNode;
|
||||
|
||||
if ((src && /\.flv(?:$|\?)/.test(src) && isLive) || videoType === 'video/x-flv') {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import Scoped, {ScopedContext, IScopedContext} from '../Scoped';
|
||||
import {Renderer, RendererProps} from '../factory';
|
||||
import {ServiceStore, IServiceStore} from '../store/service';
|
||||
|
@ -11,14 +10,6 @@ import {createObject, until, isVisible} from '../utils/helper';
|
|||
import {isApiOutdated, isEffectiveApi} from '../utils/api';
|
||||
import {IFormStore} from '../store/form';
|
||||
|
||||
export type TabProps = Schema & {
|
||||
title?: string; // 标题
|
||||
icon?: string;
|
||||
hash?: string; // 通过 hash 来控制当前选择
|
||||
tab: Schema;
|
||||
className: string;
|
||||
};
|
||||
|
||||
export interface WizardProps extends RendererProps {
|
||||
store: IServiceStore;
|
||||
readOnly?: boolean;
|
||||
|
|
|
@ -463,5 +463,5 @@ export function dataMapping(to: any, from: PlainObject): any {
|
|||
|
||||
reigsterTplEnginer("builtin", {
|
||||
test: str => !!~str.indexOf("$"),
|
||||
compile: (str: string, data: object) => tokenize(str, data)
|
||||
compile: (str: string, data: object, defaultFilter = '| html') => tokenize(str, data, defaultFilter)
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
export interface Enginer {
|
||||
test: (tpl:string) => boolean;
|
||||
compile: (tpl:string, data:object) => string;
|
||||
compile: (tpl:string, data:object, ...rest:Array<any>) => string;
|
||||
}
|
||||
|
||||
const enginers:{
|
||||
|
@ -11,7 +11,7 @@ export function reigsterTplEnginer(name:string, enginer:Enginer) {
|
|||
enginers[name] = enginer;
|
||||
}
|
||||
|
||||
export function filter(tpl: string, data: object = {}): string {
|
||||
export function filter(tpl: string, data: object = {}, ...rest:Array<any>): string {
|
||||
if (!tpl || typeof tpl !== 'string') {
|
||||
return '';
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ export function filter(tpl: string, data: object = {}): string {
|
|||
for (let i = 0, len = keys.length; i < len; i++) {
|
||||
let enginer = enginers[keys[i]];
|
||||
if (enginer.test(tpl)) {
|
||||
return enginer.compile(tpl, data);
|
||||
return enginer.compile(tpl, data, ...rest);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue