|
@@ -31,7 +31,7 @@ export class TextEditorCtrl extends ModuleControl<EditorModule> {
|
|
if (!this.state.currEditor) {
|
|
if (!this.state.currEditor) {
|
|
let alink = `<a href="${res}"><span style="font-size:14px">${res}</span></a>`;
|
|
let alink = `<a href="${res}"><span style="font-size:14px">${res}</span></a>`;
|
|
const compValue = this.store.currComp.value;
|
|
const compValue = this.store.currComp.value;
|
|
- const pTagReg = /(<p[\s\S]*?>)([\s\S]*?)(<\/p>)/gi;
|
|
|
|
|
|
+ const pTagReg = /(<(p|h2|h3)[\s\S]*?>)([\s\S]*?)(<\/(p|h2|h3)>)/gi;
|
|
const blocks = compValue.match(pTagReg);
|
|
const blocks = compValue.match(pTagReg);
|
|
if (!blocks) {
|
|
if (!blocks) {
|
|
return;
|
|
return;
|
|
@@ -58,7 +58,7 @@ export class TextEditorCtrl extends ModuleControl<EditorModule> {
|
|
}
|
|
}
|
|
const compValue = this.store.currComp.value;
|
|
const compValue = this.store.currComp.value;
|
|
|
|
|
|
- const pTagReg = /(<p[\s\S]*?>)([\s\S]*?)(<\/p>)/gi;
|
|
|
|
|
|
+ const pTagReg = /(<(p|h2|h3)[\s\S]*?>)([\s\S]*?)(<\/(p|h2|h3)>)/gi;
|
|
const blocks = compValue.match(pTagReg);
|
|
const blocks = compValue.match(pTagReg);
|
|
if (!blocks) {
|
|
if (!blocks) {
|
|
return;
|
|
return;
|
|
@@ -79,7 +79,7 @@ export class TextEditorCtrl extends ModuleControl<EditorModule> {
|
|
this.actions.updateCompData(this.store.currComp, "value", blocks.join(""));
|
|
this.actions.updateCompData(this.store.currComp, "value", blocks.join(""));
|
|
}
|
|
}
|
|
blockStyleChange(item: string, key: string, e: any) {
|
|
blockStyleChange(item: string, key: string, e: any) {
|
|
- const pStyleReg = /<p[\s|\s]*style=[\s|\S]*?>/;
|
|
|
|
|
|
+ const pStyleReg = /<(p|h2|h3)[\s|\s]*style=[\s|\S]*?>/;
|
|
let blockStr = item;
|
|
let blockStr = item;
|
|
const hasStyles = item.indexOf(stylesKey[key]);
|
|
const hasStyles = item.indexOf(stylesKey[key]);
|
|
if (hasStyles != -1) {
|
|
if (hasStyles != -1) {
|
|
@@ -89,25 +89,25 @@ export class TextEditorCtrl extends ModuleControl<EditorModule> {
|
|
return blockStr;
|
|
return blockStr;
|
|
}
|
|
}
|
|
if (pStyleReg.test(item)) {
|
|
if (pStyleReg.test(item)) {
|
|
- const addStyleReg = /(<p[\s|\s]*style=[\s|\S]*?)(">[\s|\S]*)/;
|
|
|
|
- blockStr = item.replace(addStyleReg, `$1${stylesKey[key]}:${e.value};$2`);
|
|
|
|
|
|
+ const addStyleReg = /(<(p|h2|h3)[\s|\s]*style=[\s|\S]*?)(">[\s|\S]*)/;
|
|
|
|
+ blockStr = item.replace(addStyleReg, `$1${stylesKey[key]}:${e.value};$3`);
|
|
} else {
|
|
} else {
|
|
- const noStyleReg = /(<p[\s|\s]*)(>[\s|\S]*)/;
|
|
|
|
|
|
+ const noStyleReg = /(<(p|h2|h3)[\s|\s]*)(>[\s|\S]*)/;
|
|
blockStr = item.replace(
|
|
blockStr = item.replace(
|
|
noStyleReg,
|
|
noStyleReg,
|
|
- `$1 style="${stylesKey[key]}:${e.value};"$2`
|
|
|
|
|
|
+ `$1 style="${stylesKey[key]}:${e.value};"$3`
|
|
);
|
|
);
|
|
}
|
|
}
|
|
return blockStr;
|
|
return blockStr;
|
|
}
|
|
}
|
|
spanStyleChange(item: string, key: string, e: any) {
|
|
spanStyleChange(item: string, key: string, e: any) {
|
|
- const pTagReg = /(<p[\s\S]*?>)([\s\S]*?)(<\/p>)/gi;
|
|
|
|
|
|
+ const pTagReg = /(<(p|h2|h3)[\s\S]*?>)([\s\S]*?)(<\/(p|h2|h3)>)/gi;
|
|
let spanStr = item;
|
|
let spanStr = item;
|
|
const hasSpan: any = spanStr.indexOf("span");
|
|
const hasSpan: any = spanStr.indexOf("span");
|
|
if (hasSpan == -1) {
|
|
if (hasSpan == -1) {
|
|
spanStr = spanStr.replace(
|
|
spanStr = spanStr.replace(
|
|
pTagReg,
|
|
pTagReg,
|
|
- '$1<span style="font-size:14px;">$2</span>$3'
|
|
|
|
|
|
+ '$1<span style="font-size:14px;">$3</span>$4'
|
|
);
|
|
);
|
|
}
|
|
}
|
|
const hasStyles = item.indexOf(stylesKey[key]);
|
|
const hasStyles = item.indexOf(stylesKey[key]);
|
|
@@ -134,7 +134,7 @@ export class TextEditorCtrl extends ModuleControl<EditorModule> {
|
|
|
|
|
|
addCompValueTags(key: string, e: any) {
|
|
addCompValueTags(key: string, e: any) {
|
|
const compValue = this.store.currComp.value;
|
|
const compValue = this.store.currComp.value;
|
|
- const pTagReg = /(<p[\s\S]*?>)([\s\S]*?)(<\/p>)/gi;
|
|
|
|
|
|
+ const pTagReg = /(<(p|h2|h3)[\s\S]*?>)([\s\S]*?)(<\/(p|h2|h3)>)/gi;
|
|
const blocks = compValue.match(pTagReg);
|
|
const blocks = compValue.match(pTagReg);
|
|
if (!blocks) {
|
|
if (!blocks) {
|
|
return;
|
|
return;
|
|
@@ -147,7 +147,7 @@ export class TextEditorCtrl extends ModuleControl<EditorModule> {
|
|
}
|
|
}
|
|
const spanStr = item.replace(
|
|
const spanStr = item.replace(
|
|
pTagReg,
|
|
pTagReg,
|
|
- '$1<span style="font-size:14px;">$2</span>$3'
|
|
|
|
|
|
+ '$1<span style="font-size:14px;">$3</span>$4'
|
|
);
|
|
);
|
|
blocks[index] = this.formatSortTags(spanStr, key, e);
|
|
blocks[index] = this.formatSortTags(spanStr, key, e);
|
|
});
|
|
});
|