├── .browserslistrc ├── .eslintignore ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── config.yml ├── reaction.yml ├── release-drafter.yml ├── stale.yml └── workflows │ ├── codeql-analysis.yml │ ├── dockerimage-latest.yml │ ├── dockerimage-release.yml │ └── update_docker_description.yml ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── babel.config.js ├── node_modules └── .bin │ ├── vue-cli-service │ └── vue-cli-service.cmd ├── package-lock.json ├── package.json ├── postcss.config.js ├── public ├── _redirects ├── favicon.ico ├── index.html ├── manifest.json └── robots.txt ├── src ├── App.vue ├── assets │ └── logo.png ├── business │ ├── persistence │ │ ├── StorageManager.ts │ │ ├── localstorage │ │ │ └── LocalStorageManager.ts │ │ └── preferences │ │ │ ├── PreferenceItem.ts │ │ │ ├── PreferenceItems.ts │ │ │ └── PreferenceManger.ts │ └── rest │ │ ├── RestClient.ts │ │ ├── model │ │ ├── DocumentModel.ts │ │ ├── ResourceModel.ts │ │ └── SectionModel.ts │ │ └── websockets │ │ └── DocumentSyncManager.ts ├── components │ ├── CodeEditor.vue │ ├── Settings.vue │ ├── about │ │ ├── About.vue │ │ └── pages │ │ │ ├── AboutApp.vue │ │ │ └── libraries │ │ │ ├── AboutLibraries.vue │ │ │ ├── Library.ts │ │ │ ├── LibraryItems.ts │ │ │ └── LibraryListItem.vue │ └── browser │ │ ├── FileBrowser.vue │ │ └── section │ │ ├── DocumentListItem.vue │ │ ├── ResourceListItem.vue │ │ ├── SectionListItem.vue │ │ └── SectionOverview.vue ├── libraries │ ├── PowerArray.js │ └── PowerArray.min.js ├── main.ts ├── registerServiceWorker.ts ├── router.ts ├── shims-tsx.d.ts ├── shims-vue.d.ts └── vue-extension.d.ts ├── tsconfig.json ├── tslint.json └── vue.config.js /.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not ie <= 8 -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | *.min.js 2 | src/libraries/*.js -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Steps to reproduce the behavior: 12 | 1. Go to '...' 13 | 2. Click on '....' 14 | 3. Scroll down to '....' 15 | 4. See error 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Screenshots** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | **System & Browser (please complete the following information):** 24 | - OS: [e.g. Arch Linux] 25 | - Browser: [e.g. Chromium] 26 | - Version: [e.g. Version 72.0.3626.119 (Official Build) Arch Linux (64-bit)] 27 | 28 | **Additional context** 29 | Add any other context about the problem here. 30 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /.github/config.yml: -------------------------------------------------------------------------------- 1 | # Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome 2 | 3 | # Comment to be posted to on first time issues 4 | newIssueWelcomeComment: > 5 | Thanks for opening your first issue here! :tada: 6 | 7 | # Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome 8 | 9 | # Comment to be posted to on PRs from first time contributors in your repository 10 | newPRWelcomeComment: > 11 | Thanks for opening this pull request! :nerd_face: 12 | 13 | # Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge 14 | 15 | # Comment to be posted to on pull requests merged by a first time user 16 | firstPRMergeComment: > 17 | Congrats on merging your first pull request here! You should be proud of yourself :1st_place_medal: 18 | ![Congratulations](https://media.giphy.com/media/ehhuGD0nByYxO/giphy.gif) 19 | 20 | # It is recommend to include as many gifs and emojis as possible 21 | -------------------------------------------------------------------------------- /.github/reaction.yml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | template: | 2 | ## What’s Changed 3 | 4 | $CHANGES 5 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Configuration for probot-stale - https://github.com/probot/stale 2 | 3 | # Number of days of inactivity before an Issue or Pull Request becomes stale 4 | daysUntilStale: 60 5 | 6 | # Number of days of inactivity before an Issue or Pull Request with the stale label is closed. 7 | # Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale. 8 | daysUntilClose: 14 9 | 10 | # Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable 11 | exemptLabels: 12 | - pinned 13 | - security 14 | 15 | # Set to true to ignore issues in a project (defaults to false) 16 | exemptProjects: false 17 | 18 | # Set to true to ignore issues in a milestone (defaults to false) 19 | exemptMilestones: false 20 | 21 | # Set to true to ignore issues with an assignee (defaults to false) 22 | exemptAssignees: true 23 | 24 | # Label to use when marking as stale 25 | staleLabel: wontfix 26 | 27 | # Comment to post when marking as stale. Set to `false` to disable 28 | markComment: > 29 | This issue has been automatically marked as stale because it has not had 30 | recent activity. It will be closed if no further activity occurs. Thank you 31 | for your contributions. 32 | 33 | # Comment to post when removing the stale label. 34 | # unmarkComment: > 35 | # Your comment here. 36 | 37 | # Comment to post when closing a stale Issue or Pull Request. 38 | closeComment: > 39 | There has been no incentive by contributors or maintainers to revive this stale issue and it will now be closed. 40 | 41 | # Limit the number of actions per hour, from 1-30. Default is 30 42 | limitPerRun: 30 43 | 44 | # Limit to only `issues` or `pulls` 45 | only: issues 46 | 47 | # Optionally, specify configuration settings that are specific to just 'issues' or 'pulls': 48 | # pulls: 49 | # daysUntilStale: 30 50 | # markComment: > 51 | # This pull request has been automatically marked as stale because it has not had 52 | # recent activity. It will be closed if no further activity occurs. Thank you 53 | # for your contributions. 54 | 55 | # issues: 56 | # exemptLabels: 57 | # - confirmed 58 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL" 2 | 3 | on: 4 | push: 5 | branches: [master, ] 6 | pull_request: 7 | # The branches below must be a subset of the branches above 8 | branches: [master] 9 | schedule: 10 | - cron: '0 4 * * 3' 11 | 12 | jobs: 13 | analyze: 14 | name: Analyze 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - name: Checkout repository 19 | uses: actions/checkout@v2 20 | with: 21 | # We must fetch at least the immediate parents so that if this is 22 | # a pull request then we can checkout the head. 23 | fetch-depth: 2 24 | 25 | # If this run was triggered by a pull request event, then checkout 26 | # the head of the pull request instead of the merge commit. 27 | - run: git checkout HEAD^2 28 | if: ${{ github.event_name == 'pull_request' }} 29 | 30 | # Initializes the CodeQL tools for scanning. 31 | - name: Initialize CodeQL 32 | uses: github/codeql-action/init@v1 33 | # Override language selection by uncommenting this and choosing your languages 34 | # with: 35 | # languages: go, javascript, csharp, python, cpp, java 36 | 37 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 38 | # If this step fails, then you should remove it and run the build manually (see below) 39 | - name: Autobuild 40 | uses: github/codeql-action/autobuild@v1 41 | 42 | # ℹ️ Command-line programs to run using the OS shell. 43 | # 📚 https://git.io/JvXDl 44 | 45 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 46 | # and modify them (or add more) to build your code if your project 47 | # uses a compiled language 48 | 49 | #- run: | 50 | # make bootstrap 51 | # make release 52 | 53 | - name: Perform CodeQL Analysis 54 | uses: github/codeql-action/analyze@v1 55 | -------------------------------------------------------------------------------- /.github/workflows/dockerimage-latest.yml: -------------------------------------------------------------------------------- 1 | name: Docker Image latest 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | - name: Build the Docker image 13 | run: docker build . --file Dockerfile --tag mkdocseditor/mkdocseditor-web:latest 14 | - name: Login to DockerHub Registry 15 | run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin 16 | - name: Push the Docker image 17 | run: docker push mkdocseditor/mkdocseditor-web:latest 18 | -------------------------------------------------------------------------------- /.github/workflows/dockerimage-release.yml: -------------------------------------------------------------------------------- 1 | name: Docker Image Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - "*.*.*" 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | # this writes the tag name into GIT_TAG_NAME 14 | - name: Get tag name 15 | uses: olegtarasov/get-tag@v2 16 | - name: Build the Docker image 17 | run: docker build . --file Dockerfile --tag mkdocseditor/mkdocseditor-web:$GIT_TAG_NAME 18 | - name: Login to DockerHub Registry 19 | run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin 20 | - name: Push the Docker image 21 | run: docker push mkdocseditor/mkdocseditor-web:$GIT_TAG_NAME 22 | -------------------------------------------------------------------------------- /.github/workflows/update_docker_description.yml: -------------------------------------------------------------------------------- 1 | name: Update Docker Hub Description 2 | on: [release] 3 | jobs: 4 | dockerHubDescription: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - uses: actions/checkout@v2 8 | - name: Docker Hub Description 9 | uses: peter-evans/dockerhub-description@v2.1.0 10 | env: 11 | DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} 12 | DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} 13 | DOCKERHUB_REPOSITORY: mkdocseditor/mkdocseditor-web 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | node_modules/* 4 | !node_modules/bin 5 | node_modules/bin/* 6 | !node_modules/bin/vue-cli-service 7 | !node_modules/bin/vue-cli-service.cmd 8 | 9 | /dist 10 | 11 | # local env files 12 | .env.local 13 | .env.*.local 14 | 15 | # Log files 16 | npm-debug.log* 17 | yarn-debug.log* 18 | yarn-error.log* 19 | 20 | # Editor directories and files 21 | .idea 22 | .vscode 23 | *.suo 24 | *.ntvs* 25 | *.njsproj 26 | *.sln 27 | *.sw* 28 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:lts-alpine 2 | 3 | # install simple http server for serving static content 4 | RUN npm install -g http-server 5 | 6 | # make the 'app' folder the current working directory 7 | WORKDIR /app 8 | 9 | # copy both 'package.json' and 'package-lock.json' (if available) 10 | COPY package*.json ./ 11 | 12 | # install project dependencies 13 | RUN npm install 14 | 15 | # copy project files and folders to the current working directory (i.e. 'app' folder) 16 | COPY . . 17 | 18 | # build app for production with minification 19 | RUN npm run build 20 | 21 | EXPOSE 8080 22 | CMD [ "http-server", "dist" ] 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Logo
3 |

4 | 5 | # MkDocsEditor-Web 6 | MkDocsEditor web client. 7 | 8 | [![Netlify Status](https://api.netlify.com/api/v1/badges/dd328233-3e6d-4fd8-8cf1-ce036691592b/deploy-status)](https://mkdocseditor.netlify.app/#/) 9 | 10 | # :warning: Work In Progress 11 | 12 | This project is still a work in progress and is **not yet ready for production**. 13 | 14 | 15 | # Developer Instructions 16 | 17 | ## Project setup 18 | ``` 19 | npm install -g @vue/cli 20 | npm install -g @vue/cli-service-global 21 | ``` 22 | 23 | ### Compiles and hot-reloads for development 24 | ``` 25 | npm run serve 26 | ``` 27 | 28 | User friendly debugging in chrome: 29 | ``` 30 | https://github.com/vuejs/vue-devtools#vue-devtools 31 | ``` 32 | 33 | ### Compiles and minifies for production 34 | ``` 35 | npm run build 36 | ``` 37 | 38 | ### Lints and fixes files 39 | ``` 40 | npm run lint 41 | ``` 42 | 43 | # Contributing 44 | GitHub is for social coding: if you want to write code, I encourage 45 | contributions through pull requests from forks of this repository. 46 | Create GitHub tickets for bugs and new features and comment on the ones 47 | that you are interested in. 48 | 49 | # License 50 | 51 | **AGPLv3+** 52 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/app' 4 | ] 5 | }; 6 | -------------------------------------------------------------------------------- /node_modules/.bin/vue-cli-service: -------------------------------------------------------------------------------- 1 | ../@vue/cli-service/bin/vue-cli-service.js -------------------------------------------------------------------------------- /node_modules/.bin/vue-cli-service.cmd: -------------------------------------------------------------------------------- 1 | @IF EXIST "%~dp0\node.exe" ( 2 | "%~dp0\node.exe" "%~dp0\..\@vue\cli-service\bin\vue-cli-service.js" %* 3 | ) ELSE ( 4 | @SETLOCAL 5 | @SET PATHEXT=%PATHEXT:;.JS;=;% 6 | node "%~dp0\..\@vue\cli-service\bin\vue-cli-service.js" %* 7 | ) -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mkdocseditor_web", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "axios": "^0.21.1", 12 | "core-js": "^3.8.0", 13 | "diff-match-patch": "^1.0.5", 14 | "mavon-editor": "^2.9.0", 15 | "register-service-worker": "^1.7.1", 16 | "terser": "^5.5.0", 17 | "vue": "^2.6.12", 18 | "vue-class-component": "^7.2.6", 19 | "vue-material": "^1.0.0-beta-15", 20 | "vue-property-decorator": "^9", 21 | "vue-router": "^3", 22 | "vue-toasted": "^1.1.28" 23 | }, 24 | "devDependencies": { 25 | "@typescript-eslint/eslint-plugin": "^4.8.2", 26 | "@typescript-eslint/parser": "^4.8.2", 27 | "@vue/cli-plugin-babel": "^4.5.9", 28 | "@vue/cli-plugin-eslint": "^4.5.9", 29 | "@vue/cli-plugin-pwa": "^4.5.9", 30 | "@vue/cli-plugin-typescript": "^4.5.9", 31 | "@vue/cli-service": "^4.5.9", 32 | "eslint": "^7", 33 | "eslint-plugin-vue": "^7", 34 | "husky": "^5.0.4", 35 | "lint-staged": "^10.5.2", 36 | "node-sass": "^5.0.0", 37 | "sass-loader": "^10.1.0", 38 | "typescript": "^4.1.2", 39 | "vue-template-compiler": "^2.6.12" 40 | }, 41 | "eslintConfig": { 42 | "root": true, 43 | "env": { 44 | "node": true 45 | }, 46 | "extends": [ 47 | "plugin:vue/essential", 48 | "plugin:@typescript-eslint/recommended", 49 | "eslint:recommended" 50 | ], 51 | "rules": { 52 | "no-unused-vars": "off", 53 | "@typescript-eslint/ban-ts-ignore": "off", 54 | "@typescript-eslint/no-unused-vars": "off", 55 | "@typescript-eslint/no-empty-interface": "off", 56 | "indent": "off", 57 | "@typescript-eslint/indent": "off", 58 | "@typescript-eslint/camelcase": "off", 59 | "vue/script-indent": [ 60 | "warn", 61 | 4, 62 | { 63 | "baseIndent": 1 64 | } 65 | ] 66 | }, 67 | "parser": "vue-eslint-parser", 68 | "parserOptions": { 69 | "parser": "@typescript-eslint/parser", 70 | "ecmaFeatures": { 71 | "legacyDecorators": true 72 | } 73 | }, 74 | "plugins": [ 75 | "@typescript-eslint" 76 | ] 77 | }, 78 | "gitHooks": { 79 | "pre-commit": "lint-staged" 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | autoprefixer: {} 4 | } 5 | }; 6 | -------------------------------------------------------------------------------- /public/_redirects: -------------------------------------------------------------------------------- 1 | # Netlify settings for single-page application 2 | /* /index.html 200 3 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MkDocsEditor/MkDocsEditor-Web/c10b89f3b355d5c037bd9c89bdc06fff507d365b/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | mkdocseditor_web 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 24 |
25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wordvue", 3 | "short_name": "wordvue", 4 | "icons": [ 5 | { 6 | "src": "./img/icons/android-chrome-192x192.png", 7 | "sizes": "192x192", 8 | "type": "image/png" 9 | }, 10 | { 11 | "src": "./img/icons/android-chrome-512x512.png", 12 | "sizes": "512x512", 13 | "type": "image/png" 14 | } 15 | ], 16 | "start_url": "./index.html", 17 | "display": "standalone", 18 | "background_color": "#000000", 19 | "theme_color": "#4DBA87" 20 | } 21 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 55 | 56 | 68 | 69 | 96 | 97 | 117 | -------------------------------------------------------------------------------- /src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MkDocsEditor/MkDocsEditor-Web/c10b89f3b355d5c037bd9c89bdc06fff507d365b/src/assets/logo.png -------------------------------------------------------------------------------- /src/business/persistence/StorageManager.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Interface for storage implementations 3 | */ 4 | export default interface StorageManager { 5 | 6 | /** 7 | * Loads a value 8 | * 9 | * @param storeKey the item key 10 | * @param defaultValue the default value to use if no persisted value was found 11 | */ 12 | getValue(storeKey: string, defaultValue: any): any; 13 | 14 | /** 15 | * Saves a new value 16 | * 17 | * @param storeKey the item key 18 | * @param newValue the new value 19 | */ 20 | setValue(storeKey: string, newValue: any): void; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/business/persistence/localstorage/LocalStorageManager.ts: -------------------------------------------------------------------------------- 1 | import StorageManager from '@/business/persistence/StorageManager'; 2 | 3 | /** 4 | * Manager for general access to local storage 5 | */ 6 | export default class LocalStorageManager implements StorageManager { 7 | 8 | private localStorage: any; 9 | 10 | public constructor(localStore: any) { 11 | this.localStorage = localStore; 12 | } 13 | 14 | public getValue(storeKey: string, defaultValue: any): any { 15 | let storeValue: any = localStorage.getItem(storeKey); 16 | if (storeValue) { 17 | if (storeValue instanceof Object) { 18 | // try to deserialize 19 | 20 | try { 21 | storeValue = JSON.parse(storeValue); 22 | } catch (e) { 23 | // @ts-ignore 24 | this.console.error(e); 25 | } 26 | } 27 | } 28 | 29 | if (storeValue) { 30 | return storeValue; 31 | } else { 32 | return defaultValue; 33 | } 34 | } 35 | 36 | public setValue(storeKey: string, newValue: any): void { 37 | let serialized = false; 38 | if (newValue instanceof Object) { 39 | serialized = true; 40 | } 41 | 42 | if (serialized) { 43 | // try to deserialize 44 | try { 45 | newValue = JSON.stringify(newValue); 46 | } catch (e) { 47 | // @ts-ignore 48 | this.console.error(e); 49 | } 50 | } 51 | 52 | localStorage.setItem(storeKey, newValue); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/business/persistence/preferences/PreferenceItem.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Definition of a single preference item 3 | */ 4 | export default class PreferenceItem { 5 | 6 | public key: string; 7 | public defaultValue: any; 8 | 9 | public constructor(key: string, defaultValue: any) { 10 | this.key = key; 11 | this.defaultValue = defaultValue; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/business/persistence/preferences/PreferenceItems.ts: -------------------------------------------------------------------------------- 1 | import PreferenceItem from '@/business/persistence/preferences/PreferenceItem'; 2 | 3 | /** 4 | * Preference constants 5 | */ 6 | export default { 7 | Server: { 8 | URL: new PreferenceItem('SettingsServerURL', ''), 9 | Auth: { 10 | Enabled: new PreferenceItem('settingsServerAuthEnabled', false), 11 | Username: new PreferenceItem('settingsServerAuthUsername', ''), 12 | Password: new PreferenceItem('settingsServerAuthPassword', ''), 13 | }, 14 | 15 | }, 16 | Editor: { 17 | openDefault: new PreferenceItem('settingsEditorOpenDefault', 'both'), 18 | }, 19 | }; 20 | -------------------------------------------------------------------------------- /src/business/persistence/preferences/PreferenceManger.ts: -------------------------------------------------------------------------------- 1 | import LocalStorageManager from '@/business/persistence/localstorage/LocalStorageManager'; 2 | import PreferenceItem from '@/business/persistence/preferences/PreferenceItem'; 3 | 4 | /** 5 | * Manager for application preferences 6 | */ 7 | export default class PreferenceManager { 8 | 9 | private storageManager: LocalStorageManager; 10 | 11 | public constructor(storageManager: LocalStorageManager) { 12 | this.storageManager = storageManager; 13 | } 14 | 15 | /** 16 | * Load a preference from local storage into data section of this component 17 | * 18 | * @param preferenceItem the preference item to retrieve 19 | */ 20 | public loadPreferenceValue(preferenceItem: PreferenceItem): any { 21 | const key = preferenceItem.key; 22 | const defaultValue = preferenceItem.defaultValue; 23 | 24 | return this.storageManager.getValue(key, defaultValue); 25 | } 26 | 27 | /** 28 | * Save a preference in local storage 29 | * 30 | * @param preferenceItem the preference item to set a new value for 31 | * @param newValue the new value to assign to it 32 | */ 33 | public savePreferenceValue(preferenceItem: PreferenceItem, newValue: any) { 34 | const key = preferenceItem.key; 35 | if (newValue == null) { 36 | newValue = preferenceItem.defaultValue; 37 | } 38 | 39 | this.storageManager.setValue(key, newValue); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/business/rest/RestClient.ts: -------------------------------------------------------------------------------- 1 | import axios, {AxiosInstance} from 'axios'; 2 | import SectionModel from '@/business/rest/model/SectionModel'; 3 | import DocumentModel from '@/business/rest/model/DocumentModel'; 4 | import ResourceModel from '@/business/rest/model/ResourceModel'; 5 | // import DocumentModel from "./model/DocumentModel.ts"; 6 | // import ResourceModel from "./model/ResourceModel.ts"; 7 | 8 | /** 9 | * Manager for server communication 10 | */ 11 | export default class RestClient { 12 | 13 | private static toSectionModel(data: any): SectionModel { 14 | return new SectionModel( 15 | data.id, 16 | data.name, 17 | data.subsections.map(RestClient.toSectionModel), 18 | data.documents.map(RestClient.toDocumentModel), 19 | data.resources.map(RestClient.toResourceModel), 20 | ); 21 | } 22 | 23 | private static toDocumentModel(data: any): DocumentModel { 24 | return new DocumentModel( 25 | data.id, 26 | data.name, 27 | data.mod_time, 28 | data.file_size, 29 | ); 30 | } 31 | 32 | private static toResourceModel(data: any): ResourceModel { 33 | return new ResourceModel( 34 | data.id, 35 | data.name, 36 | data.mod_time, 37 | data.file_size, 38 | ); 39 | } 40 | 41 | private axiosClient: AxiosInstance; 42 | 43 | public constructor(host: string, authEnabled: boolean, user: string, password: string) { 44 | if (!host) { 45 | host = 'localhost'; 46 | } 47 | 48 | const config = { 49 | baseUrl: host, 50 | timeout: 1000, 51 | baseURL: host, 52 | auth: { 53 | username: user, 54 | password, 55 | }, 56 | }; 57 | 58 | if (!authEnabled || !user || !password) { 59 | // @ts-ignore 60 | delete config.auth; 61 | } 62 | 63 | this.axiosClient = axios.create(config); 64 | } 65 | 66 | public getTree(): Promise { 67 | return this.axiosClient.get('section') 68 | .then((result: any) => { 69 | if (result.status !== 200) { 70 | throw Error('Error loading section! :-('); 71 | } 72 | return result.data; 73 | }).then((data: any) => RestClient.toSectionModel(data)); 74 | } 75 | 76 | /** 77 | * Get the description of a specific section 78 | * 79 | * @param id 80 | * @returns {promise} 81 | */ 82 | public getSection(id: string): Promise { 83 | return this.axiosClient.get(`section/${id}`) 84 | .then((result: any) => { 85 | if (result.status !== 200) { 86 | throw Error('Error loading section! :-('); 87 | } 88 | return result.data; 89 | }).then((data: any) => RestClient.toSectionModel(data)); 90 | } 91 | 92 | /** 93 | * Update the name of a section 94 | * 95 | * @param id 96 | * @param newName the new name 97 | * @returns {promise} 98 | */ 99 | public renameSection(id: string, newName: string) { 100 | return this.axiosClient.post('section', {id: id, data: {}}); 101 | } 102 | 103 | /** 104 | * Creates a new section as a child section of the specified parent section 105 | * 106 | * @param parentId the id of the desired parent section 107 | * @param name the name of the section 108 | * @returns {promise} 109 | */ 110 | public createSection(parentId: string, name: string) { 111 | return this.axiosClient.post('section', { 112 | Parent: parentId, 113 | Name: name, 114 | }); 115 | } 116 | 117 | /** 118 | * Deletes a section and all of it's child sections, documents and resources. 119 | * Note that this will fail if a user is currently editing any of the sections documents. 120 | * 121 | * @param id the id of the section 122 | * @returns {promise} 123 | */ 124 | public deleteSection(id: string) { 125 | return this.axiosClient.delete(`section/${id}`); 126 | } 127 | 128 | /** 129 | * Get the description of a specific document 130 | * 131 | * @param id 132 | * @returns {promise} 133 | */ 134 | public getDocument(id: string): Promise { 135 | return this.axiosClient.get(`document/${id}`) 136 | .then((result: any) => { 137 | if (result.status !== 200) { 138 | throw Error('Error loading document! :-('); 139 | } 140 | return result.data; 141 | }).then((data: any) => RestClient.toDocumentModel(data)); 142 | } 143 | 144 | /** 145 | * Creates a new document in the specified section 146 | * 147 | * @param sectionId the id of the desired parent section 148 | * @param name the name of the section 149 | * @returns {promise} 150 | */ 151 | public createDocument(sectionId: string, name: string) { 152 | return this.axiosClient.post('document', { 153 | Parent: sectionId, 154 | Name: name, 155 | }); 156 | } 157 | 158 | /** 159 | * Deletes a document entirely. 160 | * Note that this will fail if a user is still editing the file. 161 | * 162 | * @param id the id of the document 163 | * @returns {promise} 164 | */ 165 | public deleteDocument(id: string) { 166 | return this.axiosClient.delete(`document/${id}`); 167 | } 168 | 169 | /** 170 | * Get the description of a specific document 171 | * 172 | * @param id 173 | * @returns {promise} 174 | */ 175 | public getResource(id: string): Promise { 176 | return this.axiosClient.get(`resource/${id}`) 177 | .then((result: any) => { 178 | if (result.status !== 200) { 179 | throw Error('Error loading resource'); 180 | } 181 | return result.data; 182 | }).then((data: any) => RestClient.toResourceModel(data)); 183 | } 184 | 185 | /** 186 | * Deletes a resource. 187 | * 188 | * @param id the id of the resource 189 | * @returns {promise} 190 | */ 191 | public deleteResource(id: string) { 192 | return this.axiosClient.delete(`resource/${id}`); 193 | } 194 | 195 | /** 196 | * Get the file content of the specified document. 197 | * Note that this does NOT reflect any changes made while a user (or multiple) is editing the document. 198 | * 199 | * @param documentId 200 | * @returns {promise} 201 | */ 202 | public getFileContent(documentId: string): Promise { 203 | return this.axiosClient.get(`document/${documentId}/content/`) 204 | .then((result) => { 205 | if (result.status !== 200) { 206 | throw Error('Error loading document content'); 207 | } 208 | return result.data; 209 | }); 210 | } 211 | } 212 | -------------------------------------------------------------------------------- /src/business/rest/model/DocumentModel.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Model of a document 3 | */ 4 | export default class DocumentModel { 5 | 6 | public id: string; 7 | public type: string; 8 | public name: string; 9 | // tslint:disable variable-name 10 | public mod_time: number; 11 | // tslint:disable variable-name 12 | public file_size: number; 13 | 14 | // tslint:disable variable-name 15 | public constructor(id: string, name: string, mod_time: number, file_size: number) { 16 | this.id = id; 17 | this.type = 'Document'; 18 | this.name = name; 19 | this.mod_time = mod_time; 20 | this.file_size = file_size; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/business/rest/model/ResourceModel.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Model of a resource 3 | */ 4 | export default class ResourceModel { 5 | 6 | public id: string; 7 | public type: string; 8 | public name: string; 9 | // tslint:disable variable-name 10 | public mod_time: number; 11 | // tslint:disable variable-name 12 | public file_size: number; 13 | 14 | // tslint:disable variable-name 15 | public constructor(id: string, name: string, mod_time: number, file_size: number) { 16 | this.id = id; 17 | this.type = 'Resource'; 18 | this.name = name; 19 | this.mod_time = mod_time; 20 | this.file_size = file_size; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/business/rest/model/SectionModel.ts: -------------------------------------------------------------------------------- 1 | import DocumentModel from '@/business/rest/model/DocumentModel'; 2 | import ResourceModel from '@/business/rest/model/ResourceModel'; 3 | 4 | /** 5 | * Model of a section 6 | */ 7 | export default class SectionModel { 8 | 9 | public id: string; 10 | public name: string; 11 | public subsections: SectionModel[]; 12 | public documents: DocumentModel[]; 13 | public resources: ResourceModel[]; 14 | 15 | public constructor(id: string, name: string, subsections: SectionModel[], documents: DocumentModel[], 16 | resources: ResourceModel[]) { 17 | this.id = id; 18 | this.name = name; 19 | this.subsections = subsections; 20 | this.documents = documents; 21 | this.resources = resources; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/business/rest/websockets/DocumentSyncManager.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Class used to keep client and server document text in sync 3 | */ 4 | export default class DocumentSyncManager { 5 | 6 | public constructor(url: string, username: string, password: string, documentId: string) { 7 | // TODO 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/components/CodeEditor.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 109 | 110 | 126 | -------------------------------------------------------------------------------- /src/components/Settings.vue: -------------------------------------------------------------------------------- 1 | 54 | 55 | 120 | 121 | 132 | -------------------------------------------------------------------------------- /src/components/about/About.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 32 | 33 | 35 | -------------------------------------------------------------------------------- /src/components/about/pages/AboutApp.vue: -------------------------------------------------------------------------------- 1 | 36 | 37 | 50 | 51 | 58 | -------------------------------------------------------------------------------- /src/components/about/pages/libraries/AboutLibraries.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 30 | 31 | 33 | -------------------------------------------------------------------------------- /src/components/about/pages/libraries/Library.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Definition of a library item 3 | */ 4 | export default class Library { 5 | public id: number; 6 | public name: string; 7 | public description: string; 8 | public license: string; 9 | public url: string; 10 | public imageUrl: string | null; 11 | public author: string; 12 | 13 | public constructor(id: number, name: string, description: string, license: string, url: string, 14 | imageUrl: string | null, author: string) { 15 | this.id = id; 16 | this.name = name; 17 | this.description = description; 18 | this.license = license; 19 | this.url = url; 20 | this.imageUrl = imageUrl; 21 | this.author = author; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/components/about/pages/libraries/LibraryItems.ts: -------------------------------------------------------------------------------- 1 | import Library from './Library'; 2 | import '@/libraries/PowerArray.js'; 3 | 4 | /** 5 | * Definition of all library items 6 | */ 7 | export default class LibraryItems { 8 | private MavonEditor: Library = new Library( 9 | 1, 10 | 'mavonEditor', 11 | 'A markdown editor based on Vue that supports a variety of personalized features', 12 | 'MIT', 13 | 'https://md.zhystar.com/', 14 | null, 15 | 'HinesZhu', 16 | ); 17 | private VueToasted = new Library( 18 | 2, 19 | 'vue-toasted', 20 | 'Responsive Touch Compatible Toast plugin for VueJS 2+', 21 | 'MIT', 22 | 'https://github.com/shakee93/vue-toasted', 23 | 'https://camo.githubusercontent.com/ad2f797f88f98ee4988dc82a4d70e72936170871/6874' + 24 | '7470733a2f2f66726573687069786c2e636f6d2f7675652d746f61737465642e706e673f6e6577', 25 | 'Shakeeb Sadikeen', 26 | ); 27 | private PowerArray = new Library( 28 | 3, 29 | 'PowerArray', 30 | 'Power Array allows you to operate with javascript arrays in a comfortable and much easier way', 31 | 'MIT', 32 | 'https://github.com/detky/PowerArray', 33 | null, 34 | 'Sebastian Menendez', 35 | ); 36 | private diffMatchPatch = new Library( 37 | 4, 38 | 'diff-match-patch', 39 | 'Diff Match Patch is a high-performance library in multiple languages that manipulates plain text.', 40 | 'Apache 2.0', 41 | 'https://github.com/google/diff-match-patch', 42 | null, 43 | 'Neil Fraser', 44 | ); 45 | 46 | public getAllLibraries(): Library[] { 47 | const libraries: Library[] = []; 48 | 49 | for (const key in this) { 50 | if (this.hasOwnProperty.call(this, key)) { 51 | const val = this[key]; 52 | if (val instanceof Library) { 53 | libraries.push(val); 54 | } 55 | } 56 | } 57 | 58 | // @ts-ignore 59 | // eslint-disable-next-line 60 | const sortedLibraries = libraries.Sort({name: Sort.AscendingIgnoringCase}); 61 | return sortedLibraries; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/components/about/pages/libraries/LibraryListItem.vue: -------------------------------------------------------------------------------- 1 | 30 | 31 | 47 | 48 | 61 | -------------------------------------------------------------------------------- /src/components/browser/FileBrowser.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 61 | 62 | 65 | -------------------------------------------------------------------------------- /src/components/browser/section/DocumentListItem.vue: -------------------------------------------------------------------------------- 1 | 36 | 37 | 76 | 77 | 89 | -------------------------------------------------------------------------------- /src/components/browser/section/ResourceListItem.vue: -------------------------------------------------------------------------------- 1 | 33 | 34 | 81 | 82 | 89 | -------------------------------------------------------------------------------- /src/components/browser/section/SectionListItem.vue: -------------------------------------------------------------------------------- 1 | 34 | 35 | 96 | 97 | 104 | -------------------------------------------------------------------------------- /src/components/browser/section/SectionOverview.vue: -------------------------------------------------------------------------------- 1 | 29 | 30 | 79 | 80 | 87 | -------------------------------------------------------------------------------- /src/libraries/PowerArray.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var mainContainer, module = module || undefined, isModule = false, isBrowser = true; 3 | if (typeof module !== "undefined") { 4 | module.exports = {}; 5 | isModule = true; 6 | } 7 | 8 | if (typeof window === 'object') { 9 | mainContainer = window; 10 | } else { 11 | isBrowser = false; 12 | mainContainer = global; 13 | } 14 | if (mainContainer.pa && console && console.warn) { 15 | console.warn('PowerArray => Cannot load, global variable "pa" already exists. Assuming that pa is already loaded => Trusting older instance'); 16 | } 17 | mainContainer.PowerArray = mainContainer.pa = function (object) { 18 | if (object.constructor === Array || object.paIsArray) { 19 | return new paArray(object); 20 | } else { 21 | //console.warn('PowerArray => The passed object is not natively an array. Trying to handle it as an array-like object...') 22 | if ((mainContainer.ol !== undefined && ol.Collection) && object instanceof ol.Collection) { 23 | // console.log('Compatible openlayers object detected (ol.Collection)'); 24 | return paArray(object.getArray()); 25 | } 26 | if (object.length === undefined) { 27 | throw new Error('PowerArray => The passed object is not an array, or usable as such.'); 28 | } 29 | return new paArray(object); 30 | } 31 | }; 32 | pa.mainContainer = mainContainer; //pa.mainContainer is a reference to the top element containing the application (window by browsers, global by Node); 33 | 34 | /*functions directly bound to the pa object: */ 35 | mainContainer.pa.Range = function (from, to, step) { 36 | if (!pa.IsNumeric(from)) { 37 | throw new Error('PowerArray => Range fuction => The parameter "from" must be numeric. Wrong value is "' + from + '"'); 38 | } 39 | if (!pa.IsNumeric(to)) { 40 | throw new Error('PowerArray => Range fuction => The parameter "to" must be numeric. Received value is "' + to + '"'); 41 | } 42 | if (!pa.IsNumeric(step)) { 43 | throw new Error('PowerArray => Range fuction => The parameter "step" must be numeric. Received value is "' + step + '"'); 44 | } 45 | 46 | from = parseFloat(from); 47 | to = parseFloat(to); 48 | step = parseFloat(step); 49 | 50 | var result = [], i, l, currVal = from; 51 | while (currVal < to) { 52 | result.push(currVal); 53 | currVal += step; 54 | } 55 | result.push(to); 56 | return result; 57 | }; 58 | mainContainer.pa.config = { 59 | defaults: { 60 | defaultPromiseTimeout: 10000 61 | } 62 | }; 63 | mainContainer.pa.utils = {} 64 | mainContainer.pa.utils = { 65 | DataTypes: { 66 | String: 'String', 67 | Number: 'Number', 68 | Date: 'Date', 69 | Boolean: 'Boolean', 70 | Object: 'Object', 71 | ArrayOfObjects: 'ArrayOfObjects', 72 | ArrayOfPrimitives: 'ArrayOfPrimitives', 73 | RegExp: 'RegExp', 74 | Function: 'Function', 75 | Null: 'Null', 76 | Undefined: 'Undefined' 77 | }, 78 | IsStringDate: function (str) { 79 | return (str.length === 20 && str.substr(19, 1) === 'Z' && str.substr(10, 1) === 'T'); 80 | }, 81 | IsArrayOfObjects: function (val) { 82 | var l; 83 | if (!val.paIsArray || val.length === undefined) { 84 | return false; 85 | } 86 | l = val.length; 87 | while (l--) { 88 | //TODO: this could fail in collections having objects but one undefined 89 | if (pa.utils.GetTypeOf(val[l]) !== pa.utils.DataTypes.Object) { 90 | return false; 91 | } 92 | } 93 | return true; 94 | }, 95 | /** 96 | * Parses a string to boolean value. This function searches strictly for the strings "true", "True", "trUE", "falsE", etc. 97 | * @param str the string to be evaluated 98 | * @param throwIfNotMatch Boolean, if true, an exception will be raised if the string does not match. If false, null will be returned 99 | * @returns {*} boolean value if string matches, null if not 100 | */ 101 | parseBoolean: function (str, throwIfNotMatch) { 102 | if (!pa.utils.isNullEmptyOrUndefined(str)) { 103 | var strU = str.toUpperCase(); 104 | if (strU === "TRUE") { 105 | return true; 106 | } 107 | if (strU === "FALSE") { 108 | return false; 109 | } 110 | } 111 | 112 | if (throwIfNotMatch) { 113 | throw new Error("The string passed to function parseBoolean (" + str + ") doesn't match with any valid string"); 114 | } 115 | 116 | return null; 117 | }, /** 118 | * evaluate if something is empty. Deppending on the passed object what it exactly search for: 119 | * Numbers and Strings are evaluated against "", undefined and Null 120 | * Objects having at least one own property returns false (also if the property is empty!) 121 | * Arrays returns false if his length is > 0 122 | * 123 | * @param what the element to evaluate 124 | * @returns {boolean} 125 | */ 126 | isNullEmptyOrUndefined: function (what) { 127 | // null has to be evaluated before checking typeof 128 | 129 | if (what === null || what === undefined) { 130 | return true; 131 | } 132 | var t = typeof what; 133 | if (t === "boolean") { 134 | return false; 135 | } 136 | 137 | //Array 138 | if (what.paIsArray && what.length > 0) 139 | return false; 140 | 141 | //Object 142 | if (t === 'object') { 143 | var count = 0; 144 | for (var p in what) { 145 | if (what.hasOwnProperty(p)) 146 | return false; 147 | } 148 | return true; 149 | } 150 | 151 | if (t !== "number" && t !== "string" && t !== "undefined") { 152 | throw new Error("PowerArray => The function IsNullOrEmpty is designed to evaluate strings and numbers, but something different was provided (" + t + ")"); 153 | } 154 | 155 | if (t === "number" && what === 0) { 156 | return false; 157 | } 158 | 159 | if (!what) { 160 | return true; 161 | } 162 | return (what + "").length === 0; 163 | }, 164 | /** 165 | * Copy properties from a source object to a destination object 166 | * @param {Object} source source object 167 | * @param {Object} dest destination object 168 | * @param {Array} propsList list of properties to copy. if falsy is passed, all properties will be copied. 169 | * @param {boolean} excludeEmptyProps avoid the copy of empty props to the target 170 | * @param {boolean} ignoreEmptyProps 171 | * @returns {} 172 | */ 173 | CopyObjectProps: function (source, dest, propsList, excludeEmptyProps, nullOrUndefinedAsEmptyString) { 174 | if (!propsList) { 175 | for (var prop in source) { 176 | if (source.hasOwnProperty(prop)) { 177 | if (nullOrUndefinedAsEmptyString) { 178 | var sourceProp = source[prop] 179 | dest[prop] = (pa.utils.isNullEmptyOrUndefined(sourceProp)) ? '' : sourceProp; 180 | } else { 181 | if (excludeEmptyProps && pa.utils.isNullEmptyOrUndefined(source[prop])) { 182 | continue; 183 | } 184 | dest[prop] = source[prop]; 185 | } 186 | } 187 | } 188 | 189 | } else { 190 | 191 | propsList.RunEach(function (prop) { 192 | if (nullOrUndefinedAsEmptyString) { 193 | var sourceProp = source[prop] 194 | dest[prop] = (pa.utils.isNullEmptyOrUndefined(sourceProp)) ? '' : sourceProp; 195 | } else { 196 | if (excludeEmptyProps && pa.utils.isNullEmptyOrUndefined(source[prop])) { 197 | return; 198 | } 199 | dest[prop] = source[prop]; 200 | } 201 | }); 202 | } 203 | }, 204 | GetTypeOf: function (element, analyzeData) { 205 | 206 | if (element === null) { 207 | return pa.utils.DataTypes.Null; 208 | } 209 | 210 | if (element === undefined) { 211 | return pa.utils.DataTypes.Undefined; 212 | } 213 | var to = typeof element; 214 | switch (to) { 215 | case 'string': 216 | return pa.utils.DataTypes.String; 217 | case 'function': 218 | return pa.utils.DataTypes.Function; 219 | case 'number': 220 | return pa.utils.DataTypes.Number; 221 | case 'boolean': 222 | return pa.utils.DataTypes.Boolean; 223 | case 'object': 224 | //check hidden types 225 | if (element instanceof String) { 226 | return pa.utils.DataTypes.String; 227 | } 228 | 229 | if (element instanceof Date) { 230 | return pa.utils.DataTypes.Date; 231 | } 232 | 233 | if (element instanceof Number) { 234 | return pa.utils.DataTypes.Number; 235 | } 236 | 237 | if (element instanceof RegExp) { 238 | return pa.utils.DataTypes.RegExp; 239 | } 240 | if (element.paIsArray) { 241 | // If its an array of objects, it has to be handled different, 242 | if (analyzeData && pa.utils.IsArrayOfObjects(element)) { 243 | return pa.utils.DataTypes.ArrayOfObjects; 244 | } else { 245 | return pa.utils.DataTypes.ArrayOfPrimitives; 246 | } 247 | } 248 | return pa.utils.DataTypes.Object; 249 | default: 250 | //any others 251 | throw new Error("PowerArray Error : Unknown Datatype!"); 252 | } 253 | }, 254 | ArgumentsToArray: function (args, from, to) { 255 | var i = from | 0, l = to || args.length, result = []; 256 | for (; i < l; i++) { 257 | result.push(args[i]); 258 | } 259 | return result; 260 | }, 261 | GenerateUid: function (prefix, sufix) { 262 | function getRandom4Chars() { 263 | return Math.floor((1 + Math.random()) * 0x10000) 264 | .toString(16) 265 | .substring(1); 266 | } 267 | 268 | return ((prefix !== undefined) ? prefix + '-' : '') + 269 | getRandom4Chars() + '-' + 270 | getRandom4Chars() + '-' + 271 | getRandom4Chars() + 272 | getRandom4Chars() + ((sufix !== undefined) ? '-' + sufix : ''); 273 | }, 274 | PropsToArray: function (obj, valueProcessor) { 275 | var result = []; 276 | for (var prop in obj) { 277 | if (obj.hasOwnProperty(prop)) { 278 | result.push({property: prop, value: (valueProcessor) ? valueProcessor(obj[prop]) : obj[prop]}); 279 | } 280 | } 281 | return result; 282 | } 283 | }; 284 | 285 | mainContainer.pa.paEachParalellsHelper = { 286 | CheckParalellTaskStates: function (paralellId) { 287 | var paralell = mainContainer.pa.paEachParalellsHelper.currentParalellIds[paralellId]; 288 | return paralell.CompletedTasks === paralell.TotalProcesses; 289 | }, 290 | currentParalellIds: {}, 291 | actionKeys: { 292 | Runeach: 'RunEach', 293 | TaskState: 'TaskState' 294 | }, 295 | eventKeys: { 296 | RuneachDone: 'RuneachDone', 297 | TaskState: 'TaskStateResponse' 298 | } 299 | }; 300 | mainContainer.pa.paWhereHelper = { 301 | FillConditions: function (item, conditions) { 302 | var l = conditions.length, condition, result, subArray; 303 | while (l--) { 304 | condition = conditions[l]; 305 | //conditions can be functions or single values, if there are single values, they have to ve evaluated by 306 | //===. if they are functions everything should continue as by default 307 | if (typeof condition.condition !== 'function') { 308 | //if the condition is an object, it's necessary to handle it different. 309 | //If that's the case we start internally another Where() call, but we know that we are 310 | //evaluating pro Where call just ONE item and it could be very expensive. TODO: optimize this somehow! 311 | if (mainContainer.pa.utils.GetTypeOf(condition.condition) === mainContainer.pa.utils.DataTypes.Object) { 312 | var itemType = mainContainer.pa.utils.GetTypeOf(item[condition.column], true); 313 | 314 | switch (itemType) { 315 | case mainContainer.pa.utils.DataTypes.ArrayOfObjects: 316 | case mainContainer.pa.utils.DataTypes.ArrayOfPrimitives: 317 | 318 | result = item[condition.column].Where.call(item[condition.column], condition.condition, false, true); 319 | //when sending true als "justFirst", Where() will return the first found element, not an array, 320 | //because i'm sending true for performance reasons, it's necessary to evaluate the result with undefined 321 | //instead of: "return result.length > 0;" it's now "return result !== undefined;" 322 | if (result !== undefined) { 323 | continue; 324 | } else { 325 | return false; 326 | } 327 | case mainContainer.pa.utils.DataTypes.Object: 328 | subArray = pa([item[condition.column]]); 329 | result = subArray.Where.call(subArray, condition.condition, false, true); 330 | if (result !== undefined) {//See previous comment about justFirst param 331 | continue; 332 | } else { 333 | return false; 334 | } 335 | } 336 | } 337 | condition.condition = pa.EqualTo3(condition.condition); //transforms an explicit value into an === evaluation 338 | } 339 | 340 | if (!item || !condition.condition(item[condition.column])) { //if one condition is not fulfilled, just return false; 341 | return false; 342 | } 343 | } 344 | return true; 345 | }, 346 | ProcessConditionObject: function (whereConditions, keepOrder, isArrayOfConditions, justFirst, justIndexes) { 347 | //to call this function, "this" should be an array! 348 | var fc = mainContainer.pa.paWhereHelper.FillConditions, 349 | i, w, item, lw, assert, l, result = []; 350 | 351 | if (!isArrayOfConditions) { 352 | //whereConditions is not an array, but i need it in that form 353 | whereConditions = [whereConditions]; 354 | } 355 | 356 | //Where conditions must be processed in order 357 | for (i = 0, l = whereConditions.length; i < l; i++) { 358 | var whereConditionObject = whereConditions[i], realConditions = []; 359 | if (typeof whereConditionObject === 'function') { 360 | realConditions.push({ 361 | column: property, 362 | condition: whereConditionObject 363 | }); 364 | } else { 365 | for (var property in whereConditionObject) { 366 | if (property !== 'realConditions' && whereConditionObject.hasOwnProperty(property)) { 367 | //transform the keys into a better object with properties Column and Condition 368 | 369 | //if whereConditionObject[property] is an array, that means that its a multi filter for a single column, for example: array.Where({age : [GreatherThan(33), BiggerThan(21)], otherField : '33' }); 370 | if (whereConditionObject[property] && whereConditionObject[property].paIsArray) { 371 | /** MULTIPLE CONDITIONS FOR A SINGLE PROPERTY. Pushed on the realconditions as an AND **/ 372 | whereConditionObject[property].RunEach(function (subCondition) { 373 | realConditions.push({ 374 | column: property, 375 | condition: subCondition 376 | }); 377 | }); 378 | } else { 379 | realConditions.push({ 380 | column: property, 381 | condition: whereConditionObject[property] 382 | }); 383 | } 384 | } 385 | } 386 | } 387 | 388 | whereConditionObject.realConditions = realConditions; //attach the result of this loop direct to the whereConditionObject 389 | } 390 | //Real conditions stored 391 | l = this.length; 392 | if (keepOrder) { //Anti DRY pattern ;( but as long as it still being small will continue this way to improve performance 393 | for (i = 0; i < l; i++) { 394 | item = this[i]; 395 | for (w = 0, lw = whereConditions.length; w < lw; w++) { 396 | assert = fc(item, whereConditions[w].realConditions); 397 | if (assert) { 398 | break; 399 | } 400 | } 401 | if (assert) { 402 | if (justFirst) { 403 | return (justIndexes) ? i : item; 404 | } 405 | result.push((justIndexes) ? i : item); 406 | } 407 | } 408 | } else { 409 | while (l--) { 410 | item = this[l]; 411 | for (w = 0, lw = whereConditions.length; w < lw; w++) { 412 | assert = fc(item, whereConditions[w].realConditions); 413 | if (assert) { 414 | if (justFirst) { 415 | return (justIndexes) ? l : item; 416 | } 417 | result.push((justIndexes) ? l : item); 418 | break; 419 | } 420 | } 421 | } 422 | } 423 | 424 | if (justFirst) { 425 | //Because in the loops, any positive evaluation makes a return. 426 | //At this point there was no matches. 427 | return undefined; 428 | } 429 | 430 | return result; 431 | }, 432 | // The following function is a copy of the of the value_equals utiliy of 433 | // the toubkal project. 434 | // https://github.com/detky/toubkal/blob/master/lib/util/value_equals.js 435 | equals: function (a, b, enforce_properties_order, cyclic) { 436 | /* ----------------------------------------------------------------------------------------- 437 | equals( a, b [, enforce_properties_order, cyclic] ) 438 | 439 | Returns true if a and b are deeply equal, false otherwise. 440 | 441 | Parameters: 442 | - a (Any type): value to compare to b 443 | - b (Any type): value compared to a 444 | 445 | Optional Parameters: 446 | - enforce_properties_order (Boolean): true to check if Object properties are provided 447 | in the same order between a and b 448 | 449 | - cyclic (Boolean): true to check for cycles in cyclic objects 450 | 451 | Implementation: 452 | 'a' is considered equal to 'b' if all scalar values in a and b are strictly equal as 453 | compared with operator '===' except for these two special cases: 454 | - 0 === -0 but are not equal. 455 | - NaN is not === to itself but is equal. 456 | 457 | RegExp objects are considered equal if they have the same lastIndex, i.e. both regular 458 | expressions have matched the same number of times. 459 | 460 | Functions must be identical, so that they have the same closure context. 461 | 462 | "undefined" is a valid value, including in Objects 463 | 464 | 106 automated tests. 465 | 466 | Provide options for slower, less-common use cases: 467 | 468 | - Unless enforce_properties_order is true, if 'a' and 'b' are non-Array Objects, the 469 | order of occurence of their attributes is considered irrelevant: 470 | { a: 1, b: 2 } is considered equal to { b: 2, a: 1 } 471 | 472 | - Unless cyclic is true, Cyclic objects will throw: 473 | RangeError: Maximum call stack size exceeded 474 | */ 475 | return a === b /* strick equality should be enough unless zero*/ // jshint ignore:line 476 | && a !== 0 /* because 0 === -0, requires test by _equals()*/ // jshint ignore:line 477 | || _equals(a, b) /* handles not strictly equal or zero values*/ // jshint ignore:line 478 | ; 479 | 480 | function _equals(a, b) { 481 | // a and b have already failed test for strict equality or are zero 482 | 483 | var s, l, p, x, y; 484 | 485 | // They should have the same toString() signature 486 | if ((s = toString.call(a)) !== toString.call(b)) return false; // jshint ignore:line 487 | 488 | switch (s) { 489 | default: // Boolean, Date, String 490 | return a.valueOf() === b.valueOf(); 491 | 492 | case '[object Number]': 493 | // Converts Number instances into primitive values 494 | // This is required also for NaN test bellow 495 | a = +a; 496 | b = +b; 497 | 498 | return a ? // a is Non-zero and Non-NaN 499 | a === b 500 | : // a is 0, -0 or NaN 501 | a === a ? // a is 0 or -O 502 | 1 / a === 1 / b // 1/0 !== 1/-0 because Infinity !== -Infinity 503 | : b !== b // NaN, the only Number not equal to itself! 504 | ; 505 | // [object Number] 506 | 507 | case '[object RegExp]': 508 | return a.source == b.source // jshint ignore:line 509 | && a.global == b.global // jshint ignore:line 510 | && a.ignoreCase == b.ignoreCase // jshint ignore:line 511 | && a.multiline == b.multiline // jshint ignore:line 512 | && a.lastIndex == b.lastIndex // jshint ignore:line 513 | ; 514 | // [object RegExp] 515 | 516 | case '[object Function]': 517 | return false; // functions should be strictly equal because of closure context 518 | // [object Function] 519 | 520 | case '[object Array]': 521 | // intentionally duplicated bellow for [object Object] 522 | if (cyclic && (x = reference_equals(a, b)) !== null) return x; // jshint ignore:line 523 | 524 | if ((l = a.length) != b.length) return false; // jshint ignore:line 525 | // Both have as many elements 526 | 527 | while (l--) { 528 | if ((x = a[l]) === (y = b[l]) && x !== 0 || _equals(x, y)) continue; // jshint ignore:line 529 | 530 | return false; 531 | } 532 | 533 | return true; 534 | // [object Array] 535 | 536 | case '[object Object]': 537 | // intentionally duplicated from above for [object Array] 538 | if (cyclic && (x = reference_equals(a, b)) !== null) return x; // jshint ignore:line 539 | 540 | l = 0; // counter of own properties 541 | 542 | if (enforce_properties_order) { 543 | var properties = []; 544 | 545 | for (p in a) { 546 | if (a.hasOwnProperty(p)) { 547 | properties.push(p); 548 | 549 | if ((x = a[p]) === (y = b[p]) && x !== 0 || _equals(x, y)) continue; // jshint ignore:line 550 | 551 | return false; 552 | } 553 | } 554 | 555 | // Check if 'b' has as the same properties as 'a' in the same order 556 | for (p in b) 557 | if (b.hasOwnProperty(p) && properties[l++] != p) // jshint ignore:line 558 | return false; // jshint ignore:line 559 | } else { 560 | for (p in a) { 561 | if (a.hasOwnProperty(p)) { 562 | ++l; 563 | 564 | if ((x = a[p]) === (y = b[p]) && x !== 0 || _equals(x, y)) continue; // jshint ignore:line 565 | 566 | return false; 567 | } 568 | } 569 | 570 | // Check if 'b' has as not more own properties than 'a' 571 | for (p in b) 572 | if (b.hasOwnProperty(p) && --l < 0) // jshint ignore:line 573 | return false; // jshint ignore:line 574 | } 575 | 576 | return true; 577 | // [object Object] 578 | } // switch toString.call( a ) 579 | } // _equals() 580 | 581 | /* ----------------------------------------------------------------------------------------- 582 | reference_equals( a, b ) 583 | 584 | Helper function to compare object references on cyclic objects or arrays. 585 | 586 | Returns: 587 | - null if a or b is not part of a cycle, adding them to object_references array 588 | - true: same cycle found for a and b 589 | - false: different cycle found for a and b 590 | 591 | On the first call of a specific invocation of equal(), replaces self with inner function 592 | holding object_references array object in closure context. 593 | 594 | This allows to create a context only if and when an invocation of equal() compares 595 | objects or arrays. 596 | */ 597 | function reference_equals(a, b) { 598 | var object_references = []; 599 | 600 | return (reference_equals = _reference_equals)(a, b); // jshint ignore:line 601 | 602 | function _reference_equals(a, b) { 603 | var l = object_references.length; 604 | 605 | while (l--) 606 | if (object_references[l--] === b) // jshint ignore:line 607 | return object_references[l] === a; // jshint ignore:line 608 | 609 | object_references.push(a, b); 610 | 611 | return null; 612 | } // _reference_equals() 613 | } // reference_equals() 614 | } // equals() 615 | }; 616 | 617 | 618 | mainContainer.pa.auxiliaryFunctions = { 619 | Contains: function (value, enforcePropsOrder, cyclic) { 620 | return function (val) { 621 | if (!val.paIsArray) { 622 | throw new Error("PowerArray error => parameter val passed to Contains function should be an array."); 623 | } 624 | var l = val.length, isIndexable = false; 625 | var typeToEvaluate = typeof value; 626 | 627 | switch (typeToEvaluate) { 628 | case "number": 629 | case "string": 630 | case "boolean": 631 | isIndexable = true; 632 | break; 633 | default: //anything else 634 | //duck type to exclude dates 635 | if (typeof value.getMonth === 'function') { 636 | isIndexable = true; 637 | break; 638 | } 639 | isIndexable = false; 640 | break; 641 | } 642 | if (isIndexable) { 643 | return val.indexOf(value) > -1; 644 | } 645 | 646 | while (l--) { 647 | if (pa.paWhereHelper.equals(val[l], value, enforcePropsOrder, cyclic)) { 648 | return true; 649 | } 650 | } 651 | return false; 652 | 653 | }; 654 | }, 655 | Between: function (from, to, excludeExactMatches) { 656 | if (to < from) { 657 | console.warn("PowerArray warn => Parameters 'from' and 'to' passed to function Between() makes no sense: Parameter 'to' (" + to + ") should be greater than from (" + from + ")"); 658 | } 659 | if (!excludeExactMatches) { 660 | return function (val) { 661 | return val >= from && val <= to; 662 | }; 663 | } else { 664 | return function (val) { 665 | return val > from && val < to; 666 | }; 667 | } 668 | }, 669 | EndsWith: function (value) { 670 | var value2 = value + ''; 671 | return function (endsWithString) { 672 | 673 | endsWithString = endsWithString + ''; 674 | return endsWithString.substr(endsWithString.length - (value2).length) === value2; 675 | }; 676 | }, 677 | StartsWith: function (value) { 678 | var value2 = value + ''; 679 | return function (val) { 680 | val = val + ''; 681 | return val.indexOf(value2) === 0; 682 | }; 683 | }, 684 | GreaterOrEqualThan: function (value) { 685 | return function (val) { 686 | return val >= value; 687 | }; 688 | }, 689 | GreaterThan: function (value) { 690 | return function (val) { 691 | return val > value; 692 | }; 693 | }, 694 | SmallerOrEqualThan: function (value) { 695 | return function (val) { 696 | return val <= value; 697 | }; 698 | }, 699 | SmallerThan: function (value) { 700 | return function (val) { 701 | return val < value; 702 | }; 703 | }, 704 | EqualTo3: function (value) { 705 | return function (val) { 706 | return val === value; 707 | }; 708 | }, 709 | NotEqualTo3: function (value) { 710 | return function (val) { 711 | return val !== value; 712 | }; 713 | }, 714 | EqualTo2: function (value) { 715 | return function (val) { 716 | // ReSharper disable once CoercedEqualsUsing 717 | return val == value; // jshint ignore:line 718 | }; 719 | }, 720 | NotEqualTo2: function (value) { 721 | return function (val) { 722 | // ReSharper disable once CoercedEqualsUsing 723 | return val != value; // jshint ignore:line 724 | }; 725 | }, 726 | IsUndefined: function () { 727 | return function (val) { 728 | return val === undefined; 729 | }; 730 | }, 731 | IsDefined: function () { 732 | return function (val) { 733 | return val !== undefined; 734 | }; 735 | }, 736 | In: function (list) { 737 | //TODO: investigar si esta function pierde performance al no estar devolviendo una 738 | //funcion como todo el resto. 739 | 740 | if (arguments.length > 1) { 741 | list = Array.prototype.slice.call(arguments); 742 | } 743 | //TODO: Esto es muy propenso a errores, evaluar mejor los parametros [{},etc] 744 | return function (val) { 745 | return list.indexOf(val) !== -1; // jshint ignore:line 746 | }; 747 | }, 748 | NotIn: function (list) { 749 | if (arguments.length > 1) { 750 | list = Array.prototype.slice.call(arguments); 751 | } 752 | return function (val) { 753 | return list.indexOf(val) === -1; // jshint ignore:line 754 | }; 755 | }, 756 | EqualTo: function (object, func, enforcePropsOrder, cyclic) { 757 | return function (val) { 758 | if (func) { 759 | return func(val, object); 760 | } else { 761 | return pa.paWhereHelper.equals(object, val, enforcePropsOrder, cyclic); 762 | } 763 | }; 764 | }, 765 | Like: function (value) { 766 | if (!value.paIsArray) { 767 | value = Array.prototype.slice.call(arguments); 768 | } 769 | return function (val) { 770 | var l = value.length; 771 | while (l--) { 772 | if (val.indexOf(value[l]) === -1) { 773 | return false; 774 | } 775 | } 776 | return true; 777 | }; 778 | }, 779 | NotLike: function (value) { 780 | if (!value.paIsArray) { 781 | value = Array.prototype.slice.call(arguments); 782 | } 783 | return function (val) { 784 | var l = value.length; 785 | while (l--) { 786 | if (val.indexOf(value[l]) > -1) { 787 | return false; 788 | } 789 | } 790 | return true; 791 | }; 792 | }, 793 | LikeIgnoreCase: function (value) { 794 | if (value === undefined) 795 | throw new Error("PowerArray Error => undefined was passed to LikeIgnoreCase"); 796 | 797 | var valueCaseInsensitive = ''; 798 | if (!value.paIsArray) { 799 | value = Array.prototype.slice.call(arguments); 800 | } 801 | return function (val) { 802 | if (val === null || val === undefined) 803 | return false; 804 | var l = value.length; 805 | while (l--) { 806 | valueCaseInsensitive = value[l].toUpperCase(); 807 | if (val.toUpperCase().indexOf(valueCaseInsensitive) === -1) { 808 | return false; 809 | } 810 | } 811 | return true; 812 | }; 813 | }, 814 | NotLikeIgnoreCase: function (value) { 815 | var valueCaseInsensitive = ''; 816 | if (!value.paIsArray) { 817 | value = Array.prototype.slice.call(arguments); 818 | } 819 | return function (val) { 820 | var l = value.length; 821 | while (l--) { 822 | valueCaseInsensitive = value[l].toUpperCase(); 823 | if (val.toUpperCase().indexOf(valueCaseInsensitive) > -1) { 824 | return false; 825 | } 826 | } 827 | return true; 828 | }; 829 | }, 830 | IsTruthy: function () { 831 | return function (val) { 832 | return (val) ? true : false; 833 | }; 834 | }, 835 | IsFalsy: function () { 836 | return function (val) { 837 | return (val) ? false : true; 838 | } 839 | }, 840 | IsTrue: function () { 841 | return function (val) { 842 | return val === true; 843 | }; 844 | }, 845 | IsFalse: function () { 846 | return function (val) { 847 | return val === false; 848 | } 849 | }, 850 | IsEmpty: function () { 851 | return function (val) { 852 | return val === undefined || val === '' || val === null || val === 0 || (val.paIsArray && val.length === 0); 853 | } 854 | }, 855 | IsNotEmpty: function () { 856 | return function (val) { 857 | if (val === undefined || val === null) { 858 | return false; 859 | } 860 | return (val + "").length > 0; 861 | } 862 | }, 863 | IsNull: function () { 864 | return function (val) { 865 | return val === null; 866 | } 867 | }, 868 | IsNotNull: function () { 869 | return function (val) { 870 | return val !== null; 871 | } 872 | }, 873 | IsNaN: function () { 874 | return function (val) { 875 | return isNaN(val); 876 | } 877 | }, 878 | IsNotNaN: function () { 879 | return function (val) { 880 | return !isNaN(val); 881 | } 882 | }, 883 | IsNumeric: function (num) { 884 | return !isNaN(parseFloat(num)) && isFinite(num); 885 | }, 886 | IsInteger: function (num) { 887 | return num === parseInt(num, 10); 888 | } 889 | 890 | }; 891 | 892 | mainContainer.pa.prototypedFunctions_Array = { 893 | getIndexByProperty: function (valueToSearchFor) {// jshint ignore:line 894 | /** 895 | * This function, evaluates properties (or function results) over each object on an array, and answers with an 896 | * array of the found elements that matches the specified condition. The condition is given by the parameters 897 | * provided after position 2. The only fixed parameters are the objects array and the value to search for. 898 | * You can provide so many parameters as you want. Each parameter means one level deeper to search for. For example: 899 | * 900 | * let's say that you have a collection of "car" objects, having each car a function called "getPassengers" 901 | * which answers with a collection of "people" objects, and each people have a property called "name". 902 | * 903 | * To get an array of cars having a passenger called Paul, use as following: 904 | * 905 | * var namedPaul = findDistinctValuesOnObjectCollectionByProperty(theCarsCollection, 'Paul', 'getPassengers()','name'); 906 | * 907 | * @param objectsArray 908 | * @param valueToSearchFor 909 | * @returns {number} 910 | */ 911 | var objectsArray = this; 912 | //if (!objectsArray) { 913 | // return -1; 914 | //} 915 | var ia, la = arguments.length; // ia = i for arguments; la = length for arguments 916 | var io, lo = objectsArray.length; // io = i for objects; lo = length for objects 917 | 918 | for (io = 0; io < lo; io++) { //iterate objects array 919 | var tmpObj = objectsArray[io]; 920 | 921 | for (ia = 1; ia < la; ia++) { //iterate throw arguments to get the right property. Start from 1, to exclude the objectsArray self 922 | var arg = arguments[ia]; 923 | var isFunc = arg.substring(arg.length - 2) === "()"; 924 | var argName = (isFunc) ? arg.substr(0, arg.length - 2) : arg; 925 | tmpObj = (isFunc) ? tmpObj[argName]() : tmpObj[arg]; 926 | // Converting comparison needed (e.g. string id vs integer id) 927 | // ReSharper disable once CoercedEqualsUsing 928 | if (ia + 1 === la && tmpObj == valueToSearchFor) { // jshint ignore:line 929 | return io; 930 | } 931 | } 932 | } 933 | return -1; 934 | }, 935 | GetPropertyFlat: function (property, keepOrder, includeDuplicates, includeUndefineds) { // jshint ignore:line 936 | var array = this; 937 | var result = [], t = array.length; 938 | if (keepOrder === true) { 939 | for (var i = 0; i < t; i++) { 940 | if (includeDuplicates || result.indexOf(array[i][property]) === -1) { 941 | if (includeUndefineds === true || array[i][property] !== undefined) { 942 | result.push(array[i][property]); 943 | } 944 | } 945 | } 946 | } else { 947 | while (t--) { 948 | if (includeDuplicates || result.indexOf(array[t][property]) === -1) { 949 | if (includeUndefineds === true || array[t][property] !== undefined) { 950 | result.push(array[t][property]); 951 | } 952 | } 953 | } 954 | } 955 | return result; 956 | }, 957 | GetByProperty: function (valueToSearchFor) {// jshint ignore:line 958 | /** 959 | * This function, evaluates properties (or function results) over each object on an array, and answers with an 960 | * array of the found elements that matches the specified condition. The condition is given by the parameters 961 | * provided after position 2. The only fixed parameters are the objects array and the value to search for. 962 | * You can provide so many parameters as you want. Each parameter means one level deeper to search for. For example: 963 | * 964 | * let's say that you have a collection of "car" objects, having each car a function called "getPassengers" 965 | * which answers with a collection of "people" objects, and each people have a property called "name". 966 | * 967 | * To get an array of cars having a passenger called Paul, use as following: 968 | * 969 | * var passengersNamedPaul = carsArray.getByProperty('Paul', 'getPassengers()','name'); 970 | * 971 | * @param objectsArray 972 | * @param valueToSearchFor 973 | * @returns {Array} 974 | */ 975 | var objectsArray = this; 976 | var results = []; 977 | var ia, la = arguments.length; // ia = i for arguments; la = length for arguments 978 | var io, lo = objectsArray.length; // io = i for objects; lo = length for objects 979 | for (io = 0; io < lo; io++) { //iterate objects array 980 | var tmpObj = objectsArray[io]; 981 | 982 | for (ia = 1; ia < la; ia++) { //iterate throw arguments to get the right property. Start from 1, to exclude the objectsArray self 983 | var arg = arguments[ia]; 984 | var isFunc = arg.substring(arg.length - 2) === "()"; 985 | var argName = (isFunc) ? arg.substr(0, arg.length - 2) : arg; 986 | tmpObj = (isFunc) ? tmpObj[argName]() : tmpObj[arg]; 987 | if (ia + 1 === la && tmpObj === valueToSearchFor) { 988 | results.push(objectsArray[io]); 989 | } 990 | } 991 | } 992 | return results; 993 | }, 994 | /** 995 | * Executes a function (task) on each element of the array (this). 996 | * @param {} task A function to execute. It will receive 3 parameters: 997 | * 1) one array item 998 | * 2) index of the passed item (param 1) on the original array. 999 | * 3) the complete array. Warning, you should not change it. See it as read-only! 1000 | * 1001 | * @param {} callback A callback function to be executed after processing all array items. 1002 | * It will get as first parameter the results-array (that lately will be 1003 | * returned as result of this function). 1004 | * *****************************PLEASE READ********************************** 1005 | * *** If the callback function returns something different than undefined, *** 1006 | * *** the results-array will be replaced with that return value *** 1007 | * ************************************************************************** 1008 | * @param {} keepOrder 1009 | * @returns array of the result of each executed task (keeping same position as on original 1010 | * array, regardless order). Excepion: when the execution of the callback function 1011 | * returns something different than undefined, that will be returned instead of the 1012 | * . If not, 1013 | */ 1014 | RunEach: function (task, callback, keepOrder, progress) {// jshint ignore:line 1015 | var l = this.length, i = 0, result = new Array(this.length), tmp; 1016 | if (!keepOrder) { 1017 | while (l--) { 1018 | result[l] = task(this[l], l, this); 1019 | } 1020 | } else { 1021 | for (; i < l; i++) { 1022 | result[i] = task(this[i], i, this); 1023 | } 1024 | } 1025 | if (callback) { 1026 | //if the callback function returns something, 1027 | //the result will be overrided with that result. 1028 | result = callback(result) || result; 1029 | } 1030 | return result; 1031 | }, 1032 | Sort: function (sortConditions) { // jshint ignore:line 1033 | var realConditions = []; 1034 | var conditionType = typeof sortConditions; 1035 | 1036 | let isString = function (s) { 1037 | return typeof(s) === 'string' || s instanceof String; 1038 | }; 1039 | 1040 | switch (conditionType) { 1041 | case "string": 1042 | //This call, with a first parameter of type string, should be "ASC" or "DESC" 1043 | var condition = sortConditions.toUpperCase(); 1044 | switch (condition) { 1045 | case pa.Sort.Ascending: 1046 | case pa.Sort.Asc: 1047 | return this.sort(function (a, b) { 1048 | if (a < b) { 1049 | return -1; 1050 | } else if (a > b) { 1051 | return 1; 1052 | } 1053 | return 0; 1054 | }); 1055 | case pa.Sort.AscendingIgnoringCase: 1056 | case pa.Sort.AscIgnoringCase: 1057 | return this.sort(function (a, b) { 1058 | try { 1059 | return a.toLowerCase().localeCompare(b.toLowerCase()); 1060 | } catch (e) { 1061 | if (console && console.warn) { 1062 | console.warn('PowerArray => Error by sorting by ' + condition + ', all values has to be strings. Probably it\'s not the case!. Now casting to string, performance may be affected.'); 1063 | a = a + ''; 1064 | b = b + ''; 1065 | return a.toLowerCase().localeCompare(b.toLowerCase()); 1066 | } 1067 | } 1068 | }); 1069 | case pa.Sort.Descending: 1070 | case pa.Sort.Desc: 1071 | return this.sort(function (a, b) { 1072 | if (a > b) { 1073 | return -1; 1074 | } else if (a < b) { 1075 | return 1; 1076 | } 1077 | return 0; 1078 | }); 1079 | case pa.Sort.DescendingIgnoringCase: 1080 | case pa.Sort.DescIgnoringCase: 1081 | return this.sort(function (a, b) { 1082 | return (a.toLowerCase().localeCompare(b.toLowerCase())) * -1; 1083 | }); 1084 | default: 1085 | throw new Error("PowerArray Error: Invalid sort condition. If you pass a first parameter of type String to the Sort function," + 1086 | " PowerArray assumes that you have a simple array on your hand (one dimension of primitives). Possible parameter values for function Sort " + 1087 | " in that situation, are: 1) To sort Ascending: 'Asc' and 'AscIgnoreCase' (aliases: 'Ascending', 'AscendingIgnoreCase'), and 2)" + 1088 | " To sort Descending: 'Desc','Descending' (aliases: 'Descending', 'DescendingIgnoreCase') "); 1089 | } 1090 | case "object": 1091 | 1092 | if (sortConditions instanceof RegExp) { 1093 | throw new Error("PowerArray Error: Invalid sortConditions object. A RegExp is not allowed as Sort Criterion!"); 1094 | } 1095 | 1096 | if (!sortConditions) { 1097 | if (sortConditions.hasOwnProperty('length')) { 1098 | throw new Error("PowerArray Error: Invalid sortConditions object"); 1099 | } 1100 | } 1101 | 1102 | for (var property in sortConditions) { 1103 | if (sortConditions.hasOwnProperty(property)) { 1104 | 1105 | //transform the keys into a better object with properties Column and SortOrder 1106 | var value = sortConditions[property].toUpperCase(); 1107 | 1108 | if (!mainContainer.pa.Sort._validSortConfigStrings.indexOf(sortConditions[property]) === -1) { 1109 | throw new Error("PowerArray Configuration Error => Invalid sort direction for property " + property + ": '" + sortConditions[property] + "'"); 1110 | } 1111 | 1112 | realConditions.push({ 1113 | column: property, 1114 | sortDirection: value 1115 | }); 1116 | } 1117 | } 1118 | 1119 | return this.sort(function (a, b) { 1120 | 1121 | var result = 0, currentColumn, cycleValue; 1122 | 1123 | for (var i = 0, l = realConditions.length; i < l; i++) { 1124 | currentColumn = realConditions[i].column; 1125 | switch (realConditions[i].sortDirection) { 1126 | case mainContainer.pa.Sort.Ascending: 1127 | case mainContainer.pa.Sort.Asc: 1128 | case mainContainer.pa.Sort.AscendingIgnoringCase: 1129 | case mainContainer.pa.Sort.AscIgnoringCase: 1130 | let aC = a[currentColumn]; 1131 | let bC = b[currentColumn]; 1132 | if (isString(aC)) { 1133 | aC = aC.toLowerCase(); 1134 | } 1135 | if (isString(bC)) { 1136 | bC = bC.toLowerCase(); 1137 | } 1138 | 1139 | if (aC < bC) return -1; 1140 | if (aC > bC) return 1; 1141 | case mainContainer.pa.Sort.Descending: 1142 | case mainContainer.pa.Sort.Desc: 1143 | case mainContainer.pa.Sort.DescendingIgnoringCase: 1144 | case mainContainer.pa.Sort.DescIgnoringCase: 1145 | aC = a[currentColumn]; 1146 | bC = b[currentColumn]; 1147 | if (isString(aC)) { 1148 | aC = aC.toLowerCase(); 1149 | } 1150 | if (isString(bC)) { 1151 | bC = bC.toLowerCase(); 1152 | } 1153 | 1154 | if (aC < bC) return 1; 1155 | if (aC > bC) return -1; 1156 | } 1157 | } 1158 | return 0; 1159 | 1160 | }); 1161 | case "undefined": 1162 | //No parameters passed, sorting by default 1163 | return this.sort(); 1164 | case "function": 1165 | return this.sort(sortConditions); //simple forward to array.sort 1166 | default: 1167 | throw new Error("Unknown sortConditions object type (" + conditionType + ")"); 1168 | } 1169 | }, 1170 | Exists: function (whereConditions) { 1171 | if (typeof(whereConditions) === 'string') { 1172 | //transform single match strings to an EqualTo3 1173 | whereConditions = EqualTo3(whereConditions); 1174 | } 1175 | if (pa.prototypedFunctions_Array.First.call(this, whereConditions)) { 1176 | return true; 1177 | } else { 1178 | return false; 1179 | } 1180 | }, 1181 | Remove: function (whereConditions) { 1182 | if (typeof(whereConditions) === 'string') { 1183 | //transform single match strings to an EqualTo3 1184 | whereConditions = EqualTo3(whereConditions); 1185 | } 1186 | var first = this.FirstIndex(whereConditions); 1187 | while (first !== undefined) { 1188 | this.splice(first, 1); 1189 | first = this.FirstIndex(whereConditions); 1190 | } 1191 | return this; 1192 | }, 1193 | Distinct: function () { 1194 | var val, l = this.length, results = [], item, cache = [], 1195 | type = pa.utils.GetTypeOf(this, true), 1196 | types = pa.utils.DataTypes; 1197 | if (type !== types.ArrayOfPrimitives && type !== types.ArrayOfObjects) { 1198 | throw new Error("PowerArray => Distinct => Currently, the distinct function works only for arrays of primitive data."); 1199 | } 1200 | if (type !== types.ArrayOfObjects) { 1201 | //it's a primitive 1202 | while (l--) { 1203 | val = this[l]; 1204 | if (results.indexOf(val) === -1 && val !== undefined) { 1205 | results.push(val); 1206 | } 1207 | } 1208 | } else { 1209 | //TODO: this is very slow! 1210 | while (l--) { 1211 | item = this[l]; 1212 | val = JSON.stringify(item); 1213 | if (cache.indexOf(val) === -1 && val !== undefined) { 1214 | cache.push(val); 1215 | results.push(item); 1216 | } 1217 | } 1218 | } 1219 | 1220 | return results; 1221 | }, 1222 | /** Iterates an array and executes the function on each item as runeach does, but always returns the original array */ 1223 | Iterate: function (func, keepOrder) { 1224 | this.RunEach(func, undefined, keepOrder); 1225 | return this; 1226 | }, 1227 | /**returns a collection of the results of the execution of "func" in a given order */ 1228 | Collect: function (func, keepOrder) { 1229 | return this.RunEach(func, undefined, keepOrder); 1230 | }, 1231 | WhereIndexes: function (whereConditions, keepOrder, justFirst) { 1232 | return this.Where(whereConditions, keepOrder, justFirst, true); 1233 | }, 1234 | Where: function (whereConditions, keepOrder, justFirst, justIndexes) {// jshint ignore:line 1235 | var i, l = this.length, item, result = [], tmp; 1236 | justIndexes = (justIndexes) ? true : false; //just to avoid casting when comparing during loop 1237 | if (typeof whereConditions === 'object' && !(whereConditions.paIsArray)) { 1238 | if (!Object.keys(whereConditions).length) // when the conditions-object is empty (no properties), then exit returning the same array 1239 | return this; 1240 | 1241 | //If It's an object, but not an array, it is a conditions object 1242 | result = pa.paWhereHelper.ProcessConditionObject.call(this, whereConditions, keepOrder, false, justFirst, justIndexes); 1243 | } else { 1244 | 1245 | //At this point, whereConditions could be a: 1246 | // => function (a custom function), 1247 | // => an pa.EqualTo, 1248 | // => an Array of condition-objects 1249 | 1250 | if (typeof whereConditions === 'undefined') { 1251 | var a = new Error("PowerArray => Where function => No condition object provided to function 'Where(whereConditions, keepOrder)'"); 1252 | a.message = "InvalidWhereCondition"; 1253 | throw a; 1254 | } else if (whereConditions.paIsArray) { 1255 | //It's a conditions array 1256 | tmp = pa.paWhereHelper.ProcessConditionObject.call(this, whereConditions, keepOrder, true, justFirst, justIndexes); 1257 | if (justFirst) 1258 | return tmp; 1259 | result.push.apply(result, tmp); 1260 | } else { 1261 | //whereConditions it's a function. It could be a custom function on the pa standard EqualTo (that works 1262 | //different than any other standard function) 1263 | if (keepOrder) { 1264 | for (i = 0; i < l; i++) { 1265 | item = this[i]; 1266 | if (whereConditions(item)) { 1267 | if (justFirst) { 1268 | return (justIndexes) ? i : item; 1269 | } 1270 | result.push(item); 1271 | } 1272 | } 1273 | } else { 1274 | while (l--) { 1275 | item = this[l]; 1276 | if (whereConditions(item)) { 1277 | if (justFirst) { 1278 | return (justIndexes) ? l : item; 1279 | } 1280 | result.push(item); 1281 | } 1282 | } 1283 | } 1284 | } 1285 | } 1286 | if (justFirst) { 1287 | if (result !== undefined) { //it is important to check with undefined! (0 is a valid result when justIndexes = true) 1288 | if (result.paIsArray) { 1289 | if (result.length > 0) 1290 | return result[0] 1291 | return undefined; // there is only one 1292 | } 1293 | return result; 1294 | } 1295 | return undefined; 1296 | } 1297 | return result; 1298 | }, 1299 | Count: function (whereConditions) { 1300 | if (arguments.length !== 1) { 1301 | throw new Error('PowerArray => Count function => Invalid arguments. The only argument is a whereCondition or an array of whereConditions object.'); 1302 | } 1303 | return pa.prototypedFunctions_Array.Where.call(this, whereConditions, false, false).length; 1304 | }, 1305 | First: function (whereConditions) {// jshint ignore:line 1306 | if (arguments.length === 0) { 1307 | return (this.length > 0) ? this[0] : undefined; 1308 | } 1309 | return pa.prototypedFunctions_Array.Where.call(this, whereConditions, true, true); 1310 | }, 1311 | FirstIndex: function (whereConditions) {// jshint ignore:line 1312 | if (arguments.length === 0) { 1313 | return (this.length > 0) ? 0 : undefined; 1314 | } 1315 | return pa.prototypedFunctions_Array.Where.call(this, whereConditions, true, true, true); 1316 | }, 1317 | Average: function () { 1318 | //TODO: the same way to work as Max() 1319 | }, 1320 | /*Return an object containing min and max values of one or more propeties in an objects array */ 1321 | Bounds: function () { 1322 | var l = this.length, alc, al = arguments.length, maxVal, result = {}, arrayItemValue, currentArgName = ''; 1323 | if (al === 0) { 1324 | throw new Error("PowerArray => bounds => invalid params, please provide one or more target parameters"); 1325 | } 1326 | alc = al; 1327 | while (alc--) { 1328 | currentArgName = arguments[alc]; 1329 | result[currentArgName] = {min: undefined, max: undefined}; 1330 | } 1331 | while (l--) { 1332 | alc = al; 1333 | while (alc--) { 1334 | currentArgName = arguments[alc]; 1335 | arrayItemValue = this[l][currentArgName]; 1336 | if (result[currentArgName].max === undefined || (arrayItemValue !== undefined && arrayItemValue > result[currentArgName].max)) { 1337 | result[currentArgName].max = arrayItemValue; 1338 | } 1339 | if (result[currentArgName].min === undefined || (arrayItemValue !== undefined && arrayItemValue < result[currentArgName].min)) { 1340 | result[currentArgName].min = arrayItemValue; 1341 | } 1342 | } 1343 | } 1344 | 1345 | return result; 1346 | 1347 | }, 1348 | /** 1349 | * Return max values of specified properties 1350 | * @param {} target 1351 | * @returns {} 1352 | */ 1353 | Max: function () { 1354 | var l = this.length, alc, al = arguments.length, maxVal, result = {}, arrayItemValue, currentArgName = ''; 1355 | if (al === 0) { 1356 | throw new Error("PowerArray => Max => invalid params, please provide one or more target parameters"); 1357 | } 1358 | alc = al; 1359 | while (alc) { 1360 | //evaluate if the passed arguments are integers. this means that the collection has indexable objects (arrays or array like objects) 1361 | 1362 | } 1363 | while (l--) { 1364 | alc = al; 1365 | while (alc--) { 1366 | currentArgName = arguments[alc]; 1367 | arrayItemValue = this[l][currentArgName]; 1368 | if (result[currentArgName] === undefined || (arrayItemValue !== undefined && arrayItemValue > result[currentArgName])) { 1369 | result[currentArgName] = arrayItemValue; 1370 | } 1371 | } 1372 | } 1373 | 1374 | if (al === 1) { //if only one max is expected, just return it 1375 | return result[currentArgName]; 1376 | } else if (al > 1) { 1377 | 1378 | } 1379 | }, 1380 | Take: function (count, skip) { 1381 | skip = skip || 0; 1382 | var i = 0 + skip, l = this.length, result = [], added = 0; 1383 | for (; i < l && added < count; i++) { 1384 | result.push(this[i]); 1385 | added++; 1386 | } 1387 | return result; 1388 | }, 1389 | Last: function () { 1390 | var idx = this.length - 1; 1391 | return (idx > -1) ? this[idx] : null; 1392 | } 1393 | }; 1394 | 1395 | // ReSharper disable once WrongExpressionStatement 1396 | mainContainer.pa.Sort = { 1397 | Ascending: 'ASCENDING', 1398 | Asc: 'ASC', 1399 | AscendingIgnoringCase: 'ASCENDINGIGNORINGCASE', 1400 | AscIgnoringCase: 'ASCIGNORINGCASE', 1401 | Descending: 'DESCENDING', 1402 | Desc: 'DESC', 1403 | DescendingIgnoringCase: 'DESCENDINGIGNORINGCASE', 1404 | DescIgnoringCase: 'DESCIGNORINGCASE', 1405 | } 1406 | var validSortingConf = [ 1407 | mainContainer.pa.Sort.Ascending, 1408 | mainContainer.pa.Sort.Asc, 1409 | mainContainer.pa.Sort.AscendingIgnoringCase, 1410 | mainContainer.pa.Sort.AscIgnoringCase, 1411 | mainContainer.pa.Sort.Descending, 1412 | mainContainer.pa.Sort.Desc, 1413 | mainContainer.pa.Sort.DescendingIgnoringCase, 1414 | mainContainer.pa.Sort.DescIgnoringCase]; 1415 | 1416 | mainContainer.pa.Sort._validSortConfigStrings = validSortingConf; 1417 | mainContainer.Sort = mainContainer.pa.Sort; 1418 | 1419 | var paArray = function (array) { 1420 | if (!array.paIsArray) { 1421 | throw new Error('PowerArray => paArray warning => Invalid array passed to pa() function"'); 1422 | } 1423 | var newArray = array.slice(0); 1424 | 1425 | var functionsToAttach = mainContainer.pa.prototypedFunctions_Array; 1426 | for (var currentFunctionName in functionsToAttach) { 1427 | if (functionsToAttach.hasOwnProperty(currentFunctionName)) { 1428 | newArray[currentFunctionName] = functionsToAttach[currentFunctionName]; // jshint ignore:line 1429 | } 1430 | } 1431 | return newArray; 1432 | }; 1433 | 1434 | paArray.prototype.isArray = true; 1435 | 1436 | //region "Initialization" 1437 | (function () { 1438 | //Register all Pa auxiliary functions to make them accessible through the mainContainer object and mainContainer.pa object 1439 | //If a mainContainer accessor is already taken and cannot be set, warn the user. 1440 | var obj = mainContainer.pa.auxiliaryFunctions; 1441 | for (var p in obj) { 1442 | if (obj.hasOwnProperty(p)) { 1443 | mainContainer.pa[p] = obj[p]; 1444 | if (!mainContainer[p]) { 1445 | mainContainer[p] = obj[p]; 1446 | } else { 1447 | console.warn('PowerArray warning! => property mainContainer.' + p + ' already exists. PowerArrayFunction pa.' + p + ' cannot register this function on mainContainer scope. However, you can still using it by calling "pa.' + p + '"'); 1448 | } 1449 | } 1450 | } 1451 | 1452 | if (!Array.prototype.paIsArray) { 1453 | //TODO: this cannot stay fix like that ;( 1454 | Array.prototype.paIsArray = true;// jshint ignore:line 1455 | } 1456 | 1457 | //Register all Array prototype functions to make them accessible to each array. 1458 | //If function name is already is already taken, warn the user and describe alternative usage way. 1459 | var functionsToAttach = mainContainer.pa.prototypedFunctions_Array; 1460 | for (var currentFunctionName in functionsToAttach) { 1461 | if (functionsToAttach.hasOwnProperty(currentFunctionName)) { 1462 | if (Array.prototype.hasOwnProperty(currentFunctionName)) { 1463 | console.warn('PowerArray warning! => Array Prototype was modified by other library, and the function name ' + currentFunctionName + 1464 | ' is already in use. PowerArray will NOT override the prototype method. However, you can still using the function ' + currentFunctionName + 1465 | ' by surrounding your array with a pa constructor call, as following: pa(yourArrayName).' + currentFunctionName + "(...)"); 1466 | } else { 1467 | //function name is free, go on: 1468 | Array.prototype[currentFunctionName] = functionsToAttach[currentFunctionName]; // jshint ignore:line 1469 | } 1470 | // Attach all functions also to the paArray prototype, that is the wrapper for solve conflicts (pa(array)) 1471 | // from array prototype 1472 | paArray.prototype[currentFunctionName] = functionsToAttach[currentFunctionName]; // jshint ignore:line 1473 | } 1474 | } 1475 | })(); 1476 | if (isModule) { 1477 | module.exports = mainContainer.pa; 1478 | } 1479 | -------------------------------------------------------------------------------- /src/libraries/PowerArray.min.js: -------------------------------------------------------------------------------- 1 | "use strict";var mainContainer,module=module||void 0,isModule=!1,isBrowser=!0;void 0!==module&&(module.exports={},isModule=!0),"object"==typeof window?mainContainer=window:(isBrowser=!1,mainContainer=global),mainContainer.pa&&console&&console.warn&&console.warn('PowerArray => Cannot load, global variable "pa" already exists. Assuming that pa is already loaded => Trusting older instance'),mainContainer.PowerArray=mainContainer.pa=function(r){if(r.constructor===Array||r.paIsArray)return new paArray(r);if(void 0!==mainContainer.ol&&ol.Collection&&r instanceof ol.Collection)return paArray(r.getArray());if(void 0===r.length)throw new Error("PowerArray => The passed object is not an array, or usable as such.");return new paArray(r)},pa.mainContainer=mainContainer,mainContainer.pa.Range=function(r,n,e){if(!pa.IsNumeric(r))throw new Error('PowerArray => Range fuction => The parameter "from" must be numeric. Wrong value is "'+r+'"');if(!pa.IsNumeric(n))throw new Error('PowerArray => Range fuction => The parameter "to" must be numeric. Received value is "'+n+'"');if(!pa.IsNumeric(e))throw new Error('PowerArray => Range fuction => The parameter "step" must be numeric. Received value is "'+e+'"');r=parseFloat(r),n=parseFloat(n),e=parseFloat(e);for(var t=[],o=r;o0)return!1;if("object"===n){for(var e in r)if(r.hasOwnProperty(e))return!1;return!0}if("number"!==n&&"string"!==n&&"undefined"!==n)throw new Error("PowerArray => The function IsNullOrEmpty is designed to evaluate strings and numbers, but something different was provided ("+n+")");return("number"!==n||0!==r)&&(!r||0===(r+"").length)},CopyObjectProps:function(r,n,e,t,o){if(e)e.RunEach(function(e){if(o){var i=r[e];n[e]=pa.utils.isNullEmptyOrUndefined(i)?"":i}else{if(t&&pa.utils.isNullEmptyOrUndefined(r[e]))return;n[e]=r[e]}});else for(var i in r)if(r.hasOwnProperty(i))if(o){var a=r[i];n[i]=pa.utils.isNullEmptyOrUndefined(a)?"":a}else{if(t&&pa.utils.isNullEmptyOrUndefined(r[i]))continue;n[i]=r[i]}},GetTypeOf:function(r,n){if(null===r)return pa.utils.DataTypes.Null;if(void 0===r)return pa.utils.DataTypes.Undefined;switch(typeof r){case"string":return pa.utils.DataTypes.String;case"function":return pa.utils.DataTypes.Function;case"number":return pa.utils.DataTypes.Number;case"boolean":return pa.utils.DataTypes.Boolean;case"object":return r instanceof String?pa.utils.DataTypes.String:r instanceof Date?pa.utils.DataTypes.Date:r instanceof Number?pa.utils.DataTypes.Number:r instanceof RegExp?pa.utils.DataTypes.RegExp:r.paIsArray?n&&pa.utils.IsArrayOfObjects(r)?pa.utils.DataTypes.ArrayOfObjects:pa.utils.DataTypes.ArrayOfPrimitives:pa.utils.DataTypes.Object;default:throw new Error("PowerArray Error : Unknown Datatype!")}},ArgumentsToArray:function(r,n,e){for(var t=0|n,o=e||r.length,i=[];t parameter val passed to Contains function should be an array.");var o=t.length,i=!1;switch(typeof r){case"number":case"string":case"boolean":i=!0;break;default:if("function"==typeof r.getMonth){i=!0;break}i=!1}if(i)return t.indexOf(r)>-1;for(;o--;)if(pa.paWhereHelper.equals(t[o],r,n,e))return!0;return!1}},Between:function(r,n,e){return n Parameters 'from' and 'to' passed to function Between() makes no sense: Parameter 'to' ("+n+") should be greater than from ("+r+")"),e?function(e){return e>r&&e=r&&e<=n}},EndsWith:function(r){var n=r+"";return function(r){return(r+="").substr(r.length-n.length)===n}},StartsWith:function(r){var n=r+"";return function(r){return 0===(r+="").indexOf(n)}},GreaterOrEqualThan:function(r){return function(n){return n>=r}},GreaterThan:function(r){return function(n){return n>r}},SmallerOrEqualThan:function(r){return function(n){return n<=r}},SmallerThan:function(r){return function(n){return n1&&(r=Array.prototype.slice.call(arguments)),function(n){return-1!==r.indexOf(n)}},NotIn:function(r){return arguments.length>1&&(r=Array.prototype.slice.call(arguments)),function(n){return-1===r.indexOf(n)}},EqualTo:function(r,n,e,t){return function(o){return n?n(o,r):pa.paWhereHelper.equals(r,o,e,t)}},Like:function(r){return r.paIsArray||(r=Array.prototype.slice.call(arguments)),function(n){for(var e=r.length;e--;)if(-1===n.indexOf(r[e]))return!1;return!0}},NotLike:function(r){return r.paIsArray||(r=Array.prototype.slice.call(arguments)),function(n){for(var e=r.length;e--;)if(n.indexOf(r[e])>-1)return!1;return!0}},LikeIgnoreCase:function(r){if(void 0===r)throw new Error("PowerArray Error => undefined was passed to LikeIgnoreCase");var n="";return r.paIsArray||(r=Array.prototype.slice.call(arguments)),function(e){if(null===e||void 0===e)return!1;for(var t=r.length;t--;)if(n=r[t].toUpperCase(),-1===e.toUpperCase().indexOf(n))return!1;return!0}},NotLikeIgnoreCase:function(r){var n="";return r.paIsArray||(r=Array.prototype.slice.call(arguments)),function(e){for(var t=r.length;t--;)if(n=r[t].toUpperCase(),e.toUpperCase().indexOf(n)>-1)return!1;return!0}},IsTruthy:function(){return function(r){return!!r}},IsFalsy:function(){return function(r){return!r}},IsTrue:function(){return function(r){return!0===r}},IsFalse:function(){return function(r){return!1===r}},IsEmpty:function(){return function(r){return void 0===r||""===r||null===r||0===r||r.paIsArray&&0===r.length}},IsNotEmpty:function(){return function(r){return void 0!==r&&null!==r&&(r+"").length>0}},IsNull:function(){return function(r){return null===r}},IsNotNull:function(){return function(r){return null!==r}},IsNaN:function(){return function(r){return isNaN(r)}},IsNotNaN:function(){return function(r){return!isNaN(r)}},IsNumeric:function(r){return!isNaN(parseFloat(r))&&isFinite(r)},IsInteger:function(r){return r===parseInt(r,10)}},mainContainer.pa.prototypedFunctions_Array={getIndexByProperty:function(r){var n,e,t=this,o=arguments.length,i=t.length;for(e=0;en?1:0});case pa.Sort.AscendingIgnoringCase:case pa.Sort.AscIgnoringCase:return this.sort(function(r,n){try{return r.toLowerCase().localeCompare(n.toLowerCase())}catch(e){if(console&&console.warn)return console.warn("PowerArray => Error by sorting by "+t+", all values has to be strings. Probably it's not the case!. Now casting to string, performance may be affected."),r+="",n+="",r.toLowerCase().localeCompare(n.toLowerCase())}});case pa.Sort.Descending:case pa.Sort.Desc:return this.sort(function(r,n){return r>n?-1:r Invalid sort direction for property "+o+": '"+r[o]+"'");n.push({column:o,sortDirection:i})}return this.sort(function(r,e){for(var t,o=0,i=n.length;oe[t])return 1;case mainContainer.pa.Sort.Descending:case mainContainer.pa.Sort.Desc:case mainContainer.pa.Sort.DescendingIgnoringCase:case mainContainer.pa.Sort.DescIgnoringCase:if(r[t]e[t])return-1}return 0});case"undefined":return this.sort();case"function":return this.sort(r);default:throw new Error("Unknown sortConditions object type ("+e+")")}},Exists:function(r){return"string"==typeof r&&(r=EqualTo3(r)),!!pa.prototypedFunctions_Array.First.call(this,r)},Remove:function(r){"string"==typeof r&&(r=EqualTo3(r));for(var n=this.FirstIndex(r);void 0!==n;)this.splice(n,1),n=this.FirstIndex(r);return this},Distinct:function(){var r,n,e=this.length,t=[],o=[],i=pa.utils.GetTypeOf(this,!0),a=pa.utils.DataTypes;if(i!==a.ArrayOfPrimitives&&i!==a.ArrayOfObjects)throw new Error("PowerArray => Distinct => Currently, the distinct function works only for arrays of primitive data.");if(i!==a.ArrayOfObjects)for(;e--;)r=this[e],-1===t.indexOf(r)&&void 0!==r&&t.push(r);else for(;e--;)n=this[e],r=JSON.stringify(n),-1===o.indexOf(r)&&void 0!==r&&(o.push(r),t.push(n));return t},Iterate:function(r,n){return this.RunEach(r,void 0,n),this},Collect:function(r,n){return this.RunEach(r,void 0,n)},WhereIndexes:function(r,n,e){return this.Where(r,n,e,!0)},Where:function(r,n,e,t){var o,i,a,s=this.length,u=[];if(t=!!t,"object"!=typeof r||r.paIsArray){if(void 0===r){var c=new Error("PowerArray => Where function => No condition object provided to function 'Where(whereConditions, keepOrder)'");throw c.message="InvalidWhereCondition",c}if(r.paIsArray){if(a=pa.paWhereHelper.ProcessConditionObject.call(this,r,n,!0,e,t),e)return a;u.push.apply(u,a)}else if(n){for(o=0;o0)return u[0];return}return u}},Count:function(r){if(1!==arguments.length)throw new Error("PowerArray => Count function => Invalid arguments. The only argument is a whereCondition or an array of whereConditions object.");return pa.prototypedFunctions_Array.Where.call(this,r,!1,!1).length},First:function(r){return 0===arguments.length?this.length>0?this[0]:void 0:pa.prototypedFunctions_Array.Where.call(this,r,!0,!0)},FirstIndex:function(r){return 0===arguments.length?this.length>0?0:void 0:pa.prototypedFunctions_Array.Where.call(this,r,!0,!0,!0)},Average:function(){},Bounds:function(){var r,n,e=this.length,t=arguments.length,o={},i="";if(0===t)throw new Error("PowerArray => bounds => invalid params, please provide one or more target parameters");for(r=t;r--;)o[i=arguments[r]]={min:void 0,max:void 0};for(;e--;)for(r=t;r--;)i=arguments[r],n=this[e][i],(void 0===o[i].max||void 0!==n&&n>o[i].max)&&(o[i].max=n),(void 0===o[i].min||void 0!==n&&n Max => invalid params, please provide one or more target parameters");for(r=t;r;);for(;e--;)for(r=t;r--;)i=arguments[r],n=this[e][i],(void 0===o[i]||void 0!==n&&n>o[i])&&(o[i]=n);if(1===t)return o[i]},Take:function(r,n){for(var e=0+(n=n||0),t=this.length,o=[],i=0;e-1?this[r]:null}},mainContainer.pa.Sort={Ascending:"ASCENDING",Asc:"ASC",AscendingIgnoringCase:"ASCENDINGIGNORINGCASE",AscIgnoringCase:"ASCIGNORINGCASE",Descending:"DESCENDING",Desc:"DESC",DescendingIgnoringCase:"DESCENDINGIGNORINGCASE",DescIgnoringCase:"DESCIGNORINGCASE"};var validSortingConf=[mainContainer.pa.Sort.Ascending,mainContainer.pa.Sort.Asc,mainContainer.pa.Sort.AscendingIgnoringCase,mainContainer.pa.Sort.AscIgnoringCase,mainContainer.pa.Sort.Descending,mainContainer.pa.Sort.Desc,mainContainer.pa.Sort.DescendingIgnoringCase,mainContainer.pa.Sort.DescIgnoringCase];mainContainer.pa.Sort._validSortConfigStrings=validSortingConf,mainContainer.Sort=mainContainer.pa.Sort;var paArray=function(r){if(!r.paIsArray)throw new Error('PowerArray => paArray warning => Invalid array passed to pa() function"');var n=r.slice(0),e=mainContainer.pa.prototypedFunctions_Array;for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n};paArray.prototype.isArray=!0,function(){var r=mainContainer.pa.auxiliaryFunctions;for(var n in r)r.hasOwnProperty(n)&&(mainContainer.pa[n]=r[n],mainContainer[n]?console.warn("PowerArray warning! => property mainContainer."+n+" already exists. PowerArrayFunction pa."+n+' cannot register this function on mainContainer scope. However, you can still using it by calling "pa.'+n+'"'):mainContainer[n]=r[n]);Array.prototype.paIsArray||(Array.prototype.paIsArray=!0);var e=mainContainer.pa.prototypedFunctions_Array;for(var t in e)e.hasOwnProperty(t)&&(Array.prototype.hasOwnProperty(t)?console.warn("PowerArray warning! => Array Prototype was modified by other library, and the function name "+t+" is already in use. PowerArray will NOT override the prototype method. However, you can still using the function "+t+" by surrounding your array with a pa constructor call, as following: pa(yourArrayName)."+t+"(...)"):Array.prototype[t]=e[t],paArray.prototype[t]=e[t])}(),isModule&&(module.exports=mainContainer.pa); 2 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import App from './App.vue'; 3 | // @ts-ignore: vue-material does not yet have typescript support 4 | // tslint:disable-next-line 5 | import VueMaterial from 'vue-material'; 6 | import 'vue-material/dist/vue-material.css'; 7 | 8 | import VueRouter from 'vue-router'; 9 | import router from './router'; 10 | 11 | import MavonEditor from 'mavon-editor'; 12 | import 'mavon-editor/dist/css/index.css'; 13 | 14 | import Toasted from 'vue-toasted'; 15 | 16 | import RestClient from './business/rest/RestClient'; 17 | import LocalStorageManager from './business/persistence/localstorage/LocalStorageManager'; 18 | import PreferenceManager from './business/persistence/preferences/PreferenceManger'; 19 | import PreferenceItems from './business/persistence/preferences/PreferenceItems'; 20 | 21 | import './registerServiceWorker'; 22 | 23 | Vue.config.productionTip = true; 24 | 25 | Vue.use(VueMaterial); 26 | Vue.use(VueRouter); 27 | Vue.use(MavonEditor); 28 | Vue.use(Toasted, { 29 | position: 'bottom-left', 30 | className: null, 31 | duration: 4000, 32 | type: null, 33 | theme: 'primary', 34 | iconPack: 'material', 35 | }); 36 | 37 | // const router = new VueRouter({routes: Routes}); 38 | 39 | // GLOBAL PROPERTIES 40 | Vue.prototype.$appName = 'MkDocsEditor'; 41 | 42 | const localStorageManager = new LocalStorageManager(Vue.prototype.localStorage); 43 | const preferenceManager = new PreferenceManager(localStorageManager); 44 | Vue.prototype.$preferenceManager = preferenceManager; 45 | 46 | const serverUrl = preferenceManager.loadPreferenceValue(PreferenceItems.Server.URL); 47 | const authEnabled = (preferenceManager.loadPreferenceValue(PreferenceItems.Server.Auth.Enabled) === 'true'); 48 | const username = preferenceManager.loadPreferenceValue(PreferenceItems.Server.Auth.Username); 49 | const password = preferenceManager.loadPreferenceValue(PreferenceItems.Server.Auth.Password); 50 | 51 | Vue.prototype.$restClient = new RestClient(serverUrl, authEnabled, username, password); 52 | 53 | Vue.config.productionTip = false; 54 | 55 | new Vue({ 56 | router, 57 | render: (h) => h(App), 58 | }).$mount('#app'); 59 | -------------------------------------------------------------------------------- /src/registerServiceWorker.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable:no-console */ 2 | 3 | import {register} from 'register-service-worker'; 4 | 5 | if (process.env.NODE_ENV === 'production') { 6 | register(`${process.env.BASE_URL}service-worker.js`, { 7 | ready() { 8 | console.log( 9 | 'App is being served from cache by a service worker.\n' + 10 | 'For more details, visit https://goo.gl/AFskqB', 11 | ); 12 | }, 13 | registered() { 14 | console.log('Service worker has been registered.'); 15 | }, 16 | cached() { 17 | console.log('Content has been cached for offline use.'); 18 | }, 19 | updatefound() { 20 | console.log('New content is downloading.'); 21 | }, 22 | updated() { 23 | console.log('New content is available; please refresh.'); 24 | }, 25 | offline() { 26 | console.log('No internet connection found. App is running in offline mode.'); 27 | }, 28 | error(error) { 29 | console.error('Error during service worker registration:', error); 30 | }, 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /src/router.ts: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import Router from 'vue-router'; 3 | import FileBrowser from '@/components/browser/FileBrowser.vue'; 4 | import CodeEditor from '@/components/CodeEditor.vue'; 5 | import Settings from '@/components/Settings.vue'; 6 | 7 | Vue.use(Router); 8 | 9 | const router = new Router({ 10 | routes: [ 11 | { 12 | name: 'Home', path: '/', component: FileBrowser, 13 | meta: { 14 | title: 'MkDocsEditor', 15 | metaTags: [ 16 | {name: 'description', content: 'The home page of MkDocsEditor.',}, 17 | {property: 'og:description', content: 'The home page of MkDocsEditor.',}, 18 | ], 19 | }, 20 | }, 21 | { 22 | name: 'FileBrowserMain', path: '/file_browser', 23 | component: () => import(/* webpackChunkName: "codeEditor" */ '@/components/browser/FileBrowser.vue'), 24 | meta: {title: 'File Browser'}, 25 | }, 26 | { 27 | name: 'FileBrowser', path: '/file_browser/:id', 28 | component: () => import(/* webpackChunkName: "codeEditor" */ '@/components/browser/FileBrowser.vue'), 29 | meta: {title: 'File Browser'}, 30 | }, 31 | { 32 | name: 'CodeEditor', path: '/code_editor/:id', 33 | component: () => import(/* webpackChunkName: "codeEditor" */ '@/components/CodeEditor.vue'), 34 | meta: {title: 'Code Editor'}, 35 | }, 36 | { 37 | name: 'Settings', path: '/settings', 38 | component: () => import(/* webpackChunkName: "settings" */ '@/components/Settings.vue'), 39 | meta: {title: 'Settings'}, 40 | }, 41 | { 42 | name: 'AboutApp', path: '/about', 43 | component: () => import(/* webpackChunkName: "about" */ '@/components/about/About.vue'), 44 | meta: {title: 'About'}, 45 | }, 46 | { 47 | name: 'AboutLibraries', 48 | path: '/about/libraries', 49 | component: () => import(/* webpackChunkName: "about" */ '@/components/about/About.vue'), 50 | meta: {title: 'Libraries'}, 51 | }, 52 | ], 53 | }); 54 | router.beforeEach((to, from, next) => { 55 | document.title = to.meta.title; 56 | next(); 57 | }); 58 | 59 | export default router; 60 | -------------------------------------------------------------------------------- /src/shims-tsx.d.ts: -------------------------------------------------------------------------------- 1 | import Vue, {VNode} from 'vue'; 2 | 3 | declare global { 4 | namespace JSX { 5 | // tslint:disable no-empty-interface 6 | interface Element extends VNode { 7 | } 8 | 9 | // tslint:disable no-empty-interface 10 | interface ElementClass extends Vue { 11 | } 12 | 13 | interface IntrinsicElements { 14 | [elem: string]: any; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/shims-vue.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.vue' { 2 | import Vue from 'vue'; 3 | export default Vue; 4 | } 5 | -------------------------------------------------------------------------------- /src/vue-extension.d.ts: -------------------------------------------------------------------------------- 1 | import RestClient from '@/business/rest/RestClient'; 2 | import PreferenceManager from '@/business/persistence/preferences/PreferenceManger'; 3 | import {Toasted} from 'vue-toasted'; 4 | 5 | declare module 'vue/types/vue' { 6 | interface Vue { 7 | $appName: string; // define real typings here if you want 8 | $preferenceManager: PreferenceManager; 9 | $restClient: RestClient; 10 | $toasted: Toasted; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "module": "esnext", 5 | "strict": true, 6 | "jsx": "preserve", 7 | "importHelpers": true, 8 | "moduleResolution": "node", 9 | "experimentalDecorators": true, 10 | "esModuleInterop": true, 11 | "allowSyntheticDefaultImports": true, 12 | "sourceMap": true, 13 | "baseUrl": ".", 14 | "types": [ 15 | "webpack-env" 16 | ], 17 | "paths": { 18 | "@/*": [ 19 | "src/*" 20 | ] 21 | }, 22 | "lib": [ 23 | "esnext", 24 | "dom", 25 | "dom.iterable", 26 | "scripthost" 27 | ] 28 | }, 29 | "include": [ 30 | "src/**/*.ts", 31 | "src/**/*.tsx", 32 | "src/**/*.vue", 33 | "tests/**/*.ts", 34 | "tests/**/*.tsx" 35 | ], 36 | "exclude": [ 37 | "node_modules" 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultSeverity": "warning", 3 | "extends": [ 4 | "tslint:recommended" 5 | ], 6 | "linterOptions": { 7 | "exclude": [ 8 | "node_modules/**" 9 | ] 10 | }, 11 | "rules": { 12 | "quotemark": [ 13 | true, 14 | "single" 15 | ], 16 | "indent": [ 17 | true, 18 | "spaces", 19 | 2 20 | ], 21 | "interface-name": false, 22 | "ordered-imports": false, 23 | "object-literal-sort-keys": false, 24 | "no-consecutive-blank-lines": false, 25 | "@typescript-eslint/ban-ts-comment": "off" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | configureWebpack: config => { 3 | if (process.env.NODE_ENV === 'production') { 4 | // mutate config for production... 5 | } else { 6 | // mutate for development... 7 | } 8 | } 9 | }; 10 | --------------------------------------------------------------------------------