forked from mirror/MrDoc
文档编辑器添加按钮禁用逻辑,优化整合代码
This commit is contained in:
parent
51ae03481b
commit
478680ebfb
@ -13,7 +13,7 @@ import shutil
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
sys.path.extend([r'F:\pythonproject\MrDoc',])
|
||||
sys.path.extend([settings.BASE_DIR])
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE","MrDoc.settings")
|
||||
application = get_wsgi_application()
|
||||
import django
|
||||
@ -23,16 +23,30 @@ import traceback
|
||||
import time
|
||||
from pyppeteer import launch
|
||||
import asyncio
|
||||
from loguru import logger
|
||||
# import PyPDF2
|
||||
# from pdfminer import high_level
|
||||
|
||||
# 动态脑图转静态图片
|
||||
def genera_mindmap_img(html_path,img_path):
|
||||
# JS动态图形转静态图片
|
||||
@logger.catch()
|
||||
def geneta_js_img(html_path,img_path,types):
|
||||
'''
|
||||
:param html_path: HTML源文件路径
|
||||
:param img_path: 保存的静态图片路径
|
||||
:param type: 转换的类型,有mindmap、tex、flowchart、seque四种
|
||||
:return:
|
||||
'''
|
||||
type_map = {
|
||||
'mindmap':'.mindmap', # 脑图
|
||||
'tex':'.editormd-tex', # 科学公式
|
||||
'flowchart':'.flowchart', # 流程图
|
||||
'seque':'.sequence-diagram' # 序列图
|
||||
}
|
||||
async def main():
|
||||
browser = await launch(headless=True,handleSIGINT=False,handleSIGTERM=False,handleSIGHUP=False)
|
||||
page = await browser.newPage()
|
||||
await page.goto('file://' + html_path, {'waitUntil': 'networkidle0'})
|
||||
element = await page.querySelector('.mindmap')
|
||||
element = await page.querySelector(type_map[types])
|
||||
await element.screenshot({'type': 'jpeg', 'quality': 100, 'path': img_path})
|
||||
await browser.close()
|
||||
|
||||
@ -42,68 +56,14 @@ def genera_mindmap_img(html_path,img_path):
|
||||
loop = asyncio.get_event_loop()
|
||||
try:
|
||||
loop.run_until_complete(main())
|
||||
finally:
|
||||
loop.close()
|
||||
|
||||
|
||||
# 公式转图片
|
||||
def genera_tex_img(html_path,img_path):
|
||||
async def main():
|
||||
browser = await launch(headless=True,handleSIGINT=False,handleSIGTERM=False,handleSIGHUP=False)
|
||||
page = await browser.newPage()
|
||||
await page.goto('file://' + html_path, {'waitUntil': 'networkidle0'})
|
||||
element = await page.querySelector('.editormd-tex')
|
||||
await element.screenshot({'type': 'jpeg', 'quality': 100, 'path': img_path})
|
||||
await browser.close()
|
||||
|
||||
# asyncio.new_event_loop().run_until_complete(main())
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
loop = asyncio.get_event_loop()
|
||||
try:
|
||||
except:
|
||||
loop.run_until_complete(main())
|
||||
finally:
|
||||
loop.close()
|
||||
|
||||
# 流程图转图片
|
||||
def genera_flowchart_img(html_path,img_path):
|
||||
async def main():
|
||||
browser = await launch(headless=True,handleSIGINT=False,handleSIGTERM=False,handleSIGHUP=False)
|
||||
page = await browser.newPage()
|
||||
await page.goto('file://' + html_path, {'waitUntil': 'networkidle0'})
|
||||
element = await page.querySelector('.flowchart')
|
||||
await element.screenshot({'type': 'jpeg', 'quality': 100, 'path': img_path})
|
||||
await browser.close()
|
||||
|
||||
# asyncio.new_event_loop().run_until_complete(main())
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
loop = asyncio.get_event_loop()
|
||||
try:
|
||||
loop.run_until_complete(main())
|
||||
finally:
|
||||
loop.close()
|
||||
|
||||
# 时序图转图片
|
||||
def genera_seque_img(html_path,img_path):
|
||||
async def main():
|
||||
browser = await launch(headless=True,handleSIGINT=False,handleSIGTERM=False,handleSIGHUP=False)
|
||||
page = await browser.newPage()
|
||||
await page.goto('file://' + html_path, {'waitUntil': 'networkidle0'})
|
||||
element = await page.querySelector('.sequence-diagram')
|
||||
await element.screenshot({'type': 'jpeg', 'quality': 100, 'path': img_path})
|
||||
await browser.close()
|
||||
|
||||
# asyncio.new_event_loop().run_until_complete(main())
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
loop = asyncio.get_event_loop()
|
||||
try:
|
||||
loop.run_until_complete(main())
|
||||
finally:
|
||||
loop.close()
|
||||
|
||||
# HTML转PDF
|
||||
@logger.catch()
|
||||
def html_to_pdf(html_path,pdf_path):
|
||||
async def main():
|
||||
browser = await launch(
|
||||
@ -127,7 +87,6 @@ def html_to_pdf(html_path,pdf_path):
|
||||
'bottom':'1cm',
|
||||
'left':'1cm'
|
||||
}
|
||||
|
||||
})
|
||||
await browser.close()
|
||||
|
||||
@ -141,7 +100,9 @@ def html_to_pdf(html_path,pdf_path):
|
||||
finally:
|
||||
loop.close()
|
||||
|
||||
|
||||
# 导出MD文件压缩包
|
||||
@logger.catch()
|
||||
class ReportMD():
|
||||
def __init__(self,project_id):
|
||||
# 查询文集信息
|
||||
@ -253,6 +214,7 @@ class ReportMD():
|
||||
|
||||
|
||||
# 导出EPUB
|
||||
@logger.catch()
|
||||
class ReportEPUB():
|
||||
def __init__(self,project_id):
|
||||
self.project = Project.objects.get(id=project_id)
|
||||
@ -319,7 +281,7 @@ class ReportEPUB():
|
||||
|
||||
# 替换HTML文本中的脑图为静态图片
|
||||
for mindmap in mindmap_tag:
|
||||
print('转换脑图')
|
||||
# print('转换脑图')
|
||||
html_str = '''<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@ -346,9 +308,14 @@ class ReportEPUB():
|
||||
temp_mindmap_html = settings.BASE_DIR +'/media/report_epub/mindmap_{}.html'.format(str(time.time()))
|
||||
mindmap_img_filename = 'mindmap_{}.jpg'.format(str(time.time()))
|
||||
mindmap_img_path = self.base_path + '/OEBPS/Images/' + mindmap_img_filename
|
||||
|
||||
# 写入临时HTML文件
|
||||
with open(temp_mindmap_html,'w+',encoding='utf-8') as mindmap_html:
|
||||
mindmap_html.write(html_str)
|
||||
genera_mindmap_img(temp_mindmap_html,mindmap_img_path)
|
||||
|
||||
# 生成静态图片
|
||||
geneta_js_img(temp_mindmap_html,mindmap_img_path,'mindmap')
|
||||
|
||||
# 将图片标签设置进去
|
||||
mindmap.name = 'img'
|
||||
mindmap['src'] = '../Images/' + mindmap_img_filename
|
||||
@ -357,7 +324,7 @@ class ReportEPUB():
|
||||
|
||||
# 替换公式为静态图片
|
||||
for tex in tex_tag:
|
||||
print('转换公式')
|
||||
# print('转换公式')
|
||||
html_str = '''<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@ -385,9 +352,13 @@ class ReportEPUB():
|
||||
temp_tex_html = settings.BASE_DIR + '/media/report_epub/tex_{}.html'.format(str(time.time()))
|
||||
tex_img_filename = 'tex_{}.jpg'.format(str(time.time()))
|
||||
tex_img_path = self.base_path + '/OEBPS/Images/' + tex_img_filename
|
||||
|
||||
with open(temp_tex_html, 'w+', encoding='utf-8') as tex_html:
|
||||
tex_html.write(html_str)
|
||||
genera_tex_img(temp_tex_html, tex_img_path)
|
||||
|
||||
# 生成静态图片
|
||||
geneta_js_img(temp_tex_html, tex_img_path,'tex')
|
||||
|
||||
# 将图片标签添加进去
|
||||
# tex.name = 'img'
|
||||
# tex['src'] = '../Images/' + tex_img_filename
|
||||
@ -398,7 +369,7 @@ class ReportEPUB():
|
||||
|
||||
# 替换流程图为静态图片
|
||||
for flowchart in flowchart_tag:
|
||||
print("转换流程图")
|
||||
# print("转换流程图")
|
||||
html_str = '''<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@ -425,9 +396,13 @@ class ReportEPUB():
|
||||
temp_flow_html = settings.BASE_DIR + '/media/report_epub/flow_{}.html'.format(str(time.time()))
|
||||
flow_img_filename = 'flow_{}.jpg'.format(str(time.time()))
|
||||
flow_img_path = self.base_path + '/OEBPS/Images/' + flow_img_filename
|
||||
|
||||
with open(temp_flow_html, 'w+', encoding='utf-8') as flow_html:
|
||||
flow_html.write(html_str)
|
||||
genera_flowchart_img(temp_flow_html, flow_img_path)
|
||||
|
||||
# 生成静态图片
|
||||
geneta_js_img(temp_flow_html, flow_img_path,'flowchart')
|
||||
|
||||
# 将图片标签添加进去
|
||||
flowchart.string = ''
|
||||
flow_img_tag = html_soup.new_tag(name='img', src='../Images/' + flow_img_filename)
|
||||
@ -436,7 +411,7 @@ class ReportEPUB():
|
||||
|
||||
# 替换时序图为静态图片
|
||||
for seque in seque_tag:
|
||||
print("转换时序图")
|
||||
# print("转换时序图")
|
||||
html_str = '''<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@ -464,7 +439,10 @@ class ReportEPUB():
|
||||
seque_img_path = self.base_path + '/OEBPS/Images/' + seque_img_filename
|
||||
with open(temp_seque_html, 'w+', encoding='utf-8') as seque_html:
|
||||
seque_html.write(html_str)
|
||||
genera_seque_img(temp_seque_html, seque_img_path)
|
||||
|
||||
# 生成静态图片
|
||||
geneta_js_img(temp_seque_html, seque_img_path, 'seque')
|
||||
|
||||
# 将图片标签添加进去
|
||||
seque.string = ''
|
||||
seque_img_tag = html_soup.new_tag(name='img', src='../Images/' + seque_img_filename)
|
||||
@ -828,6 +806,7 @@ class ReportEPUB():
|
||||
|
||||
|
||||
# 导出PDF
|
||||
@logger.catch()
|
||||
class ReportPDF():
|
||||
def __init__(self,project_id):
|
||||
# 查询文集信息
|
||||
@ -1148,6 +1127,7 @@ class ReportDocx():
|
||||
with open(temp_file_path, 'a+', encoding='utf-8') as htmlfile:
|
||||
htmlfile.write(self.doc_str + self.content_str + "</body></html>")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# app = ReportMD(
|
||||
# project_id=7
|
||||
|
982
app_doc/views.py
982
app_doc/views.py
File diff suppressed because it is too large
Load Diff
2
static/autoc/autoc.min.js
vendored
2
static/autoc/autoc.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,342 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var os = require("os");
|
||||
var gulp = require("gulp");
|
||||
var gutil = require("gulp-util");
|
||||
var sass = require("gulp-ruby-sass");
|
||||
var jshint = require("gulp-jshint");
|
||||
var uglify = require("gulp-uglifyjs");
|
||||
var rename = require("gulp-rename");
|
||||
var concat = require("gulp-concat");
|
||||
var notify = require("gulp-notify");
|
||||
var header = require("gulp-header");
|
||||
var minifycss = require("gulp-minify-css");
|
||||
//var jsdoc = require("gulp-jsdoc");
|
||||
//var jsdoc2md = require("gulp-jsdoc-to-markdown");
|
||||
var pkg = require("./package.json");
|
||||
var dateFormat = require("dateformatter").format;
|
||||
var replace = require("gulp-replace");
|
||||
|
||||
pkg.name = "Editor.md";
|
||||
pkg.today = dateFormat;
|
||||
|
||||
var headerComment = ["/*",
|
||||
" * <%= pkg.name %>",
|
||||
" *",
|
||||
" * @file <%= fileName(file) %> ",
|
||||
" * @version v<%= pkg.version %> ",
|
||||
" * @description <%= pkg.description %>",
|
||||
" * @license MIT License",
|
||||
" * @author <%= pkg.author %>",
|
||||
" * {@link <%= pkg.homepage %>}",
|
||||
" * @updateTime <%= pkg.today('Y-m-d') %>",
|
||||
" */",
|
||||
"\r\n"].join("\r\n");
|
||||
|
||||
var headerMiniComment = "/*! <%= pkg.name %> v<%= pkg.version %> | <%= fileName(file) %> | <%= pkg.description %> | MIT License | By: <%= pkg.author %> | <%= pkg.homepage %> | <%=pkg.today('Y-m-d') %> */\r\n";
|
||||
|
||||
var scssTask = function(fileName, path) {
|
||||
|
||||
path = path || "scss/";
|
||||
|
||||
var distPath = "css";
|
||||
|
||||
return sass(path + fileName + ".scss", { style: "expanded", sourcemap: false, noCache : true })
|
||||
.pipe(gulp.dest(distPath))
|
||||
.pipe(header(headerComment, {pkg : pkg, fileName : function(file) {
|
||||
var name = file.path.split(file.base);
|
||||
return name[1].replace("\\", "");
|
||||
}}))
|
||||
.pipe(gulp.dest(distPath))
|
||||
.pipe(rename({ suffix: ".min" }))
|
||||
.pipe(gulp.dest(distPath))
|
||||
.pipe(minifycss())
|
||||
.pipe(gulp.dest(distPath))
|
||||
.pipe(header(headerMiniComment, {pkg : pkg, fileName : function(file) {
|
||||
var name = file.path.split(file.base);
|
||||
return name[1].replace("\\", "");
|
||||
}}))
|
||||
.pipe(gulp.dest(distPath))
|
||||
.pipe(notify({ message: fileName + ".scss task completed!" }));
|
||||
};
|
||||
|
||||
gulp.task("scss", function() {
|
||||
return scssTask("editormd");
|
||||
});
|
||||
|
||||
gulp.task("scss2", function() {
|
||||
return scssTask("editormd.preview");
|
||||
});
|
||||
|
||||
gulp.task("scss3", function() {
|
||||
return scssTask("editormd.logo");
|
||||
});
|
||||
|
||||
gulp.task("js", function() {
|
||||
return gulp.src("./src/editormd.js")
|
||||
.pipe(jshint("./.jshintrc"))
|
||||
.pipe(jshint.reporter("default"))
|
||||
.pipe(header(headerComment, {pkg : pkg, fileName : function(file) {
|
||||
var name = file.path.split(file.base);
|
||||
return name[1].replace(/[\\\/]?/, "");
|
||||
}}))
|
||||
.pipe(gulp.dest("./"))
|
||||
.pipe(rename({ suffix: ".min" }))
|
||||
.pipe(uglify()) // {outSourceMap: true, sourceRoot: './'}
|
||||
.pipe(gulp.dest("./"))
|
||||
.pipe(header(headerMiniComment, {pkg : pkg, fileName : function(file) {
|
||||
var name = file.path.split(file.base + ( (os.platform() === "win32") ? "\\" : "/") );
|
||||
return name[1].replace(/[\\\/]?/, "");
|
||||
}}))
|
||||
.pipe(gulp.dest("./"))
|
||||
.pipe(notify({ message: "editormd.js task complete" }));
|
||||
});
|
||||
|
||||
gulp.task("amd", function() {
|
||||
var replaceText1 = [
|
||||
'var cmModePath = "codemirror/mode/";',
|
||||
' var cmAddonPath = "codemirror/addon/";',
|
||||
'',
|
||||
' var codeMirrorModules = [',
|
||||
' "jquery", "marked", "prettify",',
|
||||
' "katex", "raphael", "underscore", "flowchart", "jqueryflowchart", "sequenceDiagram",',
|
||||
'',
|
||||
' "codemirror/lib/codemirror",',
|
||||
' cmModePath + "css/css",',
|
||||
' cmModePath + "sass/sass",',
|
||||
' cmModePath + "shell/shell",',
|
||||
' cmModePath + "sql/sql",',
|
||||
' cmModePath + "clike/clike",',
|
||||
' cmModePath + "php/php",',
|
||||
' cmModePath + "xml/xml",',
|
||||
' cmModePath + "markdown/markdown",',
|
||||
' cmModePath + "javascript/javascript",',
|
||||
' cmModePath + "htmlmixed/htmlmixed",',
|
||||
' cmModePath + "gfm/gfm",',
|
||||
' cmModePath + "http/http",',
|
||||
' cmModePath + "go/go",',
|
||||
' cmModePath + "dart/dart",',
|
||||
' cmModePath + "coffeescript/coffeescript",',
|
||||
' cmModePath + "nginx/nginx",',
|
||||
' cmModePath + "python/python",',
|
||||
' cmModePath + "perl/perl",',
|
||||
' cmModePath + "lua/lua",',
|
||||
' cmModePath + "r/r", ',
|
||||
' cmModePath + "ruby/ruby", ',
|
||||
' cmModePath + "rst/rst",',
|
||||
' cmModePath + "smartymixed/smartymixed",',
|
||||
' cmModePath + "vb/vb",',
|
||||
' cmModePath + "vbscript/vbscript",',
|
||||
' cmModePath + "velocity/velocity",',
|
||||
' cmModePath + "xquery/xquery",',
|
||||
' cmModePath + "yaml/yaml",',
|
||||
' cmModePath + "erlang/erlang",',
|
||||
' cmModePath + "jade/jade",',
|
||||
'',
|
||||
' cmAddonPath + "edit/trailingspace", ',
|
||||
' cmAddonPath + "dialog/dialog", ',
|
||||
' cmAddonPath + "search/searchcursor", ',
|
||||
' cmAddonPath + "search/search", ',
|
||||
' cmAddonPath + "scroll/annotatescrollbar", ',
|
||||
' cmAddonPath + "search/matchesonscrollbar", ',
|
||||
' cmAddonPath + "display/placeholder", ',
|
||||
' cmAddonPath + "edit/closetag", ',
|
||||
' cmAddonPath + "fold/foldcode",',
|
||||
' cmAddonPath + "fold/foldgutter",',
|
||||
' cmAddonPath + "fold/indent-fold",',
|
||||
' cmAddonPath + "fold/brace-fold",',
|
||||
' cmAddonPath + "fold/xml-fold", ',
|
||||
' cmAddonPath + "fold/markdown-fold",',
|
||||
' cmAddonPath + "fold/comment-fold", ',
|
||||
' cmAddonPath + "mode/overlay", ',
|
||||
' cmAddonPath + "selection/active-line", ',
|
||||
' cmAddonPath + "edit/closebrackets", ',
|
||||
' cmAddonPath + "display/fullscreen",',
|
||||
' cmAddonPath + "search/match-highlighter"',
|
||||
' ];',
|
||||
'',
|
||||
' define(codeMirrorModules, factory);'
|
||||
].join("\r\n");
|
||||
|
||||
var replaceText2 = [
|
||||
"if (typeof define == \"function\" && define.amd) {",
|
||||
" $ = arguments[0];",
|
||||
" marked = arguments[1];",
|
||||
" prettify = arguments[2];",
|
||||
" katex = arguments[3];",
|
||||
" Raphael = arguments[4];",
|
||||
" _ = arguments[5];",
|
||||
" flowchart = arguments[6];",
|
||||
" CodeMirror = arguments[9];",
|
||||
" }"
|
||||
].join("\r\n");
|
||||
|
||||
gulp.src("src/editormd.js")
|
||||
.pipe(rename({ suffix: ".amd" }))
|
||||
.pipe(gulp.dest('./'))
|
||||
.pipe(header(headerComment, {pkg : pkg, fileName : function(file) {
|
||||
var name = file.path.split(file.base);
|
||||
return name[1].replace(/[\\\/]?/, "");
|
||||
}}))
|
||||
.pipe(gulp.dest("./"))
|
||||
.pipe(replace("/* Require.js define replace */", replaceText1))
|
||||
.pipe(gulp.dest('./'))
|
||||
.pipe(replace("/* Require.js assignment replace */", replaceText2))
|
||||
.pipe(gulp.dest('./'))
|
||||
.pipe(rename({ suffix: ".min" }))
|
||||
.pipe(uglify()) //{outSourceMap: true, sourceRoot: './'}
|
||||
.pipe(gulp.dest("./"))
|
||||
.pipe(header(headerMiniComment, {pkg : pkg, fileName : function(file) {
|
||||
var name = file.path.split(file.base + ( (os.platform() === "win32") ? "\\" : "/") );
|
||||
return name[1].replace(/[\\\/]?/, "");
|
||||
}}))
|
||||
.pipe(gulp.dest("./"))
|
||||
.pipe(notify({ message: "amd version task complete"}));
|
||||
});
|
||||
|
||||
|
||||
var codeMirror = {
|
||||
path : {
|
||||
src : {
|
||||
mode : "lib/codemirror/mode",
|
||||
addon : "lib/codemirror/addon"
|
||||
},
|
||||
dist : "lib/codemirror"
|
||||
},
|
||||
modes : [
|
||||
"css",
|
||||
"sass",
|
||||
"shell",
|
||||
"sql",
|
||||
"clike",
|
||||
"php",
|
||||
"xml",
|
||||
"markdown",
|
||||
"javascript",
|
||||
"htmlmixed",
|
||||
"gfm",
|
||||
"http",
|
||||
"go",
|
||||
"dart",
|
||||
"coffeescript",
|
||||
"nginx",
|
||||
"python",
|
||||
"perl",
|
||||
"lua",
|
||||
"r",
|
||||
"ruby",
|
||||
"rst",
|
||||
"smartymixed",
|
||||
"vb",
|
||||
"vbscript",
|
||||
"velocity",
|
||||
"xquery",
|
||||
"yaml",
|
||||
"erlang",
|
||||
"jade",
|
||||
],
|
||||
|
||||
addons : [
|
||||
"edit/trailingspace",
|
||||
"dialog/dialog",
|
||||
"search/searchcursor",
|
||||
"search/search",
|
||||
"scroll/annotatescrollbar",
|
||||
"search/matchesonscrollbar",
|
||||
"display/placeholder",
|
||||
"edit/closetag",
|
||||
"fold/foldcode",
|
||||
"fold/foldgutter",
|
||||
"fold/indent-fold",
|
||||
"fold/brace-fold",
|
||||
"fold/xml-fold",
|
||||
"fold/markdown-fold",
|
||||
"fold/comment-fold",
|
||||
"mode/overlay",
|
||||
"selection/active-line",
|
||||
"edit/closebrackets",
|
||||
"display/fullscreen",
|
||||
"search/match-highlighter"
|
||||
]
|
||||
};
|
||||
|
||||
gulp.task("cm-mode", function() {
|
||||
|
||||
var modes = [
|
||||
codeMirror.path.src.mode + "/meta.js"
|
||||
];
|
||||
|
||||
for(var i in codeMirror.modes) {
|
||||
var mode = codeMirror.modes[i];
|
||||
modes.push(codeMirror.path.src.mode + "/" + mode + "/" + mode + ".js");
|
||||
}
|
||||
|
||||
return gulp.src(modes)
|
||||
.pipe(concat("modes.min.js"))
|
||||
.pipe(gulp.dest(codeMirror.path.dist))
|
||||
.pipe(uglify()) // {outSourceMap: true, sourceRoot: codeMirror.path.dist}
|
||||
.pipe(gulp.dest(codeMirror.path.dist))
|
||||
.pipe(header(headerMiniComment, {pkg : pkg, fileName : function(file) {
|
||||
var name = file.path.split(file.base + "\\");
|
||||
return (name[1]?name[1]:name[0]).replace(/\\/g, "");
|
||||
}}))
|
||||
.pipe(gulp.dest(codeMirror.path.dist))
|
||||
.pipe(notify({ message: "codemirror-mode task complete!" }));
|
||||
});
|
||||
|
||||
gulp.task("cm-addon", function() {
|
||||
|
||||
var addons = [];
|
||||
|
||||
for(var i in codeMirror.addons) {
|
||||
var addon = codeMirror.addons[i];
|
||||
addons.push(codeMirror.path.src.addon + "/" + addon + ".js");
|
||||
}
|
||||
|
||||
return gulp.src(addons)
|
||||
.pipe(concat("addons.min.js"))
|
||||
.pipe(gulp.dest(codeMirror.path.dist))
|
||||
.pipe(uglify()) //{outSourceMap: true, sourceRoot: codeMirror.path.dist}
|
||||
.pipe(gulp.dest(codeMirror.path.dist))
|
||||
.pipe(header(headerMiniComment, {pkg : pkg, fileName : function(file) {
|
||||
var name = file.path.split(file.base + "\\");
|
||||
return (name[1]?name[1]:name[0]).replace(/\\/g, "");
|
||||
}}))
|
||||
.pipe(gulp.dest(codeMirror.path.dist))
|
||||
.pipe(notify({ message: "codemirror-addon.js task complete" }));
|
||||
});
|
||||
/*
|
||||
gulp.task("jsdoc", function(){
|
||||
return gulp.src(["./src/editormd.js", "README.md"])
|
||||
.pipe(jsdoc.parser())
|
||||
.pipe(jsdoc.generator("./docs/html"));
|
||||
});
|
||||
|
||||
gulp.task("jsdoc2md", function() {
|
||||
return gulp.src("src/js/editormd.js")
|
||||
.pipe(jsdoc2md())
|
||||
.on("error", function(err){
|
||||
gutil.log(gutil.colors.red("jsdoc2md failed"), err.message);
|
||||
})
|
||||
.pipe(rename(function(path) {
|
||||
path.extname = ".md";
|
||||
}))
|
||||
.pipe(gulp.dest("docs/markdown"));
|
||||
});
|
||||
*/
|
||||
gulp.task("watch", function() {
|
||||
gulp.watch("scss/editormd.scss", ["scss"]);
|
||||
gulp.watch("scss/editormd.preview.scss", ["scss", "scss2"]);
|
||||
gulp.watch("scss/editormd.logo.scss", ["scss", "scss3"]);
|
||||
gulp.watch("src/editormd.js", ["js", "amd"]);
|
||||
});
|
||||
|
||||
gulp.task("default", function() {
|
||||
gulp.run("scss");
|
||||
gulp.run("scss2");
|
||||
gulp.run("scss3");
|
||||
gulp.run("js");
|
||||
gulp.run("amd");
|
||||
gulp.run("cm-addon");
|
||||
gulp.run("cm-mode");
|
||||
});
|
File diff suppressed because it is too large
Load Diff
4
static/editor.md/editormd.amd.min.js
vendored
4
static/editor.md/editormd.amd.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1519,7 +1519,6 @@
|
||||
var mmap = $(this);
|
||||
var md_data = window.markmap.transform(mmap.text().trim());
|
||||
window.markmap.markmap("svg#"+this.id,md_data)
|
||||
//drawMindMap(mmap[0]) // kityminder的实现
|
||||
});
|
||||
|
||||
return this;
|
||||
|
File diff suppressed because it is too large
Load Diff
36659
static/mindmap/markmap.js
Normal file
36659
static/mindmap/markmap.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -164,6 +164,7 @@
|
||||
<script src="{% static 'mindmap/d3@5.js' %}"></script>
|
||||
<script src="{% static 'mindmap/transform.js' %}"></script>
|
||||
<script src="{% static 'mindmap/view.js' %}"></script>
|
||||
<!-- <script src="{% static 'mindmap/markmap.js' %}"></script> -->
|
||||
<!-- 脑图结束 -->
|
||||
<script src="{% static 'editor.md/editormd.js' %}"></script>
|
||||
<!-- <script src="{% static 'editor.md/editormd.min.js' %}"></script> -->
|
||||
|
@ -197,6 +197,8 @@
|
||||
};
|
||||
//发布文档
|
||||
createDoc = function(){
|
||||
$('button.layui-btn').attr("disabled",true);
|
||||
$('button.layui-btn').addClass('layui-btn-disabled');
|
||||
var data = {
|
||||
'project':$("#project").val(),
|
||||
'parent_doc':$("#parent-doc").val(),
|
||||
@ -209,9 +211,13 @@
|
||||
console.log(data)
|
||||
if(data.doc_name == ""){
|
||||
layer.msg('请输入文档标题!');
|
||||
$('button.layui-btn').attr("disabled",false);
|
||||
$('button.layui-btn').removeClass('layui-btn-disabled');
|
||||
}
|
||||
else if(data.project == ""){
|
||||
layer.msg('请选择文集!');
|
||||
$('button.layui-btn').attr("disabled",false);
|
||||
$('button.layui-btn').removeClass('layui-btn-disabled');
|
||||
}
|
||||
else{
|
||||
//发布按钮设为禁用
|
||||
@ -231,13 +237,16 @@
|
||||
layer.closeAll("loading"); //关闭加载层
|
||||
layer.msg('发布文档失败:'+r.data);
|
||||
//恢复按钮状态
|
||||
$("#create_doc").removeAttr("disabled");
|
||||
$('button.layui-btn').attr("disabled",false);
|
||||
$('button.layui-btn').removeClass('layui-btn-disabled');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
//保存草稿
|
||||
saveDoc = function(){
|
||||
$('button.layui-btn').attr("disabled",true);
|
||||
$('button.layui-btn').addClass('layui-btn-disabled');
|
||||
var data = {
|
||||
'project':$("#project").val(),
|
||||
'parent_doc':$("#parent-doc").val(),
|
||||
@ -250,12 +259,16 @@
|
||||
console.log(data)
|
||||
if(data.doc_name == ""){
|
||||
layer.msg('请输入文档标题!');
|
||||
$('button.layui-btn').attr("disabled",false);
|
||||
$('button.layui-btn').removeClass('layui-btn-disabled');
|
||||
}
|
||||
else if(data.project == ""){
|
||||
layer.msg('请选择文集!');
|
||||
$('button.layui-btn').attr("disabled",false);
|
||||
$('button.layui-btn').removeClass('layui-btn-disabled');
|
||||
}
|
||||
else{
|
||||
layer.load();
|
||||
layer.load(1);
|
||||
$.post("{% url 'create_doc' %}",data,function(r){
|
||||
if(r.status){
|
||||
//保存成功
|
||||
@ -268,6 +281,8 @@
|
||||
//创建失败
|
||||
layer.closeAll("loading");
|
||||
layer.msg('保存草稿失败:'+r.data);
|
||||
$('button.layui-btn').attr("disabled",false);
|
||||
$('button.layui-btn').removeClass('layui-btn-disabled');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -59,6 +59,8 @@
|
||||
<script>
|
||||
//保存文档模板
|
||||
createDocTemp = function(){
|
||||
$('button.layui-btn').attr("disabled",true);
|
||||
$('button.layui-btn').addClass('layui-btn-disabled');
|
||||
layer.load();
|
||||
var data = {
|
||||
'name':$("#doctemp-name").val(),
|
||||
@ -76,6 +78,8 @@
|
||||
//创建失败
|
||||
layer.closeAll("loading");
|
||||
layer.msg('保存失败');
|
||||
$('button.layui-btn').attr("disabled",false);
|
||||
$('button.layui-btn').removeClass('layui-btn-disabled');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -169,6 +169,8 @@
|
||||
});
|
||||
//发布文档
|
||||
createDoc = function(){
|
||||
$('button.layui-btn').attr("disabled",true);
|
||||
$('button.layui-btn').addClass('layui-btn-disabled');
|
||||
layer.load(1);
|
||||
var data = {
|
||||
'doc_id':{{ doc.id }},
|
||||
@ -191,11 +193,15 @@
|
||||
}else{
|
||||
//修改失败
|
||||
layer.msg('保存失败');
|
||||
$('button.layui-btn').attr("disabled",false);
|
||||
$('button.layui-btn').removeClass('layui-btn-disabled');
|
||||
}
|
||||
});
|
||||
};
|
||||
//保存草稿
|
||||
saveDoc = function(){
|
||||
$('button.layui-btn').attr("disabled",true);
|
||||
$('button.layui-btn').addClass('layui-btn-disabled');
|
||||
layer.load(1);
|
||||
var data = {
|
||||
'doc_id':{{ doc.id }},
|
||||
@ -218,6 +224,8 @@
|
||||
}else{
|
||||
//修改失败
|
||||
layer.msg('保存失败');
|
||||
$('button.layui-btn').attr("disabled",false);
|
||||
$('button.layui-btn').removeClass('layui-btn-disabled');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -59,6 +59,8 @@
|
||||
<script>
|
||||
//修改文档模板
|
||||
modifyDocTemp = function(){
|
||||
$('button.layui-btn').attr("disabled",true);
|
||||
$('button.layui-btn').addClass('layui-btn-disabled');
|
||||
layer.load(1);
|
||||
var data = {
|
||||
'doctemp_id':{{ doctemp.id }},
|
||||
@ -76,6 +78,8 @@
|
||||
}else{
|
||||
//创建失败
|
||||
layer.msg('保存失败');
|
||||
$('button.layui-btn').attr("disabled",false);
|
||||
$('button.layui-btn').removeClass('layui-btn-disabled');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user