simple-frame-unit 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. package/.env.dev +14 -0
  2. package/CHANGELOG.md +9 -0
  3. package/README.md +24 -0
  4. package/dist/ed-frame-vue.common.1.js +11046 -0
  5. package/dist/ed-frame-vue.common.1.js.map +1 -0
  6. package/dist/ed-frame-vue.common.2.js +1715 -0
  7. package/dist/ed-frame-vue.common.2.js.map +1 -0
  8. package/dist/ed-frame-vue.common.js +53427 -0
  9. package/dist/ed-frame-vue.common.js.map +1 -0
  10. package/dist/ed-frame-vue.umd.1.js +11046 -0
  11. package/dist/ed-frame-vue.umd.1.js.map +1 -0
  12. package/dist/ed-frame-vue.umd.2.js +1715 -0
  13. package/dist/ed-frame-vue.umd.2.js.map +1 -0
  14. package/dist/ed-frame-vue.umd.js +53437 -0
  15. package/dist/ed-frame-vue.umd.js.map +1 -0
  16. package/dist/ed-frame-vue.umd.min.1.js +17 -0
  17. package/dist/ed-frame-vue.umd.min.1.js.map +1 -0
  18. package/dist/ed-frame-vue.umd.min.2.js +4 -0
  19. package/dist/ed-frame-vue.umd.min.2.js.map +1 -0
  20. package/dist/ed-frame-vue.umd.min.js +470 -0
  21. package/dist/ed-frame-vue.umd.min.js.map +1 -0
  22. package/import.easydata.js +46 -0
  23. package/lib/CHANGELOG.md +18 -0
  24. package/lib/README.md +27 -0
  25. package/lib/api/ds/index.js +124 -0
  26. package/lib/api/easyData.js +90 -0
  27. package/lib/api/easyform/easyForm.js +32 -0
  28. package/lib/api/index.js +61 -0
  29. package/lib/api/interface/index.js +32 -0
  30. package/lib/api/system.js +20 -0
  31. package/lib/index.js +80 -0
  32. package/lib/packages/BasicTemplate/EasyDataTemplate.vue +189 -0
  33. package/lib/packages/BasicTemplate/Props.js +64 -0
  34. package/lib/packages/BasicTemplate/components/TemplateComp.vue +263 -0
  35. package/lib/packages/BasicTemplate/components/TemplateViews.vue +292 -0
  36. package/lib/packages/BasicTemplate/hooks/business.js +74 -0
  37. package/lib/packages/BasicTemplate/hooks/getFormData.js +89 -0
  38. package/lib/packages/BasicTemplate/hooks/queryFormData.js +194 -0
  39. package/lib/packages/BasicTemplate/hooks/submitForm.js +53 -0
  40. package/lib/packages/BasicTemplate/hooks/useEmits.js +15 -0
  41. package/lib/packages/BasicTemplate/hooks/validate.js +42 -0
  42. package/lib/packages/EasyDataForm/EasyDataForm.vue +597 -0
  43. package/lib/packages/EasyDataForm/Props.js +22 -0
  44. package/lib/packages/EasyDataForm/components/FormItem.vue +228 -0
  45. package/lib/packages/EasyDataForm/hooks/useChosePopup.js +85 -0
  46. package/lib/packages/EasyDataForm/hooks/useEmits.js +19 -0
  47. package/lib/packages/EasyDataForm/hooks/useForm.js +169 -0
  48. package/lib/packages/EasyDataForm/hooks/useUpload.js +168 -0
  49. package/lib/packages/EasyDataList/EasyDataList.vue +348 -0
  50. package/lib/packages/EasyDataList/Props.js +116 -0
  51. package/lib/packages/EasyDataList/components/BasicModal.vue +150 -0
  52. package/lib/packages/EasyDataList/components/FormAction.vue +63 -0
  53. package/lib/packages/EasyDataList/hooks/useEmits.js +30 -0
  54. package/lib/packages/EasyDataList/hooks/useForm.js +62 -0
  55. package/lib/packages/EasyDataList/hooks/useTable.js +314 -0
  56. package/lib/packages/EasyDataTable/EasyDataTable.vue +233 -0
  57. package/lib/packages/EasyDataView/EasyDataView.vue +105 -0
  58. package/lib/packages/EdRichPreview/index.js +32 -0
  59. package/lib/packages/EdRichText/index.vue +167 -0
  60. package/lib/packages/EdRichText/replaceUrl.js +49 -0
  61. package/lib/packages/components/FileView.vue +97 -0
  62. package/lib/packages/index.js +11 -0
  63. package/lib/packages/mixins/EasyDataMixins.js +133 -0
  64. package/lib/packages/mixins/useTable.jsx +130 -0
  65. package/lib/pages/DataSource/index.js +8 -0
  66. package/lib/pages/DataSource/src/components/ControlViews/BaseProps.js +103 -0
  67. package/lib/pages/DataSource/src/components/ControlViews/control.js +1089 -0
  68. package/lib/pages/DataSource/src/components/ControlViews/index.vue +301 -0
  69. package/lib/pages/DataSource/src/components/TableOperationModal.vue +225 -0
  70. package/lib/pages/DataSource/src/components/TablePropsModal.vue +367 -0
  71. package/lib/pages/DataSource/src/components/ViewPropsModal.vue +737 -0
  72. package/lib/pages/DataSource/src/components/modal/ChooseDict.vue +119 -0
  73. package/lib/pages/DataSource/src/hooks/useTable.js +138 -0
  74. package/lib/pages/DataSource/src/index.vue +431 -0
  75. package/lib/pages/Interface/index.js +8 -0
  76. package/lib/pages/Interface/src/components/InterfaceCall.vue +73 -0
  77. package/lib/pages/Interface/src/components/InterfaceDepend.vue +299 -0
  78. package/lib/pages/Interface/src/components/InterfaceFee.vue +131 -0
  79. package/lib/pages/Interface/src/components/InterfaceMessage.vue +878 -0
  80. package/lib/pages/Interface/src/components/InterfaceMock.vue +203 -0
  81. package/lib/pages/Interface/src/components/InterfaceParam.vue +308 -0
  82. package/lib/pages/Interface/src/components/InterfaceRepeat.vue +281 -0
  83. package/lib/pages/Interface/src/components/InterfaceVariable.vue +31 -0
  84. package/lib/pages/Interface/src/index.vue +216 -0
  85. package/lib/pages/Template/index.js +8 -0
  86. package/lib/pages/Template/src/components/DefineModal.vue +524 -0
  87. package/lib/pages/Template/src/components/TemplatePreview.vue +109 -0
  88. package/lib/pages/Template/src/components/model/AddDialog.vue +60 -0
  89. package/lib/pages/Template/src/components/model/TemplatePreview2.vue +101 -0
  90. package/lib/pages/Template/src/hooks/index.js +3 -0
  91. package/lib/pages/Template/src/hooks/useEmits.js +64 -0
  92. package/lib/pages/Template/src/index.vue +124 -0
  93. package/lib/popup/index.js +8 -0
  94. package/lib/popup/src/DataSourceChoose.vue +44 -0
  95. package/lib/popup/src/DataSourceViewIdChoose.vue +67 -0
  96. package/lib/popup/src/DictChoose.vue +104 -0
  97. package/lib/popup/src/InterfaceChoose.vue +46 -0
  98. package/lib/popup/src/OrgChoose.vue +121 -0
  99. package/lib/popup/src/RoleChoose.vue +101 -0
  100. package/lib/popup/src/TemplateChoose.vue +43 -0
  101. package/lib/popup/src/UserChoose.vue +161 -0
  102. package/lib/popup//347/273/204/344/273/266/345/274/200/345/217/221/350/247/204/350/214/203.md +25 -0
  103. package/lib/style/custom.scss +126 -0
  104. package/lib/style/deep.scss +109 -0
  105. package/lib/style/index.scss +4 -0
  106. package/lib/utils/MapLoader.js +48 -0
  107. package/lib/utils/dateUtils.js +58 -0
  108. package/lib/utils/index.js +8 -0
  109. package/lib/utils/setting.js +25 -0
  110. package/lib/utils/sortable/index.js +3784 -0
  111. package/lib/utils/useBusiness.js +212 -0
  112. package/lib/utils/utils.js +588 -0
  113. package/package.json +77 -0
  114. package/src/App.vue +12 -0
  115. package/src/assets/Vue.png +0 -0
  116. package/src/assets/avatar.png +0 -0
  117. package/src/assets/images/bg.png +0 -0
  118. package/src/assets/images/logo-bills.png +0 -0
  119. package/src/assets/images/pic.png +0 -0
  120. package/src/assets/images/weplus-logo.png +0 -0
  121. package/src/assets/marker.png +0 -0
  122. package/src/assets/styles/common.scss +359 -0
  123. package/src/assets/styles/ele-docs.css +3278 -0
  124. package/src/assets/styles/fonts/icomoon.eot +0 -0
  125. package/src/assets/styles/fonts/icomoon.svg +14 -0
  126. package/src/assets/styles/fonts/icomoon.ttf +0 -0
  127. package/src/assets/styles/fonts/icomoon.woff +0 -0
  128. package/src/assets/styles/fonts/style.css +39 -0
  129. package/src/assets/styles/higtlightEle.css +84 -0
  130. package/src/assets/svg/code.svg +7 -0
  131. package/src/assets/svg/password.svg +1 -0
  132. package/src/components/Popups/DiyCompDictChoose.vue +112 -0
  133. package/src/components/Popups/index.js +28 -0
  134. package/src/components/ed-base-vue/global/variable.js +8 -0
  135. package/src/components/ed-base-vue/index.js +81 -0
  136. package/src/components/ed-base-vue/package/EdCard/index.js +7 -0
  137. package/src/components/ed-base-vue/package/EdCard/src/index.vue +87 -0
  138. package/src/components/ed-base-vue/package/EdCodeEditor/index.js +8 -0
  139. package/src/components/ed-base-vue/package/EdCodeEditor/src/AceEditor/AceConfig.js +71 -0
  140. package/src/components/ed-base-vue/package/EdCodeEditor/src/AceEditor/Editor.vue +137 -0
  141. package/src/components/ed-base-vue/package/EdCodeEditor/src/AceEditor/Toolbar.vue +68 -0
  142. package/src/components/ed-base-vue/package/EdCodeEditor/src/AceEditor/index.vue +119 -0
  143. package/src/components/ed-base-vue/package/EdCodeEditor/src/AceEditor/webpack-resolver.js +51 -0
  144. package/src/components/ed-base-vue/package/EdCodeEditor/src/Codemirror/Toolbar.vue +57 -0
  145. package/src/components/ed-base-vue/package/EdCodeEditor/src/Codemirror/config.js +64 -0
  146. package/src/components/ed-base-vue/package/EdCodeEditor/src/Codemirror/index.vue +309 -0
  147. package/src/components/ed-base-vue/package/EdCodeEditor/src/EdCodeEditor.vue +238 -0
  148. package/src/components/ed-base-vue/package/EdDate/index.js +8 -0
  149. package/src/components/ed-base-vue/package/EdDate/src/index.js +50 -0
  150. package/src/components/ed-base-vue/package/EdDescriptions/index.js +8 -0
  151. package/src/components/ed-base-vue/package/EdDescriptions/src/EdDescriptions.vue +46 -0
  152. package/src/components/ed-base-vue/package/EdDescriptions/src/EdDescriptionsItem.js +20 -0
  153. package/src/components/ed-base-vue/package/EdDescriptions/src/Props.js +20 -0
  154. package/src/components/ed-base-vue/package/EdDialog/index.js +8 -0
  155. package/src/components/ed-base-vue/package/EdDialog/src/EdDialog.vue +138 -0
  156. package/src/components/ed-base-vue/package/EdDialog/src/Props.js +91 -0
  157. package/src/components/ed-base-vue/package/EdDialog/src/components/DialogFooter.vue +42 -0
  158. package/src/components/ed-base-vue/package/EdDialog/src/components/DialogWrapper.vue +53 -0
  159. package/src/components/ed-base-vue/package/EdDrawer/index.js +8 -0
  160. package/src/components/ed-base-vue/package/EdDrawer/src/DrawerFooter.vue +41 -0
  161. package/src/components/ed-base-vue/package/EdDrawer/src/EdDrawer.vue +150 -0
  162. package/src/components/ed-base-vue/package/EdDrawer/src/props.js +71 -0
  163. package/src/components/ed-base-vue/package/EdFlow/index.js +8 -0
  164. package/src/components/ed-base-vue/package/EdFlow/src/EdFlowItem.vue +733 -0
  165. package/src/components/ed-base-vue/package/EdFlow/src/index.vue +148 -0
  166. package/src/components/ed-base-vue/package/EdForm/index.js +8 -0
  167. package/src/components/ed-base-vue/package/EdForm/src/EdForm.vue +172 -0
  168. package/src/components/ed-base-vue/package/EdForm/src/Props.js +33 -0
  169. package/src/components/ed-base-vue/package/EdForm/src/components/EdFormItem.vue +34 -0
  170. package/src/components/ed-base-vue/package/EdIcons/index.js +8 -0
  171. package/src/components/ed-base-vue/package/EdIcons/src/hooks/Icons.js +406 -0
  172. package/src/components/ed-base-vue/package/EdIcons/src/hooks/Icons1.js +830 -0
  173. package/src/components/ed-base-vue/package/EdIcons/src/index.vue +13 -0
  174. package/src/components/ed-base-vue/package/EdImage/index.js +8 -0
  175. package/src/components/ed-base-vue/package/EdImage/src/index.vue +28 -0
  176. package/src/components/ed-base-vue/package/EdInputArray/index.js +8 -0
  177. package/src/components/ed-base-vue/package/EdInputArray/src/Props.js +26 -0
  178. package/src/components/ed-base-vue/package/EdInputArray/src/index.vue +97 -0
  179. package/src/components/ed-base-vue/package/EdInputColor/index.js +8 -0
  180. package/src/components/ed-base-vue/package/EdInputColor/src/InputColor.vue +81 -0
  181. package/src/components/ed-base-vue/package/EdInputMap/index.js +9 -0
  182. package/src/components/ed-base-vue/package/EdInputMap/src/EdInputMap.vue +246 -0
  183. package/src/components/ed-base-vue/package/EdInputMap/src/EdInputMapProps.js +6 -0
  184. package/src/components/ed-base-vue/package/EdInputPop/index.js +13 -0
  185. package/src/components/ed-base-vue/package/EdInputPop/src/EdInputPop.vue +144 -0
  186. package/src/components/ed-base-vue/package/EdInputPop/src/Props.js +48 -0
  187. package/src/components/ed-base-vue/package/EdInputTable/index.js +8 -0
  188. package/src/components/ed-base-vue/package/EdInputTable/src/EdInputTable.vue +368 -0
  189. package/src/components/ed-base-vue/package/EdInputTable/src/Fetch.js +40 -0
  190. package/src/components/ed-base-vue/package/EdJsonEditor/index.js +13 -0
  191. package/src/components/ed-base-vue/package/EdJsonEditor/src/EdJsonEditor.vue +198 -0
  192. package/src/components/ed-base-vue/package/EdJsonEditor/src/assets/img/jsoneditor-icons.svg +749 -0
  193. package/src/components/ed-base-vue/package/EdJsonEditor/src/assets/jsoneditor.css +2031 -0
  194. package/src/components/ed-base-vue/package/EdJsonEditor/src/assets/plus.svg +1 -0
  195. package/src/components/ed-base-vue/package/EdJsonEditor/src/hooks.js +63 -0
  196. package/src/components/ed-base-vue/package/EdJsonViewer/index.js +8 -0
  197. package/src/components/ed-base-vue/package/EdJsonViewer/src/EdJsonViewer.vue +44 -0
  198. package/src/components/ed-base-vue/package/EdLable/index.js +8 -0
  199. package/src/components/ed-base-vue/package/EdLable/src/index.vue +34 -0
  200. package/src/components/ed-base-vue/package/EdLink/index.js +8 -0
  201. package/src/components/ed-base-vue/package/EdLink/src/index.vue +43 -0
  202. package/src/components/ed-base-vue/package/EdMarkEditor/index.js +15 -0
  203. package/src/components/ed-base-vue/package/EdMarkEditor/src/EdMarkEditor.vue +368 -0
  204. package/src/components/ed-base-vue/package/EdMarkEditor/src/extra-function.js +538 -0
  205. package/src/components/ed-base-vue/package/EdMarkEditor/src/highlight.js +95 -0
  206. package/src/components/ed-base-vue/package/EdTable/index.js +8 -0
  207. package/src/components/ed-base-vue/package/EdTable/src/EdTable.vue +240 -0
  208. package/src/components/ed-base-vue/package/EdTable/src/Props.js +97 -0
  209. package/src/components/ed-base-vue/package/EdTable/src/components/TableColumnItem.js +24 -0
  210. package/src/components/ed-base-vue/package/EdTable/src/components/TablePagination.vue +73 -0
  211. package/src/components/ed-base-vue/package/EdTableEditor/index.js +8 -0
  212. package/src/components/ed-base-vue/package/EdTableEditor/src/EdTableEditor.vue +282 -0
  213. package/src/components/ed-base-vue/package/EdTableEditor/src/Props.js +107 -0
  214. package/src/components/ed-base-vue/package/EdTableEditor/src/hooks/validate.js +90 -0
  215. package/src/components/ed-base-vue/package/EdUpload/index.js +8 -0
  216. package/src/components/ed-base-vue/package/EdUpload/src/Props.js +90 -0
  217. package/src/components/ed-base-vue/package/EdUpload/src/index.vue +88 -0
  218. package/src/components/ed-base-vue/package/EdViewer/index.js +8 -0
  219. package/src/components/ed-base-vue/package/EdViewer/src/EdViewer.vue +310 -0
  220. package/src/components/ed-base-vue/package/EdWangEditor/index.js +14 -0
  221. package/src/components/ed-base-vue/package/EdWangEditor/src/EdWangEditor.vue +127 -0
  222. package/src/components/ed-base-vue/package/ExtendSlot.js +12 -0
  223. package/src/components/ed-base-vue/package/OptionSlot.js +65 -0
  224. package/src/components/ed-base-vue/plugin/Message/index.js +2 -0
  225. package/src/components/ed-base-vue/plugin/Message/src/main.js +91 -0
  226. package/src/components/ed-base-vue/plugin/Message/src/main.vue +253 -0
  227. package/src/components/ed-base-vue/plugin/print/index.js +156 -0
  228. package/src/components/ed-base-vue/plugin/sortable/index.js +3784 -0
  229. package/src/components/ed-base-vue/style/custom.scss +107 -0
  230. package/src/components/ed-base-vue/style/deep.scss +100 -0
  231. package/src/components/ed-base-vue/style/index.scss +4 -0
  232. package/src/components/ed-base-vue/tools/date-format.js +315 -0
  233. package/src/components/ed-base-vue/tools/utils.js +124 -0
  234. package/src/layouts/components/AppMain.vue +17 -0
  235. package/src/layouts/components/Header.vue +256 -0
  236. package/src/layouts/components/Logo.vue +56 -0
  237. package/src/layouts/components/Navbar.vue +169 -0
  238. package/src/layouts/components/SideBar.vue +107 -0
  239. package/src/layouts/components/index.js +5 -0
  240. package/src/layouts/index.vue +57 -0
  241. package/src/main.js +42 -0
  242. package/src/request/config.js +6 -0
  243. package/src/request/index.js +85 -0
  244. package/src/request/request.js +147 -0
  245. package/src/router/index.js +65 -0
  246. package/src/router/modules/baseRouter.js +43 -0
  247. package/src/router/modules/easydata.js +49 -0
  248. package/src/views/base/BaseRichPreview.vue +23 -0
  249. package/src/views/base/BaseRichText.vue +28 -0
  250. package/src/views/base/EdFormView.vue +54 -0
  251. package/src/views/base/EdTable.vue +98 -0
  252. package/src/views/base/inputTable.vue +103 -0
  253. package/src/views/easydata/Interface.vue +3 -0
  254. package/src/views/easydata/dataSource.vue +13 -0
  255. package/src/views/easydata/dataSourceView.vue +71 -0
  256. package/src/views/easydata/templateDemo.vue +89 -0
  257. package/src/views/easydata/templateInfo.vue +13 -0
  258. package/src/views/index.vue +17 -0
  259. package/src/views/login.vue +208 -0
  260. package/src/views/redirect.vue +15 -0
@@ -0,0 +1,538 @@
1
+ /**
2
+ * @Author: HuaChao Chen <chc>
3
+ * @Date: 2017-06-14T23:04:34+08:00
4
+ * @Email: chenhuachaoxyz@gmail.com
5
+ * @Filename: extra-function.js
6
+ * @Last modified by: CHC
7
+ * @Last modified time: 2017-12-19T17:46:48+08:00
8
+ * @License: MIT
9
+ * @Copyright: 2017
10
+ */
11
+
12
+ /**
13
+ * Created by zhy on 2017/4/24.
14
+ */
15
+ /**
16
+ * textarea 插入内容
17
+ */
18
+ export const insertTextAtCaret = (obj, {prefix, subfix, str, type}, $vm) => {
19
+ obj.focus()
20
+ if (isExistSelectionObj(obj)) {
21
+ var startPos = obj.selectionStart;
22
+ var endPos = obj.selectionEnd;
23
+ var tmpStr = obj.value;
24
+ if (startPos === endPos) {
25
+ // 直接插入
26
+ obj.value = tmpStr.substring(0, startPos) + prefix + str + subfix + tmpStr.substring(endPos, tmpStr.length);
27
+ obj.selectionStart = startPos + prefix.length;
28
+ obj.selectionEnd = startPos + (str.length + prefix.length);
29
+ } else {
30
+ // 存在选中区域
31
+ if (tmpStr.substring(startPos - prefix.length, startPos) === prefix && tmpStr.substring(endPos, endPos + subfix.length) === subfix && judgeItalicAndBold(prefix, subfix, tmpStr, startPos, endPos)) {
32
+ // 取消
33
+ obj.value = tmpStr.substring(0, startPos - prefix.length) + tmpStr.substring(startPos, endPos) + tmpStr.substring(endPos + subfix.length, tmpStr.length);
34
+ obj.selectionStart = startPos - prefix.length;
35
+ obj.selectionEnd = endPos - prefix.length;
36
+ } else {
37
+ // 确定
38
+ obj.value = tmpStr.substring(0, startPos) + prefix + tmpStr.substring(startPos, endPos) + subfix + tmpStr.substring(endPos, tmpStr.length);
39
+ obj.selectionStart = startPos + prefix.length;
40
+ obj.selectionEnd = startPos + (endPos - startPos + prefix.length);
41
+ }
42
+ }
43
+ } else {
44
+ alert('Error: Browser version is too low')
45
+ // obj.value += str;
46
+ }
47
+ // 触发change事件
48
+ $vm.d_value = obj.value
49
+ obj.focus()
50
+ }
51
+
52
+ const code_structure = {
53
+ prefix: "```",
54
+ subfix: "\n```\n",
55
+ defaultLanguageText: "language"
56
+ }
57
+
58
+ export const insertCodeBlock = ($vm) => {
59
+ let obj = $vm.getTextareaDom();
60
+
61
+ if (isExistSelectionObj(obj)) {
62
+ const {defaultLanguageText: language} = code_structure;
63
+ let { selectionStart: startPos, selectionEnd: endPos, value: tmpStr } = obj;
64
+
65
+ if (startPos === endPos) {
66
+ // 直接插入
67
+ insertCodeBlockToVM(language, "", obj);
68
+ } else {
69
+ // 存在选中区域
70
+ if (isCancelCodeBlock(obj)) {
71
+ // 取消
72
+ removeCodeBlockFromVM(obj);
73
+ } else {
74
+ // 确定
75
+ let value = tmpStr.substring(startPos, endPos);
76
+ insertCodeBlockToVM("", value, obj);
77
+ }
78
+ }
79
+ } else {
80
+ alert('Error: Browser version is too low');
81
+ return;
82
+ }
83
+
84
+ // 触发change事件
85
+ $vm.d_value = obj.value
86
+ obj.focus();
87
+ }
88
+
89
+ function insertCodeBlockToVM(language, content, selectionObj) {
90
+ const {prefix, subfix} = code_structure;
91
+ let { selectionStart: startPos, selectionEnd: endPos, value: tmpStr } = selectionObj;
92
+
93
+ let value = tmpStr.substring(0, startPos);
94
+ value += prefix + language + "\n";
95
+ value += content;
96
+ value += subfix;
97
+ value += tmpStr.substring(endPos, tmpStr.length);
98
+
99
+ selectionObj.value = value;
100
+ selectionObj.selectionStart = startPos + prefix.length + (language ? 0 : 1);
101
+ selectionObj.selectionEnd = selectionObj.selectionStart + language.length + content.length;
102
+ }
103
+
104
+ function removeCodeBlockFromVM(selectionObj) {
105
+ let {prefix, subfix, defaultLanguageText: language} = code_structure;
106
+ let { selectionStart: startPos, selectionEnd: endPos, value: content } = selectionObj;
107
+ let selectedValue = content.substring(startPos, endPos);
108
+
109
+ if (content.substring(startPos - 1, startPos) === "\n")
110
+ {
111
+ prefix = prefix + "\n";
112
+ } else {
113
+ subfix = "\n" + subfix;
114
+ if (prefix + language + subfix === content.substring(startPos - prefix.length,endPos + subfix.length)) {
115
+ let value = content.substring(0, startPos - prefix.length);
116
+ value += content.substring(endPos + subfix.length, content.length)
117
+
118
+ selectionObj.value = value;
119
+ selectionObj.selectionStart = startPos - prefix.length;
120
+ selectionObj.selectionEnd = selectionObj.selectionStart;
121
+ return;
122
+ }
123
+ }
124
+
125
+ let value = content.substring(0, startPos - prefix.length);
126
+ value += selectedValue;
127
+ value += content.substring(endPos + subfix.length, content.length)
128
+
129
+ selectionObj.value = value;
130
+ selectionObj.selectionStart = startPos - prefix.length;
131
+ selectionObj.selectionEnd = selectionObj.selectionStart + selectedValue.length;
132
+ }
133
+
134
+ function isExistSelectionObj(textareaDom) {
135
+ return typeof textareaDom.selectionStart === 'number' && typeof textareaDom.selectionEnd === 'number';
136
+ }
137
+
138
+ function isCancelCodeBlock(selectionObj) {
139
+ let { selectionStart: startPos, selectionEnd: endPos, value: content } = selectionObj;
140
+ let {prefix, subfix} = code_structure;
141
+
142
+ if (content.substring(startPos - 1, startPos) === "\n")
143
+ {
144
+ prefix = prefix + "\n";
145
+ } else {
146
+ subfix = "\n" + subfix;
147
+ }
148
+
149
+ return content.substring(startPos - prefix.length, startPos) === prefix &&
150
+ content.substring(endPos, endPos + subfix.length) === subfix;
151
+ }
152
+
153
+ // 处理粗体与斜体冲突问题
154
+ function judgeItalicAndBold(prefix, subfix, tmpStr, startPos, endPos) {
155
+ if (prefix === '*' && subfix === '*') {
156
+ if (tmpStr.substring(startPos - 2, startPos - 1) === '*' && tmpStr.substring(endPos + 1, endPos + 2) === '*') {
157
+ return false
158
+ }
159
+ }
160
+ return true
161
+ }
162
+ // 插入有序列表
163
+ export const insertOl = ($vm) => {
164
+ let obj = $vm.getTextareaDom();
165
+ if (isExistSelectionObj(obj)) {
166
+ var startPos = obj.selectionStart;
167
+ var endPos = obj.selectionEnd;
168
+ var tmpStr = obj.value;
169
+ if (startPos === endPos) {
170
+ // 直接插入
171
+ obj.value = tmpStr.substring(0, startPos) + '1. ' + tmpStr.substring(endPos, tmpStr.length);
172
+ obj.selectionEnd = obj.selectionStart = startPos + 3;
173
+ } else {
174
+ // 存在选中区域
175
+ let start = startPos
176
+ while (start > 0 && tmpStr.substring(start - 1, start) !== '\n') {
177
+ start--
178
+ }
179
+ let selectStr = tmpStr.substring(start, endPos)
180
+ let selectStrs = selectStr.split('\n')
181
+ for (let i = 0; i < selectStrs.length; i++) {
182
+ selectStrs[i] = (i + 1) + '. ' + selectStrs[i]
183
+ }
184
+ let newSelectStr = selectStrs.join('\n')
185
+ obj.value = tmpStr.substring(0, start) + newSelectStr + tmpStr.substring(endPos, tmpStr.length);
186
+ obj.selectionStart = start
187
+ obj.selectionEnd = endPos + newSelectStr.length - selectStr.length;
188
+ }
189
+ } else {
190
+ alert('Error: Browser version is too low')
191
+ // obj.value += str;
192
+ }
193
+ // 触发change事件
194
+ $vm.d_value = obj.value
195
+ obj.focus();
196
+ }
197
+ // 删除行
198
+ export const removeLine = ($vm) => {
199
+ let obj = $vm.getTextareaDom();
200
+ if (isExistSelectionObj(obj)) {
201
+ var startPos = obj.selectionStart;
202
+ var endPos = obj.selectionEnd;
203
+ var tmpStr = obj.value;
204
+ // 找到行首、行尾
205
+ let start = startPos
206
+ while (start > 0 && tmpStr.substring(start - 1, start) !== '\n') {
207
+ start--
208
+ }
209
+ let end = endPos
210
+ while (end < tmpStr.length && tmpStr.substring(end, end + 1) !== '\n') {
211
+ end++
212
+ }
213
+ if (end < tmpStr.length) {
214
+ end++
215
+ }
216
+ obj.value = tmpStr.substring(0, start) + tmpStr.substring(end, tmpStr.length);
217
+ obj.selectionEnd = obj.selectionStart = start === 0 ? 0 : start - 1;
218
+ } else {
219
+ alert('Error: Browser version is too low')
220
+ // obj.value += str;
221
+ }
222
+ // 触发change事件
223
+ $vm.d_value = obj.value
224
+ obj.focus();
225
+ }
226
+ // 插入无序列表
227
+ export const insertUl = ($vm) => {
228
+ let obj = $vm.getTextareaDom();
229
+ if (isExistSelectionObj(obj)) {
230
+ var startPos = obj.selectionStart;
231
+ var endPos = obj.selectionEnd;
232
+ var tmpStr = obj.value;
233
+ if (startPos === endPos) {
234
+ // 直接插入
235
+ obj.value = tmpStr.substring(0, startPos) + '- ' + tmpStr.substring(endPos, tmpStr.length);
236
+ obj.selectionEnd = obj.selectionStart = startPos + 2;
237
+ } else {
238
+ // 存在选中区域
239
+ let start = startPos
240
+ while (start > 0 && tmpStr.substring(start - 1, start) !== '\n') {
241
+ start--
242
+ }
243
+ let selectStr = tmpStr.substring(start, endPos)
244
+ let newSelectStr = selectStr.replace(/\n/g, '\n- ')
245
+ newSelectStr = '- ' + newSelectStr
246
+ obj.value = tmpStr.substring(0, start) + newSelectStr + tmpStr.substring(endPos, tmpStr.length);
247
+ obj.selectionStart = start
248
+ obj.selectionEnd = endPos + newSelectStr.length - selectStr.length;
249
+ }
250
+ } else {
251
+ alert('Error: Browser version is too low')
252
+ // obj.value += str;
253
+ }
254
+ // 触发change事件
255
+ $vm.d_value = obj.value
256
+ obj.focus();
257
+ }
258
+ // 插入tab
259
+ export const insertTab = ($vm, tab) => {
260
+ tab = tab ? (new Array(tab)).fill(' ').join('') : '\t'
261
+ let obj = $vm.getTextareaDom();
262
+ if (isExistSelectionObj(obj)) {
263
+ var startPos = obj.selectionStart;
264
+ var endPos = obj.selectionEnd;
265
+ var tmpStr = obj.value;
266
+ let lastLine = tmpStr.substring(0, startPos).split('\n').pop()
267
+ if (lastLine.match(/^\s*[0-9]+\.\s+\S*/)) {
268
+ // 有序列表
269
+ let temp = lastLine.replace(/(\d+)/, 1)
270
+ obj.value = tmpStr.substring(0, startPos - temp.length) + tab + temp + tmpStr.substring(endPos, tmpStr.length);
271
+ } else if (lastLine.match(/^\s*-\s+\S*/)) {
272
+ // 无序列表
273
+ obj.value = tmpStr.substring(0, startPos - lastLine.length) + tab + lastLine + tmpStr.substring(endPos, tmpStr.length);
274
+ } else {
275
+ obj.value = tmpStr.substring(0, startPos) + tab + tmpStr.substring(endPos, tmpStr.length);
276
+ }
277
+ obj.selectionStart = obj.selectionEnd = startPos + tab.length;
278
+ } else {
279
+ alert('Error: Browser version is too low')
280
+ // obj.value += str;
281
+ }
282
+ // 触发change事件
283
+ $vm.d_value = obj.value
284
+ obj.focus();
285
+ }
286
+ // shift + tab
287
+ export const unInsertTab = ($vm, tab) => {
288
+ let regTab = new RegExp(tab ? `\\s{${tab}}` : '\t')
289
+ console.log(`regTab:`, regTab)
290
+ let obj = $vm.getTextareaDom();
291
+ if (isExistSelectionObj(obj)) {
292
+ var startPos = obj.selectionStart;
293
+ var endPos = obj.selectionEnd;
294
+ var tmpStr = obj.value;
295
+ let lastLine = tmpStr.substring(0, startPos).split('\n').pop()
296
+ if (lastLine.search(regTab) >= 0) {
297
+ // 替换最后一个制表符为空
298
+ obj.value = tmpStr.substring(0, startPos - lastLine.length) + lastLine.replace(regTab, '') + tmpStr.substring(endPos, tmpStr.length);
299
+ obj.selectionStart = obj.selectionEnd = startPos - (tab || 1);
300
+ }
301
+ } else {
302
+ alert('Error: Browser version is too low')
303
+ // obj.value += str;
304
+ }
305
+ // 触发change事件
306
+ $vm.d_value = obj.value
307
+ obj.focus();
308
+ }
309
+ // 插入enter
310
+ export const insertEnter = ($vm, event) => {
311
+ let obj = $vm.getTextareaDom()
312
+ if (isExistSelectionObj(obj)) {
313
+ var startPos = obj.selectionStart;
314
+ var endPos = obj.selectionEnd;
315
+ var tmpStr = obj.value;
316
+ // 获取光标前最后一行字符串
317
+ let lastLine = tmpStr.substring(0, startPos).split('\n').pop()
318
+ let matchListNeedChangeLine = lastLine.match(/^\s*(?:[0-9]+\.|-)\s+\S+/)
319
+ if (matchListNeedChangeLine) {
320
+ // 需要自动产生下一个列表项
321
+ event.preventDefault()
322
+ // eg: [1. test] 仅获取[1. ]
323
+ let subfix = matchListNeedChangeLine.shift().match(/^\s*(?:[0-9]+\.|-)\s/).shift()
324
+ if (subfix.search(/-/) >= 0) {
325
+ // 无序列表
326
+ obj.value = tmpStr.substring(0, startPos) + '\n' + subfix + tmpStr.substring(endPos, tmpStr.length);
327
+ obj.selectionStart = obj.selectionEnd = startPos + subfix.length + 1
328
+ } else {
329
+ // 有序列表
330
+ let temp = subfix.replace(/(\d+)/, parseInt(subfix) + 1)
331
+ obj.value = tmpStr.substring(0, startPos) + '\n' + temp + tmpStr.substring(endPos, tmpStr.length);
332
+ obj.selectionStart = obj.selectionEnd = startPos + temp.length + 1
333
+ }
334
+ } else {
335
+ let matchListNeedRemoveLine = lastLine.match(/^\s*(?:[0-9]+\.|-)\s+$/)
336
+ if (matchListNeedRemoveLine) {
337
+ // 需要跳出列表
338
+ event.preventDefault()
339
+ let preLength = matchListNeedRemoveLine.shift().length
340
+ obj.value = tmpStr.substring(0, startPos - preLength) + '\n' + tmpStr.substring(endPos, tmpStr.length);
341
+ obj.selectionStart = obj.selectionEnd = startPos - preLength
342
+ // TODO 检测是否存在嵌套列表,自动生成上一级
343
+ }
344
+ }
345
+ } else {
346
+ alert('Error: Browser version is too low')
347
+ }
348
+ $vm.d_value = obj.value
349
+ obj.focus();
350
+ }
351
+ /**
352
+ * 生成导航目录
353
+ */
354
+ export const getNavigation = ($vm , full) => {
355
+ let navigationContent;
356
+
357
+ navigationContent = $vm.$refs.navigationContent
358
+
359
+ navigationContent.innerHTML = $vm.d_render
360
+ let nodes = navigationContent.children
361
+ if (nodes.length) {
362
+ for (let i = 0; i < nodes.length; i++) {
363
+ judageH(nodes[i] , i , nodes)
364
+ }
365
+ }
366
+ function judageH(node , i , nodes) {
367
+ let reg = /^H[1-6]{1}$/;
368
+ if (!reg.exec(node.tagName)) {
369
+ node.style.display = 'none'
370
+ } else {
371
+ node.onclick = function () {
372
+ let vShowContent = $vm.$refs.vShowContent;
373
+ let vNoteEdit = $vm.$refs.vNoteEdit;
374
+ if ($vm.s_subfield) {
375
+ // 双栏
376
+ if ($vm.s_preview_switch) {
377
+ // 编辑预览
378
+ vNoteEdit.scrollTop = vShowContent.children[i].offsetTop * (vNoteEdit.scrollHeight - vNoteEdit.offsetHeight) / (vShowContent.scrollHeight - vShowContent.offsetHeight);
379
+ } else {
380
+ // todo 编辑
381
+ }
382
+ } else {
383
+ // 单栏
384
+ if ($vm.s_preview_switch) {
385
+ // 预览
386
+ vShowContent.scrollTop = vShowContent.children[i].offsetTop;
387
+ } else {
388
+ // todo 编辑
389
+ }
390
+ }
391
+ }
392
+ }
393
+ }
394
+ }
395
+
396
+ /**
397
+ * 滚动条联动
398
+ */
399
+ export const scrollLink = ($event, $vm) => {
400
+ let element = $event.srcElement ? $event.srcElement : $event.target
401
+ let ratio = element.scrollTop / (element.scrollHeight - element.offsetHeight)
402
+ if ($vm.edit_scroll_height >= 0 && element.scrollHeight !== $vm.edit_scroll_height && (element.scrollHeight - element.offsetHeight - element.scrollTop <= 30)) {
403
+ // star 内容变化 导致 高度增加 且滚动条距离底部小于25px 自动滚动到底部
404
+ $vm.$refs.vNoteEdit.scrollTop = element.scrollHeight - element.offsetHeight
405
+ ratio = 1
406
+ }
407
+ $vm.edit_scroll_height = element.scrollHeight
408
+ // end ----
409
+ if ($vm.$refs.vShowContent.scrollHeight > $vm.$refs.vShowContent.offsetHeight) {
410
+ $vm.$refs.vShowContent.scrollTop = ($vm.$refs.vShowContent.scrollHeight - $vm.$refs.vShowContent.offsetHeight) * ratio
411
+ }
412
+ }
413
+ /**
414
+ * 监听浏览器fullscreen
415
+ * @param $vm
416
+ */
417
+ export const fullscreenchange = ($vm) => {
418
+ // 阅读模式 全屏监听事件
419
+ $vm.$el.addEventListener('fullscreenchange', function (e) {
420
+ $vm.$toolbar_right_read_change_status()
421
+ }, false);
422
+ $vm.$el.addEventListener('mozfullscreenchange', function (e) {
423
+ $vm.$toolbar_right_read_change_status()
424
+ }, false);
425
+ $vm.$el.addEventListener('webkitfullscreenchange', function (e) {
426
+ $vm.$toolbar_right_read_change_status()
427
+ }, false);
428
+ $vm.$el.addEventListener('msfullscreenchange', function (e) {
429
+ $vm.$toolbar_right_read_change_status()
430
+ }, false);
431
+ }
432
+
433
+ /**
434
+ * 监听浏览器onresize
435
+ * @param $vm
436
+ */
437
+ export const windowResize = ($vm) => {
438
+ function sizeToStatus() {
439
+ if ($vm.$el.clientWidth > 768) {
440
+ // > 768
441
+ $vm.s_subfield = $vm.subfield;
442
+ }
443
+ else {
444
+ // < 768
445
+ $vm.s_subfield = false;
446
+ }
447
+ }
448
+
449
+ sizeToStatus();
450
+ window.addEventListener('resize', sizeToStatus);
451
+ }
452
+
453
+ export function loadScript(src, callback) {
454
+ if (!(typeof callback === 'function')) {
455
+ callback = function() {};
456
+ }
457
+ var check = document.querySelectorAll("script[src='" + src + "']");
458
+ if (check.length > 0) {
459
+ check[0].addEventListener('load', function() {
460
+ callback();
461
+ });
462
+ callback();
463
+ return;
464
+ }
465
+ var script = document.createElement('script');
466
+ var head = document.getElementsByTagName('head')[0];
467
+ script.type = 'text/javascript';
468
+ script.charset = 'UTF-8';
469
+ script.src = src;
470
+ if (script.addEventListener) {
471
+ script.addEventListener('load', function () {
472
+ callback();
473
+ }, false);
474
+ } else if (script.attachEvent) {
475
+ script.attachEvent('onreadystatechange', function () {
476
+ var target = window.event.srcElement;
477
+ if (target.readyState === 'loaded') {
478
+ callback();
479
+ }
480
+ });
481
+ }
482
+ head.appendChild(script);
483
+ }
484
+
485
+ // <link href="https://cdn.bootcss.com/highlight.js/9.12.0/styles/agate.min.css" rel="stylesheet">
486
+ export function loadLink(src, callback, id) {
487
+ if (!(typeof callback === 'function')) {
488
+ callback = function() {};
489
+ }
490
+ var check = document.querySelectorAll("link[href='" + src + "']");
491
+ if (check.length > 0) {
492
+ callback();
493
+ return;
494
+ }
495
+
496
+ if (id) {
497
+ var styles = document.querySelectorAll("link#" + id);
498
+ if (styles.length) {
499
+ styles[0].href = src;
500
+ return;
501
+ }
502
+ }
503
+
504
+ var link = document.createElement('link');
505
+ var head = document.getElementsByTagName('head')[0];
506
+ link.rel = 'stylesheet';
507
+ link.href = src;
508
+ id && (link['id'] = id);
509
+ if (link.addEventListener) {
510
+ link.addEventListener('load', function () {
511
+ callback();
512
+ }, false);
513
+ } else if (link.attachEvent) {
514
+ link.attachEvent('onreadystatechange', function () {
515
+ var target = window.event.srcElement;
516
+ if (target.readyState === 'loaded') {
517
+ callback();
518
+ }
519
+ });
520
+ }
521
+ head.appendChild(link);
522
+ }
523
+
524
+ export const ImagePreviewListener = ($vm) => {
525
+ // vShowContent
526
+ $vm.$refs.vShowContent.addEventListener('click', function (event) {
527
+ event = event ? event : window.event;
528
+ let ele = event.srcElement ? event.srcElement : event.target;
529
+ if (ele.tagName === 'IMG') {
530
+ if ($vm.imageClick != null) {
531
+ // 覆盖图片点击事件
532
+ $vm.imageClick(ele);
533
+ } else {
534
+ $vm.d_preview_imgsrc = ele.src;
535
+ }
536
+ }
537
+ })
538
+ }
@@ -0,0 +1,95 @@
1
+ /**
2
+ * @Author: HuaChao Chen <CHC>
3
+ * @Date: 2017-06-16T21:01:47+08:00
4
+ * @Email: chenhuachaoxyz@gmail.com
5
+ * @Filename: highlight.js
6
+ * @Last modified by: chc
7
+ * @Last modified time: 2017-11-24T19:55:22+08:00
8
+ * @License: MIT
9
+ * @Copyright: 2017
10
+ */
11
+
12
+ import {
13
+ loadScript
14
+ } from './extra-function.js'
15
+ function highLightCode(str, callback, hljsLangFuc, hljsFuc) {
16
+ var hljs = window.hljs;
17
+ if (!hljs) {
18
+ if (typeof hljsFuc !== 'function') {
19
+ console.warn('external_link.hljs_js is not a function, hljs can not load by mavon-editor, if you want to disabled this log, set external_link.hljs_js to function');
20
+ callback(str);
21
+ return;
22
+ }
23
+ var url = hljsFuc();
24
+ console.warn('hljs parsing file is missing. mavon-editor will autoload', url);
25
+ loadScript(url, function() {
26
+ _highLightCode(str, callback, hljsLangFuc);
27
+ });
28
+ } else {
29
+ if (typeof hljsLangFuc === 'function') {
30
+ _highLightCode(str, callback, hljsLangFuc);
31
+ } else {
32
+ console.warn('external_link.hljs_lang is not a function, hljs will not to work');
33
+ callback(str);
34
+ }
35
+ }
36
+ }
37
+ function _highLightCode(str, callback, hljsLangFuc) {
38
+ var dom = document.createElement('div');
39
+ var hljs = window.hljs;
40
+ dom.innerHTML = str;
41
+ var pre_code = dom.querySelectorAll('pre > div.hljs > code');
42
+ if (pre_code && hljs && (typeof hljsLangFuc === 'function')) {
43
+ var flag = 0;
44
+ var i = 0;
45
+ var deal = 0;
46
+ var not_include_lang = {}; // these lang parse file need to be include.
47
+ var url = '';
48
+ for (i = 0; i < pre_code.length; i++) {
49
+ var lang = pre_code[i].className.toLowerCase();
50
+ if (lang.length > 0) {
51
+ // if this lang parse file missing
52
+ url = hljsLangFuc(lang);
53
+ if (!hljs.getLanguage(lang) && !not_include_lang.hasOwnProperty(lang) && url.length > 0) {
54
+ not_include_lang[lang] = url;
55
+ }
56
+ }
57
+ }
58
+ // we need to include these lang parse file manually
59
+ var need_langs = [];
60
+ for (var key in not_include_lang) {
61
+ if (not_include_lang.hasOwnProperty(key)) {
62
+ need_langs.push(key);
63
+ }
64
+ }
65
+ for (i = 0; i < need_langs.length; i++) {
66
+ url = not_include_lang[need_langs[i]];
67
+ loadScript(url, function() {
68
+ deal = deal + 1;
69
+ if (deal === need_langs.length) {
70
+ for (var i = 0; i < pre_code.length; i++) {
71
+ var lang = pre_code[i].className;
72
+ // if lang is valid.
73
+ if (lang.length > 0 && hljs.getLanguage(lang)) {
74
+ hljs.highlightBlock(pre_code[i])
75
+ }
76
+ }
77
+ callback(dom.innerHTML);
78
+ }
79
+ });
80
+ }
81
+ if (need_langs.length === 0) {
82
+ for (i = 0; i < pre_code.length; i++) {
83
+ lang = pre_code[i].className;
84
+ // if lang is valid.
85
+ if (lang.length > 0 && hljs.getLanguage(lang)) {
86
+ hljs.highlightBlock(pre_code[i])
87
+ }
88
+ }
89
+ callback(dom.innerHTML);
90
+ }
91
+ } else {
92
+ callback(dom.innerHTML);
93
+ }
94
+ }
95
+ export default highLightCode;
@@ -0,0 +1,8 @@
1
+ import EdTable from './src/EdTable.vue';
2
+
3
+ /* istanbul ignore next */
4
+ EdTable.install = function (Vue) {
5
+ Vue.component(EdTable.name, EdTable)
6
+ }
7
+
8
+ export default EdTable;