Fix - URL bases replacement didn't work for HBS tag language.
This commit is contained in:
parent
23e683192f
commit
bb237b3da4
16 changed files with 63 additions and 43 deletions
|
@ -721,7 +721,7 @@ export default class CUD extends Component {
|
||||||
|
|
||||||
templateEdit = <div>
|
templateEdit = <div>
|
||||||
<Dropdown id="data_sourceCustom_type" label={t('type')} options={this.customTemplateTypeOptions}/>
|
<Dropdown id="data_sourceCustom_type" label={t('type')} options={this.customTemplateTypeOptions}/>
|
||||||
<Dropdown id="data_sourceCustom_tag_language" label={t('Tag language')} options={this.customTemplateTagLanguageOptions} disabled={isEdit && (!customTemplateTypeKey || this.templateTypes[customTemplateTypeKey].isTagLanguageSelectorDisabledForEdit)}/>
|
<Dropdown id="data_sourceCustom_tag_language" label={t('Tag language')} options={this.customTemplateTagLanguageOptions} disabled={isEdit}/>
|
||||||
|
|
||||||
{customTemplateTypeForm}
|
{customTemplateTypeForm}
|
||||||
</div>;
|
</div>;
|
||||||
|
|
|
@ -277,7 +277,7 @@ export default class CustomContent extends Component {
|
||||||
{customTemplateTypeKey && this.templateTypes[customTemplateTypeKey].typeName}
|
{customTemplateTypeKey && this.templateTypes[customTemplateTypeKey].typeName}
|
||||||
</StaticField>
|
</StaticField>
|
||||||
|
|
||||||
<Dropdown id="data_sourceCustom_tag_language" label={t('Tag language')} options={this.customTemplateTagLanguageOptions} disabled={!customTemplateTypeKey || this.templateTypes[customTemplateTypeKey].isTagLanguageSelectorDisabledForEdit}/>
|
<Dropdown id="data_sourceCustom_tag_language" label={t('Tag language')} options={this.customTemplateTagLanguageOptions} disabled={true}/>
|
||||||
|
|
||||||
{customTemplateTypeKey && getTypeForm(this, customTemplateTypeKey, true)}
|
{customTemplateTypeKey && getTypeForm(this, customTemplateTypeKey, true)}
|
||||||
|
|
||||||
|
|
9
client/src/lib/sandbox-common.js
Normal file
9
client/src/lib/sandbox-common.js
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
export function getTagLanguageFromEntity(entity, entityTypeId) {
|
||||||
|
if (entityTypeId === 'template') {
|
||||||
|
return entity.tag_language;
|
||||||
|
} else if (entityTypeId === 'campaign') {
|
||||||
|
return entity.data.sourceCustom.tag_language;
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,7 +27,7 @@ class CKEditorSandbox extends Component {
|
||||||
const trustedUrlBase = getTrustedUrl();
|
const trustedUrlBase = getTrustedUrl();
|
||||||
const sandboxUrlBase = getSandboxUrl();
|
const sandboxUrlBase = getSandboxUrl();
|
||||||
const publicUrlBase = getPublicUrl();
|
const publicUrlBase = getPublicUrl();
|
||||||
const source = this.props.initialSource && base(this.props.initialSource, trustedUrlBase, sandboxUrlBase, publicUrlBase);
|
const source = this.props.initialSource && base(this.props.initialSource, this.props.tagLanguage, trustedUrlBase, sandboxUrlBase, publicUrlBase);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
source
|
source
|
||||||
|
@ -37,6 +37,7 @@ class CKEditorSandbox extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
entityTypeId: PropTypes.string,
|
entityTypeId: PropTypes.string,
|
||||||
entityId: PropTypes.number,
|
entityId: PropTypes.number,
|
||||||
|
tagLanguage: PropTypes.string,
|
||||||
initialSource: PropTypes.string
|
initialSource: PropTypes.string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +49,7 @@ class CKEditorSandbox extends Component {
|
||||||
const preHtml = '<!doctype html><html><head><meta charset="utf-8"><title></title></head><body>';
|
const preHtml = '<!doctype html><html><head><meta charset="utf-8"><title></title></head><body>';
|
||||||
const postHtml = '</body></html>';
|
const postHtml = '</body></html>';
|
||||||
|
|
||||||
const unbasedSource = unbase(this.state.source, trustedUrlBase, sandboxUrlBase, publicUrlBase, true);
|
const unbasedSource = unbase(this.state.source, this.props.tagLanguage, trustedUrlBase, sandboxUrlBase, publicUrlBase, true);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
source: unbasedSource,
|
source: unbasedSource,
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {getTrustedUrl} from "./urls";
|
||||||
|
|
||||||
import {initialHeight} from "./sandboxed-ckeditor-shared";
|
import {initialHeight} from "./sandboxed-ckeditor-shared";
|
||||||
import {withComponentMixins} from "./decorator-helpers";
|
import {withComponentMixins} from "./decorator-helpers";
|
||||||
|
import {getTagLanguageFromEntity} from "./sandbox-common";
|
||||||
|
|
||||||
const navbarHeight = 34; // Sync this with navbarheight in sandboxed-ckeditor.scss
|
const navbarHeight = 34; // Sync this with navbarheight in sandboxed-ckeditor.scss
|
||||||
|
|
||||||
|
@ -83,6 +84,7 @@ export class CKEditorHost extends Component {
|
||||||
const editorData = {
|
const editorData = {
|
||||||
entityTypeId: this.props.entityTypeId,
|
entityTypeId: this.props.entityTypeId,
|
||||||
entityId: this.props.entity.id,
|
entityId: this.props.entity.id,
|
||||||
|
tagLanguage: getTagLanguageFromEntity(this.props.entity, this.props.entityTypeId),
|
||||||
initialSource: this.props.initialSource
|
initialSource: this.props.initialSource
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ class CodeEditorSandbox extends Component {
|
||||||
const trustedUrlBase = getTrustedUrl();
|
const trustedUrlBase = getTrustedUrl();
|
||||||
const sandboxUrlBase = getSandboxUrl();
|
const sandboxUrlBase = getSandboxUrl();
|
||||||
const publicUrlBase = getPublicUrl();
|
const publicUrlBase = getPublicUrl();
|
||||||
const source = this.props.initialSource ? base(this.props.initialSource, trustedUrlBase, sandboxUrlBase, publicUrlBase) : defaultSource;
|
const source = this.props.initialSource ? base(this.props.initialSource, this.props.tagLanguage, trustedUrlBase, sandboxUrlBase, publicUrlBase) : defaultSource;
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
source,
|
source,
|
||||||
|
@ -87,6 +87,7 @@ class CodeEditorSandbox extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
entityTypeId: PropTypes.string,
|
entityTypeId: PropTypes.string,
|
||||||
entityId: PropTypes.number,
|
entityId: PropTypes.number,
|
||||||
|
tagLanguage: PropTypes.string,
|
||||||
initialSource: PropTypes.string,
|
initialSource: PropTypes.string,
|
||||||
sourceType: PropTypes.string,
|
sourceType: PropTypes.string,
|
||||||
initialPreview: PropTypes.bool,
|
initialPreview: PropTypes.bool,
|
||||||
|
@ -98,8 +99,8 @@ class CodeEditorSandbox extends Component {
|
||||||
const sandboxUrlBase = getSandboxUrl();
|
const sandboxUrlBase = getSandboxUrl();
|
||||||
const publicUrlBase = getPublicUrl();
|
const publicUrlBase = getPublicUrl();
|
||||||
return {
|
return {
|
||||||
html: unbase(this.getHtml(), trustedUrlBase, sandboxUrlBase, publicUrlBase, true),
|
html: unbase(this.getHtml(), this.props.tagLanguage, trustedUrlBase, sandboxUrlBase, publicUrlBase, true),
|
||||||
source: unbase(this.state.source, trustedUrlBase, sandboxUrlBase, publicUrlBase, true)
|
source: unbase(this.state.source, this.props.tagLanguage, trustedUrlBase, sandboxUrlBase, publicUrlBase, true)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +150,7 @@ class CodeEditorSandbox extends Component {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!this.refreshTimeoutId) {
|
if (!this.refreshTimeoutId) {
|
||||||
this.refreshTimeoutId = setTimeout(() => this.refresh(), refreshTimeout);
|
this.refreshTimeoutId = setTimeout(this.refreshHandler, refreshTimeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import {UntrustedContentHost} from './untrusted';
|
||||||
import {Icon} from "./bootstrap-components";
|
import {Icon} from "./bootstrap-components";
|
||||||
import {getTrustedUrl} from "./urls";
|
import {getTrustedUrl} from "./urls";
|
||||||
import {withComponentMixins} from "./decorator-helpers";
|
import {withComponentMixins} from "./decorator-helpers";
|
||||||
|
import {getTagLanguageFromEntity} from "./sandbox-common";
|
||||||
|
|
||||||
@withComponentMixins([
|
@withComponentMixins([
|
||||||
withTranslation
|
withTranslation
|
||||||
|
@ -75,6 +76,7 @@ export class CodeEditorHost extends Component {
|
||||||
const editorData = {
|
const editorData = {
|
||||||
entityTypeId: this.props.entityTypeId,
|
entityTypeId: this.props.entityTypeId,
|
||||||
entityId: this.props.entity.id,
|
entityId: this.props.entity.id,
|
||||||
|
tagLanguage: getTagLanguageFromEntity(this.props.entity, this.props.entityTypeId),
|
||||||
initialSource: this.props.initialSource,
|
initialSource: this.props.initialSource,
|
||||||
sourceType: this.props.sourceType,
|
sourceType: this.props.sourceType,
|
||||||
initialPreview: this.state.preview,
|
initialPreview: this.state.preview,
|
||||||
|
|
|
@ -54,6 +54,7 @@ export class GrapesJSSandbox extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
entityTypeId: PropTypes.string,
|
entityTypeId: PropTypes.string,
|
||||||
entityId: PropTypes.number,
|
entityId: PropTypes.number,
|
||||||
|
tagLanguage: PropTypes.string,
|
||||||
initialSource: PropTypes.string,
|
initialSource: PropTypes.string,
|
||||||
initialStyle: PropTypes.string,
|
initialStyle: PropTypes.string,
|
||||||
sourceType: PropTypes.string
|
sourceType: PropTypes.string
|
||||||
|
@ -75,8 +76,8 @@ export class GrapesJSSandbox extends Component {
|
||||||
const sandboxUrlBase = getSandboxUrl();
|
const sandboxUrlBase = getSandboxUrl();
|
||||||
const publicUrlBase = getPublicUrl();
|
const publicUrlBase = getPublicUrl();
|
||||||
|
|
||||||
const source = unbase(editor.getHtml(), trustedUrlBase, sandboxUrlBase, publicUrlBase, true);
|
const source = unbase(editor.getHtml(), this.props.tagLanguage, trustedUrlBase, sandboxUrlBase, publicUrlBase, true);
|
||||||
const style = unbase(editor.getCss(), trustedUrlBase, sandboxUrlBase, publicUrlBase, true);
|
const style = unbase(editor.getCss(), this.props.tagLanguage, trustedUrlBase, sandboxUrlBase, publicUrlBase, true);
|
||||||
|
|
||||||
let html;
|
let html;
|
||||||
|
|
||||||
|
@ -96,7 +97,7 @@ export class GrapesJSSandbox extends Component {
|
||||||
|
|
||||||
const preHtml = '<!doctype html><html><head><meta charset="utf-8"><title></title></head><body>';
|
const preHtml = '<!doctype html><html><head><meta charset="utf-8"><title></title></head><body>';
|
||||||
const postHtml = '</body></html>';
|
const postHtml = '</body></html>';
|
||||||
html = preHtml + unbase(htmlBody, trustedUrlBase, sandboxUrlBase, publicUrlBase, true) + postHtml;
|
html = preHtml + unbase(htmlBody, this.props.tagLanguage, trustedUrlBase, sandboxUrlBase, publicUrlBase, true) + postHtml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -603,8 +604,8 @@ export class GrapesJSSandbox extends Component {
|
||||||
config.plugins.push('gjs-preset-newsletter');
|
config.plugins.push('gjs-preset-newsletter');
|
||||||
}
|
}
|
||||||
|
|
||||||
config.components = props.initialSource ? base(props.initialSource, trustedUrlBase, sandboxUrlBase, publicUrlBase) : defaultSource;
|
config.components = props.initialSource ? base(props.initialSource, this.props.tagLanguage, trustedUrlBase, sandboxUrlBase, publicUrlBase) : defaultSource;
|
||||||
config.style = props.initialStyle ? base(props.initialStyle, trustedUrlBase, sandboxUrlBase, publicUrlBase) : defaultStyle;
|
config.style = props.initialStyle ? base(props.initialStyle, this.props.tagLanguage, trustedUrlBase, sandboxUrlBase, publicUrlBase) : defaultStyle;
|
||||||
|
|
||||||
config.plugins.push('mailtrain-remove-buttons');
|
config.plugins.push('mailtrain-remove-buttons');
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {Icon} from "./bootstrap-components";
|
||||||
import {getTrustedUrl} from "./urls";
|
import {getTrustedUrl} from "./urls";
|
||||||
import {withComponentMixins} from "./decorator-helpers";
|
import {withComponentMixins} from "./decorator-helpers";
|
||||||
import {GrapesJSSourceType} from "./sandboxed-grapesjs-shared";
|
import {GrapesJSSourceType} from "./sandboxed-grapesjs-shared";
|
||||||
|
import {getTagLanguageFromEntity} from "./sandbox-common";
|
||||||
|
|
||||||
@withComponentMixins([
|
@withComponentMixins([
|
||||||
withTranslation
|
withTranslation
|
||||||
|
@ -57,6 +58,7 @@ export class GrapesJSHost extends Component {
|
||||||
const editorData = {
|
const editorData = {
|
||||||
entityTypeId: this.props.entityTypeId,
|
entityTypeId: this.props.entityTypeId,
|
||||||
entityId: this.props.entity.id,
|
entityId: this.props.entity.id,
|
||||||
|
tagLanguage: getTagLanguageFromEntity(this.props.entity, this.props.entityTypeId),
|
||||||
initialSource: this.props.initialSource,
|
initialSource: this.props.initialSource,
|
||||||
initialStyle: this.props.initialStyle,
|
initialStyle: this.props.initialStyle,
|
||||||
sourceType: this.props.sourceType
|
sourceType: this.props.sourceType
|
||||||
|
|
|
@ -27,6 +27,7 @@ class MosaicoSandbox extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
entityTypeId: PropTypes.string,
|
entityTypeId: PropTypes.string,
|
||||||
entityId: PropTypes.number,
|
entityId: PropTypes.number,
|
||||||
|
tagLanguage: PropTypes.string,
|
||||||
templateId: PropTypes.number,
|
templateId: PropTypes.number,
|
||||||
templatePath: PropTypes.string,
|
templatePath: PropTypes.string,
|
||||||
initialModel: PropTypes.string,
|
initialModel: PropTypes.string,
|
||||||
|
@ -60,9 +61,9 @@ class MosaicoSandbox extends Component {
|
||||||
html = juice(html);
|
html = juice(html);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
html: unbase(html, trustedUrlBase, sandboxUrlBase, publicUrlBase, true),
|
html: unbase(html, this.props.tagLanguage, trustedUrlBase, sandboxUrlBase, publicUrlBase, true),
|
||||||
model: unbase(this.viewModel.exportJSON(), trustedUrlBase, sandboxUrlBase, publicUrlBase),
|
model: unbase(this.viewModel.exportJSON(), this.props.tagLanguage, trustedUrlBase, sandboxUrlBase, publicUrlBase),
|
||||||
metadata: unbase(this.viewModel.exportMetadata(), trustedUrlBase, sandboxUrlBase, publicUrlBase)
|
metadata: unbase(this.viewModel.exportMetadata(), this.props.tagLanguage, trustedUrlBase, sandboxUrlBase, publicUrlBase)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,8 +129,8 @@ class MosaicoSandbox extends Component {
|
||||||
const trustedUrlBase = getTrustedUrl();
|
const trustedUrlBase = getTrustedUrl();
|
||||||
const sandboxUrlBase = getSandboxUrl();
|
const sandboxUrlBase = getSandboxUrl();
|
||||||
const publicUrlBase = getPublicUrl();
|
const publicUrlBase = getPublicUrl();
|
||||||
const metadata = this.props.initialMetadata && JSON.parse(base(this.props.initialMetadata, trustedUrlBase, sandboxUrlBase, publicUrlBase));
|
const metadata = this.props.initialMetadata && JSON.parse(base(this.props.initialMetadata, this.props.tagLanguage, trustedUrlBase, sandboxUrlBase, publicUrlBase));
|
||||||
const model = this.props.initialModel && JSON.parse(base(this.props.initialModel, trustedUrlBase, sandboxUrlBase, publicUrlBase));
|
const model = this.props.initialModel && JSON.parse(base(this.props.initialModel, this.props.tagLanguage, trustedUrlBase, sandboxUrlBase, publicUrlBase));
|
||||||
const template = this.props.templateId ? getSandboxUrl(`mosaico/templates/${this.props.templateId}/index.html`) : this.props.templatePath;
|
const template = this.props.templateId ? getSandboxUrl(`mosaico/templates/${this.props.templateId}/index.html`) : this.props.templatePath;
|
||||||
|
|
||||||
const allPlugins = plugins.concat(window.mosaicoPlugins);
|
const allPlugins = plugins.concat(window.mosaicoPlugins);
|
||||||
|
|
|
@ -9,6 +9,7 @@ import {UntrustedContentHost} from './untrusted';
|
||||||
import {Icon} from "./bootstrap-components";
|
import {Icon} from "./bootstrap-components";
|
||||||
import {getTrustedUrl} from "./urls";
|
import {getTrustedUrl} from "./urls";
|
||||||
import {withComponentMixins} from "./decorator-helpers";
|
import {withComponentMixins} from "./decorator-helpers";
|
||||||
|
import {getTagLanguageFromEntity} from "./sandbox-common";
|
||||||
|
|
||||||
|
|
||||||
@withComponentMixins([
|
@withComponentMixins([
|
||||||
|
@ -58,6 +59,7 @@ export class MosaicoHost extends Component {
|
||||||
const editorData = {
|
const editorData = {
|
||||||
entityTypeId: this.props.entityTypeId,
|
entityTypeId: this.props.entityTypeId,
|
||||||
entityId: this.props.entity.id,
|
entityId: this.props.entity.id,
|
||||||
|
tagLanguage: getTagLanguageFromEntity(this.props.entity, this.props.entityTypeId),
|
||||||
templateId: this.props.templateId,
|
templateId: this.props.templateId,
|
||||||
templatePath: this.props.templatePath,
|
templatePath: this.props.templatePath,
|
||||||
initialModel: this.props.initialModel,
|
initialModel: this.props.initialModel,
|
||||||
|
|
|
@ -376,7 +376,7 @@ export default class CUD extends Component {
|
||||||
|
|
||||||
{typeForm}
|
{typeForm}
|
||||||
|
|
||||||
<Dropdown id="tag_language" label={t('Tag language')} options={tagLanguageOptions} disabled={isEdit && (!typeKey || this.templateTypes[typeKey].isTagLanguageSelectorDisabledForEdit)}/>
|
<Dropdown id="tag_language" label={t('Tag language')} options={tagLanguageOptions} disabled={isEdit}/>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,6 @@ export function getTemplateTypes(t, prefix = '', entityTypeId = ResourceType.TEM
|
||||||
mutState.setIn([prefix + 'mosaicoTemplate', 'value'], null);
|
mutState.setIn([prefix + 'mosaicoTemplate', 'value'], null);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isTagLanguageSelectorDisabledForEdit: true,
|
|
||||||
validate: state => {
|
validate: state => {
|
||||||
const mosaicoTemplate = state.getIn([prefix + 'mosaicoTemplate', 'value']);
|
const mosaicoTemplate = state.getIn([prefix + 'mosaicoTemplate', 'value']);
|
||||||
if (!mosaicoTemplate) {
|
if (!mosaicoTemplate) {
|
||||||
|
@ -256,7 +255,6 @@ export function getTemplateTypes(t, prefix = '', entityTypeId = ResourceType.TEM
|
||||||
},
|
},
|
||||||
afterTagLanguageChange: (mutState, isEdit) => {
|
afterTagLanguageChange: (mutState, isEdit) => {
|
||||||
},
|
},
|
||||||
isTagLanguageSelectorDisabledForEdit: false,
|
|
||||||
validate: state => {
|
validate: state => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -346,7 +344,6 @@ export function getTemplateTypes(t, prefix = '', entityTypeId = ResourceType.TEM
|
||||||
},
|
},
|
||||||
afterTagLanguageChange: (mutState, isEdit) => {
|
afterTagLanguageChange: (mutState, isEdit) => {
|
||||||
},
|
},
|
||||||
isTagLanguageSelectorDisabledForEdit: false,
|
|
||||||
validate: state => {
|
validate: state => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -408,7 +405,6 @@ export function getTemplateTypes(t, prefix = '', entityTypeId = ResourceType.TEM
|
||||||
},
|
},
|
||||||
afterTagLanguageChange: (mutState, isEdit) => {
|
afterTagLanguageChange: (mutState, isEdit) => {
|
||||||
},
|
},
|
||||||
isTagLanguageSelectorDisabledForEdit: false,
|
|
||||||
validate: state => {
|
validate: state => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -495,7 +491,6 @@ export function getTemplateTypes(t, prefix = '', entityTypeId = ResourceType.TEM
|
||||||
},
|
},
|
||||||
afterTagLanguageChange: (mutState, isEdit) => {
|
afterTagLanguageChange: (mutState, isEdit) => {
|
||||||
},
|
},
|
||||||
isTagLanguageSelectorDisabledForEdit: false,
|
|
||||||
validate: state => {
|
validate: state => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const {renderTag} = require('../../shared/templates');
|
||||||
|
|
||||||
function convertFileURLs(sourceCustom, fromEntityType, fromEntityId, toEntityType, toEntityId) {
|
function convertFileURLs(sourceCustom, fromEntityType, fromEntityId, toEntityType, toEntityId) {
|
||||||
|
|
||||||
|
const tagLanguage = sourceCustom.tag_language;
|
||||||
|
|
||||||
function convertText(text) {
|
function convertText(text) {
|
||||||
if (text) {
|
if (text) {
|
||||||
const fromUrl = `/files/${fromEntityType}/file/${fromEntityId}`;
|
const fromUrl = `/files/${fromEntityType}/file/${fromEntityId}`;
|
||||||
|
@ -10,10 +14,10 @@ function convertFileURLs(sourceCustom, fromEntityType, fromEntityId, toEntityTyp
|
||||||
const encodedFromUrl = encodeURIComponent(fromUrl);
|
const encodedFromUrl = encodeURIComponent(fromUrl);
|
||||||
const encodedToUrl = encodeURIComponent(toUrl);
|
const encodedToUrl = encodeURIComponent(toUrl);
|
||||||
|
|
||||||
text = text.split('[URL_BASE]' + fromUrl).join('[URL_BASE]' + toUrl);
|
text = text.split(renderTag(tagLanguage, 'URL_BASE') + fromUrl).join(renderTag(tagLanguage, 'URL_BASE') + toUrl);
|
||||||
text = text.split('[SANDBOX_URL_BASE]' + fromUrl).join('[SANDBOX_URL_BASE]' + toUrl);
|
text = text.split(renderTag(tagLanguage,'SANDBOX_URL_BASE') + fromUrl).join(renderTag(tagLanguage, 'SANDBOX_URL_BASE') + toUrl);
|
||||||
text = text.split('[ENCODED_URL_BASE]' + encodedFromUrl).join('[ENCODED_URL_BASE]' + encodedToUrl);
|
text = text.split(renderTag(tagLanguage, 'ENCODED_URL_BASE') + encodedFromUrl).join(renderTag(tagLanguage, 'ENCODED_URL_BASE') + encodedToUrl);
|
||||||
text = text.split('[ENCODED_SANDBOX_URL_BASE]' + encodedFromUrl).join('[ENCODED_SANDBOX_URL_BASE]' + encodedToUrl);
|
text = text.split(renderTag(tagLanguage, 'ENCODED_SANDBOX_URL_BASE') + encodedFromUrl).join(renderTag(tagLanguage, 'ENCODED_SANDBOX_URL_BASE') + encodedToUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
|
|
|
@ -141,7 +141,7 @@ async function getRouter(appType) {
|
||||||
const tmpl = await mosaicoTemplates.getById(req.context, castToInteger(req.params.mosaicoTemplateId));
|
const tmpl = await mosaicoTemplates.getById(req.context, castToInteger(req.params.mosaicoTemplateId));
|
||||||
|
|
||||||
res.set('Content-Type', 'text/html');
|
res.set('Content-Type', 'text/html');
|
||||||
res.send(base(tmpl.data.html, getTrustedUrl(), getSandboxUrl('', req.context), getPublicUrl()));
|
res.send(base(tmpl.data.html, tmpl.tag_language, getTrustedUrl(), getSandboxUrl('', req.context), getPublicUrl()));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Mosaico looks for block thumbnails in edres folder relative to index.html of the template. We respond to such requests here.
|
// Mosaico looks for block thumbnails in edres folder relative to index.html of the template. We respond to such requests here.
|
||||||
|
|
|
@ -44,28 +44,28 @@ function getMergeTagsForBases(trustedBaseUrl, sandboxBaseUrl, publicBaseUrl) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function base(text, trustedBaseUrl, sandboxBaseUrl, publicBaseUrl) {
|
function base(text, tagLanguage, trustedBaseUrl, sandboxBaseUrl, publicBaseUrl) {
|
||||||
const bases = _getBases(trustedBaseUrl, sandboxBaseUrl, publicBaseUrl);
|
const bases = _getBases(trustedBaseUrl, sandboxBaseUrl, publicBaseUrl);
|
||||||
|
|
||||||
text = text.split('[URL_BASE]').join(bases.publicBaseUrl);
|
text = text.split(renderTag(tagLanguage, 'URL_BASE')).join(bases.publicBaseUrl);
|
||||||
text = text.split('[TRUSTED_URL_BASE]').join(bases.trustedBaseUrl);
|
text = text.split(renderTag(tagLanguage, 'TRUSTED_URL_BASE')).join(bases.trustedBaseUrl);
|
||||||
text = text.split('[SANDBOX_URL_BASE]').join(bases.sandboxBaseUrl);
|
text = text.split(renderTag(tagLanguage, 'SANDBOX_URL_BASE')).join(bases.sandboxBaseUrl);
|
||||||
text = text.split('[ENCODED_URL_BASE]').join(encodeURIComponent(bases.publicBaseUrl));
|
text = text.split(renderTag(tagLanguage, 'ENCODED_URL_BASE')).join(encodeURIComponent(bases.publicBaseUrl));
|
||||||
text = text.split('[ENCODED_TRUSTED_URL_BASE]').join(encodeURIComponent(bases.trustedBaseUrl));
|
text = text.split(renderTag(tagLanguage, 'ENCODED_TRUSTED_URL_BASE')).join(encodeURIComponent(bases.trustedBaseUrl));
|
||||||
text = text.split('[ENCODED_SANDBOX_URL_BASE]').join(encodeURIComponent(bases.sandboxBaseUrl));
|
text = text.split(renderTag(tagLanguage, 'ENCODED_SANDBOX_URL_BASE')).join(encodeURIComponent(bases.sandboxBaseUrl));
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
function unbase(text, trustedBaseUrl, sandboxBaseUrl, publicBaseUrl, treatAllAsPublic = false) {
|
function unbase(text, tagLanguage, trustedBaseUrl, sandboxBaseUrl, publicBaseUrl, treatAllAsPublic = false) {
|
||||||
const bases = _getBases(trustedBaseUrl, sandboxBaseUrl, publicBaseUrl);
|
const bases = _getBases(trustedBaseUrl, sandboxBaseUrl, publicBaseUrl);
|
||||||
|
|
||||||
text = text.split(bases.publicBaseUrl).join('[URL_BASE]');
|
text = text.split(bases.publicBaseUrl).join(renderTag(tagLanguage, 'URL_BASE'));
|
||||||
text = text.split(bases.trustedBaseUrl).join(treatAllAsPublic ? '[URL_BASE]' : '[TRUSTED_URL_BASE]');
|
text = text.split(bases.trustedBaseUrl).join(renderTag(tagLanguage, treatAllAsPublic ? 'URL_BASE' : 'TRUSTED_URL_BASE'));
|
||||||
text = text.split(bases.sandboxBaseUrl).join(treatAllAsPublic ? '[URL_BASE]' : '[SANDBOX_URL_BASE]');
|
text = text.split(bases.sandboxBaseUrl).join(renderTag(tagLanguage, treatAllAsPublic ? 'URL_BASE' : 'SANDBOX_URL_BASE'));
|
||||||
text = text.split(encodeURIComponent(bases.publicBaseUrl)).join('[ENCODED_URL_BASE]');
|
text = text.split(encodeURIComponent(bases.publicBaseUrl)).join(renderTag(tagLanguage, 'ENCODED_URL_BASE'));
|
||||||
text = text.split(encodeURIComponent(bases.trustedBaseUrl)).join(treatAllAsPublic ? '[ENCODED_URL_BASE]' : '[ENCODED_TRUSTED_URL_BASE]');
|
text = text.split(encodeURIComponent(bases.trustedBaseUrl)).join(renderTag(tagLanguage, treatAllAsPublic ? 'ENCODED_URL_BASE' : 'ENCODED_TRUSTED_URL_BASE'));
|
||||||
text = text.split(encodeURIComponent(bases.sandboxBaseUrl)).join(treatAllAsPublic ? '[ENCODED_URL_BASE]' : '[ENCODED_SANDBOX_URL_BASE]');
|
text = text.split(encodeURIComponent(bases.sandboxBaseUrl)).join(renderTag(tagLanguage, treatAllAsPublic ? 'ENCODED_URL_BASE' : 'ENCODED_SANDBOX_URL_BASE'));
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue