Skip to content

Commit

Permalink
1、增加ueditor编辑器支持
Browse files Browse the repository at this point in the history
2、优化代码
  • Loading branch information
liyuepeng committed Aug 24, 2020
1 parent 257dc3a commit 3fb802f
Show file tree
Hide file tree
Showing 281 changed files with 98,206 additions and 2,337 deletions.
5 changes: 5 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
"src/app.js",
"src/app.css",
"src/home.html",
{
"glob": "**/*",
"input": "./ueditor/",
"output": "/assets/ueditor/"
},
{
"glob": "**/*",
"input": "./node_modules/@ant-design/icons-angular/src/inline-svg/",
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@
"moment": "^2.24.0",
"monaco-editor": "^0.14.0",
"ng-zorro-antd": "^8.5.2",
"ngx-electron": "^2.2.0",
"ngx-ueditor": "^2.1.3",
"qrious": "^4.0.2",
"rxjs": "~6.4.0",
"screenfull": "^5.0.0",
"ts-md5": "^1.2.7",
"tslib": "^1.10.0",
"ueditor": "^1.2.3",
"web-animations-js": "^2.3.2",
"zone.js": "~0.9.1"
},
Expand All @@ -93,8 +94,6 @@
"babel-polyfill": "^6.26.0",
"codecov": "^3.6.1",
"codelyzer": "^5.0.0",
"electron": "^8.2.3",
"electron-builder": "^22.4.1",
"gh-pages": "^2.1.1",
"husky": "^3.0.9",
"jasmine-core": "~3.4.0",
Expand Down
2 changes: 1 addition & 1 deletion src/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
window.eruptSiteConfig = {
//global config
domain: "http:https://localhost:9999",
fileDomain: "http:https://oos.erupt.xyz",
fileDomain: "http:https://localhost:9999",
title: "Erupt Framework", //通用数据管理框架
desc: "通用数据管理框架",
routerReuse: false,
Expand Down
15 changes: 12 additions & 3 deletions src/app/build/erupt/components/edit-type/edit-type.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -573,13 +573,22 @@
</se>
</div>
</ng-container>
<ng-container *ngSwitchCase="editType.HTML_EDIT">
<ng-container *ngSwitchCase="editType.HTML_EDITOR">
<div nz-col [nzSpan]="24">
<se [label]="field.eruptFieldJson.edit.title"
[required]="field.eruptFieldJson.edit.notNull"
[optionalHelp]="field.eruptFieldJson.edit.desc">
<ckeditor [(value)]="field.eruptFieldJson.edit.$value"
[eruptField]="field" [erupt]="eruptModel"></ckeditor>
<ng-container
*ngIf="field.eruptFieldJson.edit.htmlEditorType.value===htmlEditorType.CKEDITOR">
<ckeditor [(value)]="field.eruptFieldJson.edit.$value"
[eruptField]="field" [erupt]="eruptModel"></ckeditor>
</ng-container>
<ng-container
*ngIf="field.eruptFieldJson.edit.htmlEditorType.value===htmlEditorType.UEDITOR">
<erupt-ueditor [eruptField]="field" [erupt]="eruptModel">

</erupt-ueditor>
</ng-container>
</se>
</div>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
:host {
::ng-deep {
.edui-editor {
width: 100% !important;
}

form.ant-form-horizontal {
se .ant-form-item-label {
max-width: 150px;
Expand Down Expand Up @@ -61,4 +65,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
Output
} from "@angular/core";
import {Edit, EruptField, EruptFieldModel} from "../../model/erupt-field.model";
import {AttachmentEnum, ChoiceEnum, DateEnum, EditType} from "../../model/erupt.enum";
import {AttachmentEnum, ChoiceEnum, DateEnum, EditType, HtmlEditTypeEnum} from "../../model/erupt.enum";
import {DataService} from "@shared/service/data.service";
import {TreeSelectComponent} from "../tree-select/tree-select.component";
import {NzMessageService, NzModalService, UploadFile} from "ng-zorro-antd";
Expand Down Expand Up @@ -58,6 +58,8 @@ export class EditTypeComponent implements OnInit, OnDestroy, DoCheck {

editType = EditType;

htmlEditorType = HtmlEditTypeEnum;

choiceEnum = ChoiceEnum;

dateEnum = DateEnum;
Expand Down
2 changes: 2 additions & 0 deletions src/app/build/erupt/components/ueditor/ueditor.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<ueditor [name]="eruptField.fieldName" [(ngModel)]="eruptField.eruptFieldJson.edit.$value"
[config]="{serverUrl:serverPath,readonly:eruptField.eruptFieldJson.edit.readOnly}"></ueditor>
33 changes: 33 additions & 0 deletions src/app/build/erupt/components/ueditor/ueditor.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {Component, EventEmitter, Inject, Input, OnInit, Output} from '@angular/core';
import {EruptFieldModel} from "../../model/erupt-field.model";
import {EruptModel} from "../../model/erupt.model";
import {RestPath} from "../../model/erupt.enum";
import {DA_SERVICE_TOKEN, ITokenService, TokenService} from "@delon/auth";
import {WindowModel} from "@shared/model/window.model";

@Component({
selector: 'erupt-ueditor',
templateUrl: './ueditor.component.html',
styles: []
})
export class UeditorComponent implements OnInit {

@Input() eruptField: EruptFieldModel;

@Input() erupt: EruptModel;

serverPath: string;

constructor(@Inject(DA_SERVICE_TOKEN) private tokenService: ITokenService) {
}

ngOnInit() {
let rf = RestPath.file;
if (!WindowModel.domain) {
rf = "/" + rf;
}
this.serverPath = rf + "/upload-ueditor/" + this.erupt.eruptName + "/" +
this.eruptField.fieldName + "?_erupt=" + this.erupt.eruptName + "&_token=" + this.tokenService.get().token;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
}

p {
text-indent: 2em;
line-height: 35px;
font-size: 18px;
word-wrap: break-word;
Expand All @@ -60,4 +59,4 @@

}
}
}
}
21 changes: 17 additions & 4 deletions src/app/build/erupt/erupt.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,29 @@ import {TreeComponent} from "./view/tree/tree.component";
import {TableViewComponent} from "./view/table-view/table-view.component";
import {EditComponent} from "./view/edit/edit.component";
import {TableComponent} from './view/table/table.component';
import { LayoutTreeComponent } from './view/layout-tree/layout-tree.component';
import {LayoutTreeComponent} from './view/layout-tree/layout-tree.component';
import {NzCodeEditorModule} from "ng-zorro-antd/code-editor";
import { CodeEditorComponent } from './components/code-editor/code-editor.component';
import {CodeEditorComponent} from './components/code-editor/code-editor.component';
import {UEditorModule} from "ngx-ueditor";
import {UeditorComponent} from './components/ueditor/ueditor.component';

@NgModule({
imports: [
CommonModule,
SharedModule,
HttpClientModule,
EruptRoutingModule,
NzCodeEditorModule
NzCodeEditorModule,
UEditorModule.forRoot({
js: [
'./assets/ueditor/ueditor.config.js',
'./assets/ueditor/ueditor.all.min.js',
],
// 默认前端配置项
options: {
UEDITOR_HOME_URL: './assets/ueditor/'
}
})
],
providers: [
DataHandlerService
Expand Down Expand Up @@ -60,7 +72,8 @@ import { CodeEditorComponent } from './components/code-editor/code-editor.compon
TableViewComponent,
TableComponent,
LayoutTreeComponent,
CodeEditorComponent
CodeEditorComponent,
UeditorComponent
]
})
export class EruptModule {
Expand Down
7 changes: 6 additions & 1 deletion src/app/build/erupt/model/erupt-field.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
AttachmentEnum,
ChoiceEnum,
DateEnum,
EditType,
EditType, HtmlEditTypeEnum,
SaveMode,
TabEnum,
ViewType
Expand Down Expand Up @@ -56,6 +56,7 @@ export interface Edit {
referenceTableType: ReferenceTableType;
attachmentType: AttachmentType;
autoCompleteType: AutoCompleteType;
htmlEditorType: HtmlEditorType;
boolType: BoolType;
choiceType: ChoiceType;
dateType: DateType;
Expand All @@ -71,6 +72,10 @@ export interface Edit {
$r_val?: any;
}

interface HtmlEditorType {
value: HtmlEditTypeEnum;
}

interface Search {
value: boolean;
vague: boolean;
Expand Down
9 changes: 8 additions & 1 deletion src/app/build/erupt/model/erupt.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class RestPath {
public static comp: string = RestPath.erupt + "/comp";
public static excel: string = RestPath.erupt + "/excel";
public static file: string = RestPath.erupt + "/file";
public static eruptAttachment: string = WindowModel.domain + "/erupt-attachment";
public static bi: string = RestPath.erupt + "/bi";
}

Expand All @@ -33,7 +34,7 @@ export enum EditType {
SLIDER = "SLIDER", //数字滑块
EMPTY = "EMPTY",
TPL = "TPL",
HTML_EDIT = "HTML_EDIT",
HTML_EDITOR = "HTML_EDITOR",
MAP = "MAP",
CODE_EDITOR = "CODE_EDITOR",
}
Expand All @@ -44,6 +45,12 @@ export enum TabEnum {
LIST_SELECT = "LIST_SELECT",
}

export enum HtmlEditTypeEnum {
CKEDITOR = "CKEDITOR",
UEDITOR = "UEDITOR",
// MARKDOWN = "MARKDOWN"
}

export enum ViewType {
TEXT = "TEXT",
LINK = "LINK",
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/model/window.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export class WindowModel {

public static domain: string = WindowModel.config["domain"] ? WindowModel.config["domain"] + "/" : '';

public static fileDomain: string = WindowModel.config["fileDomain"] || '';
public static fileDomain: string = WindowModel.config["fileDomain"] || undefined;

public static r_tools: CustomerTool[] = WindowModel.config["r_tools"] || [];

Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/service/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class DataService {
if (WindowModel.fileDomain) {
return WindowModel.fileDomain + "/" + path;
} else {
return RestPath.file + "/preview-attachment" + "/" + path;
return RestPath.eruptAttachment + "/" + path;
}
}

Expand Down
40 changes: 40 additions & 0 deletions ueditor/dialogs/anchor/anchor.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http:https://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<style type="text/css">
*{color: #838383;margin: 0;padding: 0}
html,body {font-size: 12px;overflow: hidden; }
.content{padding:5px 0 0 15px;}
input{width:210px;height:21px;line-height:21px;margin-left: 4px;}
</style>
</head>
<body>
<div class="content">
<span><var id="lang_input_anchorName"></var></span><input id="anchorName" value="" />
</div>
<script type="text/javascript" src="../internal.js"></script>
<script type="text/javascript">
var anchorInput = $G('anchorName'),
node = editor.selection.getRange().getClosedNode();
if(node && node.tagName == 'IMG' && (node = node.getAttribute('anchorname'))){
anchorInput.value = node;
}
anchorInput.onkeydown = function(evt){
evt = evt || window.event;
if(evt.keyCode == 13){
editor.execCommand('anchor', anchorInput.value);
dialog.close();
domUtils.preventDefault(evt)
}
};
dialog.onok = function (){
editor.execCommand('anchor', anchorInput.value);
dialog.close();
};
$focus(anchorInput);
</script>
</body>
</html>
Loading

0 comments on commit 3fb802f

Please sign in to comment.