├── .dockerignore ├── .gitignore ├── Dockerfile ├── README.md ├── demo-front ├── .eslintignore ├── .eslintrc.js ├── .travis.yml ├── LICENSE ├── babel.config.js ├── build │ └── index.js ├── jsconfig.json ├── package-lock.json ├── package.json ├── postcss.config.js ├── public │ ├── favicon.ico │ ├── index.html │ └── tinymce │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── bower.json │ │ ├── composer.json │ │ ├── icons │ │ └── default │ │ │ ├── icons.js │ │ │ ├── icons.min.js │ │ │ └── index.js │ │ ├── jquery.tinymce.js │ │ ├── jquery.tinymce.min.js │ │ ├── langs │ │ └── zh_CN.js │ │ ├── license.txt │ │ ├── package.json │ │ ├── plugins │ │ ├── advlist │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── anchor │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── autolink │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── autoresize │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── autosave │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── bbcode │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── charmap │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── code │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── codesample │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── colorpicker │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── contextmenu │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── directionality │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── emoticons │ │ │ ├── index.js │ │ │ ├── js │ │ │ │ ├── emojiimages.js │ │ │ │ ├── emojiimages.min.js │ │ │ │ ├── emojis.js │ │ │ │ └── emojis.min.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── fullpage │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── fullscreen │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── help │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── hr │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── image │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── imagetools │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── importcss │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── insertdatetime │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── legacyoutput │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── link │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── lists │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── media │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── nonbreaking │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── noneditable │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── pagebreak │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── paste │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── preview │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── print │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── quickbars │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── save │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── searchreplace │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── spellchecker │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── tabfocus │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── table │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── template │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── textcolor │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── textpattern │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── toc │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── visualblocks │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── visualchars │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ └── wordcount │ │ │ ├── index.js │ │ │ ├── plugin.js │ │ │ └── plugin.min.js │ │ ├── skins │ │ ├── content │ │ │ ├── dark │ │ │ │ ├── content.css │ │ │ │ └── content.min.css │ │ │ ├── default │ │ │ │ ├── content.css │ │ │ │ └── content.min.css │ │ │ ├── document │ │ │ │ ├── content.css │ │ │ │ └── content.min.css │ │ │ └── writer │ │ │ │ ├── content.css │ │ │ │ └── content.min.css │ │ └── ui │ │ │ ├── oxide-dark │ │ │ ├── content.css │ │ │ ├── content.inline.css │ │ │ ├── content.inline.min.css │ │ │ ├── content.min.css │ │ │ ├── content.mobile.css │ │ │ ├── content.mobile.min.css │ │ │ ├── fonts │ │ │ │ └── tinymce-mobile.woff │ │ │ ├── skin.css │ │ │ ├── skin.min.css │ │ │ ├── skin.mobile.css │ │ │ ├── skin.mobile.min.css │ │ │ ├── skin.shadowdom.css │ │ │ └── skin.shadowdom.min.css │ │ │ └── oxide │ │ │ ├── content.css │ │ │ ├── content.inline.css │ │ │ ├── content.inline.min.css │ │ │ ├── content.min.css │ │ │ ├── content.mobile.css │ │ │ ├── content.mobile.min.css │ │ │ ├── fonts │ │ │ └── tinymce-mobile.woff │ │ │ ├── skin.css │ │ │ ├── skin.min.css │ │ │ ├── skin.mobile.css │ │ │ ├── skin.mobile.min.css │ │ │ ├── skin.shadowdom.css │ │ │ └── skin.shadowdom.min.css │ │ ├── themes │ │ ├── mobile │ │ │ ├── index.js │ │ │ ├── theme.js │ │ │ └── theme.min.js │ │ └── silver │ │ │ ├── index.js │ │ │ ├── theme.js │ │ │ └── theme.min.js │ │ ├── tinymce.d.ts │ │ ├── tinymce.js │ │ └── tinymce.min.js ├── src │ ├── App.vue │ ├── assets │ │ └── images │ │ │ ├── fail.jpg │ │ │ └── load.gif │ ├── components │ │ └── header.vue │ ├── main.js │ ├── plugins │ │ ├── component.js │ │ ├── element.js │ │ ├── index.js │ │ └── prototype.js │ ├── router │ │ └── index.js │ ├── settings.js │ └── views │ │ ├── Home.vue │ │ └── secondarylist │ │ ├── dialog.vue │ │ ├── story.vue │ │ ├── style │ │ └── home.scss │ │ └── text.vue └── vue.config.js ├── demo_adapter.py ├── demos ├── dialogue │ └── __init__.py ├── fillblank │ └── __init__.py └── generatestory │ └── __init__.py ├── demotomodel.py ├── gpu_info.py ├── images ├── .DS_Store ├── demo1.jpg ├── demo2.jpg └── demo3.jpg ├── main.py └── requirements.txt /.dockerignore: -------------------------------------------------------------------------------- 1 | venv 2 | images -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | 131 | # Logs 132 | logs 133 | *.log 134 | npm-debug.log* 135 | yarn-debug.log* 136 | yarn-error.log* 137 | lerna-debug.log* 138 | 139 | # Diagnostic reports (https://nodejs.org/api/report.html) 140 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 141 | 142 | # Runtime data 143 | pids 144 | *.pid 145 | *.seed 146 | *.pid.lock 147 | 148 | # Directory for instrumented libs generated by jscoverage/JSCover 149 | lib-cov 150 | 151 | # Coverage directory used by tools like istanbul 152 | coverage 153 | *.lcov 154 | 155 | # nyc test coverage 156 | .nyc_output 157 | 158 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 159 | .grunt 160 | 161 | # Bower dependency directory (https://bower.io/) 162 | bower_components 163 | 164 | # node-waf configuration 165 | .lock-wscript 166 | 167 | # Compiled binary addons (https://nodejs.org/api/addons.html) 168 | build/Release 169 | 170 | # Dependency directories 171 | node_modules/ 172 | jspm_packages/ 173 | 174 | # TypeScript v1 declaration files 175 | typings/ 176 | 177 | # TypeScript cache 178 | *.tsbuildinfo 179 | 180 | # Optional npm cache directory 181 | .npm 182 | 183 | # Optional eslint cache 184 | .eslintcache 185 | 186 | # Microbundle cache 187 | .rpt2_cache/ 188 | .rts2_cache_cjs/ 189 | .rts2_cache_es/ 190 | .rts2_cache_umd/ 191 | 192 | # Optional REPL history 193 | .node_repl_history 194 | 195 | # Output of 'npm pack' 196 | *.tgz 197 | 198 | # Yarn Integrity file 199 | .yarn-integrity 200 | 201 | # dotenv environment variables file 202 | .env 203 | .env.test 204 | 205 | # parcel-bundler cache (https://parceljs.org/) 206 | .cache 207 | 208 | # Next.js build output 209 | .next 210 | 211 | # Nuxt.js build / generate output 212 | .nuxt 213 | dist 214 | 215 | # Gatsby files 216 | .cache/ 217 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 218 | # https://nextjs.org/blog/next-9-1#public-directory-support 219 | # public 220 | 221 | # vuepress build output 222 | .vuepress/dist 223 | 224 | # Serverless directories 225 | .serverless/ 226 | 227 | # FuseBox cache 228 | .fusebox/ 229 | 230 | # DynamoDB Local files 231 | .dynamodb/ 232 | 233 | # TernJS port file 234 | .tern-port 235 | 236 | .DS_Store -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:lts-alpine 2 | WORKDIR /build 3 | COPY demo-front demo-front 4 | RUN cd demo-front && npm install --registry=https://registry.npm.taobao.org && npm run build 5 | 6 | FROM openbmb/bminf:latest 7 | WORKDIR /app 8 | COPY --from=0 /build/demo-front/dist statics 9 | ADD requirements.txt requirements.txt 10 | RUN pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --no-cache-dir 11 | ADD . . 12 | ENTRYPOINT ["python3", "main.py"] 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # **Introduction** 2 | 3 | BMInf(Big Model Inference)-Demos is three examples designed according to three models in BMInf. These three examples are: 4 | 5 | + **Fill Blank.** It is a use case designed according to CPM2.1 model. It can support arbitrary input of a paragraph of text and generate corresponding blank content according to context semantics. 6 | 7 | + **Generate Story.** It is an example based on CPM1 model. You only need to write the beginning of a paragraph, and it can create a beautiful essay for you。 8 | 9 | + **Dialogue.** It is an example we created based on EVA model. Here, you can talk freely with the machine. 10 | 11 | # Usage 12 | 13 | 14 | ### Step1: 15 | Run following commands with `nvidia-docker2`. 16 | 17 | ```console 18 | $ docker run -it --gpus 1 -v $HOME/.cache/bigmodels:/root/.cache/bigmodels -p 0.0.0.0:8000:8000 --rm openbmb/bminf-demos 19 | ``` 20 | 21 | ### Step2: 22 | 23 | Visit http://localhost:8000/ with your browser. 24 | 25 | 26 | # **Demonstration** 27 | + Fill Blank 28 |
12 |
13 |
]*>/gi, '[quote]'); 47 | rep(/<\/blockquote>/gi, '[/quote]'); 48 | rep(/
/gi, '\n'); 49 | rep(/
/gi, '\n'); 50 | rep(/
/gi, '\n'); 51 | rep(//gi, ''); 52 | rep(/<\/p>/gi, '\n'); 53 | rep(/ |\u00a0/gi, ' '); 54 | rep(/"/gi, '"'); 55 | rep(/</gi, '<'); 56 | rep(/>/gi, '>'); 57 | rep(/&/gi, '&'); 58 | return s; 59 | }; 60 | var bbcode2html = function (s) { 61 | s = global.trim(s); 62 | var rep = function (re, str) { 63 | s = s.replace(re, str); 64 | }; 65 | rep(/\n/gi, '
'); 66 | rep(/\[b\]/gi, ''); 67 | rep(/\[\/b\]/gi, ''); 68 | rep(/\[i\]/gi, ''); 69 | rep(/\[\/i\]/gi, ''); 70 | rep(/\[u\]/gi, ''); 71 | rep(/\[\/u\]/gi, ''); 72 | rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi, '$2'); 73 | rep(/\[url\](.*?)\[\/url\]/gi, '$1'); 74 | rep(/\[img\](.*?)\[\/img\]/gi, ''); 75 | rep(/\[color=(.*?)\](.*?)\[\/color\]/gi, '$2'); 76 | rep(/\[code\](.*?)\[\/code\]/gi, '$1 '); 77 | rep(/\[quote.*?\](.*?)\[\/quote\]/gi, '$1 '); 78 | return s; 79 | }; 80 | 81 | function Plugin () { 82 | global$1.add('bbcode', function (editor) { 83 | console.warn('The bbcode plugin has been deprecated and marked for removal in TinyMCE 6.0'); 84 | editor.on('BeforeSetContent', function (e) { 85 | e.content = bbcode2html(e.content); 86 | }); 87 | editor.on('PostProcess', function (e) { 88 | if (e.set) { 89 | e.content = bbcode2html(e.content); 90 | } 91 | if (e.get) { 92 | e.content = html2bbcode(e.content); 93 | } 94 | }); 95 | }); 96 | } 97 | 98 | Plugin(); 99 | 100 | }()); 101 | -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/bbcode/plugin.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. 3 | * Licensed under the LGPL or a commercial license. 4 | * For LGPL see License.txt in the project root for license information. 5 | * For commercial licenses see https://www.tiny.cloud/ 6 | * 7 | * Version: 5.9.1 (2021-08-27) 8 | */ 9 | !function(){"use strict";function i(t){function o(o,e){t=t.replace(o,e)}return t=n.trim(t),o(/\n/gi,"
"),o(/\[b\]/gi,""),o(/\[\/b\]/gi,""),o(/\[i\]/gi,""),o(/\[\/i\]/gi,""),o(/\[u\]/gi,""),o(/\[\/u\]/gi,""),o(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,'$2'),o(/\[url\](.*?)\[\/url\]/gi,'$1'),o(/\[img\](.*?)\[\/img\]/gi,''),o(/\[color=(.*?)\](.*?)\[\/color\]/gi,'$2'),o(/\[code\](.*?)\[\/code\]/gi,'$1 '),o(/\[quote.*?\](.*?)\[\/quote\]/gi,'$1 '),t}var o=tinymce.util.Tools.resolve("tinymce.PluginManager"),n=tinymce.util.Tools.resolve("tinymce.util.Tools");o.add("bbcode",function(o){console.warn("The bbcode plugin has been deprecated and marked for removal in TinyMCE 6.0"),o.on("BeforeSetContent",function(o){o.content=i(o.content)}),o.on("PostProcess",function(o){function e(o,e){t=t.replace(o,e)}var t;o.set&&(o.content=i(o.content)),o.get&&(o.content=(t=o.content,t=n.trim(t),e(/
(.*?)<\/a>/gi,"[url=$1]$2[/url]"),e(/ (.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]"),e(/ (.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]"),e(/ (.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]"),e(/ (.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]"),e(/(.*?)<\/span>/gi,"[color=$1]$2[/color]"),e(/ (.*?)<\/font>/gi,"[color=$1]$2[/color]"),e(/(.*?)<\/span>/gi,"[size=$1]$2[/size]"),e(/(.*?)<\/font>/gi,"$1"),e(/ /gi,"[img]$1[/img]"),e(/(.*?)<\/span>/gi,"[code]$1[/code]"),e(/(.*?)<\/span>/gi,"[quote]$1[/quote]"),e(/(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]"),e(/(.*?)<\/strong>/gi,"[quote][b]$1[/b][/quote]"),e(/(.*?)<\/em>/gi,"[code][i]$1[/i][/code]"),e(/(.*?)<\/em>/gi,"[quote][i]$1[/i][/quote]"),e(/(.*?)<\/u>/gi,"[code][u]$1[/u][/code]"),e(/(.*?)<\/u>/gi,"[quote][u]$1[/u][/quote]"),e(/<\/(strong|b)>/gi,"[/b]"),e(/<(strong|b)>/gi,"[b]"),e(/<\/(em|i)>/gi,"[/i]"),e(/<(em|i)>/gi,"[i]"),e(/<\/u>/gi,"[/u]"),e(/(.*?)<\/span>/gi,"[u]$1[/u]"),e(//gi,"[u]"),e(/ ]*>/gi,"[quote]"),e(/<\/blockquote>/gi,"[/quote]"),e(/":o(" ",e);n.undoManager.transact(function(){return n.insertContent(a)})}var n=tinymce.util.Tools.resolve("tinymce.PluginManager"),c=tinymce.util.Tools.resolve("tinymce.util.VK");n.add("nonbreaking",function(n){var e,a,o,t,i;function r(){return a.execCommand("mceNonBreaking")}(e=n).addCommand("mceNonBreaking",function(){s(e,1)}),(a=n).ui.registry.addButton("nonbreaking",{icon:"non-breaking",tooltip:"Nonbreaking space",onAction:r}),a.ui.registry.addMenuItem("nonbreaking",{icon:"non-breaking",text:"Nonbreaking space",onAction:r}),0<(i="boolean"==typeof(t=(o=n).getParam("nonbreaking_force_tab",0))?!0===t?3:0:t)&&o.on("keydown",function(n){n.keyCode!==c.TAB||n.isDefaultPrevented()||n.shiftKey||(n.preventDefault(),n.stopImmediatePropagation(),s(o,i))})})}(); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/noneditable/index.js: -------------------------------------------------------------------------------- 1 | // Exports the "noneditable" plugin for usage with module loaders 2 | // Usage: 3 | // CommonJS: 4 | // require('tinymce/plugins/noneditable') 5 | // ES2015: 6 | // import 'tinymce/plugins/noneditable' 7 | require('./plugin.js'); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/noneditable/plugin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. 3 | * Licensed under the LGPL or a commercial license. 4 | * For LGPL see License.txt in the project root for license information. 5 | * For commercial licenses see https://www.tiny.cloud/ 6 | * 7 | * Version: 5.9.1 (2021-08-27) 8 | */ 9 | (function () { 10 | 'use strict'; 11 | 12 | var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager'); 13 | 14 | var global = tinymce.util.Tools.resolve('tinymce.util.Tools'); 15 | 16 | var getNonEditableClass = function (editor) { 17 | return editor.getParam('noneditable_noneditable_class', 'mceNonEditable'); 18 | }; 19 | var getEditableClass = function (editor) { 20 | return editor.getParam('noneditable_editable_class', 'mceEditable'); 21 | }; 22 | var getNonEditableRegExps = function (editor) { 23 | var nonEditableRegExps = editor.getParam('noneditable_regexp', []); 24 | if (nonEditableRegExps && nonEditableRegExps.constructor === RegExp) { 25 | return [nonEditableRegExps]; 26 | } else { 27 | return nonEditableRegExps; 28 | } 29 | }; 30 | 31 | var hasClass = function (checkClassName) { 32 | return function (node) { 33 | return (' ' + node.attr('class') + ' ').indexOf(checkClassName) !== -1; 34 | }; 35 | }; 36 | var replaceMatchWithSpan = function (editor, content, cls) { 37 | return function (match) { 38 | var args = arguments, index = args[args.length - 2]; 39 | var prevChar = index > 0 ? content.charAt(index - 1) : ''; 40 | if (prevChar === '"') { 41 | return match; 42 | } 43 | if (prevChar === '>') { 44 | var findStartTagIndex = content.lastIndexOf('<', index); 45 | if (findStartTagIndex !== -1) { 46 | var tagHtml = content.substring(findStartTagIndex, index); 47 | if (tagHtml.indexOf('contenteditable="false"') !== -1) { 48 | return match; 49 | } 50 | } 51 | } 52 | return '' + editor.dom.encode(typeof args[1] === 'string' ? args[1] : args[0]) + ''; 53 | }; 54 | }; 55 | var convertRegExpsToNonEditable = function (editor, nonEditableRegExps, e) { 56 | var i = nonEditableRegExps.length, content = e.content; 57 | if (e.format === 'raw') { 58 | return; 59 | } 60 | while (i--) { 61 | content = content.replace(nonEditableRegExps[i], replaceMatchWithSpan(editor, content, getNonEditableClass(editor))); 62 | } 63 | e.content = content; 64 | }; 65 | var setup = function (editor) { 66 | var contentEditableAttrName = 'contenteditable'; 67 | var editClass = ' ' + global.trim(getEditableClass(editor)) + ' '; 68 | var nonEditClass = ' ' + global.trim(getNonEditableClass(editor)) + ' '; 69 | var hasEditClass = hasClass(editClass); 70 | var hasNonEditClass = hasClass(nonEditClass); 71 | var nonEditableRegExps = getNonEditableRegExps(editor); 72 | editor.on('PreInit', function () { 73 | if (nonEditableRegExps.length > 0) { 74 | editor.on('BeforeSetContent', function (e) { 75 | convertRegExpsToNonEditable(editor, nonEditableRegExps, e); 76 | }); 77 | } 78 | editor.parser.addAttributeFilter('class', function (nodes) { 79 | var i = nodes.length, node; 80 | while (i--) { 81 | node = nodes[i]; 82 | if (hasEditClass(node)) { 83 | node.attr(contentEditableAttrName, 'true'); 84 | } else if (hasNonEditClass(node)) { 85 | node.attr(contentEditableAttrName, 'false'); 86 | } 87 | } 88 | }); 89 | editor.serializer.addAttributeFilter(contentEditableAttrName, function (nodes) { 90 | var i = nodes.length, node; 91 | while (i--) { 92 | node = nodes[i]; 93 | if (!hasEditClass(node) && !hasNonEditClass(node)) { 94 | continue; 95 | } 96 | if (nonEditableRegExps.length > 0 && node.attr('data-mce-content')) { 97 | node.name = '#text'; 98 | node.type = 3; 99 | node.raw = true; 100 | node.value = node.attr('data-mce-content'); 101 | } else { 102 | node.attr(contentEditableAttrName, null); 103 | } 104 | } 105 | }); 106 | }); 107 | }; 108 | 109 | function Plugin () { 110 | global$1.add('noneditable', function (editor) { 111 | setup(editor); 112 | }); 113 | } 114 | 115 | Plugin(); 116 | 117 | }()); 118 | -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/noneditable/plugin.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. 3 | * Licensed under the LGPL or a commercial license. 4 | * For LGPL see License.txt in the project root for license information. 5 | * For commercial licenses see https://www.tiny.cloud/ 6 | * 7 | * Version: 5.9.1 (2021-08-27) 8 | */ 9 | !function(){"use strict";function l(t){return t.getParam("noneditable_noneditable_class","mceNonEditable")}function u(e){return function(t){return-1!==(" "+t.attr("class")+" ").indexOf(e)}}function e(e){var t,r="contenteditable",n=" "+f.trim(e.getParam("noneditable_editable_class","mceEditable"))+" ",a=" "+f.trim(l(e))+" ",i=u(n),o=u(a),c=(t=e.getParam("noneditable_regexp",[]))&&t.constructor===RegExp?[t]:t;e.on("PreInit",function(){0
/gi,"\n"),e(/
/gi,"\n"),e(/
/gi,"\n"),e(//gi,""),e(/<\/p>/gi,"\n"),e(/ |\u00a0/gi," "),e(/"/gi,'"'),e(/</gi,"<"),e(/>/gi,">"),e(/&/gi,"&"),t))})})}(); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/charmap/index.js: -------------------------------------------------------------------------------- 1 | // Exports the "charmap" plugin for usage with module loaders 2 | // Usage: 3 | // CommonJS: 4 | // require('tinymce/plugins/charmap') 5 | // ES2015: 6 | // import 'tinymce/plugins/charmap' 7 | require('./plugin.js'); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/code/index.js: -------------------------------------------------------------------------------- 1 | // Exports the "code" plugin for usage with module loaders 2 | // Usage: 3 | // CommonJS: 4 | // require('tinymce/plugins/code') 5 | // ES2015: 6 | // import 'tinymce/plugins/code' 7 | require('./plugin.js'); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/code/plugin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. 3 | * Licensed under the LGPL or a commercial license. 4 | * For LGPL see License.txt in the project root for license information. 5 | * For commercial licenses see https://www.tiny.cloud/ 6 | * 7 | * Version: 5.9.1 (2021-08-27) 8 | */ 9 | (function () { 10 | 'use strict'; 11 | 12 | var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); 13 | 14 | var setContent = function (editor, html) { 15 | editor.focus(); 16 | editor.undoManager.transact(function () { 17 | editor.setContent(html); 18 | }); 19 | editor.selection.setCursorLocation(); 20 | editor.nodeChanged(); 21 | }; 22 | var getContent = function (editor) { 23 | return editor.getContent({ source_view: true }); 24 | }; 25 | 26 | var open = function (editor) { 27 | var editorContent = getContent(editor); 28 | editor.windowManager.open({ 29 | title: 'Source Code', 30 | size: 'large', 31 | body: { 32 | type: 'panel', 33 | items: [{ 34 | type: 'textarea', 35 | name: 'code' 36 | }] 37 | }, 38 | buttons: [ 39 | { 40 | type: 'cancel', 41 | name: 'cancel', 42 | text: 'Cancel' 43 | }, 44 | { 45 | type: 'submit', 46 | name: 'save', 47 | text: 'Save', 48 | primary: true 49 | } 50 | ], 51 | initialData: { code: editorContent }, 52 | onSubmit: function (api) { 53 | setContent(editor, api.getData().code); 54 | api.close(); 55 | } 56 | }); 57 | }; 58 | 59 | var register$1 = function (editor) { 60 | editor.addCommand('mceCodeEditor', function () { 61 | open(editor); 62 | }); 63 | }; 64 | 65 | var register = function (editor) { 66 | var onAction = function () { 67 | return editor.execCommand('mceCodeEditor'); 68 | }; 69 | editor.ui.registry.addButton('code', { 70 | icon: 'sourcecode', 71 | tooltip: 'Source code', 72 | onAction: onAction 73 | }); 74 | editor.ui.registry.addMenuItem('code', { 75 | icon: 'sourcecode', 76 | text: 'Source code', 77 | onAction: onAction 78 | }); 79 | }; 80 | 81 | function Plugin () { 82 | global.add('code', function (editor) { 83 | register$1(editor); 84 | register(editor); 85 | return {}; 86 | }); 87 | } 88 | 89 | Plugin(); 90 | 91 | }()); 92 | -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/code/plugin.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. 3 | * Licensed under the LGPL or a commercial license. 4 | * For LGPL see License.txt in the project root for license information. 5 | * For commercial licenses see https://www.tiny.cloud/ 6 | * 7 | * Version: 5.9.1 (2021-08-27) 8 | */ 9 | !function(){"use strict";tinymce.util.Tools.resolve("tinymce.PluginManager").add("code",function(e){var t,o;function n(){return o.execCommand("mceCodeEditor")}return(t=e).addCommand("mceCodeEditor",function(){var n,e;e=(n=t).getContent({source_view:!0}),n.windowManager.open({title:"Source Code",size:"large",body:{type:"panel",items:[{type:"textarea",name:"code"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:{code:e},onSubmit:function(e){var t=n,o=e.getData().code;t.focus(),t.undoManager.transact(function(){t.setContent(o)}),t.selection.setCursorLocation(),t.nodeChanged(),e.close()}})}),(o=e).ui.registry.addButton("code",{icon:"sourcecode",tooltip:"Source code",onAction:n}),o.ui.registry.addMenuItem("code",{icon:"sourcecode",text:"Source code",onAction:n}),{}})}(); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/codesample/index.js: -------------------------------------------------------------------------------- 1 | // Exports the "codesample" plugin for usage with module loaders 2 | // Usage: 3 | // CommonJS: 4 | // require('tinymce/plugins/codesample') 5 | // ES2015: 6 | // import 'tinymce/plugins/codesample' 7 | require('./plugin.js'); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/colorpicker/index.js: -------------------------------------------------------------------------------- 1 | // Exports the "colorpicker" plugin for usage with module loaders 2 | // Usage: 3 | // CommonJS: 4 | // require('tinymce/plugins/colorpicker') 5 | // ES2015: 6 | // import 'tinymce/plugins/colorpicker' 7 | require('./plugin.js'); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/colorpicker/plugin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. 3 | * Licensed under the LGPL or a commercial license. 4 | * For LGPL see License.txt in the project root for license information. 5 | * For commercial licenses see https://www.tiny.cloud/ 6 | * 7 | * Version: 5.9.1 (2021-08-27) 8 | */ 9 | (function () { 10 | 'use strict'; 11 | 12 | var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); 13 | 14 | function Plugin () { 15 | global.add('colorpicker', function () { 16 | console.warn('Color picker plugin is now built in to the core editor, please remove it from your editor configuration'); 17 | }); 18 | } 19 | 20 | Plugin(); 21 | 22 | }()); 23 | -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/colorpicker/plugin.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. 3 | * Licensed under the LGPL or a commercial license. 4 | * For LGPL see License.txt in the project root for license information. 5 | * For commercial licenses see https://www.tiny.cloud/ 6 | * 7 | * Version: 5.9.1 (2021-08-27) 8 | */ 9 | !function(){"use strict";tinymce.util.Tools.resolve("tinymce.PluginManager").add("colorpicker",function(){console.warn("Color picker plugin is now built in to the core editor, please remove it from your editor configuration")})}(); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/contextmenu/index.js: -------------------------------------------------------------------------------- 1 | // Exports the "contextmenu" plugin for usage with module loaders 2 | // Usage: 3 | // CommonJS: 4 | // require('tinymce/plugins/contextmenu') 5 | // ES2015: 6 | // import 'tinymce/plugins/contextmenu' 7 | require('./plugin.js'); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/contextmenu/plugin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. 3 | * Licensed under the LGPL or a commercial license. 4 | * For LGPL see License.txt in the project root for license information. 5 | * For commercial licenses see https://www.tiny.cloud/ 6 | * 7 | * Version: 5.9.1 (2021-08-27) 8 | */ 9 | (function () { 10 | 'use strict'; 11 | 12 | var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); 13 | 14 | function Plugin () { 15 | global.add('contextmenu', function () { 16 | console.warn('Context menu plugin is now built in to the core editor, please remove it from your editor configuration'); 17 | }); 18 | } 19 | 20 | Plugin(); 21 | 22 | }()); 23 | -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/contextmenu/plugin.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. 3 | * Licensed under the LGPL or a commercial license. 4 | * For LGPL see License.txt in the project root for license information. 5 | * For commercial licenses see https://www.tiny.cloud/ 6 | * 7 | * Version: 5.9.1 (2021-08-27) 8 | */ 9 | !function(){"use strict";tinymce.util.Tools.resolve("tinymce.PluginManager").add("contextmenu",function(){console.warn("Context menu plugin is now built in to the core editor, please remove it from your editor configuration")})}(); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/directionality/index.js: -------------------------------------------------------------------------------- 1 | // Exports the "directionality" plugin for usage with module loaders 2 | // Usage: 3 | // CommonJS: 4 | // require('tinymce/plugins/directionality') 5 | // ES2015: 6 | // import 'tinymce/plugins/directionality' 7 | require('./plugin.js'); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/directionality/plugin.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. 3 | * Licensed under the LGPL or a commercial license. 4 | * For LGPL see License.txt in the project root for license information. 5 | * For commercial licenses see https://www.tiny.cloud/ 6 | * 7 | * Version: 5.9.1 (2021-08-27) 8 | */ 9 | !function(){"use strict";function n(t){return function(n){return typeof n===t}}function u(n){return function(){return n}}function t(n){return n}function r(){return d}var o,e=tinymce.util.Tools.resolve("tinymce.PluginManager"),i=function(n){return r=typeof(t=n),(null===t?"null":"object"==r&&(Array.prototype.isPrototypeOf(t)||t.constructor&&"Array"===t.constructor.name)?"array":"object"==r&&(String.prototype.isPrototypeOf(t)||t.constructor&&"String"===t.constructor.name)?"string":r)===o;var t,r},c=n("boolean"),f=n("function"),l=n("number"),a=u(!(o="string")),m=u(!0),d={fold:function(n,t){return n()},isSome:a,isNone:m,getOr:t,getOrThunk:s,getOrDie:function(n){throw new Error(n||"error: getOrDie called on none.")},getOrNull:u(null),getOrUndefined:u(void 0),or:t,orThunk:s,map:r,each:function(){},bind:r,exists:a,forall:m,filter:function(){return d},toArray:function(){return[]},toString:u("none()")};function s(n){return n()}function g(n,t){for(var r=0,o=n.length;r
'); 17 | }); 18 | }; 19 | 20 | var register = function (editor) { 21 | var onAction = function () { 22 | return editor.execCommand('InsertHorizontalRule'); 23 | }; 24 | editor.ui.registry.addButton('hr', { 25 | icon: 'horizontal-rule', 26 | tooltip: 'Horizontal line', 27 | onAction: onAction 28 | }); 29 | editor.ui.registry.addMenuItem('hr', { 30 | icon: 'horizontal-rule', 31 | text: 'Horizontal line', 32 | onAction: onAction 33 | }); 34 | }; 35 | 36 | function Plugin () { 37 | global.add('hr', function (editor) { 38 | register$1(editor); 39 | register(editor); 40 | }); 41 | } 42 | 43 | Plugin(); 44 | 45 | }()); 46 | -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/hr/plugin.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. 3 | * Licensed under the LGPL or a commercial license. 4 | * For LGPL see License.txt in the project root for license information. 5 | * For commercial licenses see https://www.tiny.cloud/ 6 | * 7 | * Version: 5.9.1 (2021-08-27) 8 | */ 9 | !function(){"use strict";tinymce.util.Tools.resolve("tinymce.PluginManager").add("hr",function(n){var o,t;function e(){return t.execCommand("InsertHorizontalRule")}(o=n).addCommand("InsertHorizontalRule",function(){o.execCommand("mceInsertContent",!1,"
")}),(t=n).ui.registry.addButton("hr",{icon:"horizontal-rule",tooltip:"Horizontal line",onAction:e}),t.ui.registry.addMenuItem("hr",{icon:"horizontal-rule",text:"Horizontal line",onAction:e})})}(); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/image/index.js: -------------------------------------------------------------------------------- 1 | // Exports the "image" plugin for usage with module loaders 2 | // Usage: 3 | // CommonJS: 4 | // require('tinymce/plugins/image') 5 | // ES2015: 6 | // import 'tinymce/plugins/image' 7 | require('./plugin.js'); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/imagetools/index.js: -------------------------------------------------------------------------------- 1 | // Exports the "imagetools" plugin for usage with module loaders 2 | // Usage: 3 | // CommonJS: 4 | // require('tinymce/plugins/imagetools') 5 | // ES2015: 6 | // import 'tinymce/plugins/imagetools' 7 | require('./plugin.js'); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/importcss/index.js: -------------------------------------------------------------------------------- 1 | // Exports the "importcss" plugin for usage with module loaders 2 | // Usage: 3 | // CommonJS: 4 | // require('tinymce/plugins/importcss') 5 | // ES2015: 6 | // import 'tinymce/plugins/importcss' 7 | require('./plugin.js'); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/importcss/plugin.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. 3 | * Licensed under the LGPL or a commercial license. 4 | * For LGPL see License.txt in the project root for license information. 5 | * For commercial licenses see https://www.tiny.cloud/ 6 | * 7 | * Version: 5.9.1 (2021-08-27) 8 | */ 9 | !function(){"use strict";function t(n){return function(t){return r=typeof(e=t),(null===e?"null":"object"==r&&(Array.prototype.isPrototypeOf(e)||e.constructor&&"Array"===e.constructor.name)?"array":"object"==r&&(String.prototype.isPrototypeOf(e)||e.constructor&&"String"===e.constructor.name)?"string":r)===n;var e,r}}function y(t){return t.getParam("importcss_selector_converter")}function u(e){return l(e)?function(t){return-1!==t.indexOf(e)}:e instanceof RegExp?function(t){return e.test(t)}:e}function h(t,e){var r,n=/^(?:([a-z0-9\-_]+))?(\.[a-z0-9_\-\.]+)$/i.exec(e);if(n){var o=n[1],i=n[2].substr(1).split(".").join(" "),c=x.makeMap("a,img");return n[1]?(r={title:e},t.schema.getTextBlockElements()[o]?r.block=o:t.schema.getBlockElements()[o]||c[o.toLowerCase()]?r.selector=o:r.inline=o):n[2]&&(r={inline:"span",title:e.substr(1),classes:i}),!1!==t.getParam("importcss_merge_classes")?r.classes=i:r.attributes={class:i},r}}function d(t,e){return null===e||!1!==t.getParam("importcss_exclusive")}function r(v){v.on("init",function(){function o(t,e){if(f=t,p=g,!(d(v,m=e)?f in p:f in m.selectors)){a=t,l=g,d(v,u=e)?l[a]=!0:u.selectors[a]=!0;var r=(i=(o=v).plugins.importcss,c=t,((s=e)&&s.selector_converter?s.selector_converter:y(o)?y(o):function(){return h(o,c)}).call(i,c,s));if(r){var n=r.name||_.DOM.uniqueId();return v.formatter.register(n,r),{title:r.title,format:n}}}var o,i,c,s,a,u,l,f,m,p;return null}var e,r,n,t,i=(e=[],r=[],n={},{addItemToGroup:function(t,e){n[t]?n[t].push(e):(r.push(t),n[t]=[e])},addItem:function(t){e.push(t)},toFormats:function(){return function(t){for(var e=[],r=0,n=t.length;r'+n+"")):e.insertContent(l(e,t))}var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),a="Sun Mon Tue Wed Thu Fri Sat Sun".split(" "),i="Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "),o="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),u="January February March April May June July August September October November December".split(" "),p=tinymce.util.Tools.resolve("tinymce.util.Tools");e.add("insertdatetime",function(e){var t,n,r,a,i,o,u,c;(t=e).addCommand("mceInsertDate",function(){d(t,t.getParam("insertdatetime_dateformat",t.translate("%Y-%m-%d")))}),t.addCommand("mceInsertTime",function(){d(t,m(t))}),u=s(n=e),r=0<(o=s(i=n)).length?o[0]:m(i),a=r,c={get:function(){return a},set:function(e){a=e}},n.ui.registry.addSplitButton("insertdatetime",{icon:"insert-time",tooltip:"Insert date/time",select:function(e){return e===c.get()},fetch:function(e){e(p.map(u,function(e){return{type:"choiceitem",text:l(n,e),value:e}}))},onAction:function(e){d(n,c.get())},onItemAction:function(e,t){c.set(t),d(n,t)}}),n.ui.registry.addNestedMenuItem("insertdatetime",{icon:"insert-time",text:"Date/time",getSubmenuItems:function(){return p.map(u,function(e){return{type:"menuitem",text:l(n,e),onAction:(t=e,function(){c.set(t),d(n,t)})};var t})}})})}(); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/legacyoutput/index.js: -------------------------------------------------------------------------------- 1 | // Exports the "legacyoutput" plugin for usage with module loaders 2 | // Usage: 3 | // CommonJS: 4 | // require('tinymce/plugins/legacyoutput') 5 | // ES2015: 6 | // import 'tinymce/plugins/legacyoutput' 7 | require('./plugin.js'); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/legacyoutput/plugin.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. 3 | * Licensed under the LGPL or a commercial license. 4 | * For LGPL see License.txt in the project root for license information. 5 | * For commercial licenses see https://www.tiny.cloud/ 6 | * 7 | * Version: 5.9.1 (2021-08-27) 8 | */ 9 | !function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),l=tinymce.util.Tools.resolve("tinymce.util.Tools");e.add("legacyoutput",function(e){var s,t;console.warn("The legacyoutput plugin has been deprecated and marked for removal in TinyMCE 6.0"),(t=s=e).settings.inline_styles=!1,t.getParam("fontsize_formats")||(t.settings.fontsize_formats="8pt=1 10pt=2 12pt=3 14pt=4 18pt=5 24pt=6 36pt=7"),t.getParam("font_formats")||(t.settings.font_formats="Andale Mono=andale mono,monospace;Arial=arial,helvetica,sans-serif;Arial Black=arial black,sans-serif;Book Antiqua=book antiqua,palatino,serif;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,palatino,serif;Helvetica=helvetica,arial,sans-serif;Impact=impact,sans-serif;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco,monospace;Times New Roman=times new roman,times,serif;Trebuchet MS=trebuchet ms,geneva,sans-serif;Verdana=verdana,geneva,sans-serif;Webdings=webdings;Wingdings=wingdings,zapf dingbats"),s.on("PreInit",function(){var e=s,t="p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table",i=l.explode(e.getParam("font_size_style_values","xx-small,x-small,small,medium,large,x-large,xx-large")),a=e.schema;e.formatter.register({alignleft:{selector:t,attributes:{align:"left"}},aligncenter:{selector:t,attributes:{align:"center"}},alignright:{selector:t,attributes:{align:"right"}},alignjustify:{selector:t,attributes:{align:"justify"}},bold:[{inline:"b",remove:"all",preserve_attributes:["class","style"]},{inline:"strong",remove:"all",preserve_attributes:["class","style"]},{inline:"span",styles:{fontWeight:"bold"}}],italic:[{inline:"i",remove:"all",preserve_attributes:["class","style"]},{inline:"em",remove:"all",preserve_attributes:["class","style"]},{inline:"span",styles:{fontStyle:"italic"}}],underline:[{inline:"u",remove:"all",preserve_attributes:["class","style"]},{inline:"span",styles:{textDecoration:"underline"},exact:!0}],strikethrough:[{inline:"strike",remove:"all",preserve_attributes:["class","style"]},{inline:"span",styles:{textDecoration:"line-through"},exact:!0}],fontname:{inline:"font",toggle:!1,attributes:{face:"%value"}},fontsize:{inline:"font",toggle:!1,attributes:{size:function(e){return String(l.inArray(i,e.value)+1)}}},forecolor:{inline:"font",attributes:{color:"%value"},links:!0,remove_similar:!0,clear_child_styles:!0},hilitecolor:{inline:"font",styles:{backgroundColor:"%value"},links:!0,remove_similar:!0,clear_child_styles:!0}}),l.each("b,i,u,strike".split(","),function(e){a.addValidElements(e+"[*]")}),a.getElementRule("font")||a.addValidElements("font[face|size|color|style]"),l.each(t.split(","),function(e){var t=a.getElementRule(e);t&&(t.attributes.align||(t.attributes.align={},t.attributesOrder.push("align")))})})})}(); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/link/index.js: -------------------------------------------------------------------------------- 1 | // Exports the "link" plugin for usage with module loaders 2 | // Usage: 3 | // CommonJS: 4 | // require('tinymce/plugins/link') 5 | // ES2015: 6 | // import 'tinymce/plugins/link' 7 | require('./plugin.js'); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/lists/index.js: -------------------------------------------------------------------------------- 1 | // Exports the "lists" plugin for usage with module loaders 2 | // Usage: 3 | // CommonJS: 4 | // require('tinymce/plugins/lists') 5 | // ES2015: 6 | // import 'tinymce/plugins/lists' 7 | require('./plugin.js'); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/media/index.js: -------------------------------------------------------------------------------- 1 | // Exports the "media" plugin for usage with module loaders 2 | // Usage: 3 | // CommonJS: 4 | // require('tinymce/plugins/media') 5 | // ES2015: 6 | // import 'tinymce/plugins/media' 7 | require('./plugin.js'); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/nonbreaking/index.js: -------------------------------------------------------------------------------- 1 | // Exports the "nonbreaking" plugin for usage with module loaders 2 | // Usage: 3 | // CommonJS: 4 | // require('tinymce/plugins/nonbreaking') 5 | // ES2015: 6 | // import 'tinymce/plugins/nonbreaking' 7 | require('./plugin.js'); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/nonbreaking/plugin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. 3 | * Licensed under the LGPL or a commercial license. 4 | * For LGPL see License.txt in the project root for license information. 5 | * For commercial licenses see https://www.tiny.cloud/ 6 | * 7 | * Version: 5.9.1 (2021-08-27) 8 | */ 9 | (function () { 10 | 'use strict'; 11 | 12 | var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager'); 13 | 14 | var getKeyboardSpaces = function (editor) { 15 | var spaces = editor.getParam('nonbreaking_force_tab', 0); 16 | if (typeof spaces === 'boolean') { 17 | return spaces === true ? 3 : 0; 18 | } else { 19 | return spaces; 20 | } 21 | }; 22 | var wrapNbsps = function (editor) { 23 | return editor.getParam('nonbreaking_wrap', true, 'boolean'); 24 | }; 25 | 26 | var stringRepeat = function (string, repeats) { 27 | var str = ''; 28 | for (var index = 0; index < repeats; index++) { 29 | str += string; 30 | } 31 | return str; 32 | }; 33 | var isVisualCharsEnabled = function (editor) { 34 | return editor.plugins.visualchars ? editor.plugins.visualchars.isEnabled() : false; 35 | }; 36 | var insertNbsp = function (editor, times) { 37 | var classes = function () { 38 | return isVisualCharsEnabled(editor) ? 'mce-nbsp-wrap mce-nbsp' : 'mce-nbsp-wrap'; 39 | }; 40 | var nbspSpan = function () { 41 | return '' + stringRepeat(' ', times) + ''; 42 | }; 43 | var shouldWrap = wrapNbsps(editor); 44 | var html = shouldWrap || editor.plugins.visualchars ? nbspSpan() : stringRepeat(' ', times); 45 | editor.undoManager.transact(function () { 46 | return editor.insertContent(html); 47 | }); 48 | }; 49 | 50 | var register$1 = function (editor) { 51 | editor.addCommand('mceNonBreaking', function () { 52 | insertNbsp(editor, 1); 53 | }); 54 | }; 55 | 56 | var global = tinymce.util.Tools.resolve('tinymce.util.VK'); 57 | 58 | var setup = function (editor) { 59 | var spaces = getKeyboardSpaces(editor); 60 | if (spaces > 0) { 61 | editor.on('keydown', function (e) { 62 | if (e.keyCode === global.TAB && !e.isDefaultPrevented()) { 63 | if (e.shiftKey) { 64 | return; 65 | } 66 | e.preventDefault(); 67 | e.stopImmediatePropagation(); 68 | insertNbsp(editor, spaces); 69 | } 70 | }); 71 | } 72 | }; 73 | 74 | var register = function (editor) { 75 | var onAction = function () { 76 | return editor.execCommand('mceNonBreaking'); 77 | }; 78 | editor.ui.registry.addButton('nonbreaking', { 79 | icon: 'non-breaking', 80 | tooltip: 'Nonbreaking space', 81 | onAction: onAction 82 | }); 83 | editor.ui.registry.addMenuItem('nonbreaking', { 84 | icon: 'non-breaking', 85 | text: 'Nonbreaking space', 86 | onAction: onAction 87 | }); 88 | }; 89 | 90 | function Plugin () { 91 | global$1.add('nonbreaking', function (editor) { 92 | register$1(editor); 93 | register(editor); 94 | setup(editor); 95 | }); 96 | } 97 | 98 | Plugin(); 99 | 100 | }()); 101 | -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/nonbreaking/plugin.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. 3 | * Licensed under the LGPL or a commercial license. 4 | * For LGPL see License.txt in the project root for license information. 5 | * For commercial licenses see https://www.tiny.cloud/ 6 | * 7 | * Version: 5.9.1 (2021-08-27) 8 | */ 9 | !function(){"use strict";function o(n,e){for(var a="",o=0;o '+o(" ",e)+" "===r){var a=o.lastIndexOf("<",n);if(-1!==a&&-1!==o.substring(a,n).indexOf('contenteditable="false"'))return t}return''+i.dom.encode("string"==typeof e[1]?e[1]:e[0])+""}}(t,a,l(t)));n.content=a}}(e,c,t)}),e.parser.addAttributeFilter("class",function(t){for(var e,n=t.length;n--;)e=t[n],i(e)?e.attr(r,"true"):o(e)&&e.attr(r,"false")}),e.serializer.addAttributeFilter(r,function(t){for(var e,n=t.length;n--;)e=t[n],(i(e)||o(e))&&(0 '); 18 | }; 19 | var shouldSplitBlock = function (editor) { 20 | return editor.getParam('pagebreak_split_block', false); 21 | }; 22 | 23 | var pageBreakClass = 'mce-pagebreak'; 24 | var getPlaceholderHtml = function (shouldSplitBlock) { 25 | var html = ' '; 26 | return shouldSplitBlock ? '
' + html + '
' : html; 27 | }; 28 | var setup$1 = function (editor) { 29 | var separatorHtml = getSeparatorHtml(editor); 30 | var shouldSplitBlock$1 = function () { 31 | return shouldSplitBlock(editor); 32 | }; 33 | var pageBreakSeparatorRegExp = new RegExp(separatorHtml.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function (a) { 34 | return '\\' + a; 35 | }), 'gi'); 36 | editor.on('BeforeSetContent', function (e) { 37 | e.content = e.content.replace(pageBreakSeparatorRegExp, getPlaceholderHtml(shouldSplitBlock$1())); 38 | }); 39 | editor.on('PreInit', function () { 40 | editor.serializer.addNodeFilter('img', function (nodes) { 41 | var i = nodes.length, node, className; 42 | while (i--) { 43 | node = nodes[i]; 44 | className = node.attr('class'); 45 | if (className && className.indexOf(pageBreakClass) !== -1) { 46 | var parentNode = node.parent; 47 | if (editor.schema.getBlockElements()[parentNode.name] && shouldSplitBlock$1()) { 48 | parentNode.type = 3; 49 | parentNode.value = separatorHtml; 50 | parentNode.raw = true; 51 | node.remove(); 52 | continue; 53 | } 54 | node.type = 3; 55 | node.value = separatorHtml; 56 | node.raw = true; 57 | } 58 | } 59 | }); 60 | }); 61 | }; 62 | 63 | var register$1 = function (editor) { 64 | editor.addCommand('mcePageBreak', function () { 65 | editor.insertContent(getPlaceholderHtml(shouldSplitBlock(editor))); 66 | }); 67 | }; 68 | 69 | var setup = function (editor) { 70 | editor.on('ResolveName', function (e) { 71 | if (e.target.nodeName === 'IMG' && editor.dom.hasClass(e.target, pageBreakClass)) { 72 | e.name = 'pagebreak'; 73 | } 74 | }); 75 | }; 76 | 77 | var register = function (editor) { 78 | var onAction = function () { 79 | return editor.execCommand('mcePageBreak'); 80 | }; 81 | editor.ui.registry.addButton('pagebreak', { 82 | icon: 'page-break', 83 | tooltip: 'Page break', 84 | onAction: onAction 85 | }); 86 | editor.ui.registry.addMenuItem('pagebreak', { 87 | text: 'Page break', 88 | icon: 'page-break', 89 | onAction: onAction 90 | }); 91 | }; 92 | 93 | function Plugin () { 94 | global$1.add('pagebreak', function (editor) { 95 | register$1(editor); 96 | register(editor); 97 | setup$1(editor); 98 | setup(editor); 99 | }); 100 | } 101 | 102 | Plugin(); 103 | 104 | }()); 105 | -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/pagebreak/plugin.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. 3 | * Licensed under the LGPL or a commercial license. 4 | * For LGPL see License.txt in the project root for license information. 5 | * For commercial licenses see https://www.tiny.cloud/ 6 | * 7 | * Version: 5.9.1 (2021-08-27) 8 | */ 9 | !function(){"use strict";function u(e){return e.getParam("pagebreak_split_block",!1)}function l(e){var a='';return e?"
"+a+"
":a}var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),n=tinymce.util.Tools.resolve("tinymce.Env"),m="mce-pagebreak";e.add("pagebreak",function(e){var a,n,o,i,t,r;function c(){return n.execCommand("mcePageBreak")}function g(){return u(o)}(a=e).addCommand("mcePageBreak",function(){a.insertContent(l(u(a)))}),(n=e).ui.registry.addButton("pagebreak",{icon:"page-break",tooltip:"Page break",onAction:c}),n.ui.registry.addMenuItem("pagebreak",{text:"Page break",icon:"page-break",onAction:c}),i=(o=e).getParam("pagebreak_separator","\x3c!-- pagebreak --\x3e"),t=new RegExp(i.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g,function(e){return"\\"+e}),"gi"),o.on("BeforeSetContent",function(e){e.content=e.content.replace(t,l(g()))}),o.on("PreInit",function(){o.serializer.addNodeFilter("img",function(e){for(var a,n,t,r=e.length;r--;)(t=(n=e[r]).attr("class"))&&-1!==t.indexOf(m)&&(a=n.parent,o.schema.getBlockElements()[a.name]&&g()?(a.type=3,a.value=i,a.raw=!0,n.remove()):(n.type=3,n.value=i,n.raw=!0))})}),(r=e).on("ResolveName",function(e){"IMG"===e.target.nodeName&&r.dom.hasClass(e.target,m)&&(e.name="pagebreak")})})}(); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/paste/index.js: -------------------------------------------------------------------------------- 1 | // Exports the "paste" plugin for usage with module loaders 2 | // Usage: 3 | // CommonJS: 4 | // require('tinymce/plugins/paste') 5 | // ES2015: 6 | // import 'tinymce/plugins/paste' 7 | require('./plugin.js'); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/preview/index.js: -------------------------------------------------------------------------------- 1 | // Exports the "preview" plugin for usage with module loaders 2 | // Usage: 3 | // CommonJS: 4 | // require('tinymce/plugins/preview') 5 | // ES2015: 6 | // import 'tinymce/plugins/preview' 7 | require('./plugin.js'); -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/preview/plugin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. 3 | * Licensed under the LGPL or a commercial license. 4 | * For LGPL see License.txt in the project root for license information. 5 | * For commercial licenses see https://www.tiny.cloud/ 6 | * 7 | * Version: 5.9.1 (2021-08-27) 8 | */ 9 | (function () { 10 | 'use strict'; 11 | 12 | var global$2 = tinymce.util.Tools.resolve('tinymce.PluginManager'); 13 | 14 | var global$1 = tinymce.util.Tools.resolve('tinymce.Env'); 15 | 16 | var global = tinymce.util.Tools.resolve('tinymce.util.Tools'); 17 | 18 | var getContentStyle = function (editor) { 19 | return editor.getParam('content_style', '', 'string'); 20 | }; 21 | var shouldUseContentCssCors = function (editor) { 22 | return editor.getParam('content_css_cors', false, 'boolean'); 23 | }; 24 | var getBodyClassByHash = function (editor) { 25 | var bodyClass = editor.getParam('body_class', '', 'hash'); 26 | return bodyClass[editor.id] || ''; 27 | }; 28 | var getBodyClass = function (editor) { 29 | var bodyClass = editor.getParam('body_class', '', 'string'); 30 | if (bodyClass.indexOf('=') === -1) { 31 | return bodyClass; 32 | } else { 33 | return getBodyClassByHash(editor); 34 | } 35 | }; 36 | var getBodyIdByHash = function (editor) { 37 | var bodyId = editor.getParam('body_id', '', 'hash'); 38 | return bodyId[editor.id] || bodyId; 39 | }; 40 | var getBodyId = function (editor) { 41 | var bodyId = editor.getParam('body_id', 'tinymce', 'string'); 42 | if (bodyId.indexOf('=') === -1) { 43 | return bodyId; 44 | } else { 45 | return getBodyIdByHash(editor); 46 | } 47 | }; 48 | 49 | var getPreviewHtml = function (editor) { 50 | var headHtml = ''; 51 | var encode = editor.dom.encode; 52 | var contentStyle = getContentStyle(editor); 53 | headHtml += ''; 54 | var cors = shouldUseContentCssCors(editor) ? ' crossorigin="anonymous"' : ''; 55 | global.each(editor.contentCSS, function (url) { 56 | headHtml += ''; 57 | }); 58 | if (contentStyle) { 59 | headHtml += ''; 60 | } 61 | var bodyId = getBodyId(editor); 62 | var bodyClass = getBodyClass(editor); 63 | var isMetaKeyPressed = global$1.mac ? 'e.metaKey' : 'e.ctrlKey && !e.altKey'; 64 | var preventClicksOnLinksScript = ' '; 65 | var directionality = editor.getBody().dir; 66 | var dirAttr = directionality ? ' dir="' + encode(directionality) + '"' : ''; 67 | var previewHtml = '' + '' + '' + headHtml + '' + '' + editor.getContent() + preventClicksOnLinksScript + '' + ''; 68 | return previewHtml; 69 | }; 70 | 71 | var open = function (editor) { 72 | var content = getPreviewHtml(editor); 73 | var dataApi = editor.windowManager.open({ 74 | title: 'Preview', 75 | size: 'large', 76 | body: { 77 | type: 'panel', 78 | items: [{ 79 | name: 'preview', 80 | type: 'iframe', 81 | sandboxed: true 82 | }] 83 | }, 84 | buttons: [{ 85 | type: 'cancel', 86 | name: 'close', 87 | text: 'Close', 88 | primary: true 89 | }], 90 | initialData: { preview: content } 91 | }); 92 | dataApi.focus('close'); 93 | }; 94 | 95 | var register$1 = function (editor) { 96 | editor.addCommand('mcePreview', function () { 97 | open(editor); 98 | }); 99 | }; 100 | 101 | var register = function (editor) { 102 | var onAction = function () { 103 | return editor.execCommand('mcePreview'); 104 | }; 105 | editor.ui.registry.addButton('preview', { 106 | icon: 'preview', 107 | tooltip: 'Preview', 108 | onAction: onAction 109 | }); 110 | editor.ui.registry.addMenuItem('preview', { 111 | icon: 'preview', 112 | text: 'Preview', 113 | onAction: onAction 114 | }); 115 | }; 116 | 117 | function Plugin () { 118 | global$2.add('preview', function (editor) { 119 | register$1(editor); 120 | register(editor); 121 | }); 122 | } 123 | 124 | Plugin(); 125 | 126 | }()); 127 | -------------------------------------------------------------------------------- /demo-front/public/tinymce/plugins/preview/plugin.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. 3 | * Licensed under the LGPL or a commercial license. 4 | * For LGPL see License.txt in the project root for license information. 5 | * For commercial licenses see https://www.tiny.cloud/ 6 | * 7 | * Version: 5.9.1 (2021-08-27) 8 | */ 9 | !function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),f=tinymce.util.Tools.resolve("tinymce.Env"),w=tinymce.util.Tools.resolve("tinymce.util.Tools");e.add("preview",function(e){var n,t;function i(){return t.execCommand("mcePreview")}(n=e).addCommand("mcePreview",function(){var e,t;t=function(t){var n="",i=t.dom.encode,e=t.getParam("content_style","","string");n+=' ';var o=t.getParam("content_css_cors",!1,"boolean")?' crossorigin="anonymous"':"";w.each(t.contentCSS,function(e){n+='"}),e&&(n+='");var a,r,s,c,d,l,m,y=-1===(c=(a=t).getParam("body_id","tinymce","string")).indexOf("=")?c:(s=(r=a).getParam("body_id","","hash"))[r.id]||s,u=-1===(m=(d=t).getParam("body_class","","string")).indexOf("=")?m:(l=d).getParam("body_class","","hash")[l.id]||"",v=' 47 | 48 | 143 | -------------------------------------------------------------------------------- /demo-front/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App' 3 | import router from './router' 4 | 5 | // elementui 6 | import ElementUI from 'element-ui'; 7 | import 'element-ui/lib/theme-chalk/index.css'; 8 | 9 | Vue.use(ElementUI); 10 | Vue.config.productionTip = false 11 | 12 | new Vue({ 13 | el: '#app', 14 | router, 15 | render: h => h(App) 16 | }) 17 | -------------------------------------------------------------------------------- /demo-front/src/plugins/component.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | 3 | import emptyStatus from '@/components/emptyStatus' 4 | import ellipsisTooltip from '@/components/ellipsisTooltip' 5 | 6 | // 暂无数据 7 | Vue.component('empty-status', emptyStatus) 8 | // Tooltip 二次封装 (超出显示,不超出不显示) 9 | Vue.component('ellipsis-tooltip', ellipsisTooltip) 10 | -------------------------------------------------------------------------------- /demo-front/src/plugins/element.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import ElementUI from 'element-ui' 3 | import 'element-ui/lib/theme-chalk/index.css' 4 | 5 | // element css 6 | import '@/styles/element-ui.scss' 7 | 8 | // import locale from 'element-ui/lib/locale/lang/en' // lang i18n 9 | 10 | // set ElementUI lang to EN 11 | // Vue.use(ElementUI, { locale }) 12 | // 如果想要中文版 element-ui,按如下方式声明 13 | Vue.use(ElementUI) 14 | -------------------------------------------------------------------------------- /demo-front/src/plugins/index.js: -------------------------------------------------------------------------------- 1 | // 公共引入 2 | import Vue from 'vue' 3 | 4 | // Element-ui 5 | import './element' 6 | // global prototype 7 | import './prototype' 8 | // global components 9 | import './component' 10 | // A modern alternative to CSS resets 11 | import 'normalize.css/normalize.css' 12 | -------------------------------------------------------------------------------- /demo-front/src/plugins/prototype.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | 3 | // qs 4 | import qs from 'qs' 5 | Vue.prototype.qs = qs 6 | 7 | // common 8 | import common from '@/utils/common' 9 | Vue.prototype.$common = common 10 | 11 | // 引入echarts 12 | import echarts from 'echarts' 13 | Vue.prototype.$echarts = echarts 14 | 15 | // 引入全局css变量 16 | import themes_style from '@/styles/themes.scss' 17 | Vue.prototype.$themes_style = themes_style 18 | 19 | // 时间格式转换 20 | import moment from 'moment/moment' 21 | Vue.prototype.$moment = moment 22 | -------------------------------------------------------------------------------- /demo-front/src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import VueRouter from 'vue-router' 3 | 4 | 5 | Vue.use(VueRouter) 6 | 7 | const routes = [ 8 | 9 | { 10 | path: '/', 11 | name: 'Home', 12 | component: () => import('../views/Home.vue'), 13 | children:[ 14 | { 15 | // 文本填写 16 | path: '/text', 17 | name: 'text', 18 | component: () => import('../views/secondarylist/text.vue'), 19 | }, 20 | { 21 | // 对话 22 | path: '/dialog', 23 | name: 'dialog', 24 | component: () => import('../views/secondarylist/dialog.vue'), 25 | }, 26 | { 27 | // 故事 28 | path: '/story', 29 | name: 'story', 30 | component: () => import('../views/secondarylist/story.vue'), 31 | }, 32 | ] 33 | } 34 | ] 35 | 36 | const router = new VueRouter({ 37 | routes 38 | }) 39 | 40 | export default router 41 | -------------------------------------------------------------------------------- /demo-front/src/settings.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 3 | title: 'Admin', 4 | 5 | /** 6 | * @type {boolean} true | false 7 | * @description Whether fix the header 8 | */ 9 | fixedHeader: true, 10 | 11 | /** 12 | * @type {boolean} true | false 13 | * @description Whether show the logo in sidebar 14 | */ 15 | sidebarLogo: true, 16 | 17 | /** 18 | * @type {string} 19 | * @description 本地存储前缀 20 | */ 21 | prefix: 'default' 22 | } 23 | -------------------------------------------------------------------------------- /demo-front/src/views/Home.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 |39 | 40 | 41 | 97 | 172 | -------------------------------------------------------------------------------- /demo-front/src/views/secondarylist/story.vue: -------------------------------------------------------------------------------- 1 | 2 |4 |6 |5 | 7 |38 | 32 |33 |37 |34 |36 |35 | 3 |32 | 33 | 129 | 209 | -------------------------------------------------------------------------------- /demo-front/src/views/secondarylist/style/home.scss: -------------------------------------------------------------------------------- 1 | *{ 2 | margin: 0; 3 | padding: 0; 4 | } 5 | input,textarea,a{ 6 | outline: none; 7 | border: 0; 8 | text-decoration: none !important; 9 | color: black; 10 | } 11 | .home{ 12 | 13 | width: 100vw; 14 | height: 100vh; 15 | display: flex; 16 | flex-direction: column; 17 | } 18 | 19 | .content{ 20 | flex:1; 21 | display: flex; 22 | } 23 | .nav{ 24 | box-shadow: 2px 0 20px 0 rgba(0,0,0,0.10); 25 | position: absolute; 26 | top: 0; 27 | z-index: 1000; 28 | height: 100%; 29 | background-color: #FFF; 30 | } 31 | /deep/ .el-icon-arrow-down:before{ 32 | content:"\e791"; 33 | } 34 | /deep/ .el-submenu.is-opened>.el-submenu__title .el-submenu__icon-arrow{ 35 | transform: rotateZ(90deg); 36 | } 37 | /deep/ .el-submenu__title>span{ 38 | font-size: 14px; 39 | margin-left: 8px; 40 | font-family: Source Han Sans CN; 41 | font-weight: 600; 42 | color: #030B1D; 43 | } 44 | /deep/ .is-active{ 45 | background-color: #E8EEFC !important; 46 | } 47 | /deep/ .el-menu{ 48 | border-right: none; 49 | } 50 | /deep/ .el-menu-item-group__title{ 51 | padding: 0; 52 | } 53 | .nav>>>.el-submenu .el-menu-item{ 54 | min-width: 224px !important; 55 | } 56 | /deep/ .el-menu-vertical-demo{ 57 | // height: 100%; 58 | box-sizing: border-box; 59 | padding-top: 24px; 60 | } 61 | /deep/ .el-submenu__title{ 62 | width: 224px; 63 | } 64 | /deep/ .el-menu-item{ 65 | padding-left: 68px !important; 66 | text-align: left; 67 | } 68 | .el-icon-cpu:before{ 69 | color: #909399; 70 | } 71 | .cont{ 72 | flex: 1; 73 | display: flex; 74 | flex-direction: column; 75 | padding-left: 226px; 76 | // background-color: #F7FAFF; 77 | .breadcrumb{ 78 | width: 100%; 79 | height: 36px; 80 | display: flex; 81 | align-items: center; 82 | padding: 0 18px; 83 | box-sizing: border-box; 84 | background: #FFFFFF; 85 | } 86 | 87 | } 88 | 89 | // 面包屑 90 | 91 | /deep/ .bread1>span:nth-of-type(1){ 92 | // color: red !important; 93 | font-size: 12px; 94 | font-family: Source Han Sans CN; 95 | font-weight: 400; 96 | 97 | } 98 | /deep/ .el-breadcrumb__separator{ 99 | display: none; 100 | } 101 | /deep/ .bread2>span:nth-of-type(1){ 102 | font-size: 12px; 103 | font-family: Source Han Sans CN; 104 | font-weight: 400; 105 | color: #2F3033 !important; 106 | } -------------------------------------------------------------------------------- /demo-front/src/views/secondarylist/text.vue: -------------------------------------------------------------------------------- 1 | 2 |4 |8 |5 |
模型正在加载中...6 |首次加载时间较长(可能会需要十分钟),请耐心等待!7 |9 |31 |10 |27 |11 | 12 | 生成故事 13 | 14 | 按TAB生成下文 15 | 16 | 17 | 随机一个例子 18 |19 |20 | 21 |26 |22 |25 |{{ hint.replace("\n", "↲") }}
23 | 24 |28 | 29 |30 |3 |30 | 31 | 154 | 215 | -------------------------------------------------------------------------------- /demo-front/vue.config.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const path = require('path') 3 | const defaultSettings = require('./src/settings.js') 4 | function resolve(dir) { 5 | return path.join(__dirname, dir) 6 | } 7 | 8 | const port = process.env.port || process.env.npm_config_port || 8080 // dev port 9 | 10 | // All configuration item explanations can be find in https://cli.vuejs.org/config/ 11 | module.exports = { 12 | /** 13 | * You will need to set publicPath if you plan to deploy your site under a sub path, 14 | * for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/, 15 | * then publicPath should be set to "/bar/". 16 | * In most cases please use '/' !!! 17 | * Detail: https://cli.vuejs.org/config/#publicpath 18 | */ 19 | runtimeCompiler: true, 20 | publicPath: './', 21 | outputDir: 'dist', 22 | assetsDir: 'static', 23 | lintOnSave: process.env.NODE_ENV === 'development', 24 | productionSourceMap: false, 25 | devServer: { 26 | hot:true, 27 | port: port, 28 | open: true, 29 | overlay: { 30 | warnings: false, 31 | errors: true 32 | }, 33 | 34 | proxy: { 35 | '/api': { 36 | target: "http://localhost:29100/", 37 | changeOrigin: true, 38 | }, 39 | } 40 | }, 41 | configureWebpack: { 42 | // provide the app's title in webpack's name field, so that 43 | // it can be accessed in index.html to inject the correct title. 44 | name: 'BMInf Demos', 45 | resolve: { 46 | modules: [path.resolve('node_modules'), 'node_modules'], 47 | alias: { 48 | '@': resolve('src') 49 | } 50 | }, 51 | entry: './src/main.js' 52 | }, 53 | chainWebpack(config) { 54 | // it can improve the speed of the first screen, it is recommended to turn on preload 55 | config.plugin('preload').tap(() => [ 56 | { 57 | rel: 'preload', 58 | // to ignore runtime.js 59 | // https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/config/app.js#L171 60 | fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/], 61 | include: 'initial' 62 | } 63 | ]) 64 | 65 | // when there are many pages, it will cause too many meaningless requests 66 | config.plugins.delete('prefetch') 67 | 68 | // set svg-sprite-loader 69 | config.module 70 | .rule('svg') 71 | .exclude.add(resolve('src/icons')) 72 | .end() 73 | config.module 74 | .rule('icons') 75 | .test(/\.svg$/) 76 | .include.add(resolve('src/icons')) 77 | .end() 78 | .use('svg-sprite-loader') 79 | .loader('svg-sprite-loader') 80 | .options({ 81 | symbolId: 'icon-[name]' 82 | }) 83 | .end() 84 | 85 | config 86 | .when(process.env.NODE_ENV !== 'development', 87 | config => { 88 | config 89 | .plugin('ScriptExtHtmlWebpackPlugin') 90 | .after('html') 91 | .use('script-ext-html-webpack-plugin', [{ 92 | // `runtime` must same as runtimeChunk name. default is `runtime` 93 | inline: /runtime\..*\.js$/ 94 | }]) 95 | .end() 96 | config 97 | .optimization.splitChunks({ 98 | chunks: 'all', 99 | cacheGroups: { 100 | libs: { 101 | name: 'chunk-libs', 102 | test: /[\\/]node_modules[\\/]/, 103 | priority: 10, 104 | chunks: 'initial' // only package third parties that are initially dependent 105 | }, 106 | elementUI: { 107 | name: 'chunk-elementUI', // split elementUI into a single package 108 | priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app 109 | test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm 110 | }, 111 | commons: { 112 | name: 'chunk-commons', 113 | test: resolve('src/components'), // can customize your rules 114 | minChunks: 3, // minimum common number 115 | priority: 5, 116 | reuseExistingChunk: true 117 | } 118 | } 119 | }) 120 | // https:// webpack.js.org/configuration/optimization/#optimizationruntimechunk 121 | config.optimization.runtimeChunk('single') 122 | } 123 | ) 124 | 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /demo_adapter.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | import importlib 3 | 4 | def demo_adapter(demoname, model, req_json): 5 | package = find_packages('demos') 6 | for i in range(len(package)): 7 | if package[i] == demoname: 8 | path='demos.'+package[i] 9 | module = importlib.import_module(path) 10 | return module.demoImpl(model, req_json) 11 | 12 | -------------------------------------------------------------------------------- /demos/dialogue/__init__.py: -------------------------------------------------------------------------------- 1 | def demoImpl(model, req_json): 2 | text = req_json.get('text') 3 | max_tokens1 = req_json.get('max_tokens') 4 | top_p1 = req_json.get('top_p') 5 | top_n1 = req_json.get('top_n') 6 | temperature1 = req_json.get('temperature') 7 | frequency_penalty1 = req_json.get('frequency_penalty') 8 | presence_penalty1 = req_json.get('presence_penalty') 9 | result = model.dialogue(text, 10 | max_tokens = max_tokens1, 11 | top_p = top_p1, 12 | top_n = top_n1, 13 | temperature = temperature1, 14 | frequency_penalty = frequency_penalty1, 15 | presence_penalty = presence_penalty1) 16 | return result -------------------------------------------------------------------------------- /demos/fillblank/__init__.py: -------------------------------------------------------------------------------- 1 | def demoImpl(model,req_json): 2 | TOKEN_SPAN = "" 3 | text = req_json.get('text') 4 | top_p1 = req_json.get('top_p') 5 | top_n1 = req_json.get('top_n') 6 | temperature1 = req_json.get('temperature') 7 | frequency_penalty1 = req_json.get('frequency_penalty') 8 | presence_penalty1 = req_json.get('presence_penalty') 9 | result = model.fill_blank(text, 10 | top_p = top_p1, 11 | top_n = top_n1, 12 | temperature = temperature1, 13 | frequency_penalty = frequency_penalty1, 14 | presence_penalty = presence_penalty1) 15 | 16 | for v in result: 17 | value = v["text"] 18 | text = text.replace(TOKEN_SPAN, value , 1) 19 | res = {"list":result,"resp_text":text} 20 | return res 21 | 22 | 23 | -------------------------------------------------------------------------------- /demos/generatestory/__init__.py: -------------------------------------------------------------------------------- 1 | def demoImpl(model, req_json): 2 | text = req_json.get('text') 3 | max_tokens = req_json.get('max_tokens') 4 | top_p1 = req_json.get('top_p') 5 | top_n1 = req_json.get('top_n') 6 | temperature1 = req_json.get('temperature') 7 | frequency_penalty1 = req_json.get('frequency_penalty') 8 | presence_penalty1 = req_json.get('presence_penalty') 9 | 10 | result=[] 11 | for _ in range(3): 12 | resp = model.generate(text,max_tokens = max_tokens,top_n = top_n1,top_p = top_p1,temperature = temperature1,frequency_penalty = frequency_penalty1,presence_penalty = presence_penalty1) 13 | result.append(resp) 14 | return result -------------------------------------------------------------------------------- /demotomodel.py: -------------------------------------------------------------------------------- 1 | # 1 --> cpm1 model 2 | # 2 --> cpm2 model 3 | # 3 --> eva model 4 | 5 | demotomodel = {'generatestory':1,'fillblank':2,'dialogue':3} 6 | def demoToModel(demoname): 7 | return demotomodel.get(demoname) 8 | -------------------------------------------------------------------------------- /gpu_info.py: -------------------------------------------------------------------------------- 1 | import pynvml 2 | 3 | def gpu_info(): 4 | NUM_EXPAND = 1024*1024 5 | pynvml.nvmlInit() 6 | handle = pynvml.nvmlDeviceGetHandleByIndex(0) 7 | info = pynvml.nvmlDeviceGetMemoryInfo(handle) 8 | mem_used_rate = round(info.used/info.total,4)*100 #显存 9 | utilization = pynvml.nvmlDeviceGetUtilizationRates(handle) 10 | gpu_rate = round(utilization.gpu,4) #gpu使用率 11 | memory_rate = round(utilization.memory,4) #内存使用率 12 | 13 | pynvml.nvmlShutdown() 14 | 15 | rate={} 16 | rate['memory_rate']= memory_rate 17 | rate['gpu_rate']= gpu_rate 18 | rate['meme_used_rate'] = mem_used_rate 19 | return rate 20 | -------------------------------------------------------------------------------- /images/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBMB/BMInf-demos/0a55d22905515c87656d1adb790a8d54017b828e/images/.DS_Store -------------------------------------------------------------------------------- /images/demo1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBMB/BMInf-demos/0a55d22905515c87656d1adb790a8d54017b828e/images/demo1.jpg -------------------------------------------------------------------------------- /images/demo2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBMB/BMInf-demos/0a55d22905515c87656d1adb790a8d54017b828e/images/demo2.jpg -------------------------------------------------------------------------------- /images/demo3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenBMB/BMInf-demos/0a55d22905515c87656d1adb790a8d54017b828e/images/demo3.jpg -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import threading 2 | from flask import Flask,request,jsonify 3 | from flask.helpers import send_from_directory 4 | import gpu_info as gpuinfo 5 | import demo_adapter as adapter 6 | import demotomodel as dm 7 | import bminf 8 | import os 9 | 10 | CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) 11 | 12 | app = Flask(__name__, static_url_path="", static_folder="statics") 13 | 14 | model = None 15 | current_key = None 16 | #lock methods 17 | lock = threading.Lock() 18 | 19 | @app.route('/api/loadmodel',methods=['GET']) 20 | def model_load(): 21 | res = request.args.get('key') 22 | key = int(res) 23 | 24 | global model, current_key 25 | 26 | if lock.locked(): 27 | data={'code':201,'message':'sorry,此模型正在被其他人独霸,请稍后再试!'} 28 | return jsonify(data),201 29 | else: 30 | if key == current_key: 31 | return jsonify({'code':200,'message':'success'}) 32 | if key == 1: 33 | lock.acquire() 34 | model = None 35 | print('loading cpm1') 36 | model = bminf.models.CPM1() 37 | lock.release() 38 | elif key == 2: 39 | lock.acquire() 40 | model = None 41 | print('loading cpm2') 42 | model = bminf.models.CPM2() 43 | lock.release() 44 | elif key == 3: 45 | lock.acquire() 46 | model = None 47 | print('loading eva') 48 | model = bminf.models.EVA() 49 | lock.release() 50 | current_key = key 51 | return jsonify({'code':200,'message':'success'}) 52 | 53 | @app.route('/api/gpuinfo',methods=['GET']) 54 | def gpu_info(): 55 | rate = gpuinfo.gpu_info() 56 | return jsonify({'code':200,'message':'success','data':rate}) 57 | 58 | @app.route('/api/4 |8 |5 |
模型正在加载中...6 |首次加载时间较长(可能会需要十分钟),请耐心等待!7 |9 |29 |10 |21 |11 | 文本填空 12 | 随机一个例子 13 |14 |20 | 22 | 23 | 24 |25 |26 | 27 |28 |',methods=['POST']) 59 | def demo(demoname): 60 | if current_key != dm.demoToModel(demoname): 61 | return jsonify({'code':202,'message':'模型已经失效,请刷新后重新加载'}),201 62 | if lock.locked() == False: 63 | lock.acquire() 64 | req_json = request.json 65 | result = adapter.demo_adapter(demoname, model, req_json) 66 | lock.release() 67 | return jsonify({'code':200,'message':'success','data':result}) 68 | else: 69 | return jsonify({'code':201,'message':'sorry,此接口正在被其他人独霸,请稍后再试!'}),201 70 | 71 | @app.route("/", methods=["GET"]) 72 | def index(): 73 | return send_from_directory( 74 | os.path.join(CURRENT_DIR, "statics"), 75 | "index.html" 76 | ) 77 | 78 | if __name__ == '__main__': 79 | app.config['JSON_AS_ASCII']= False 80 | app.run(host='0.0.0.0',port=8000) 81 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | bminf 2 | flask 3 | pynvml --------------------------------------------------------------------------------