|
@@ -33,6 +33,11 @@ export class TextEditorCtrl extends ModuleControl<EditorModule> {
|
|
|
}
|
|
|
setCompValueInReg(key: string, e: any) {
|
|
|
console.log(key, e);
|
|
|
+ const addTagsKey = ["bold", "italic", "underline", "strikethrough"];
|
|
|
+ if (addTagsKey.includes(key)) {
|
|
|
+ this.addCompValueTags(key, e);
|
|
|
+ return;
|
|
|
+ }
|
|
|
const compValue = this.store.currComp.value;
|
|
|
const regString = `(${stylesKey[key]}:)([0-9a-zA-z#.])*(\\;)`;
|
|
|
const styleReg = new RegExp(regString, "ig");
|
|
@@ -41,6 +46,40 @@ export class TextEditorCtrl extends ModuleControl<EditorModule> {
|
|
|
const changeValue = compValue.replace(styleReg, `$1${e.value}$3`);
|
|
|
console.log(changeValue);
|
|
|
this.actions.updateCompData(this.store.currComp, "value", changeValue);
|
|
|
+ } else {
|
|
|
+ console.log(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ addCompValueTags(key: string, e: any) {
|
|
|
+ console.log(key, e);
|
|
|
+ // const
|
|
|
+ // ("i s strong u");
|
|
|
+ const keyToTags = {
|
|
|
+ italic: {
|
|
|
+ tag: "<strong>",
|
|
|
+ end: "</strong>",
|
|
|
+ },
|
|
|
+ strikethrough: {
|
|
|
+ tag: "<strong>",
|
|
|
+ end: "</strong>",
|
|
|
+ },
|
|
|
+
|
|
|
+ bold: {
|
|
|
+ tag: "<strong>",
|
|
|
+ end: "</strong>",
|
|
|
+ },
|
|
|
+ underline: {
|
|
|
+ tag: "<strong>",
|
|
|
+ end: "</strong>",
|
|
|
+ },
|
|
|
+ };
|
|
|
+ const compValue = this.store.currComp.value;
|
|
|
+ console.log(compValue);
|
|
|
+ const blocks = compValue.match(/<p(([\s\S])*?)<\/p>/gi);
|
|
|
+ if (!blocks) {
|
|
|
+ return;
|
|
|
}
|
|
|
+ blocks.map((item: string, index: number) => {});
|
|
|
+ console.log(blocks);
|
|
|
}
|
|
|
}
|