清理未用到的quill编辑器

dev_aliyun2
harry 5 years ago
parent eb02258a54
commit 593cbfc1b8

@ -14019,6 +14019,24 @@
}
}
},
"showdown-katex": {
"version": "0.6.0",
"resolved": "https://registry.npm.taobao.org/showdown-katex/download/showdown-katex-0.6.0.tgz",
"integrity": "sha1-Jaq2qjH2DA/4aIwe2KcI6hgjqHQ=",
"requires": {
"katex": "^0.10.0"
},
"dependencies": {
"katex": {
"version": "0.10.2",
"resolved": "https://registry.npm.taobao.org/katex/download/katex-0.10.2.tgz",
"integrity": "sha1-OZc+27Ze2ltvnn9BZIeB5VfdSTI=",
"requires": {
"commander": "^2.19.0"
}
}
}
},
"signal-exit": {
"version": "3.0.2",
"resolved": "http://registry.npm.taobao.org/signal-exit/download/signal-exit-3.0.2.tgz",

@ -52,6 +52,7 @@
"rsuite": "^4.0.1",
"scroll-into-view": "^1.12.3",
"showdown": "^1.9.1",
"showdown-katex": "^0.6.0",
"store": "^2.0.12",
"styled-components": "^5.0.1",
"whatwg-fetch": "2.0.3",

@ -10,8 +10,6 @@ import './index.less';
import React, { useState } from 'react';
import { Form, Button, Input } from 'antd';
import QuillForEditor from '../../quillForEditor';
// import { QuillDeltaToHtmlConverter } from 'quill-delta-to-html'
// import {formatDelta} from './util';
const FormItem = Form.Item;
function CommentForm(props) {

@ -7,10 +7,6 @@
* @LastEditTime : 2019-12-27 11:05:17
*/
import './index.less';
import 'quill/dist/quill.core.css'; // 核心样式
import 'quill/dist/quill.snow.css'; // 有工具栏
import 'quill/dist/quill.bubble.css'; // 无工具栏
import 'katex/dist/katex.min.css'; // katex 表达式样式
import React, { useState } from 'react';
import CommentIcon from './CommentIcon';
import { getImageUrl, CNotificationHOC } from 'educoder'
@ -20,7 +16,6 @@ import QuillForEditor from '../../quillForEditor';
function CommentItem({
isAdmin,
options,
confirm,
comment,
submitDeleteComment,

@ -21,7 +21,6 @@ import ImageBlot from './ImageBlot';
import FillBlot from './FillBlot';
const Size = Quill.import('attributors/style/size');
const Font = Quill.import('formats/font');
// const Color = Quill.import('attributes/style/color');
Size.whitelist = ['12px', '14px', '16px', '18px', '20px', false];
Font.whitelist = ['SimSun', 'SimHei', 'Microsoft-YaHei', 'KaiTi', 'FangSong', 'Arial', 'Times-New-Roman', 'sans-serif'];
@ -30,11 +29,9 @@ window.katex = katex;
Quill.register(ImageBlot);
Quill.register(Size);
Quill.register(Font, true);
// Quill.register({'modules/toolbar': Toolbar});
Quill.register({
'formats/fill': FillBlot
});
// Quill.register(Color);
function QuillForEditor({

@ -1,20 +1,14 @@
import React, { Component } from "react";
import {
Form, Input, InputNumber, Switch, Radio,
Slider, Button, Upload, Icon, Rate, Checkbox, message,
Row, Col, Select, Modal, Tooltip
InputNumber, Tooltip
} from 'antd';
import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor';
import axios from 'axios'
import update from 'immutability-helper'
import {getUrl, ActionBtn, DMDEditor, ConditionToolTip} from 'educoder';
import { ActionBtn, DMDEditor, ConditionToolTip } from 'educoder';
import QuillForEditor from "../../../../common/quillForEditor";
const { TextArea } = Input;
const confirm = Modal.confirm;
const $ = window.$
const { Option } = Select;
const tagArray = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',

@ -7,16 +7,13 @@
* @LastEditTime : 2020-02-05 13:26:58
*/
import './index.less';
// import 'katex/dist/katex.css';
import React from 'react';
import { Form, Input, Select, InputNumber, Button, Cascader, notification } from 'antd';
import { connect } from 'react-redux';
import AddTestDemo from './AddTestDemo';
// import QuillEditor from '../../../quillEditor';
import actions from '../../../../../redux/actions';
import CONST from '../../../../../constants';
import { toStore } from 'educoder'; // 保存和读取store值
// import Wrapper from '../../../../../common/reactQuill';
import QuillForEditor from '../../../../../common/quillForEditor';
import KnowLedge from '../../../components/knowledge';
const scrollIntoView = require('scroll-into-view');
@ -462,17 +459,6 @@ class EditTab extends React.Component {
/>
</FormItem>
{/* <FormItem
className={`input_area flex_50 flex_50_right`}
label={<span>{myLabel(jcLabel['openOrNot'], '社区:您的任务将向整个社会公开')}</span>}
validateStatus={ojFormValidate.openOrNot.validateStatus}
help={ojFormValidate.openOrNot.errMsg}
colon={ false }
>
<Select onChange={this.handleChangeOpenOrNot} value={`${ojForm.openOrNot}`}>
{getOptions('openOrNot')}
</Select>
</FormItem> */}
</Form>

@ -1,183 +0,0 @@
<!--
* @Description:
* @Author: tangjiang
* @Github:
* @Date: 2019-11-25 09:46:10
* @LastEditors: tangjiang
* @LastEditTime: 2019-11-25 10:10:11
-->
## Quill配置
### 容器
- css 或者 DOM元素
```
const editor = new Quill(container)
```
### 配置项
var options = {
debug: 'info',
modules: {
toolbar: '#toolbar' // toolbar为一个代码块在页面中指定所需要的工具
},
placeholder: '', //
readOnly: false,
theme: 'snow'
}
const editor = new Quill('#editor', options);
- 对应的接口模型
```
export interface QuillOptionsStatic {
debug?: string | boolean;
modules: StringMap;
placeholder?: string;
readOnly?: boolean;
theme?: string;
formats?: string[];
bounds?: HTMLElement | string;
scrollingContainer?: HTMLElement | string;
strict?: boolean;
}
```
### 格式化
<br> Inline </br>
- background 背景色
- bold 粗体
- color 颜色
- font 字体
- code 内联代码
- italic 斜体
- link 链接
- size 大小
- strike 删除线
- script 上标/下标
- underline 下划线
<br> Block </br>
- blockquote 引用
- header 标题
- indent 缩进
- list 列表
- align 对齐方式
- direction 文字方向
- code-block 代码块
<br> Embeds </br>
- formula 公式 (需要 Katex)
- image 图片
- video 视频
### Quill 常用模块
- 工具栏
- 键盘
- 历史记录
- 剪贴板
- 语法高量
<b> 用法 </b>
> 工具栏模块 [toolbar](src="https://quilljs.com/docs/modules/toolbar/")
modules: {
toolbar: {
container: '#toolbar',
xx: {}
}
}
> 键盘模块 [keyboard](src="https://quilljs.com/docs/modules/keyboard/")
modules: {
keyboard: {
bindings: {
tab: {
key: 9,
handler: function () {}
}
}
}
}
> 历史模块
负责记录模块负责处理Quill的撤销和重做
modules: {
history: {
delay: 2000, // 在2000毫秒内的更改将被合并为单次更改
maxStack: 500, // 历史记录撤销/重做堆栈的大小
userOnly: true // 仅撤销或重做用户的更改
}
}
> 剪贴板模块
处理 Quill 和外部应用程序之间的复制
modules: {
clipboard: {
matchers: [
['B', xx]
]
}
}
> 语法高亮模块
语法高亮模块通过自动检测和应用语法突出显示来增强代码块格式。该模块依赖 [highlight.js](url="https://highlightjs.org/") 库用作解析和格式化代码块。
hljs.configure({ // optionally configure hljs
languages: ['javascript', 'ruby', 'python']
});
var quill = new Quill('#editor', {
modules: {
syntax: true, // Include syntax module
toolbar: [['code-block']] // Include button in toolbar
},
theme: 'snow'
});
> 模块扩展
Quill 中的模块可以被扩展和重新注册,从而替换原始模块
var Clipboard = Quill.import('modules/clipboard');
var Delta = Quill.import('delta');
class PlainClipboard extends Clipboard {
convert(html = null) {
if (typeof html === 'string') {
this.container.innerHTML = html;
}
let text = this.container.innerText;
this.container.innerHTML = '';
return new Delta().insert(text);
}
}
Quill.register('modules/clipboard', PlainClipboard, true);
// Will be created with instance of PlainClipboard
var quill = new Quill('#editor');

@ -1,134 +0,0 @@
/*
* @Description: Quill 编辑器
* @Author: tangjiang
* @Github:
* @Date: 2019-11-25 09:46:03
* @LastEditors: tangjiang
* @LastEditTime: 2019-12-10 16:10:23
*/
// import 'quill/dist/quill.core.css';
// import 'quill/dist/quill.bubble.css';
// import 'quill/dist/quill.snow.css';
// import 'katex/dist/katex.css';
import './index.less';
import 'katex/dist/katex.min.css';
import React from 'react';
import katex from 'katex';
const Quill = require('quill');
// 将katex挂载到window上
window.katex = katex;
window.Quill = Quill;
// const Quill = window.Quill;
// 指定 Quill 默认配置项
const defaultOptions = [
[{ header: [1, 2, 3, 4, 5, 6, false] }], // 自定义标题大小
['bold', 'italic', 'underline', 'strike'], // 切换按钮
['blockquote', 'code-block'], // 代码块
[{ 'list': 'ordered' }, { 'list': 'bullet' }], // 列表
[{ 'script': 'sub' }, { 'script': 'super' }], // 上标/下标
[{ 'indent': '-1' }, { 'indent': '+1' }], // 减少缩进/缩进
[{ 'direction': 'rtl' }],
[{ 'size': ['small', 'large', 'huge', false] }], // 用户自定义下拉
[{ 'color': [] }, { 'background': [] }], // 字体颜色与背景色
[{ 'font': [] }, { 'align': [] }], // 字体与对齐方式
['formula', 'image', 'video'], // 数学公式、图片、视频
['clean'], // 清除格式
];
/**
* @description 抽取一个React编辑器组件基于Quill
* @class QuillEditor类
* @param [object] props 接收的属性
* props: {
* options: {} // 编辑器配置信息, 不传使用 defaultOptions, 传了的话 使用用户自定义的,
* placeholder: '' // 编辑器提示信息
* innerHtml: '', // 编辑器内容
* onEditorChange: '', // 编辑器内容改变时调用此方法, 返回更改的内容
* }
* @return [stirng] content 返回编辑器内容
*/
class QuillEditor extends React.Component {
state = {
quillEditor: null,
// quillOptions: defaultOptions
}
constructor(props) {
super(props);
this.editorRef = React.createRef(null);
}
componentDidMount() {
const { options, placeholder = '', readOnly = false } = this.props;
let { quillEditor } = this.state;
// console.log(placeholder);
const renderOptions = options || defaultOptions;
const editorOption = {
placeholder: placeholder,
modules: {
toolbar: renderOptions
},
readOnly,
theme: readOnly ? 'bubble' : 'snow',
}
// 实例化 Quill 编辑器
quillEditor = new Quill(this.editorRef.current, editorOption);
this.setState({
quillEditor: quillEditor
});
// 开启一个定时器读取 html初始时, 如果没有最多执行10次后自动清
let count = 0;
this.timer = setInterval(() => {
count++;
if (count >= 10 || this.props.htmlCtx) {
quillEditor.container.firstChild.innerHTML = this.props.htmlCtx || '';
clearInterval(this.timer);
this.timer = null;
}
}, 50);
// quillEditor.setText('<p>aaa</p>');
quillEditor.on('editor-change', this.handleQuillChange);
// console.log('====>>>', quillEditor);
}
// 处理quill事件 editor-change
/**
* @param [string] eventName 事件名
* @param [object] args 参数
*/
handleQuillChange = (eventName, ...args) => {
const { onEditorChange } = this.props;
// 获取编辑器内容
const innerHTML = this.state.quillEditor.container.firstChild.innerHTML;
onEditorChange && onEditorChange(innerHTML);
// if ('text-change' === eventName) {
// const {delta, oldDelta, source} = args;
// console.log('textChange', delta, oldDelta, source);
// } else if ('selection-change' === eventName) {
// const {range, oldRange, source} = args;
// console.log('selectionChange', range, oldRange, source);
// }
}
componentWillUnmount() {
// 删除事件监听
this.state.quillEditor.off(this.handleQuillChange);
}
render() {
const styles = this.props.style || {}
return (
<div
id="quill_editor"
style={styles}
className={'quill_editor_area'}
ref={this.editorRef}>
</div>
);
}
}
export default QuillEditor;

@ -6,15 +6,12 @@
* @LastEditors : tangjiang
* @LastEditTime : 2020-01-02 14:23:43
*/
import React, { useState, useEffect } from 'react';
import React, { useState } from 'react';
import { connect } from 'react-redux';
import MyMonacoEditor from '../../components/myMonacoEditor';
import ControlSetting from '../../components/controlSetting';
import actions from '../../../../redux/actions';
// import QuillForEditor from '../../../../common/quillForEditor';
// import TextArea from 'antd/lib/input/TextArea';
import { Input, Form, Button } from 'antd';
// import FormItem from 'antd/lib/form/FormItem';
const { TextArea } = Input;
const FormItem = Form.Item;
const RightPane = (props) => {
@ -33,33 +30,16 @@ const RightPane = (props) => {
updateNotice,
saveUserInputCode,
restoreInitialCode,
// saveOpacityType,
saveUserCodeForInterval,
addNotes,
changeLoadingState
} = props;
// const [editorCode, setEditorCode] = useState(editor_code || hack.code);
const [noteClazz, setNoteClazz] = useState('editor_nodte_area');
const [noteCount] = useState(5000);
// const [code, setCode] = useState(editor_code || hack.code);
// let initFlag = true;
// useEffect(() => {
// if (editor_code) {
// setEditorCode(editor_code);
// } else {
// setEditorCode(hack.code);
// }
// }, [hack, editor_code]);
const handleSubmitForm = () => {
// 提交时, 先调用提交接口,提交成功后,循环调用测评接口
// saveOpacityType('submit');
submitUserCode(identifier, submitInput, 'submit');
// // 提交时,先调用评测接口, 评测通过后才调用保存接口
// updateCode(identifier, submitInput, 'submit');
}
let timer = null; // 定时器

@ -1,20 +1,8 @@
import React, { Component } from "react";
import {Link, NavLink} from 'react-router-dom';
import {WordsBtn, ActionBtn, getImageUrl, markdownToHTML} from 'educoder';
import axios from 'axios';
import { markdownToHTML } from 'educoder';
import {
notification,
Spin,
Table,
Pagination,
Drawer,
Input,
Button,
Breadcrumb,
Radio
} from "antd";
import Itembankstop from "./component/Itembankstop";
import NoneData from './component/NoneData';
import './questioncss/questioncom.css';
import '../tpm/newshixuns/css/Newshixuns.css';
import QuillForEditor from "../../common/quillForEditor";
@ -144,7 +132,8 @@ class Paperreview_single extends Component {
{
objectsingle.item_type === "PROGRAM" ?
<div className="w100s sortinxdirection">
<div className=" tites lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{wordBreak: "break-word",
<div className=" tites lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{
wordBreak: "break-word",
minWidth: "32px"
}}
>
@ -157,7 +146,8 @@ class Paperreview_single extends Component {
</div>
:
<div className="w100s sortinxdirection">
<div className="tites lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{wordBreak: "break-word",
<div className="tites lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{
wordBreak: "break-word",
minWidth: "32px"
}}
>

@ -1,20 +1,10 @@
import React, { Component } from "react";
import {
Form, Input, InputNumber, Switch, Radio,
Slider, Button, Upload, Icon, Rate, Checkbox, message,
Row, Col, Select, Modal, Tooltip
} from 'antd';
import TPMMDEditor from '../../../modules/tpm/challengesnew/TPMMDEditor';
import axios from 'axios'
import { Tooltip } from 'antd';
import update from 'immutability-helper'
import './../questioncss/questioncom.css';
import {getUrl, ActionBtn, DMDEditor, ConditionToolTip} from 'educoder';
import { ConditionToolTip } from 'educoder';
import QuillForEditor from '../../../common/quillForEditor';
const { TextArea } = Input;
const confirm = Modal.confirm;
const $ = window.$
const { Option } = Select;
const tagArray = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',

@ -1,22 +1,10 @@
import React, { Component } from "react";
import {
Form, Input, InputNumber, Switch, Radio,
Slider, Button, Upload, Icon, Rate, Checkbox, message,
Row, Col, Select, Modal, Tooltip
} from 'antd';
import TPMMDEditor from '../../../modules/tpm/challengesnew/TPMMDEditor';
import axios from 'axios'
import { Radio } from 'antd';
import update from 'immutability-helper'
import './../questioncss/questioncom.css';
import {getUrl, ActionBtn, DMDEditor, ConditionToolTip} from 'educoder';
import QuillForEditor from '../../../common/quillForEditor';
const { TextArea } = Input;
const confirm = Modal.confirm;
const $ = window.$
const { Option } = Select;
const tagArray = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',

@ -1,12 +1,6 @@
import React, { Component } from "react";
import {Link, NavLink} from 'react-router-dom';
import {WordsBtn, ActionBtn, SnackbarHOC, getImageUrl, markdownToHTML} from 'educoder';
import axios from 'axios';
import { markdownToHTML } from 'educoder';
import {
notification,
Spin,
Table,
Pagination,
Radio,
Tooltip
} from "antd";

@ -1,21 +1,10 @@
import React, { Component } from "react";
import {
Form, Input, InputNumber, Switch, Radio,
Slider, Button, Upload, Icon, Rate, Checkbox, message,
Row, Col, Select, Modal, Tooltip
} from 'antd';
import { Tooltip } from 'antd';
import QuillForEditor from '../../../common/quillForEditor';
import TPMMDEditor from '../../../modules/tpm/challengesnew/TPMMDEditor';
import axios from 'axios'
import update from 'immutability-helper'
import './../questioncss/questioncom.css';
import {getUrl, ActionBtn, DMDEditor, ConditionToolTip} from 'educoder';
const { TextArea } = Input;
const confirm = Modal.confirm;
const $ = window.$
const { Option } = Select;
import { ConditionToolTip } from 'educoder';
const tagArray = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',

@ -1,16 +1,6 @@
import React, { Component } from "react";
import {Link, NavLink} from 'react-router-dom';
import {WordsBtn, ActionBtn, getImageUrl, markdownToHTML} from 'educoder';
import axios from 'axios';
import { markdownToHTML } from 'educoder';
import {
notification,
Spin,
Table,
Pagination,
Drawer,
Input,
Button,
Breadcrumb,
Radio
} from "antd";
import '../testioncss/testioncss.css';
@ -140,7 +130,8 @@ class Paperlibraryseeid_items extends Component {
{
objectsingle.item_type === "PROGRAM" ?
<div className="w100s sortinxdirection">
<div className=" tites lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{wordBreak: "break-word",
<div className=" tites lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{
wordBreak: "break-word",
minWidth: "32px"
}}
>
@ -153,8 +144,10 @@ class Paperlibraryseeid_items extends Component {
</div>
:
<div className="w100s sortinxdirection">
<div className="tites lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{wordBreak: "break-word",
minWidth:"32px"}}
<div className="tites lh28 listjihetixingstit markdown-body cretitlecolrlist " style={{
wordBreak: "break-word",
minWidth: "32px"
}}
>
({objectsingle.score})
</div>

Loading…
Cancel
Save