├── .gitignore ├── LICENSE ├── README.md ├── markdowneditor ├── markdowneditor.pro ├── markdowneditor.rc ├── qmls │ ├── base.qrc │ ├── custom │ │ ├── FileTree │ │ │ ├── FileTreeRightMenu.qml │ │ │ ├── FileTreeViewStyle.qml │ │ │ └── SubTree.qml │ │ ├── MarkdownEditor.qml │ │ ├── MarkdownViewer.qml │ │ ├── SettingsItem.qml │ │ ├── items │ │ │ └── ImageButton.qml │ │ ├── navigationbar │ │ │ ├── TitleNavigationBar.qml │ │ │ └── TitleNavigationItem.qml │ │ └── partition │ │ │ ├── DragLine.qml │ │ │ └── Triangle.qml │ └── main.qml ├── resources │ ├── 3rdparty │ │ ├── markdown.css │ │ ├── markdown.css.save │ │ ├── marked.min.js │ │ └── simple-markdown.css │ ├── default.md │ ├── images.qrc │ ├── images │ │ ├── 32x32 │ │ │ ├── markdown-editor-logo.ico │ │ │ └── markdown-editor-logo.png │ │ └── svg │ │ │ ├── add.svg │ │ │ ├── delete.svg │ │ │ ├── dir.svg │ │ │ ├── dir_open.svg │ │ │ ├── doc.svg │ │ │ ├── doc_null.svg │ │ │ ├── file-markdown.svg │ │ │ ├── max.svg │ │ │ ├── min.svg │ │ │ ├── point.svg │ │ │ ├── sets │ │ │ ├── edit.svg │ │ │ ├── edit_view.svg │ │ │ ├── file_list.svg │ │ │ ├── look.svg │ │ │ ├── set_hollow.svg │ │ │ └── set_solid.svg │ │ │ ├── triangle_down.svg │ │ │ └── triangle_right.svg │ ├── index.html │ ├── markdown-it │ │ ├── markdown-it-footnote.js │ │ ├── markdown-it-math.js │ │ ├── markdown-it.js │ │ └── mathjax.css │ ├── markdowneditor.qrc │ └── qwebchannel.js └── src │ ├── document.cpp │ ├── document.h │ ├── dragarea.cpp │ ├── dragarea.h │ ├── filemodel.cpp │ ├── filemodel.h │ ├── main.cpp │ ├── utils.cpp │ └── utils.h └── screenShot └── home.png /.gitignore: -------------------------------------------------------------------------------- 1 | *.pro.user* 2 | */output 3 | build-markdowneditor-* 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 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 General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # markdown-editor 2 | A qml markdown editor 3 | 4 | download [releases](https://github.com/CrazyCxl/markdown-editor/releases) 5 | 6 | ![home](https://raw.githubusercontent.com/CrazyCxl/markdown-editor/master/screenShot/home.png) 7 | 8 | # Todo list 9 | 10 | - Syntax highlighting 11 | - The chart support 12 | 13 | # Reference 14 | - [github-markdown-css](https://github.com/sindresorhus/github-markdown-css) 15 | - [Moeditor](https://github.com/Moeditor/Moeditor) 16 | - [qtwebengine-webenginewidgets-markdowneditor-example](https://doc.qt.io/qt-5.10/qtwebengine-webenginewidgets-markdowneditor-example.html) 17 | - [mathml css](https://github.com/fred-wang/mathml.css) 18 | - [markdown it](https://github.com/markdown-it/markdown-it) 19 | - [markdown it math](https://github.com/runarberg/markdown-it-math) 20 | - [markdown-it-footnote](https://github.com/markdown-it/markdown-it-footnote) 21 | -------------------------------------------------------------------------------- /markdowneditor/markdowneditor.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | DESTDIR = $$PWD/bin 3 | PROJECT_DIR = $$[DESTDIR] 4 | 5 | QT += webenginewidgets webchannel qml quick webengine 6 | CONFIG += c++11 7 | 8 | HEADERS += \ 9 | src/document.h \ 10 | src/filemodel.h \ 11 | src/utils.h \ 12 | src/dragarea.h 13 | 14 | SOURCES = \ 15 | src/main.cpp \ 16 | src/document.cpp \ 17 | src/filemodel.cpp \ 18 | src/utils.cpp \ 19 | src/dragarea.cpp 20 | 21 | RESOURCES = \ 22 | resources/markdowneditor.qrc \ 23 | resources/images.qrc \ 24 | qmls/base.qrc 25 | 26 | FORMS += 27 | 28 | DISTFILES += \ 29 | resources/3rdparty/MARKDOWN-LICENSE.txt \ 30 | resources/3rdparty/MARKED-LICENSE.txt 31 | 32 | # Copies the given files to the destination directory 33 | defineTest(CopyToDestDir) { 34 | files = $$1 35 | 36 | for(FILE, files) { 37 | DDIR = $$DESTDIR 38 | 39 | # Replace slashes in paths with backslashes for Windows 40 | win32:FILE ~= s,/,\\,g 41 | win32:DDIR ~= s,/,\\,g 42 | 43 | QMAKE_POST_LINK += $$QMAKE_COPY $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t) 44 | } 45 | 46 | export(QMAKE_POST_LINK) 47 | } 48 | 49 | CONFIG(debug, debug|release){ 50 | CONFIG += console 51 | DESTDIR = $$PWD/output/debug 52 | } 53 | 54 | CONFIG(release, debug|release){ 55 | CONFIG -= app_bundle 56 | CONFIG -= console 57 | DESTDIR = $$PWD/output/release 58 | } 59 | 60 | QML_IMPORT_PATH = $$[QT_INSTALL_QML] 61 | 62 | win32 { 63 | RC_FILE = markdowneditor.rc 64 | } 65 | 66 | mqmls = $$PWD/qmls/main.qml \ 67 | $$PWD/qmls/custom/partition/DragLine.qml \ 68 | $$PWD/qmls/custom/partition/Triangle.qml \ 69 | $$PWD/qmls/custom/MarkdownViewer.qml \ 70 | $$PWD/qmls/custom/MarkdownEditor.qml \ 71 | $$PWD/qmls/custom/FileTree/SubTree.qml \ 72 | $$PWD/qmls/custom/FileTree/FileTreeViewStyle.qml \ 73 | $$PWD/qmls/custom/FileTree/FileTreeRightMenu.qml \ 74 | $$PWD/qmls/custom/SettingsItem.qml \ 75 | $$PWD/qmls/custom/items/ImageButton.qml \ 76 | $$PWD/qmls/custom/navigationbar/TitleNavigationBar.qml \ 77 | $$PWD/qmls/custom/navigationbar/TitleNavigationItem.qml 78 | 79 | qml_scenes.depends = $$mqmls 80 | qml_scenes.commands = 81 | QMAKE_EXTRA_TARGETS += qml_scenes 82 | 83 | # install 84 | target.path = $$PWD/bin 85 | plugins_platforms.path = $$PWD/bin/platforms 86 | 87 | INSTALLS += target 88 | INSTALLS += plugins_platforms 89 | 90 | -------------------------------------------------------------------------------- /markdowneditor/markdowneditor.rc: -------------------------------------------------------------------------------- 1 | #include "winver.h" 2 | IDI_ICON1 ICON "./resources/images/32x32/markdown-editor-logo.ico" 3 | 4 | #define VERSION_1 0 5 | #define VERSION_2 0 6 | #define VERSION_3 1 7 | 8 | VS_VERSION_INFO VERSIONINFO 9 | FILEVERSION VERSION_1,VERSION_2,VERSION_3 10 | PRODUCTVERSION VERSION_1,VERSION_2,VERSION_3 11 | FILEFLAGS 0x0L 12 | FILEFLAGSMASK 0x3fL 13 | FILEOS 0x40004L 14 | FILETYPE 0x1L 15 | FILESUBTYPE 0x0L 16 | BEGIN 17 | BLOCK "StringFileInfo" 18 | BEGIN 19 | BLOCK "080404b0" 20 | BEGIN 21 | VALUE "CompanyName", "Chengdu cxl." 22 | VALUE "FileDescription", "Cxl Markdown Editor" 23 | VALUE "FileVersion", VERSION_1"." VERSION_2"." VERSION_3 24 | VALUE "LegalCopyright", "Copyright 2018-2019 The Chengdu Cxl. All rights reserved." 25 | VALUE "InternalName", "markdowneditor.exe" 26 | VALUE "OriginalFilename", "markdowneditor.exe" 27 | VALUE "ProductName", "Cxl Markdown Editor" 28 | VALUE "ProductVersion", VERSION_1"." VERSION_2"." VERSION_3 29 | END 30 | END 31 | BLOCK "VarFileInfo" 32 | BEGIN 33 | VALUE "Translation", 0x804, 1200 34 | END 35 | END 36 | -------------------------------------------------------------------------------- /markdowneditor/qmls/base.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main.qml 4 | custom/MarkdownViewer.qml 5 | custom/MarkdownEditor.qml 6 | custom/SettingsItem.qml 7 | custom/items/ImageButton.qml 8 | custom/navigationbar/TitleNavigationBar.qml 9 | custom/navigationbar/TitleNavigationItem.qml 10 | custom/FileTree/SubTree.qml 11 | custom/FileTree/FileTreeViewStyle.qml 12 | custom/FileTree/FileTreeRightMenu.qml 13 | custom/partition/DragLine.qml 14 | custom/partition/Triangle.qml 15 | 16 | 17 | -------------------------------------------------------------------------------- /markdowneditor/qmls/custom/FileTree/FileTreeRightMenu.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import QtQuick.Controls 2.2 3 | import cxl.normal 1.0 4 | 5 | Menu{ 6 | property var selectFileIndex 7 | property bool isDir: false 8 | property bool isDirExpanded: false 9 | property bool isSpaceClick: false 10 | MenuItem{ 11 | text: isDir? (isDirExpanded ? qsTr("Fold") : qsTr("Expanded") ): qsTr("Open") 12 | visible:!isSpaceClick 13 | height:visible?implicitHeight :0 14 | onTriggered: { 15 | if(isDir){ 16 | if(isDirExpanded){ 17 | view.collapse(selectFileIndex) 18 | }else{ 19 | view.expand(selectFileIndex) 20 | } 21 | }else{ 22 | file_view.selectTitle = fileMode.data(selectFileIndex, FileModel.BaseNameStringRole) 23 | file_view.pathSelected(fileMode.data(selectFileIndex, FileModel.UrlStringRole)) 24 | } 25 | } 26 | } 27 | 28 | MenuItem{ 29 | text: qsTr("Open the folder") 30 | visible:!isSpaceClick 31 | height:visible?implicitHeight :0 32 | onTriggered: { 33 | var url = fileMode.data(selectFileIndex, FileModel.DirStringRole) 34 | Qt.openUrlExternally(url) 35 | } 36 | } 37 | 38 | MenuItem{ 39 | text: qsTr("Set working folders") 40 | visible:isSpaceClick 41 | height:visible?implicitHeight :0 42 | onTriggered: { 43 | file_view.showChangeDirDialog() 44 | } 45 | } 46 | 47 | function reload(index){ 48 | selectFileIndex = index 49 | if(fileMode.data(index, FileModel.IsValidRole)){ 50 | isSpaceClick = false 51 | if(!fileMode.data(index, FileModel.IsDirRole)){ 52 | isDir = false 53 | }else{ 54 | isDir = true 55 | isDirExpanded = view.isExpanded(index) 56 | } 57 | }else{ 58 | isSpaceClick = true 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /markdowneditor/qmls/custom/FileTree/FileTreeViewStyle.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import QtQuick.Controls.Styles 1.4 3 | import cxl.normal 1.0 4 | 5 | TreeViewStyle { 6 | frame:null 7 | branchDelegate: Image { 8 | width: 14 9 | height: width 10 | source:styleData.isExpanded ? "qrc:/item/images/svg/triangle_down.svg" : "qrc:/item/images/svg/triangle_right.svg" 11 | } 12 | 13 | itemDelegate: Item { 14 | Image { 15 | id: doc_type_image 16 | anchors.left: parent.left 17 | anchors.leftMargin: 3 18 | anchors.verticalCenter: parent.verticalCenter 19 | width: 15 20 | height: width 21 | source: styleData.hasChildren? 22 | (styleData.isExpanded?"qrc:/item/images/svg/dir_open.svg":"qrc:/item/images/svg/dir.svg"): 23 | (fileMode.data(styleData.index, FileModel.IsMarkdownFileRole)?"qrc:/item/images/svg/file-markdown.svg": 24 | "qrc:/item/images/svg/doc_null.svg") 25 | } 26 | 27 | Text { 28 | anchors.left: doc_type_image.right 29 | anchors.leftMargin: 5 30 | anchors.verticalCenter: parent.verticalCenter 31 | anchors.right: parent.right 32 | elide: Text.ElideMiddle 33 | text: styleData.value 34 | } 35 | } 36 | 37 | rowDelegate:Rectangle{ 38 | height: 25 39 | color: styleData.selected?"#efefef":"#ffffff" 40 | } 41 | 42 | handle: Rectangle { 43 | implicitWidth: 10 44 | color: styleData.hovered?"#c0c0c0":"#e0e0e0" 45 | } 46 | 47 | scrollBarBackground: Rectangle { 48 | implicitWidth: 10 49 | color: "#f5f5f5" 50 | } 51 | decrementControl: null 52 | incrementControl: null 53 | } 54 | -------------------------------------------------------------------------------- /markdowneditor/qmls/custom/FileTree/SubTree.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.4 2 | import QtQuick.Controls 1.4 3 | import QtQml.Models 2.2 4 | import QtQuick.Dialogs 1.0 5 | import cxl.normal 1.0 6 | 7 | Rectangle { 8 | color:"#ffffff" 9 | 10 | property string selectTitle 11 | property string dirPath 12 | property var fileMode 13 | property bool enableChangeDir: false 14 | 15 | signal pathSelected(var path) 16 | 17 | function showChangeDirDialog(){ 18 | if(enableChangeDir){ 19 | fileDialog.visible = true 20 | } 21 | } 22 | 23 | Rectangle{ 24 | id:top_item 25 | anchors.top: parent.top 26 | width: parent.width 27 | height: 30 28 | visible: false 29 | Text { 30 | id:text_field 31 | anchors.centerIn: parent 32 | width: parent.width-20 33 | text: fileMode.dirPath 34 | elide: Text.ElideMiddle 35 | color:top_area.containsMouse?"#202020":"#000000" 36 | } 37 | 38 | MouseArea{ 39 | id:top_area 40 | anchors.fill: parent 41 | hoverEnabled: true 42 | onClicked: { 43 | showChangeDirDialog() 44 | } 45 | } 46 | 47 | FileDialog { 48 | id: fileDialog 49 | title: qsTr("Please choose a directory") 50 | folder: "file:///" + fileMode.dirPath 51 | selectFolder:true 52 | selectMultiple:false 53 | onAccepted: { 54 | console.log("You chose: " + fileDialog.fileUrls) 55 | dirPath = fileDialog.fileUrl 56 | } 57 | } 58 | } 59 | 60 | ItemSelectionModel { 61 | id: sel 62 | model: fileMode 63 | } 64 | 65 | TreeView { 66 | id: view 67 | anchors.top: top_item.visible?top_item.bottom:parent.top 68 | width: parent.width 69 | anchors.bottom: parent.bottom 70 | model: fileMode 71 | rootIndex: fileMode.rootIndex 72 | selection: sel 73 | headerVisible: false 74 | 75 | TableViewColumn { 76 | role: "fileName" 77 | } 78 | 79 | FileTreeRightMenu{ 80 | id:right_menu 81 | } 82 | 83 | style:FileTreeViewStyle{} 84 | 85 | onDoubleClicked: { 86 | if(!fileMode.data(index, FileModel.IsDirRole)){ 87 | selectTitle = fileMode.data(index, FileModel.BaseNameStringRole) 88 | pathSelected(fileMode.data(index, FileModel.UrlStringRole)) 89 | }else{ 90 | if(view.isExpanded(index)){ 91 | view.collapse(index) 92 | }else{ 93 | view.expand(index) 94 | } 95 | 96 | } 97 | } 98 | 99 | MouseArea { 100 | anchors.fill: parent 101 | propagateComposedEvents: true 102 | acceptedButtons: Qt.RightButton 103 | onClicked: mouse.accepted = false; 104 | onPressed: { 105 | var index_t = parent.indexAt(mouse.x,mouse.y) 106 | right_menu.x = mouse.x 107 | right_menu.y = mouse.y 108 | right_menu.visible = true 109 | view.selection.setCurrentIndex(index_t,ItemSelectionModel.Select) 110 | right_menu.reload(index_t) 111 | mouse.accepted = false; 112 | } 113 | onReleased: mouse.accepted = false; 114 | onDoubleClicked: mouse.accepted = false; 115 | onPositionChanged: mouse.accepted = false; 116 | onPressAndHold: mouse.accepted = false; 117 | } 118 | } 119 | 120 | onDirPathChanged: { 121 | fileMode.dirPath = dirPath 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /markdowneditor/qmls/custom/MarkdownEditor.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.10 2 | import QtQuick.Controls 2.2 3 | import QtQuick.Controls.Styles 1.4 4 | import QtQuick.Dialogs 1.3 5 | import cxl.normal 1.0 6 | 7 | Flickable{ 8 | anchors.leftMargin: root.stepSize*3 9 | // anchors.bottomMargin: root.stepSize*3 10 | // anchors.topMargin: root.stepSize*3 11 | // boundsBehavior: Flickable.OvershootBounds 12 | ScrollBar.vertical: scroller 13 | property string text 14 | property string path 15 | 16 | TextArea.flickable: TextArea{ 17 | id:text_area 18 | selectByMouse: true 19 | text: editor.text 20 | font.pixelSize: 15 21 | font.family: "Microsoft YaHei UI" 22 | rightPadding:20 23 | onTextChanged: { 24 | if(editor.text !== text_area.text){ 25 | editor.text = text_area.text 26 | navigation_bar.setCurrentItemUnsaved(true) 27 | } 28 | } 29 | } 30 | 31 | Shortcut { 32 | sequence: StandardKey.Save 33 | context: Qt.ApplicationShortcut 34 | onActivated: { 35 | if(navigation_bar.isCurrentItemUnsaved()){ 36 | if(path !== null && path.length !== 0){ 37 | saveDoc(path) 38 | }else{ 39 | save_file_dialog.visible = true 40 | } 41 | } 42 | } 43 | } 44 | 45 | function saveDoc(path){ 46 | var ret = utils.saveDocToFile(editor.text,path) 47 | console.log("saved "+path +" "+ret) 48 | navigation_bar.setCurrentItemUnsaved(!ret) 49 | } 50 | 51 | FileDialog{ 52 | id:save_file_dialog 53 | title: qsTr("Save File") 54 | folder: shortcuts.home 55 | selectMultiple: false 56 | selectExisting :false 57 | selectFolder:false 58 | nameFilters: [qsTr("Markdown Files (*.md)"),qsTr("Text Files (*.txt)"),qsTr("All Files (*.*)")] 59 | onAccepted: { 60 | saveDoc(fileUrl) 61 | editor.path = fileUrl 62 | navigation_bar.changeCurrentPath(fileUrl) 63 | } 64 | } 65 | } 66 | 67 | 68 | -------------------------------------------------------------------------------- /markdowneditor/qmls/custom/MarkdownViewer.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.2 2 | import QtQuick.Controls 2.2 3 | import QtWebChannel 1.0 4 | import QtWebEngine 1.1 5 | import QtQml 2.2 6 | import QtWebEngine 1.6 7 | 8 | import cxl.normal 1.0 9 | 10 | 11 | Item { 12 | id: flick 13 | property string text 14 | WebEngineView{ 15 | id:web_view 16 | url: "qrc:/index.html" 17 | anchors.fill: parent 18 | settings.showScrollBars:false 19 | focus: true 20 | webChannel:WebChannel{ 21 | registeredObjects:[m_content] 22 | } 23 | 24 | Document{ 25 | id:m_content 26 | text:viewer.text 27 | WebChannel.id:"content" 28 | } 29 | } 30 | 31 | MouseArea{ 32 | id:view_area 33 | width: web_view.width 34 | height: web_view.height 35 | property bool callScrollUp: false 36 | property double scrollEnhance: 0 37 | acceptedButtons: Qt.LeftButton | Qt.RightButton 38 | onWheel: { 39 | scroll_run_timer.stop() 40 | scroll_stop_timer.stop() 41 | scroll_start_timer.stop() 42 | if(wheel.angleDelta.y > 0){ 43 | callScrollUp = false 44 | }else{ 45 | callScrollUp = true 46 | } 47 | scroller.stepSize = 0.02 48 | updateScroller() 49 | scroll_start_timer.start() 50 | } 51 | 52 | function updateScroller(){ 53 | if(callScrollUp){ 54 | if(web_view.height > editor.contentHeight){ 55 | editor.contentHeight = web_view.height +100 56 | } 57 | scroller.increase() 58 | }else{ 59 | scroller.decrease() 60 | } 61 | } 62 | 63 | Timer{ 64 | id:scroll_run_timer 65 | interval: 10 66 | repeat: true 67 | onTriggered: { 68 | view_area.updateScroller() 69 | scroll_run_timer.interval++ 70 | scroller.stepSize -= scroller.stepSize/5 71 | } 72 | } 73 | 74 | Timer{ 75 | id:scroll_stop_timer 76 | interval: 500 77 | onTriggered: { 78 | scroll_run_timer.stop() 79 | scroll_run_timer.interval = 10 80 | } 81 | } 82 | 83 | Timer{ 84 | id:scroll_start_timer 85 | interval: 20 86 | onTriggered: { 87 | scroll_run_timer.restart() 88 | scroll_stop_timer.restart() 89 | } 90 | } 91 | } 92 | 93 | Connections { 94 | target:scroller 95 | onPositionChanged: { 96 | web_view.runJavaScript( 97 | "document.documentElement.scrollHeight", 98 | function (i_actualPageWidth) { 99 | view_area.scrollEnhance = editor.contentY/(editor.contentHeight-editor.height) * 100 | (i_actualPageWidth-web_view.height) 101 | }) 102 | web_view.runJavaScript("window.scrollTo(0,"+view_area.scrollEnhance+")") 103 | } 104 | } 105 | } 106 | 107 | 108 | -------------------------------------------------------------------------------- /markdowneditor/qmls/custom/SettingsItem.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.10 2 | import "./items" 3 | 4 | Item { 5 | id:set_item 6 | x:0 7 | y:0 8 | 9 | signal callChangeDir() 10 | signal callOnlyEdit() 11 | signal callOnlyRead() 12 | signal callReadEdit() 13 | 14 | property int offset:{ 15 | var w = set_hollow.width + list_set.width + edit_set.width+look_set.width+ edit_look_set.width +itemMargin*5 16 | if( set_hollow.x+w > root.width){ 17 | return -w; 18 | } 19 | return w; 20 | } 21 | 22 | property int itemMargin: 10 23 | 24 | Rectangle{ 25 | id:sets_background 26 | anchors.left: set_hollow.left 27 | anchors.verticalCenter: set_hollow.verticalCenter 28 | anchors.right: set_solid.right 29 | anchors.margins: -5 30 | height: set_hollow.height+itemMargin 31 | color: "#e0e0e0" 32 | radius: 8 33 | } 34 | 35 | Image{ 36 | id:set_solid 37 | width: 30 38 | height: width 39 | x:set_hollow.x 40 | y:set_hollow.y 41 | source: "qrc:/item/images/svg/sets/set_solid.svg" 42 | MouseArea{ 43 | anchors.fill: parent 44 | onClicked: changeState() 45 | } 46 | } 47 | 48 | Image{ 49 | id:set_hollow 50 | y:root.height - set_hollow.height*2 51 | x:set_hollow.width 52 | width: set_solid.width 53 | height: width 54 | source: "qrc:/item/images/svg/sets/set_hollow.svg" 55 | 56 | MouseArea{ 57 | id:set_hollow_area 58 | anchors.fill: parent 59 | drag{ 60 | target: parent 61 | axis: Drag.XAndYAxis 62 | minimumX: -set_hollow.width+5 63 | maximumX: root.width - 5 64 | minimumY: 0 65 | maximumY: root.height -set_hollow.height 66 | } 67 | onClicked: changeState() 68 | } 69 | } 70 | 71 | ImageButton{ 72 | id:list_set 73 | x:offset > 0? set_hollow.x + set_hollow.width+itemMargin:set_hollow.x - list_set.width - itemMargin 74 | anchors.verticalCenter: set_hollow.verticalCenter 75 | width: 30;height: list_set.width 76 | imageSource: "qrc:/item/images/svg/sets/file_list.svg" 77 | onClicked: callChangeDir() 78 | normalColor: sets_background.color 79 | hoverColor: "#ffffff" 80 | } 81 | 82 | ImageButton{ 83 | id:edit_set 84 | x:offset > 0? list_set.x + list_set.width+itemMargin:list_set.x - edit_set.width - itemMargin 85 | anchors.verticalCenter: set_hollow.verticalCenter 86 | width: list_set.width;height: list_set.width 87 | opacity:list_set.opacity 88 | visible: list_set.visible 89 | imageSource: "qrc:/item/images/svg/sets/edit.svg" 90 | onClicked: callOnlyEdit() 91 | normalColor: sets_background.color 92 | hoverColor: list_set.hoverColor 93 | } 94 | 95 | 96 | ImageButton{ 97 | id:look_set 98 | x:offset > 0? edit_set.x + edit_set.width+itemMargin:edit_set.x - look_set.width - itemMargin 99 | anchors.verticalCenter: set_hollow.verticalCenter 100 | width: edit_set.width;height: look_set.width 101 | opacity:list_set.opacity 102 | normalColor: sets_background.color 103 | hoverColor: list_set.hoverColor 104 | imageSource: "qrc:/item/images/svg/sets/look.svg" 105 | onClicked: callOnlyRead() 106 | } 107 | 108 | 109 | ImageButton{ 110 | id:edit_look_set 111 | x:offset > 0? look_set.x + look_set.width+itemMargin:look_set.x - edit_look_set.width - itemMargin 112 | anchors.verticalCenter: set_hollow.verticalCenter 113 | width: edit_set.width;height: look_set.width 114 | opacity:list_set.opacity 115 | imageSource: "qrc:/item/images/svg/sets/edit_view.svg" 116 | onClicked: callReadEdit() 117 | normalColor: sets_background.color 118 | hoverColor: list_set.hoverColor 119 | } 120 | 121 | function changeState(){ 122 | if(set_item.state == "SETTING"){ 123 | set_item.state ="UNSET" 124 | }else{ 125 | set_item.state ="SETTING" 126 | } 127 | } 128 | 129 | state:"UNSET" 130 | 131 | states: [ 132 | State { 133 | name: "SETTING" 134 | PropertyChanges { target: set_solid; x: set_hollow.x+offset} 135 | PropertyChanges { target: set_solid; rotation: 180} 136 | PropertyChanges { target: list_set; opacity:1} 137 | }, 138 | State { 139 | name: "UNSET" 140 | PropertyChanges { target: set_solid; x: set_hollow.x} 141 | PropertyChanges { target: set_solid; rotation: 0} 142 | PropertyChanges { target: list_set; opacity:0 } 143 | } 144 | ] 145 | 146 | transitions: [ 147 | Transition { 148 | from: "SETTING" 149 | to: "UNSET" 150 | PropertyAnimation {target: set_solid; duration: 200;properties: "x"; easing.type: Easing.InOutQuad} 151 | PropertyAnimation {target: set_solid; duration: 200;properties: "rotation"; easing.type: Easing.Linear} 152 | PropertyAnimation {target: list_set; duration: 500;properties: "opacity"; easing.type: Easing.Linear} 153 | }, 154 | Transition { 155 | from: "UNSET" 156 | to: "SETTING" 157 | PropertyAnimation { target: set_solid; duration: 200;properties: "x"; easing.type: Easing.InOutQuad} 158 | PropertyAnimation {target: set_solid; duration: 200;properties: "rotation"; easing.type: Easing.Linear} 159 | PropertyAnimation {target: list_set; duration: 500;properties: "opacity"; easing.type: Easing.Linear} 160 | } 161 | ] 162 | } 163 | -------------------------------------------------------------------------------- /markdowneditor/qmls/custom/items/ImageButton.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.4 2 | 3 | Rectangle{ 4 | id:_rect 5 | property color normalColor 6 | property color hoverColor 7 | property url imageSource 8 | 9 | signal clicked() 10 | 11 | radius: width/5 12 | color: _rect_area.containsMouse?hoverColor:normalColor 13 | Image{ 14 | anchors.fill: parent 15 | anchors.margins: parent.width/6 16 | mipmap:true 17 | source: imageSource 18 | MouseArea{ 19 | id:_rect_area 20 | anchors.fill: parent 21 | hoverEnabled: true 22 | onClicked: _rect.clicked() 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /markdowneditor/qmls/custom/navigationbar/TitleNavigationBar.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.10 2 | 3 | Rectangle { 4 | color:"#ffffff" 5 | property var tiltes:[] 6 | 7 | signal titleChecked(var title_data) 8 | signal callAddPage() 9 | 10 | function hasItemUnsaved(){ 11 | for(var i = 0;i= 0 && titles_list.count > index){ 21 | titles_mode.setProperty(index,"doc",doc) 22 | } 23 | } 24 | 25 | function setCurrentItemUnsaved(status){ 26 | if(titles_list.currentIndex >= 0){ 27 | titles_mode.setProperty(titles_list.currentIndex,"unsaved",status) 28 | } 29 | } 30 | 31 | function isCurrentItemUnsaved(){ 32 | if(titles_list.currentIndex >= 0){ 33 | return titles_mode.get(titles_list.currentIndex).unsaved; 34 | } 35 | 36 | return true; 37 | } 38 | 39 | function touchItem(title,path,doc){ 40 | var i = titles_mode.getIndexByPath(path) 41 | console.log("touch title:"+title+" path:"+path+" i:"+i) 42 | if(i === -1){ 43 | if((parent.width - 60)/(titles_mode.count+1) > 50 ){ 44 | var js = {"title":title,"path":path,"unsaved":false,"doc":doc} 45 | titles_mode.append(js) 46 | titles_list.currentIndex = titles_mode.count-1 47 | }else{ 48 | //too many titles 49 | } 50 | }else{ 51 | titles_list.currentIndex = i 52 | } 53 | } 54 | 55 | function changeCurrentPath(new_path){ 56 | var new_path_str = JSON.stringify(new_path) 57 | var i = titles_mode.getIndexByPath(new_path_str) 58 | if(i === -1){ 59 | if(titles_list.currentIndex >= 0){ 60 | //current is null path 61 | titles_mode.setProperty(titles_list.currentIndex,"title", 62 | utils.getBaseNameFromPath(new_path)) 63 | titles_mode.setProperty(titles_list.currentIndex,"path",new_path_str) 64 | }else{ 65 | //title list is null 66 | touchItem(utils.getBaseNameFromPath(new_path),new_path_str,editor.text) 67 | } 68 | }else if(i === titles_list.currentIndex){ 69 | //current and new path is same 70 | }else{ 71 | //new path is existed 72 | titles_mode.setProperty(titles_list.currentIndex,"title", 73 | utils.getBaseNameFromPath(new_path)) 74 | titles_mode.setProperty(titles_list.currentIndex,"path",new_path_str) 75 | titles_mode.setProperty(titles_list.currentIndex,"doc",editor.text) 76 | console.log("will remove same title "+i+" "+new_path_str) 77 | titles_mode.remove(i,1) 78 | } 79 | } 80 | 81 | ListView{ 82 | id:titles_list 83 | anchors.left: parent.left 84 | anchors.top: parent.top 85 | anchors.bottom:parent.bottom 86 | orientation: ListView.Horizontal 87 | width: itemWidth*titles_mode.count 88 | model: titles_mode 89 | interactive:false 90 | 91 | property int itemWidth: { 92 | var h = 50; 93 | if(titles_mode.count > 0){ 94 | h = (parent.width - 60)/titles_mode.count; 95 | if(h > parent.width /3){ 96 | h = parent.width /3; 97 | }else if( h < 50){ 98 | h = 50; 99 | } 100 | } 101 | return h; 102 | } 103 | 104 | delegate:TitleNavigationItem{} 105 | 106 | property int indexSave: -1 107 | onCurrentIndexChanged: { 108 | setItemDoc(editor.text,indexSave) 109 | 110 | if(currentIndex >= 0){ 111 | titleChecked(titles_mode.get(currentIndex)) 112 | }else{ 113 | var js = {"title":null,"path":null,"unsaved":false,"doc":null} 114 | titleChecked(js) 115 | } 116 | 117 | indexSave = currentIndex 118 | } 119 | } 120 | 121 | Image { 122 | anchors.verticalCenter: titles_list.verticalCenter 123 | anchors.left: titles_list.right 124 | anchors.leftMargin: 5 125 | width: 20 126 | height: 20 127 | source: "qrc:/item/images/svg/add.svg" 128 | MouseArea{ 129 | anchors.fill: parent 130 | onClicked: { 131 | callAddPage() 132 | } 133 | } 134 | } 135 | 136 | ListModel{ 137 | id:titles_mode 138 | function getIndexByPath(path){ 139 | if(path === null) 140 | return -1; 141 | 142 | for(var i = 0;i < count;i++){ 143 | if(path === get(i).path ){ 144 | return i; 145 | } 146 | } 147 | return -1; 148 | } 149 | } 150 | 151 | Item { 152 | id: add_btn 153 | anchors.left: titles_list.right 154 | anchors.top: parent.top 155 | anchors.bottom:parent.bottom 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /markdowneditor/qmls/custom/navigationbar/TitleNavigationItem.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import QtQuick.Controls 2.0 3 | 4 | Component{ 5 | Rectangle{ 6 | id:title_text 7 | width: titles_list.itemWidth 8 | height: titles_list.height 9 | radius: height/4 10 | 11 | color:ListView.isCurrentItem?colorSelect:colorNormal 12 | 13 | property color colorSelect: "#efefef" 14 | property color colorNormal: "#ffffff" 15 | property bool isNormal: !ListView.isCurrentItem && !item_area.containsMouse && !delete_btn_area.containsMouse 16 | 17 | Rectangle{ 18 | anchors.bottom: parent.bottom 19 | anchors.left:parent.left 20 | anchors.right: parent.right 21 | color: parent.color 22 | height: parent.radius 23 | } 24 | 25 | Image{ 26 | anchors.left: parent.left 27 | anchors.verticalCenter: parent.verticalCenter 28 | source: "qrc:/item/images/svg/point.svg" 29 | width: 20 30 | height: 20 31 | visible: unsaved 32 | } 33 | 34 | Text { 35 | id:tilte_text 36 | text: title 37 | anchors.centerIn: parent 38 | } 39 | 40 | MouseArea{ 41 | id:item_area 42 | anchors.fill: parent 43 | onClicked:titles_list.currentIndex = index 44 | hoverEnabled: true 45 | onEntered: { 46 | var tmp = titles_mode.get(index).path 47 | if (typeof tmp !== 'undefined'){ 48 | title_path_tooltip.visible = true 49 | } 50 | } 51 | onExited: title_path_tooltip.visible = false 52 | ToolTip{ 53 | id:title_path_tooltip 54 | delay:500 55 | onVisibleChanged:{ 56 | if(title_path_tooltip.visible){ 57 | title_path_tooltip.text = utils.filterNativeSeparators(titles_mode.get(index).path) 58 | } 59 | } 60 | } 61 | } 62 | 63 | Rectangle{ 64 | id:delete_btn 65 | anchors.right: parent.right 66 | anchors.rightMargin: 10 67 | anchors.verticalCenter: parent.verticalCenter 68 | visible: !isNormal 69 | width: 20 70 | height: 20 71 | radius: width/2 72 | color: delete_btn_area.containsMouse?colorNormal:parent.color 73 | 74 | Image{ 75 | anchors.centerIn: parent 76 | width: 10 77 | height: 10 78 | source: "qrc:/item/images/svg/delete.svg" 79 | } 80 | 81 | MouseArea{ 82 | id:delete_btn_area 83 | anchors.fill: parent 84 | hoverEnabled: true 85 | onClicked: titles_mode.remove(index,1) 86 | } 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /markdowneditor/qmls/custom/partition/DragLine.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.4 2 | 3 | Rectangle { 4 | x: (parent.width-width+file_view.width)/2 5 | width: 2 6 | height: parent.height 7 | 8 | MouseArea { 9 | anchors.fill: parent 10 | cursorShape : Qt.SplitHCursor 11 | drag{ 12 | target: parent 13 | axis: Drag.XAxis 14 | minimumX: file_view.width 15 | maximumX: root.width 16 | } 17 | 18 | onPressed: root_area.cursorShape = Qt.SplitHCursor 19 | onReleased: root_area.cursorShape = Qt.ArrowCursor 20 | } 21 | 22 | state:"EDITVIEW" 23 | 24 | states: [ 25 | State { 26 | name: "EDIT" 27 | PropertyChanges { target: drog_line; x: root.width} 28 | }, 29 | State { 30 | name: "VIEW" 31 | PropertyChanges { target: drog_line; x: file_view.width} 32 | }, 33 | State { 34 | name: "EDITVIEW" 35 | PropertyChanges { target: drog_line; x: (root.width-drog_line.width+file_view.width)/2} 36 | } 37 | ] 38 | 39 | transitions: [ 40 | Transition { 41 | PropertyAnimation { properties: "x"; easing.type: Easing.InOutQuad } 42 | } 43 | ] 44 | } 45 | -------------------------------------------------------------------------------- /markdowneditor/qmls/custom/partition/Triangle.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | 3 | Canvas { 4 | id:canvas 5 | implicitWidth: 10 6 | implicitHeight: 10 7 | height: width 8 | property color color:"#a0a0a0" 9 | property int rightTop: 0 10 | property int rightBottom: 1 11 | property int leftTop: 2 12 | property int leftBottom: 3 13 | 14 | property int trianglePosition:rightBottom 15 | signal clicked() 16 | 17 | onPaint: { 18 | var ctx = getContext("2d"); 19 | ctx.fillStyle = color 20 | 21 | var sWidth = canvas.width; 22 | var sHeight = canvas.height; 23 | ctx.beginPath(); 24 | if(trianglePosition === rightTop){ 25 | ctx.moveTo(0,0); 26 | ctx.lineTo(sWidth,sHeight); 27 | ctx.lineTo(sWidth,0); 28 | }else if(trianglePosition === leftBottom){ 29 | ctx.moveTo(0,0); 30 | ctx.lineTo(sWidth,sHeight); 31 | ctx.lineTo(0,height); 32 | }else if(trianglePosition === leftTop){ 33 | ctx.moveTo(sWidth,0); 34 | ctx.lineTo(0,sHeight); 35 | ctx.lineTo(0,0); 36 | }else if(trianglePosition === rightBottom){ 37 | ctx.moveTo(sWidth,0); 38 | ctx.lineTo(0,sHeight); 39 | ctx.lineTo(sWidth,sHeight); 40 | } 41 | 42 | ctx.closePath(); 43 | ctx.fill(); 44 | } 45 | MouseArea{ 46 | id:_triangle_area 47 | anchors.fill: parent 48 | cursorShape:Qt.PointingHandCursor 49 | onClicked: parent.clicked() 50 | } 51 | } 52 | 53 | -------------------------------------------------------------------------------- /markdowneditor/qmls/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.2 2 | import QtQuick.Controls 2.2 3 | import QtQuick.Layouts 1.0 4 | import QtQuick.Dialogs 1.1 5 | import QtQuick.Window 2.1 6 | import QtQuick.Controls.Styles 1.4 7 | 8 | import "./custom" 9 | import "./custom/partition" 10 | import "./custom/FileTree" 11 | import "./custom/navigationbar" 12 | import cxl.normal 1.0 13 | 14 | ApplicationWindow { 15 | id:root 16 | visible: true 17 | width: 1340 18 | height: 820 19 | minimumWidth: 640 20 | minimumHeight: 480 21 | title: " " 22 | color:"#efefef" 23 | // flags: Qt.FramelessWindowHint | Qt.Window 24 | property int stepSize: 15 25 | 26 | MouseArea{ 27 | id:root_area 28 | anchors.fill: parent 29 | } 30 | 31 | Utils{ 32 | id:utils 33 | } 34 | 35 | TitleNavigationBar{ 36 | id:navigation_bar 37 | anchors.top: file_view.top 38 | anchors.left: file_view.right 39 | anchors.right: drog_line.left 40 | height: 30 41 | 42 | onTitleChecked: { 43 | if(title_data.path !== null){ 44 | editor.text = title_data.doc 45 | editor.path = typeof title_data.path === 'undefined'?null:title_data.path 46 | }else{ 47 | editor.text = "" 48 | } 49 | } 50 | 51 | onCallAddPage: { 52 | touchItem(qsTr("New Page"),null,"") 53 | } 54 | } 55 | 56 | MarkdownEditor{ 57 | id:editor 58 | anchors.top: navigation_bar.bottom 59 | anchors.left: file_view.right 60 | anchors.right: drog_line.left 61 | anchors.bottom: parent.bottom 62 | onTextChanged: { 63 | viewer.text = editor.text 64 | } 65 | } 66 | 67 | ScrollBar{ 68 | id: scroller 69 | anchors.right: drog_line.left 70 | anchors.top: parent.top 71 | anchors.bottom: parent.bottom 72 | } 73 | 74 | DragLine{ 75 | id:drog_line 76 | } 77 | 78 | Rectangle{ 79 | color:"#ffffff" 80 | anchors.top: parent.top 81 | anchors.right: parent.right 82 | anchors.bottom: parent.bottom 83 | anchors.left: viewer.left 84 | } 85 | 86 | MarkdownViewer{ 87 | id:viewer 88 | anchors.top:parent.top 89 | anchors.left: drog_line.right 90 | anchors.right: parent.right 91 | anchors.bottom: parent.bottom 92 | // anchors.bottomMargin: root.stepSize*3 93 | // anchors.topMargin: root.stepSize*3 94 | } 95 | 96 | Triangle{ 97 | property bool isOnlyEdit: false 98 | anchors.bottom:drog_line.bottom 99 | anchors.right:drog_line.left 100 | onClicked: { 101 | isOnlyEdit = !isOnlyEdit 102 | if(isOnlyEdit){ 103 | drog_line.state = "EDIT" 104 | }else{ 105 | drog_line.state = "EDITVIEW" 106 | } 107 | } 108 | } 109 | 110 | Triangle{ 111 | property bool isOnlyRead: false 112 | anchors.bottom:parent.bottom 113 | anchors.left:drog_line.left 114 | trianglePosition:leftBottom 115 | color: "#c0c0c0" 116 | onClicked: { 117 | isOnlyRead = !isOnlyRead 118 | if(isOnlyRead){ 119 | drog_line.state = "VIEW" 120 | }else{ 121 | drog_line.state = "EDITVIEW" 122 | } 123 | } 124 | } 125 | 126 | SubTree{ 127 | id:file_view 128 | anchors.top: parent.top 129 | anchors.left: parent.left 130 | anchors.bottom: parent.bottom 131 | fileMode:fileModel 132 | enableChangeDir: true 133 | width:200 134 | 135 | onPathSelected: { 136 | navigation_bar.touchItem(file_view.selectTitle,path,utils.readFile(path)) 137 | } 138 | } 139 | 140 | SettingsItem{ 141 | visible: false 142 | onCallChangeDir: file_view.showChangeDirDialog() 143 | onCallOnlyEdit: drog_line.state = "EDIT" 144 | onCallOnlyRead: drog_line.state = "VIEW" 145 | onCallReadEdit: drog_line.state = "EDITVIEW" 146 | } 147 | 148 | DragArea{ 149 | anchors.fill: parent 150 | onTextDrop: { 151 | editor.text += text 152 | navigation_bar.setCurrentItemUnsaved(true) 153 | } 154 | onFileDrop: navigation_bar.touchItem(utils.getBaseNameFromPath(file_path), 155 | file_path,utils.readFile(file_path)) 156 | } 157 | 158 | Component.onCompleted: { 159 | if(typeof argPath !== 'undefined'){ 160 | navigation_bar.touchItem(utils.getBaseNameFromPath(argPath), 161 | argPath,utils.readFile(argPath)) 162 | } 163 | } 164 | 165 | property bool sureClose: false 166 | 167 | onClosing: { 168 | if(navigation_bar.hasItemUnsaved() && !sureClose){ 169 | message_dialog.visible = true 170 | close.accepted = false 171 | } 172 | } 173 | 174 | Dialog{ 175 | id:message_dialog 176 | title: qsTr("Warning") 177 | x: (parent.width - width) / 2 178 | y: (parent.height - height) / 2 179 | onAccepted: { 180 | sureClose = true 181 | root.close() 182 | } 183 | 184 | contentItem: Rectangle { 185 | implicitWidth: 300 186 | implicitHeight: 60 187 | Text { 188 | text: qsTr("You have unsaved content, are you sure to close?") 189 | anchors.centerIn: parent 190 | } 191 | } 192 | 193 | standardButtons:StandardButton.Yes|StandardButton.Cancel 194 | } 195 | } 196 | -------------------------------------------------------------------------------- /markdowneditor/resources/3rdparty/markdown.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: octicons-link; 3 | src: url(data:font/woff;charset=utf-8;base64,d09GRgABAAAAAAZwABAAAAAACFQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEU0lHAAAGaAAAAAgAAAAIAAAAAUdTVUIAAAZcAAAACgAAAAoAAQAAT1MvMgAAAyQAAABJAAAAYFYEU3RjbWFwAAADcAAAAEUAAACAAJThvmN2dCAAAATkAAAABAAAAAQAAAAAZnBnbQAAA7gAAACyAAABCUM+8IhnYXNwAAAGTAAAABAAAAAQABoAI2dseWYAAAFsAAABPAAAAZwcEq9taGVhZAAAAsgAAAA0AAAANgh4a91oaGVhAAADCAAAABoAAAAkCA8DRGhtdHgAAAL8AAAADAAAAAwGAACfbG9jYQAAAsAAAAAIAAAACABiATBtYXhwAAACqAAAABgAAAAgAA8ASm5hbWUAAAToAAABQgAAAlXu73sOcG9zdAAABiwAAAAeAAAAME3QpOBwcmVwAAAEbAAAAHYAAAB/aFGpk3jaTY6xa8JAGMW/O62BDi0tJLYQincXEypYIiGJjSgHniQ6umTsUEyLm5BV6NDBP8Tpts6F0v+k/0an2i+itHDw3v2+9+DBKTzsJNnWJNTgHEy4BgG3EMI9DCEDOGEXzDADU5hBKMIgNPZqoD3SilVaXZCER3/I7AtxEJLtzzuZfI+VVkprxTlXShWKb3TBecG11rwoNlmmn1P2WYcJczl32etSpKnziC7lQyWe1smVPy/Lt7Kc+0vWY/gAgIIEqAN9we0pwKXreiMasxvabDQMM4riO+qxM2ogwDGOZTXxwxDiycQIcoYFBLj5K3EIaSctAq2kTYiw+ymhce7vwM9jSqO8JyVd5RH9gyTt2+J/yUmYlIR0s04n6+7Vm1ozezUeLEaUjhaDSuXHwVRgvLJn1tQ7xiuVv/ocTRF42mNgZGBgYGbwZOBiAAFGJBIMAAizAFoAAABiAGIAznjaY2BkYGAA4in8zwXi+W2+MjCzMIDApSwvXzC97Z4Ig8N/BxYGZgcgl52BCSQKAA3jCV8CAABfAAAAAAQAAEB42mNgZGBg4f3vACQZQABIMjKgAmYAKEgBXgAAeNpjYGY6wTiBgZWBg2kmUxoDA4MPhGZMYzBi1AHygVLYQUCaawqDA4PChxhmh/8ODDEsvAwHgMKMIDnGL0x7gJQCAwMAJd4MFwAAAHjaY2BgYGaA4DAGRgYQkAHyGMF8NgYrIM3JIAGVYYDT+AEjAwuDFpBmA9KMDEwMCh9i/v8H8sH0/4dQc1iAmAkALaUKLgAAAHjaTY9LDsIgEIbtgqHUPpDi3gPoBVyRTmTddOmqTXThEXqrob2gQ1FjwpDvfwCBdmdXC5AVKFu3e5MfNFJ29KTQT48Ob9/lqYwOGZxeUelN2U2R6+cArgtCJpauW7UQBqnFkUsjAY/kOU1cP+DAgvxwn1chZDwUbd6CFimGXwzwF6tPbFIcjEl+vvmM/byA48e6tWrKArm4ZJlCbdsrxksL1AwWn/yBSJKpYbq8AXaaTb8AAHja28jAwOC00ZrBeQNDQOWO//sdBBgYGRiYWYAEELEwMTE4uzo5Zzo5b2BxdnFOcALxNjA6b2ByTswC8jYwg0VlNuoCTWAMqNzMzsoK1rEhNqByEyerg5PMJlYuVueETKcd/89uBpnpvIEVomeHLoMsAAe1Id4AAAAAAAB42oWQT07CQBTGv0JBhagk7HQzKxca2sJCE1hDt4QF+9JOS0nbaaYDCQfwCJ7Au3AHj+LO13FMmm6cl7785vven0kBjHCBhfpYuNa5Ph1c0e2Xu3jEvWG7UdPDLZ4N92nOm+EBXuAbHmIMSRMs+4aUEd4Nd3CHD8NdvOLTsA2GL8M9PODbcL+hD7C1xoaHeLJSEao0FEW14ckxC+TU8TxvsY6X0eLPmRhry2WVioLpkrbp84LLQPGI7c6sOiUzpWIWS5GzlSgUzzLBSikOPFTOXqly7rqx0Z1Q5BAIoZBSFihQYQOOBEdkCOgXTOHA07HAGjGWiIjaPZNW13/+lm6S9FT7rLHFJ6fQbkATOG1j2OFMucKJJsxIVfQORl+9Jyda6Sl1dUYhSCm1dyClfoeDve4qMYdLEbfqHf3O/AdDumsjAAB42mNgYoAAZQYjBmyAGYQZmdhL8zLdDEydARfoAqIAAAABAAMABwAKABMAB///AA8AAQAAAAAAAAAAAAAAAAABAAAAAA==) format('woff'); 4 | } 5 | 6 | .markdown-body { 7 | -ms-text-size-adjust: 100%; 8 | -webkit-text-size-adjust: 100%; 9 | line-height: 1.5; 10 | color: #24292e; 11 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; 12 | font-size: 16px; 13 | line-height: 1.5; 14 | word-wrap: break-word; 15 | } 16 | 17 | .markdown-body .pl-c { 18 | color: #6a737d; 19 | } 20 | 21 | .markdown-body .pl-c1, 22 | .markdown-body .pl-s .pl-v { 23 | color: #005cc5; 24 | } 25 | 26 | .markdown-body .pl-e, 27 | .markdown-body .pl-en { 28 | color: #6f42c1; 29 | } 30 | 31 | .markdown-body .pl-smi, 32 | .markdown-body .pl-s .pl-s1 { 33 | color: #24292e; 34 | } 35 | 36 | .markdown-body .pl-ent { 37 | color: #22863a; 38 | } 39 | 40 | .markdown-body .pl-k { 41 | color: #d73a49; 42 | } 43 | 44 | .markdown-body .pl-s, 45 | .markdown-body .pl-pds, 46 | .markdown-body .pl-s .pl-pse .pl-s1, 47 | .markdown-body .pl-sr, 48 | .markdown-body .pl-sr .pl-cce, 49 | .markdown-body .pl-sr .pl-sre, 50 | .markdown-body .pl-sr .pl-sra { 51 | color: #032f62; 52 | } 53 | 54 | .markdown-body .pl-v, 55 | .markdown-body .pl-smw { 56 | color: #e36209; 57 | } 58 | 59 | .markdown-body .pl-bu { 60 | color: #b31d28; 61 | } 62 | 63 | .markdown-body .pl-ii { 64 | color: #fafbfc; 65 | background-color: #b31d28; 66 | } 67 | 68 | .markdown-body .pl-c2 { 69 | color: #fafbfc; 70 | background-color: #d73a49; 71 | } 72 | 73 | .markdown-body .pl-c2::before { 74 | content: "^M"; 75 | } 76 | 77 | .markdown-body .pl-sr .pl-cce { 78 | font-weight: bold; 79 | color: #22863a; 80 | } 81 | 82 | .markdown-body .pl-ml { 83 | color: #735c0f; 84 | } 85 | 86 | .markdown-body .pl-mh, 87 | .markdown-body .pl-mh .pl-en, 88 | .markdown-body .pl-ms { 89 | font-weight: bold; 90 | color: #005cc5; 91 | } 92 | 93 | .markdown-body .pl-mi { 94 | font-style: italic; 95 | color: #24292e; 96 | } 97 | 98 | .markdown-body .pl-mb { 99 | font-weight: bold; 100 | color: #24292e; 101 | } 102 | 103 | .markdown-body .pl-md { 104 | color: #b31d28; 105 | background-color: #ffeef0; 106 | } 107 | 108 | .markdown-body .pl-mi1 { 109 | color: #22863a; 110 | background-color: #f0fff4; 111 | } 112 | 113 | .markdown-body .pl-mc { 114 | color: #e36209; 115 | background-color: #ffebda; 116 | } 117 | 118 | .markdown-body .pl-mi2 { 119 | color: #f6f8fa; 120 | background-color: #005cc5; 121 | } 122 | 123 | .markdown-body .pl-mdr { 124 | font-weight: bold; 125 | color: #6f42c1; 126 | } 127 | 128 | .markdown-body .pl-ba { 129 | color: #586069; 130 | } 131 | 132 | .markdown-body .pl-sg { 133 | color: #959da5; 134 | } 135 | 136 | .markdown-body .pl-corl { 137 | text-decoration: underline; 138 | color: #032f62; 139 | } 140 | 141 | .markdown-body .octicon { 142 | display: inline-block; 143 | vertical-align: text-top; 144 | fill: currentColor; 145 | } 146 | 147 | .markdown-body a { 148 | background-color: transparent; 149 | } 150 | 151 | .markdown-body a:active, 152 | .markdown-body a:hover { 153 | outline-width: 0; 154 | } 155 | 156 | .markdown-body strong { 157 | font-weight: inherit; 158 | } 159 | 160 | .markdown-body strong { 161 | font-weight: bolder; 162 | } 163 | 164 | .markdown-body h1 { 165 | font-size: 2em; 166 | margin: 0.67em 0; 167 | } 168 | 169 | .markdown-body img { 170 | border-style: none; 171 | } 172 | 173 | .markdown-body code, 174 | .markdown-body kbd, 175 | .markdown-body pre { 176 | font-family: monospace, monospace; 177 | font-size: 1em; 178 | } 179 | 180 | .markdown-body hr { 181 | box-sizing: content-box; 182 | height: 0; 183 | overflow: visible; 184 | } 185 | 186 | .markdown-body input { 187 | font: inherit; 188 | margin: 0; 189 | } 190 | 191 | .markdown-body input { 192 | overflow: visible; 193 | } 194 | 195 | .markdown-body [type="checkbox"] { 196 | box-sizing: border-box; 197 | padding: 0; 198 | } 199 | 200 | .markdown-body * { 201 | box-sizing: border-box; 202 | } 203 | 204 | .markdown-body input { 205 | font-family: inherit; 206 | font-size: inherit; 207 | line-height: inherit; 208 | } 209 | 210 | .markdown-body a { 211 | color: #0366d6; 212 | text-decoration: none; 213 | } 214 | 215 | .markdown-body a:hover { 216 | text-decoration: underline; 217 | } 218 | 219 | .markdown-body strong { 220 | font-weight: 600; 221 | } 222 | 223 | .markdown-body hr { 224 | height: 0; 225 | margin: 15px 0; 226 | overflow: hidden; 227 | background: transparent; 228 | border: 0; 229 | border-bottom: 1px solid #dfe2e5; 230 | } 231 | 232 | .markdown-body hr::before { 233 | display: table; 234 | content: ""; 235 | } 236 | 237 | .markdown-body hr::after { 238 | display: table; 239 | clear: both; 240 | content: ""; 241 | } 242 | 243 | .markdown-body table { 244 | border-spacing: 0; 245 | border-collapse: collapse; 246 | } 247 | 248 | .markdown-body td, 249 | .markdown-body th { 250 | padding: 0; 251 | } 252 | 253 | .markdown-body h1, 254 | .markdown-body h2, 255 | .markdown-body h3, 256 | .markdown-body h4, 257 | .markdown-body h5, 258 | .markdown-body h6 { 259 | margin-top: 0; 260 | margin-bottom: 0; 261 | } 262 | 263 | .markdown-body h1 { 264 | font-size: 32px; 265 | font-weight: 600; 266 | } 267 | 268 | .markdown-body h2 { 269 | font-size: 24px; 270 | font-weight: 600; 271 | } 272 | 273 | .markdown-body h3 { 274 | font-size: 20px; 275 | font-weight: 600; 276 | } 277 | 278 | .markdown-body h4 { 279 | font-size: 16px; 280 | font-weight: 600; 281 | } 282 | 283 | .markdown-body h5 { 284 | font-size: 14px; 285 | font-weight: 600; 286 | } 287 | 288 | .markdown-body h6 { 289 | font-size: 12px; 290 | font-weight: 600; 291 | } 292 | 293 | .markdown-body p { 294 | margin-top: 0; 295 | margin-bottom: 10px; 296 | } 297 | 298 | .markdown-body blockquote { 299 | margin: 0; 300 | } 301 | 302 | .markdown-body ul, 303 | .markdown-body ol { 304 | padding-left: 0; 305 | margin-top: 0; 306 | margin-bottom: 0; 307 | } 308 | 309 | .markdown-body ol ol, 310 | .markdown-body ul ol { 311 | list-style-type: lower-roman; 312 | } 313 | 314 | .markdown-body ul ul ol, 315 | .markdown-body ul ol ol, 316 | .markdown-body ol ul ol, 317 | .markdown-body ol ol ol { 318 | list-style-type: lower-alpha; 319 | } 320 | 321 | .markdown-body dd { 322 | margin-left: 0; 323 | } 324 | 325 | .markdown-body code { 326 | font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace; 327 | font-size: 12px; 328 | } 329 | 330 | .markdown-body pre { 331 | margin-top: 0; 332 | margin-bottom: 0; 333 | font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace; 334 | font-size: 12px; 335 | } 336 | 337 | .markdown-body .octicon { 338 | vertical-align: text-bottom; 339 | } 340 | 341 | .markdown-body .pl-0 { 342 | padding-left: 0 !important; 343 | } 344 | 345 | .markdown-body .pl-1 { 346 | padding-left: 4px !important; 347 | } 348 | 349 | .markdown-body .pl-2 { 350 | padding-left: 8px !important; 351 | } 352 | 353 | .markdown-body .pl-3 { 354 | padding-left: 16px !important; 355 | } 356 | 357 | .markdown-body .pl-4 { 358 | padding-left: 24px !important; 359 | } 360 | 361 | .markdown-body .pl-5 { 362 | padding-left: 32px !important; 363 | } 364 | 365 | .markdown-body .pl-6 { 366 | padding-left: 40px !important; 367 | } 368 | 369 | .markdown-body::before { 370 | display: table; 371 | content: ""; 372 | } 373 | 374 | .markdown-body::after { 375 | display: table; 376 | clear: both; 377 | content: ""; 378 | } 379 | 380 | .markdown-body>*:first-child { 381 | margin-top: 0 !important; 382 | } 383 | 384 | .markdown-body>*:last-child { 385 | margin-bottom: 0 !important; 386 | } 387 | 388 | .markdown-body a:not([href]) { 389 | color: inherit; 390 | text-decoration: none; 391 | } 392 | 393 | .markdown-body .anchor { 394 | float: left; 395 | padding-right: 4px; 396 | margin-left: -20px; 397 | line-height: 1; 398 | } 399 | 400 | .markdown-body .anchor:focus { 401 | outline: none; 402 | } 403 | 404 | .markdown-body p, 405 | .markdown-body blockquote, 406 | .markdown-body ul, 407 | .markdown-body ol, 408 | .markdown-body dl, 409 | .markdown-body table, 410 | .markdown-body pre { 411 | margin-top: 0; 412 | margin-bottom: 16px; 413 | } 414 | 415 | .markdown-body hr { 416 | height: 0.25em; 417 | padding: 0; 418 | margin: 24px 0; 419 | background-color: #e1e4e8; 420 | border: 0; 421 | } 422 | 423 | .markdown-body blockquote { 424 | padding: 0 1em; 425 | color: #6a737d; 426 | border-left: 0.25em solid #dfe2e5; 427 | } 428 | 429 | .markdown-body blockquote>:first-child { 430 | margin-top: 0; 431 | } 432 | 433 | .markdown-body blockquote>:last-child { 434 | margin-bottom: 0; 435 | } 436 | 437 | .markdown-body kbd { 438 | display: inline-block; 439 | padding: 3px 5px; 440 | font-size: 11px; 441 | line-height: 10px; 442 | color: #444d56; 443 | vertical-align: middle; 444 | background-color: #fafbfc; 445 | border: solid 1px #c6cbd1; 446 | border-bottom-color: #959da5; 447 | border-radius: 3px; 448 | box-shadow: inset 0 -1px 0 #959da5; 449 | } 450 | 451 | .markdown-body h1, 452 | .markdown-body h2, 453 | .markdown-body h3, 454 | .markdown-body h4, 455 | .markdown-body h5, 456 | .markdown-body h6 { 457 | margin-top: 24px; 458 | margin-bottom: 16px; 459 | font-weight: 600; 460 | line-height: 1.25; 461 | } 462 | 463 | .markdown-body h1 .octicon-link, 464 | .markdown-body h2 .octicon-link, 465 | .markdown-body h3 .octicon-link, 466 | .markdown-body h4 .octicon-link, 467 | .markdown-body h5 .octicon-link, 468 | .markdown-body h6 .octicon-link { 469 | color: #1b1f23; 470 | vertical-align: middle; 471 | visibility: hidden; 472 | } 473 | 474 | .markdown-body h1:hover .anchor, 475 | .markdown-body h2:hover .anchor, 476 | .markdown-body h3:hover .anchor, 477 | .markdown-body h4:hover .anchor, 478 | .markdown-body h5:hover .anchor, 479 | .markdown-body h6:hover .anchor { 480 | text-decoration: none; 481 | } 482 | 483 | .markdown-body h1:hover .anchor .octicon-link, 484 | .markdown-body h2:hover .anchor .octicon-link, 485 | .markdown-body h3:hover .anchor .octicon-link, 486 | .markdown-body h4:hover .anchor .octicon-link, 487 | .markdown-body h5:hover .anchor .octicon-link, 488 | .markdown-body h6:hover .anchor .octicon-link { 489 | visibility: visible; 490 | } 491 | 492 | .markdown-body h1 { 493 | padding-bottom: 0.3em; 494 | font-size: 2em; 495 | border-bottom: 1px solid #eaecef; 496 | } 497 | 498 | .markdown-body h2 { 499 | padding-bottom: 0.3em; 500 | font-size: 1.5em; 501 | border-bottom: 1px solid #eaecef; 502 | } 503 | 504 | .markdown-body h3 { 505 | font-size: 1.25em; 506 | } 507 | 508 | .markdown-body h4 { 509 | font-size: 1em; 510 | } 511 | 512 | .markdown-body h5 { 513 | font-size: 0.875em; 514 | } 515 | 516 | .markdown-body h6 { 517 | font-size: 0.85em; 518 | color: #6a737d; 519 | } 520 | 521 | .markdown-body ul, 522 | .markdown-body ol { 523 | padding-left: 2em; 524 | } 525 | 526 | .markdown-body ul ul, 527 | .markdown-body ul ol, 528 | .markdown-body ol ol, 529 | .markdown-body ol ul { 530 | margin-top: 0; 531 | margin-bottom: 0; 532 | } 533 | 534 | .markdown-body li { 535 | word-wrap: break-all; 536 | } 537 | 538 | .markdown-body li>p { 539 | margin-top: 16px; 540 | } 541 | 542 | .markdown-body li+li { 543 | margin-top: 0.25em; 544 | } 545 | 546 | .markdown-body dl { 547 | padding: 0; 548 | } 549 | 550 | .markdown-body dl dt { 551 | padding: 0; 552 | margin-top: 16px; 553 | font-size: 1em; 554 | font-style: italic; 555 | font-weight: 600; 556 | } 557 | 558 | .markdown-body dl dd { 559 | padding: 0 16px; 560 | margin-bottom: 16px; 561 | } 562 | 563 | .markdown-body table { 564 | display: block; 565 | width: 100%; 566 | overflow: auto; 567 | } 568 | 569 | .markdown-body table th { 570 | font-weight: 600; 571 | } 572 | 573 | .markdown-body table th, 574 | .markdown-body table td { 575 | padding: 6px 13px; 576 | border: 1px solid #dfe2e5; 577 | } 578 | 579 | .markdown-body table tr { 580 | background-color: #fff; 581 | border-top: 1px solid #c6cbd1; 582 | } 583 | 584 | .markdown-body table tr:nth-child(2n) { 585 | background-color: #f6f8fa; 586 | } 587 | 588 | .markdown-body img { 589 | max-width: 100%; 590 | box-sizing: content-box; 591 | background-color: #fff; 592 | } 593 | 594 | .markdown-body img[align=right] { 595 | padding-left: 20px; 596 | } 597 | 598 | .markdown-body img[align=left] { 599 | padding-right: 20px; 600 | } 601 | 602 | .markdown-body code { 603 | padding: 0.2em 0.4em; 604 | margin: 0; 605 | font-size: 85%; 606 | background-color: rgba(27,31,35,0.05); 607 | border-radius: 3px; 608 | } 609 | 610 | .markdown-body pre { 611 | word-wrap: normal; 612 | } 613 | 614 | .markdown-body pre>code { 615 | padding: 0; 616 | margin: 0; 617 | font-size: 100%; 618 | word-break: normal; 619 | white-space: pre; 620 | background: transparent; 621 | border: 0; 622 | } 623 | 624 | .markdown-body .highlight { 625 | margin-bottom: 16px; 626 | } 627 | 628 | .markdown-body .highlight pre { 629 | margin-bottom: 0; 630 | word-break: normal; 631 | } 632 | 633 | .markdown-body .highlight pre, 634 | .markdown-body pre { 635 | padding: 16px; 636 | overflow: auto; 637 | font-size: 85%; 638 | line-height: 1.45; 639 | background-color: #f6f8fa; 640 | border-radius: 3px; 641 | } 642 | 643 | .markdown-body pre code { 644 | display: inline; 645 | max-width: auto; 646 | padding: 0; 647 | margin: 0; 648 | overflow: visible; 649 | line-height: inherit; 650 | word-wrap: normal; 651 | background-color: transparent; 652 | border: 0; 653 | } 654 | 655 | .markdown-body .full-commit .btn-outline:not(:disabled):hover { 656 | color: #005cc5; 657 | border-color: #005cc5; 658 | } 659 | 660 | .markdown-body kbd { 661 | display: inline-block; 662 | padding: 3px 5px; 663 | font: 11px "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace; 664 | line-height: 10px; 665 | color: #444d56; 666 | vertical-align: middle; 667 | background-color: #fafbfc; 668 | border: solid 1px #d1d5da; 669 | border-bottom-color: #c6cbd1; 670 | border-radius: 3px; 671 | box-shadow: inset 0 -1px 0 #c6cbd1; 672 | } 673 | 674 | .markdown-body :checked+.radio-label { 675 | position: relative; 676 | z-index: 1; 677 | border-color: #0366d6; 678 | } 679 | 680 | .markdown-body .task-list-item { 681 | list-style-type: none; 682 | } 683 | 684 | .markdown-body .task-list-item+.task-list-item { 685 | margin-top: 3px; 686 | } 687 | 688 | .markdown-body .task-list-item input { 689 | margin: 0 0.2em 0.25em -1.6em; 690 | vertical-align: middle; 691 | } 692 | 693 | .markdown-body hr { 694 | border-bottom-color: #eee; 695 | } 696 | -------------------------------------------------------------------------------- /markdowneditor/resources/3rdparty/markdown.css.save: -------------------------------------------------------------------------------- 1 | body{ 2 | margin: 0 auto; 3 | font-family: Georgia, Palatino, serif; 4 | color: #444444; 5 | line-height: 1; 6 | max-width: 960px; 7 | padding: 30px; 8 | } 9 | h1, h2, h3, h4 { 10 | color: #111111; 11 | font-weight: 400; 12 | } 13 | h1, h2, h3, h4, h5, p { 14 | margin-bottom: 24px; 15 | padding: 0; 16 | } 17 | h1 { 18 | font-size: 48px; 19 | } 20 | h2 { 21 | font-size: 36px; 22 | /* The bottom margin is small. It's designed to be used with gray meta text 23 | * below a post title. */ 24 | margin: 24px 0 6px; 25 | } 26 | h3 { 27 | font-size: 24px; 28 | } 29 | h4 { 30 | font-size: 21px; 31 | } 32 | h5 { 33 | font-size: 18px; 34 | } 35 | a { 36 | color: #0099ff; 37 | margin: 0; 38 | padding: 0; 39 | vertical-align: baseline; 40 | } 41 | a:hover { 42 | text-decoration: none; 43 | color: #ff6600; 44 | } 45 | a:visited { 46 | color: purple; 47 | } 48 | ul, ol { 49 | padding: 0; 50 | margin: 0; 51 | } 52 | li { 53 | line-height: 24px; 54 | } 55 | li ul, li ul { 56 | margin-left: 24px; 57 | } 58 | p, ul, ol { 59 | font-size: 16px; 60 | line-height: 24px; 61 | max-width: 540px; 62 | } 63 | pre { 64 | padding: 0px 24px; 65 | max-width: 800px; 66 | white-space: pre-wrap; 67 | } 68 | code { 69 | font-family: Consolas, Monaco, Andale Mono, monospace; 70 | line-height: 1.5; 71 | font-size: 13px; 72 | } 73 | aside { 74 | display: block; 75 | float: right; 76 | width: 390px; 77 | } 78 | blockquote { 79 | border-left:.5em solid #eee; 80 | padding: 0 2em; 81 | margin-left:0; 82 | max-width: 476px; 83 | } 84 | blockquote cite { 85 | font-size:14px; 86 | line-height:20px; 87 | color:#bfbfbf; 88 | } 89 | blockquote cite:before { 90 | content: '\2014 \00A0'; 91 | } 92 | 93 | blockquote p { 94 | color: #666; 95 | max-width: 460px; 96 | } 97 | hr { 98 | width: 540px; 99 | text-align: left; 100 | margin: 0 auto 0 0; 101 | color: #999; 102 | } 103 | 104 | /* Code below this line is copyright Twitter Inc. */ 105 | 106 | button, 107 | input, 108 | select, 109 | textarea { 110 | font-size: 100%; 111 | margin: 0; 112 | vertical-align: baseline; 113 | *vertical-align: middle; 114 | } 115 | button, input { 116 | line-height: normal; 117 | *overflow: visible; 118 | } 119 | button::-moz-focus-inner, input::-moz-focus-inner { 120 | border: 0; 121 | padding: 0; 122 | } 123 | button, 124 | input[type="button"], 125 | input[type="reset"], 126 | input[type="submit"] { 127 | cursor: pointer; 128 | -webkit-appearance: button; 129 | } 130 | input[type=checkbox], input[type=radio] { 131 | cursor: pointer; 132 | } 133 | /* override default chrome & firefox settings */ 134 | input:not([type="image"]), textarea { 135 | -webkit-box-sizing: content-box; 136 | -moz-box-sizing: content-box; 137 | box-sizing: content-box; 138 | } 139 | 140 | input[type="search"] { 141 | -webkit-appearance: textfield; 142 | -webkit-box-sizing: content-box; 143 | -moz-box-sizing: content-box; 144 | box-sizing: content-box; 145 | } 146 | input[type="search"]::-webkit-search-decoration { 147 | -webkit-appearance: none; 148 | } 149 | label, 150 | input, 151 | select, 152 | textarea { 153 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 154 | font-size: 13px; 155 | font-weight: normal; 156 | line-height: normal; 157 | margin-bottom: 18px; 158 | } 159 | input[type=checkbox], input[type=radio] { 160 | cursor: pointer; 161 | margin-bottom: 0; 162 | } 163 | input[type=text], 164 | input[type=password], 165 | textarea, 166 | select { 167 | display: inline-block; 168 | width: 210px; 169 | padding: 4px; 170 | font-size: 13px; 171 | font-weight: normal; 172 | line-height: 18px; 173 | height: 18px; 174 | color: #808080; 175 | border: 1px solid #ccc; 176 | -webkit-border-radius: 3px; 177 | -moz-border-radius: 3px; 178 | border-radius: 3px; 179 | } 180 | select, input[type=file] { 181 | height: 27px; 182 | line-height: 27px; 183 | } 184 | textarea { 185 | height: auto; 186 | } 187 | 188 | /* grey out placeholders */ 189 | :-moz-placeholder { 190 | color: #bfbfbf; 191 | } 192 | ::-webkit-input-placeholder { 193 | color: #bfbfbf; 194 | } 195 | 196 | input[type=text], 197 | input[type=password], 198 | select, 199 | textarea { 200 | -webkit-transition: border linear 0.2s, box-shadow linear 0.2s; 201 | -moz-transition: border linear 0.2s, box-shadow linear 0.2s; 202 | transition: border linear 0.2s, box-shadow linear 0.2s; 203 | -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1); 204 | -moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1); 205 | box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1); 206 | } 207 | input[type=text]:focus, input[type=password]:focus, textarea:focus { 208 | outline: none; 209 | border-color: rgba(82, 168, 236, 0.8); 210 | -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6); 211 | -moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6); 212 | box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6); 213 | } 214 | 215 | /* buttons */ 216 | button { 217 | display: inline-block; 218 | padding: 4px 14px; 219 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 220 | font-size: 13px; 221 | line-height: 18px; 222 | -webkit-border-radius: 4px; 223 | -moz-border-radius: 4px; 224 | border-radius: 4px; 225 | -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); 226 | -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); 227 | box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); 228 | background-color: #0064cd; 229 | background-repeat: repeat-x; 230 | background-image: -khtml-gradient(linear, left top, left bottom, from(#049cdb), to(#0064cd)); 231 | background-image: -moz-linear-gradient(top, #049cdb, #0064cd); 232 | background-image: -ms-linear-gradient(top, #049cdb, #0064cd); 233 | background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #049cdb), color-stop(100%, #0064cd)); 234 | background-image: -webkit-linear-gradient(top, #049cdb, #0064cd); 235 | background-image: -o-linear-gradient(top, #049cdb, #0064cd); 236 | background-image: linear-gradient(top, #049cdb, #0064cd); 237 | color: #fff; 238 | text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); 239 | border: 1px solid #004b9a; 240 | border-bottom-color: #003f81; 241 | -webkit-transition: 0.1s linear all; 242 | -moz-transition: 0.1s linear all; 243 | transition: 0.1s linear all; 244 | border-color: #0064cd #0064cd #003f81; 245 | border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); 246 | } 247 | button:hover { 248 | color: #fff; 249 | background-position: 0 -15px; 250 | text-decoration: none; 251 | } 252 | button:active { 253 | -webkit-box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); 254 | -moz-box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); 255 | box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); 256 | } 257 | button::-moz-focus-inner { 258 | padding: 0; 259 | border: 0; 260 | } 261 | -------------------------------------------------------------------------------- /markdowneditor/resources/3rdparty/marked.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * marked - a markdown parser 3 | * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed) 4 | * https://github.com/chjj/marked 5 | */ 6 | (function(){var block={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:noop,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:noop,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:noop,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};block.bullet=/(?:[*+-]|\d+\.)/;block.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;block.item=replace(block.item,"gm")(/bull/g,block.bullet)();block.list=replace(block.list)(/bull/g,block.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+block.def.source+")")();block.blockquote=replace(block.blockquote)("def",block.def)();block._tag="(?!(?:"+"a|em|strong|small|s|cite|q|dfn|abbr|data|time|code"+"|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo"+"|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b";block.html=replace(block.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/])*?>/)(/tag/g,block._tag)();block.paragraph=replace(block.paragraph)("hr",block.hr)("heading",block.heading)("lheading",block.lheading)("blockquote",block.blockquote)("tag","<"+block._tag)("def",block.def)();block.normal=merge({},block);block.gfm=merge({},block.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/});block.gfm.paragraph=replace(block.paragraph)("(?!","(?!"+block.gfm.fences.source.replace("\\1","\\2")+"|"+block.list.source.replace("\\1","\\3")+"|")();block.tables=merge({},block.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/});function Lexer(options){this.tokens=[];this.tokens.links={};this.options=options||marked.defaults;this.rules=block.normal;if(this.options.gfm){if(this.options.tables){this.rules=block.tables}else{this.rules=block.gfm}}}Lexer.rules=block;Lexer.lex=function(src,options){var lexer=new Lexer(options);return lexer.lex(src)};Lexer.prototype.lex=function(src){src=src.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n");return this.token(src,true)};Lexer.prototype.token=function(src,top,bq){var src=src.replace(/^ +$/gm,""),next,loose,cap,bull,b,item,space,i,l;while(src){if(cap=this.rules.newline.exec(src)){src=src.substring(cap[0].length);if(cap[0].length>1){this.tokens.push({type:"space"})}}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);cap=cap[0].replace(/^ {4}/gm,"");this.tokens.push({type:"code",text:!this.options.pedantic?cap.replace(/\n+$/,""):cap});continue}if(cap=this.rules.fences.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"code",lang:cap[2],text:cap[3]||""});continue}if(cap=this.rules.heading.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"heading",depth:cap[1].length,text:cap[2]});continue}if(top&&(cap=this.rules.nptable.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/\n$/,"").split("\n")};for(i=0;i ?/gm,"");this.token(cap,top,true);this.tokens.push({type:"blockquote_end"});continue}if(cap=this.rules.list.exec(src)){src=src.substring(cap[0].length);bull=cap[2];this.tokens.push({type:"list_start",ordered:bull.length>1});cap=cap[0].match(this.rules.item);next=false;l=cap.length;i=0;for(;i1&&b.length>1)){src=cap.slice(i+1).join("\n")+src;i=l-1}}loose=next||/\n\n(?!\s*$)/.test(item);if(i!==l-1){next=item.charAt(item.length-1)==="\n";if(!loose)loose=next}this.tokens.push({type:loose?"loose_item_start":"list_item_start"});this.token(item,false,bq);this.tokens.push({type:"list_item_end"})}this.tokens.push({type:"list_end"});continue}if(cap=this.rules.html.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&(cap[1]==="pre"||cap[1]==="script"||cap[1]==="style"),text:cap[0]});continue}if(!bq&&top&&(cap=this.rules.def.exec(src))){src=src.substring(cap[0].length);this.tokens.links[cap[1].toLowerCase()]={href:cap[2],title:cap[3]};continue}if(top&&(cap=this.rules.table.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/(?: *\| *)?\n$/,"").split("\n")};for(i=0;i])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:noop,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:noop,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/;inline.link=replace(inline.link)("inside",inline._inside)("href",inline._href)();inline.reflink=replace(inline.reflink)("inside",inline._inside)();inline.normal=merge({},inline);inline.pedantic=merge({},inline.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/});inline.gfm=merge({},inline.normal,{escape:replace(inline.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:replace(inline.text)("]|","~]|")("|","|https?://|")()});inline.breaks=merge({},inline.gfm,{br:replace(inline.br)("{2,}","*")(),text:replace(inline.gfm.text)("{2,}","*")()});function InlineLexer(links,options){this.options=options||marked.defaults;this.links=links;this.rules=inline.normal;this.renderer=this.options.renderer||new Renderer;this.renderer.options=this.options;if(!this.links){throw new Error("Tokens array requires a `links` property.")}if(this.options.gfm){if(this.options.breaks){this.rules=inline.breaks}else{this.rules=inline.gfm}}else if(this.options.pedantic){this.rules=inline.pedantic}}InlineLexer.rules=inline;InlineLexer.output=function(src,links,options){var inline=new InlineLexer(links,options);return inline.output(src)};InlineLexer.prototype.output=function(src){var out="",link,text,href,cap;while(src){if(cap=this.rules.escape.exec(src)){src=src.substring(cap[0].length);out+=cap[1];continue}if(cap=this.rules.autolink.exec(src)){src=src.substring(cap[0].length);if(cap[2]==="@"){text=cap[1].charAt(6)===":"?this.mangle(cap[1].substring(7)):this.mangle(cap[1]);href=this.mangle("mailto:")+text}else{text=escape(cap[1]);href=text}out+=this.renderer.link(href,null,text);continue}if(!this.inLink&&(cap=this.rules.url.exec(src))){src=src.substring(cap[0].length);text=escape(cap[1]);href=text;out+=this.renderer.link(href,null,text);continue}if(cap=this.rules.tag.exec(src)){if(!this.inLink&&/^/i.test(cap[0])){this.inLink=false}src=src.substring(cap[0].length);out+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(cap[0]):escape(cap[0]):cap[0];continue}if(cap=this.rules.link.exec(src)){src=src.substring(cap[0].length);this.inLink=true;out+=this.outputLink(cap,{href:cap[2],title:cap[3]});this.inLink=false;continue}if((cap=this.rules.reflink.exec(src))||(cap=this.rules.nolink.exec(src))){src=src.substring(cap[0].length);link=(cap[2]||cap[1]).replace(/\s+/g," ");link=this.links[link.toLowerCase()];if(!link||!link.href){out+=cap[0].charAt(0);src=cap[0].substring(1)+src;continue}this.inLink=true;out+=this.outputLink(cap,link);this.inLink=false;continue}if(cap=this.rules.strong.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.strong(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.em.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.em(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.codespan(escape(cap[2],true));continue}if(cap=this.rules.br.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.br();continue}if(cap=this.rules.del.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.del(this.output(cap[1]));continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.text(escape(this.smartypants(cap[0])));continue}if(src){throw new Error("Infinite loop on byte: "+src.charCodeAt(0))}}return out};InlineLexer.prototype.outputLink=function(cap,link){var href=escape(link.href),title=link.title?escape(link.title):null;return cap[0].charAt(0)!=="!"?this.renderer.link(href,title,this.output(cap[1])):this.renderer.image(href,title,escape(cap[1]))};InlineLexer.prototype.smartypants=function(text){if(!this.options.smartypants)return text;return text.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")};InlineLexer.prototype.mangle=function(text){if(!this.options.mangle)return text;var out="",l=text.length,i=0,ch;for(;i.5){ch="x"+ch.toString(16)}out+="&#"+ch+";"}return out};function Renderer(options){this.options=options||{}}Renderer.prototype.code=function(code,lang,escaped){if(this.options.highlight){var out=this.options.highlight(code,lang);if(out!=null&&out!==code){escaped=true;code=out}}if(!lang){return"
"+(escaped?code:escape(code,true))+"\n
"}return'
'+(escaped?code:escape(code,true))+"\n
\n"};Renderer.prototype.blockquote=function(quote){return"
\n"+quote+"
\n"};Renderer.prototype.html=function(html){return html};Renderer.prototype.heading=function(text,level,raw){return"'+text+"\n"};Renderer.prototype.hr=function(){return this.options.xhtml?"
\n":"
\n"};Renderer.prototype.list=function(body,ordered){var type=ordered?"ol":"ul";return"<"+type+">\n"+body+"\n"};Renderer.prototype.listitem=function(text){return"
  • "+text+"
  • \n"};Renderer.prototype.paragraph=function(text){return"

    "+text+"

    \n"};Renderer.prototype.table=function(header,body){return"\n"+"\n"+header+"\n"+"\n"+body+"\n"+"
    \n"};Renderer.prototype.tablerow=function(content){return"\n"+content+"\n"};Renderer.prototype.tablecell=function(content,flags){var type=flags.header?"th":"td";var tag=flags.align?"<"+type+' style="text-align:'+flags.align+'">':"<"+type+">";return tag+content+"\n"};Renderer.prototype.strong=function(text){return""+text+""};Renderer.prototype.em=function(text){return""+text+""};Renderer.prototype.codespan=function(text){return""+text+""};Renderer.prototype.br=function(){return this.options.xhtml?"
    ":"
    "};Renderer.prototype.del=function(text){return""+text+""};Renderer.prototype.link=function(href,title,text){if(this.options.sanitize){try{var prot=decodeURIComponent(unescape(href)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return""}if(prot.indexOf("javascript:")===0||prot.indexOf("vbscript:")===0){return""}}var out='
    ";return out};Renderer.prototype.image=function(href,title,text){var out=''+text+'":">";return out};Renderer.prototype.text=function(text){return text};function Parser(options){this.tokens=[];this.token=null;this.options=options||marked.defaults;this.options.renderer=this.options.renderer||new Renderer;this.renderer=this.options.renderer;this.renderer.options=this.options}Parser.parse=function(src,options,renderer){var parser=new Parser(options,renderer);return parser.parse(src)};Parser.prototype.parse=function(src){this.inline=new InlineLexer(src.links,this.options,this.renderer);this.tokens=src.reverse();var out="";while(this.next()){out+=this.tok()}return out};Parser.prototype.next=function(){return this.token=this.tokens.pop()};Parser.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0};Parser.prototype.parseText=function(){var body=this.token.text;while(this.peek().type==="text"){body+="\n"+this.next().text}return this.inline.output(body)};Parser.prototype.tok=function(){switch(this.token.type){case"space":{return""}case"hr":{return this.renderer.hr()}case"heading":{return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text)}case"code":{return this.renderer.code(this.token.text,this.token.lang,this.token.escaped)}case"table":{var header="",body="",i,row,cell,flags,j;cell="";for(i=0;i/g,">").replace(/"/g,""").replace(/'/g,"'")}function unescape(html){return html.replace(/&([#\w]+);/g,function(_,n){n=n.toLowerCase();if(n==="colon")return":";if(n.charAt(0)==="#"){return n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1))}return""})}function replace(regex,opt){regex=regex.source;opt=opt||"";return function self(name,val){if(!name)return new RegExp(regex,opt);val=val.source||val;val=val.replace(/(^|[^\[])\^/g,"$1");regex=regex.replace(name,val);return self}}function noop(){}noop.exec=noop;function merge(obj){var i=1,target,key;for(;iAn error occurred:

    "+escape(e.message+"",true)+"
    "}throw e}}marked.options=marked.setOptions=function(opt){merge(marked.defaults,opt);return marked};marked.defaults={gfm:true,tables:true,breaks:false,pedantic:false,sanitize:false,sanitizer:null,mangle:true,smartLists:false,silent:false,highlight:null,langPrefix:"lang-",smartypants:false,headerPrefix:"",renderer:new Renderer,xhtml:false};marked.Parser=Parser;marked.parser=Parser.parse;marked.Renderer=Renderer;marked.Lexer=Lexer;marked.lexer=Lexer.lex;marked.InlineLexer=InlineLexer;marked.inlineLexer=InlineLexer.output;marked.parse=marked;if(typeof module!=="undefined"&&typeof exports==="object"){module.exports=marked}else if(typeof define==="function"&&define.amd){define(function(){return marked})}else{this.marked=marked}}).call(function(){return this||(typeof window!=="undefined"?window:global)}()); 7 | -------------------------------------------------------------------------------- /markdowneditor/resources/3rdparty/simple-markdown.css: -------------------------------------------------------------------------------- 1 | table { 2 | border-width: 1px; 3 | } 4 | 5 | pre { 6 | background-color: #ff0000; 7 | } 8 | -------------------------------------------------------------------------------- /markdowneditor/resources/default.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 标题测试1 5 | === 6 | 链接测试:[Proper method to acquire root access on Linux for Qt applications](https://stackoverflow.com/questions/47885043/proper-method-to-acquire-root-access-on-linux-for-qt-applications) 7 | 8 | 标题测试2 9 | --- 10 | 11 | 斜体测试 *晶晶很可爱* 12 | 13 | 加粗 小晶晶很**傻** 14 | 15 | 引用 16 | >./configure&make 17 | 18 | 19 | # Title 20 | 21 | ## Title 2 22 | 23 | ### Title 3 24 | 25 | ## 什么是 Markdown 26 | 27 | Markdown 是一种方便记忆、书写的纯文本标记语言,用户可以使用这些标记符号以最小的输入代价生成极富表现力的文档:譬如您正在阅读的这份文档。它使用简单的符号标记不同的标题,分割不同的段落,**粗体** 或者 *斜体* 某些文字,更棒的是,它还可以 28 | 29 | ### 1. 制作一份待办事宜 [Todo 列表](https://www.zybuluo.com/mdeditor?url=https://www.zybuluo.com/static/editor/md-help.markdown#13-待办事宜-todo-列表) 30 | 31 | - 支持以 PDF 格式导出文稿 32 | - 改进 Cmd 渲染算法,使用局部渲染技术提高渲染效率 33 | - ~~新增 Todo 列表功能~~ 34 | - ~~修复 LaTex 公式渲染问题~~ 35 | - 新增 LaTex 公式编号功能 36 | 37 | ### 2. 书写一个质能守恒公式[^LaTeX] 38 | 39 | $$E=mc^2$$ 40 | 41 | 42 | Pythagoran theorem is $$a^2 + b^2 = c^2$$. 43 | 44 | Bayes theorem: 45 | 46 | $$$ 47 | P(A | B) = (P(B | A)P(A)) / P(B) 48 | $$$ 49 | 50 | ### 3. 高亮一段代码[^code] 51 | 52 | ```python 53 | @requires_authorization 54 | class SomeClass: 55 | pass 56 | 57 | if __name__ == '__main__': 58 | # A comment 59 | print 'hello world' 60 | ``` 61 | 62 | ### 4. 高效绘制 [流程图](https://www.zybuluo.com/mdeditor?url=https://www.zybuluo.com/static/editor/md-help.markdown#7-流程图) 63 | 64 | ```flow 65 | st=>start: Start 66 | op=>operation: Your Operation 67 | cond=>condition: Yes or No? 68 | e=>end 69 | 70 | st->op->cond 71 | cond(yes)->e 72 | cond(no)->op 73 | ``` 74 | 75 | ### 5. 高效绘制 [序列图](https://www.zybuluo.com/mdeditor?url=https://www.zybuluo.com/static/editor/md-help.markdown#8-序列图) 76 | 77 | ```seq 78 | Alice->Bob: Hello Bob, how are you? 79 | Note right of Bob: Bob thinks 80 | Bob-->Alice: I am good thanks! 81 | ``` 82 | 83 | ### 6. 高效绘制 [甘特图](https://www.zybuluo.com/mdeditor?url=https://www.zybuluo.com/static/editor/md-help.markdown#9-甘特图) 84 | 85 | ```gantt 86 | title 项目开发流程 87 | section 项目确定 88 | 需求分析 :a1, 2016-06-22, 3d 89 | 可行性报告 :after a1, 5d 90 | 概念验证 : 5d 91 | section 项目实施 92 | 概要设计 :2016-07-05 , 5d 93 | 详细设计 :2016-07-08, 10d 94 | 编码 :2016-07-15, 10d 95 | 测试 :2016-07-22, 5d 96 | section 发布验收 97 | 发布: 2d 98 | 验收: 3d 99 | ``` 100 | 101 | ### 7. 绘制表格 102 | 103 | | 项目 | 价格 | 数量 | 104 | | -------- | -----: | :----: | 105 | | 计算机 | \$1600 | 5 | 106 | | 手机 | \$12 | 12 | 107 | | 管线 | \$1 | 234 | 108 | 109 | ### 8. 更详细语法说明 110 | 111 | 想要查看更详细的语法说明,可以参考我们准备的 [Cmd Markdown 简明语法手册][1],进阶用户可以参考 [Cmd Markdown 高阶语法手册][2] 了解更多高级功能。 112 | 113 | 总而言之,不同于其它 *所见即所得* 的编辑器:你只需使用键盘专注于书写文本内容,就可以生成印刷级的排版格式,省却在键盘和工具栏之间来回切换,调整内容和格式的麻烦。**Markdown 在流畅的书写和印刷级的阅读体验之间找到了平衡。** 目前它已经成为世界上最大的技术分享网站 GitHub 和 技术问答网站 StackOverFlow 的御用书写格式。 114 | 115 | [^LaTeX]: 支持 **LaTeX** 编辑显示支持,例如:$\sum_{i=1}^n a_i=0$, 访问 [MathJax][4] 参考更多使用方法。 116 | 117 | [^code]: 代码高亮功能支持包括 Java, Python, JavaScript 在内的,**四十一**种主流编程语言。 118 | -------------------------------------------------------------------------------- /markdowneditor/resources/images.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/32x32/markdown-editor-logo.png 4 | 5 | 6 | images/svg/delete.svg 7 | images/svg/max.svg 8 | images/svg/min.svg 9 | images/svg/point.svg 10 | images/svg/dir.svg 11 | images/svg/dir_open.svg 12 | images/svg/doc.svg 13 | images/svg/doc_null.svg 14 | images/svg/triangle_down.svg 15 | images/svg/triangle_right.svg 16 | images/svg/file-markdown.svg 17 | images/svg/sets/edit.svg 18 | images/svg/sets/file_list.svg 19 | images/svg/sets/look.svg 20 | images/svg/sets/set_hollow.svg 21 | images/svg/sets/set_solid.svg 22 | images/svg/sets/edit_view.svg 23 | images/svg/add.svg 24 | 25 | 26 | -------------------------------------------------------------------------------- /markdowneditor/resources/images/32x32/markdown-editor-logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CrazyCxl/markdown-editor/9e563fe0bfab382064c002ad0cc00302904269aa/markdowneditor/resources/images/32x32/markdown-editor-logo.ico -------------------------------------------------------------------------------- /markdowneditor/resources/images/32x32/markdown-editor-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CrazyCxl/markdown-editor/9e563fe0bfab382064c002ad0cc00302904269aa/markdowneditor/resources/images/32x32/markdown-editor-logo.png -------------------------------------------------------------------------------- /markdowneditor/resources/images/svg/add.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /markdowneditor/resources/images/svg/delete.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /markdowneditor/resources/images/svg/dir.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /markdowneditor/resources/images/svg/dir_open.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /markdowneditor/resources/images/svg/doc.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /markdowneditor/resources/images/svg/doc_null.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /markdowneditor/resources/images/svg/file-markdown.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /markdowneditor/resources/images/svg/max.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /markdowneditor/resources/images/svg/min.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /markdowneditor/resources/images/svg/point.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /markdowneditor/resources/images/svg/sets/edit.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Layer 1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /markdowneditor/resources/images/svg/sets/edit_view.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Layer 1 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /markdowneditor/resources/images/svg/sets/file_list.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /markdowneditor/resources/images/svg/sets/look.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Layer 1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /markdowneditor/resources/images/svg/sets/set_hollow.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /markdowneditor/resources/images/svg/sets/set_solid.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /markdowneditor/resources/images/svg/triangle_down.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /markdowneditor/resources/images/svg/triangle_right.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /markdowneditor/resources/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
    13 | 19 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /markdowneditor/resources/markdown-it/markdown-it-footnote.js: -------------------------------------------------------------------------------- 1 | /*! markdown-it-footnote 3.0.1 https://github.com//markdown-it/markdown-it-footnote @license MIT */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.markdownitFootnote = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0) { 24 | n += ':' + tokens[idx].meta.subId; 25 | } 26 | 27 | return '[' + n + ']'; 28 | } 29 | 30 | function render_footnote_ref(tokens, idx, options, env, slf) { 31 | var id = slf.rules.footnote_anchor_name(tokens, idx, options, env, slf); 32 | var caption = slf.rules.footnote_caption(tokens, idx, options, env, slf); 33 | var refid = id; 34 | 35 | if (tokens[idx].meta.subId > 0) { 36 | refid += ':' + tokens[idx].meta.subId; 37 | } 38 | 39 | return '
    ' + caption + ''; 40 | } 41 | 42 | function render_footnote_block_open(tokens, idx, options) { 43 | return (options.xhtmlOut ? '
    \n' : '
    \n') + 44 | '
    \n' + 45 | '
      \n'; 46 | } 47 | 48 | function render_footnote_block_close() { 49 | return '
    \n
    \n'; 50 | } 51 | 52 | function render_footnote_open(tokens, idx, options, env, slf) { 53 | var id = slf.rules.footnote_anchor_name(tokens, idx, options, env, slf); 54 | 55 | if (tokens[idx].meta.subId > 0) { 56 | id += ':' + tokens[idx].meta.subId; 57 | } 58 | 59 | return '
  • '; 60 | } 61 | 62 | function render_footnote_close() { 63 | return '
  • \n'; 64 | } 65 | 66 | function render_footnote_anchor(tokens, idx, options, env, slf) { 67 | var id = slf.rules.footnote_anchor_name(tokens, idx, options, env, slf); 68 | 69 | if (tokens[idx].meta.subId > 0) { 70 | id += ':' + tokens[idx].meta.subId; 71 | } 72 | 73 | /* ↩ with escape code to prevent display as Apple Emoji on iOS */ 74 | return ' \u21a9\uFE0E'; 75 | } 76 | 77 | 78 | module.exports = function footnote_plugin(md) { 79 | var parseLinkLabel = md.helpers.parseLinkLabel, 80 | isSpace = md.utils.isSpace; 81 | 82 | md.renderer.rules.footnote_ref = render_footnote_ref; 83 | md.renderer.rules.footnote_block_open = render_footnote_block_open; 84 | md.renderer.rules.footnote_block_close = render_footnote_block_close; 85 | md.renderer.rules.footnote_open = render_footnote_open; 86 | md.renderer.rules.footnote_close = render_footnote_close; 87 | md.renderer.rules.footnote_anchor = render_footnote_anchor; 88 | 89 | // helpers (only used in other rules, no tokens are attached to those) 90 | md.renderer.rules.footnote_caption = render_footnote_caption; 91 | md.renderer.rules.footnote_anchor_name = render_footnote_anchor_name; 92 | 93 | // Process footnote block definition 94 | function footnote_def(state, startLine, endLine, silent) { 95 | var oldBMark, oldTShift, oldSCount, oldParentType, pos, label, token, 96 | initial, offset, ch, posAfterColon, 97 | start = state.bMarks[startLine] + state.tShift[startLine], 98 | max = state.eMarks[startLine]; 99 | 100 | // line should be at least 5 chars - "[^x]:" 101 | if (start + 4 > max) { return false; } 102 | 103 | if (state.src.charCodeAt(start) !== 0x5B/* [ */) { return false; } 104 | if (state.src.charCodeAt(start + 1) !== 0x5E/* ^ */) { return false; } 105 | 106 | for (pos = start + 2; pos < max; pos++) { 107 | if (state.src.charCodeAt(pos) === 0x20) { return false; } 108 | if (state.src.charCodeAt(pos) === 0x5D /* ] */) { 109 | break; 110 | } 111 | } 112 | 113 | if (pos === start + 2) { return false; } // no empty footnote labels 114 | if (pos + 1 >= max || state.src.charCodeAt(++pos) !== 0x3A /* : */) { return false; } 115 | if (silent) { return true; } 116 | pos++; 117 | 118 | if (!state.env.footnotes) { state.env.footnotes = {}; } 119 | if (!state.env.footnotes.refs) { state.env.footnotes.refs = {}; } 120 | label = state.src.slice(start + 2, pos - 2); 121 | state.env.footnotes.refs[':' + label] = -1; 122 | 123 | token = new state.Token('footnote_reference_open', '', 1); 124 | token.meta = { label: label }; 125 | token.level = state.level++; 126 | state.tokens.push(token); 127 | 128 | oldBMark = state.bMarks[startLine]; 129 | oldTShift = state.tShift[startLine]; 130 | oldSCount = state.sCount[startLine]; 131 | oldParentType = state.parentType; 132 | 133 | posAfterColon = pos; 134 | initial = offset = state.sCount[startLine] + pos - (state.bMarks[startLine] + state.tShift[startLine]); 135 | 136 | while (pos < max) { 137 | ch = state.src.charCodeAt(pos); 138 | 139 | if (isSpace(ch)) { 140 | if (ch === 0x09) { 141 | offset += 4 - offset % 4; 142 | } else { 143 | offset++; 144 | } 145 | } else { 146 | break; 147 | } 148 | 149 | pos++; 150 | } 151 | 152 | state.tShift[startLine] = pos - posAfterColon; 153 | state.sCount[startLine] = offset - initial; 154 | 155 | state.bMarks[startLine] = posAfterColon; 156 | state.blkIndent += 4; 157 | state.parentType = 'footnote'; 158 | 159 | if (state.sCount[startLine] < state.blkIndent) { 160 | state.sCount[startLine] += state.blkIndent; 161 | } 162 | 163 | state.md.block.tokenize(state, startLine, endLine, true); 164 | 165 | state.parentType = oldParentType; 166 | state.blkIndent -= 4; 167 | state.tShift[startLine] = oldTShift; 168 | state.sCount[startLine] = oldSCount; 169 | state.bMarks[startLine] = oldBMark; 170 | 171 | token = new state.Token('footnote_reference_close', '', -1); 172 | token.level = --state.level; 173 | state.tokens.push(token); 174 | 175 | return true; 176 | } 177 | 178 | // Process inline footnotes (^[...]) 179 | function footnote_inline(state, silent) { 180 | var labelStart, 181 | labelEnd, 182 | footnoteId, 183 | token, 184 | tokens, 185 | max = state.posMax, 186 | start = state.pos; 187 | 188 | if (start + 2 >= max) { return false; } 189 | if (state.src.charCodeAt(start) !== 0x5E/* ^ */) { return false; } 190 | if (state.src.charCodeAt(start + 1) !== 0x5B/* [ */) { return false; } 191 | 192 | labelStart = start + 2; 193 | labelEnd = parseLinkLabel(state, start + 1); 194 | 195 | // parser failed to find ']', so it's not a valid note 196 | if (labelEnd < 0) { return false; } 197 | 198 | // We found the end of the link, and know for a fact it's a valid link; 199 | // so all that's left to do is to call tokenizer. 200 | // 201 | if (!silent) { 202 | if (!state.env.footnotes) { state.env.footnotes = {}; } 203 | if (!state.env.footnotes.list) { state.env.footnotes.list = []; } 204 | footnoteId = state.env.footnotes.list.length; 205 | 206 | state.md.inline.parse( 207 | state.src.slice(labelStart, labelEnd), 208 | state.md, 209 | state.env, 210 | tokens = [] 211 | ); 212 | 213 | token = state.push('footnote_ref', '', 0); 214 | token.meta = { id: footnoteId }; 215 | 216 | state.env.footnotes.list[footnoteId] = { tokens: tokens }; 217 | } 218 | 219 | state.pos = labelEnd + 1; 220 | state.posMax = max; 221 | return true; 222 | } 223 | 224 | // Process footnote references ([^...]) 225 | function footnote_ref(state, silent) { 226 | var label, 227 | pos, 228 | footnoteId, 229 | footnoteSubId, 230 | token, 231 | max = state.posMax, 232 | start = state.pos; 233 | 234 | // should be at least 4 chars - "[^x]" 235 | if (start + 3 > max) { return false; } 236 | 237 | if (!state.env.footnotes || !state.env.footnotes.refs) { return false; } 238 | if (state.src.charCodeAt(start) !== 0x5B/* [ */) { return false; } 239 | if (state.src.charCodeAt(start + 1) !== 0x5E/* ^ */) { return false; } 240 | 241 | for (pos = start + 2; pos < max; pos++) { 242 | if (state.src.charCodeAt(pos) === 0x20) { return false; } 243 | if (state.src.charCodeAt(pos) === 0x0A) { return false; } 244 | if (state.src.charCodeAt(pos) === 0x5D /* ] */) { 245 | break; 246 | } 247 | } 248 | 249 | if (pos === start + 2) { return false; } // no empty footnote labels 250 | if (pos >= max) { return false; } 251 | pos++; 252 | 253 | label = state.src.slice(start + 2, pos - 1); 254 | if (typeof state.env.footnotes.refs[':' + label] === 'undefined') { return false; } 255 | 256 | if (!silent) { 257 | if (!state.env.footnotes.list) { state.env.footnotes.list = []; } 258 | 259 | if (state.env.footnotes.refs[':' + label] < 0) { 260 | footnoteId = state.env.footnotes.list.length; 261 | state.env.footnotes.list[footnoteId] = { label: label, count: 0 }; 262 | state.env.footnotes.refs[':' + label] = footnoteId; 263 | } else { 264 | footnoteId = state.env.footnotes.refs[':' + label]; 265 | } 266 | 267 | footnoteSubId = state.env.footnotes.list[footnoteId].count; 268 | state.env.footnotes.list[footnoteId].count++; 269 | 270 | token = state.push('footnote_ref', '', 0); 271 | token.meta = { id: footnoteId, subId: footnoteSubId, label: label }; 272 | } 273 | 274 | state.pos = pos; 275 | state.posMax = max; 276 | return true; 277 | } 278 | 279 | // Glue footnote tokens to end of token stream 280 | function footnote_tail(state) { 281 | var i, l, j, t, lastParagraph, list, token, tokens, current, currentLabel, 282 | insideRef = false, 283 | refTokens = {}; 284 | 285 | if (!state.env.footnotes) { return; } 286 | 287 | state.tokens = state.tokens.filter(function (tok) { 288 | if (tok.type === 'footnote_reference_open') { 289 | insideRef = true; 290 | current = []; 291 | currentLabel = tok.meta.label; 292 | return false; 293 | } 294 | if (tok.type === 'footnote_reference_close') { 295 | insideRef = false; 296 | // prepend ':' to avoid conflict with Object.prototype members 297 | refTokens[':' + currentLabel] = current; 298 | return false; 299 | } 300 | if (insideRef) { current.push(tok); } 301 | return !insideRef; 302 | }); 303 | 304 | if (!state.env.footnotes.list) { return; } 305 | list = state.env.footnotes.list; 306 | 307 | token = new state.Token('footnote_block_open', '', 1); 308 | state.tokens.push(token); 309 | 310 | for (i = 0, l = list.length; i < l; i++) { 311 | token = new state.Token('footnote_open', '', 1); 312 | token.meta = { id: i, label: list[i].label }; 313 | state.tokens.push(token); 314 | 315 | if (list[i].tokens) { 316 | tokens = []; 317 | 318 | token = new state.Token('paragraph_open', 'p', 1); 319 | token.block = true; 320 | tokens.push(token); 321 | 322 | token = new state.Token('inline', '', 0); 323 | token.children = list[i].tokens; 324 | token.content = ''; 325 | tokens.push(token); 326 | 327 | token = new state.Token('paragraph_close', 'p', -1); 328 | token.block = true; 329 | tokens.push(token); 330 | 331 | } else if (list[i].label) { 332 | tokens = refTokens[':' + list[i].label]; 333 | } 334 | 335 | state.tokens = state.tokens.concat(tokens); 336 | if (state.tokens[state.tokens.length - 1].type === 'paragraph_close') { 337 | lastParagraph = state.tokens.pop(); 338 | } else { 339 | lastParagraph = null; 340 | } 341 | 342 | t = list[i].count > 0 ? list[i].count : 1; 343 | for (j = 0; j < t; j++) { 344 | token = new state.Token('footnote_anchor', '', 0); 345 | token.meta = { id: i, subId: j, label: list[i].label }; 346 | state.tokens.push(token); 347 | } 348 | 349 | if (lastParagraph) { 350 | state.tokens.push(lastParagraph); 351 | } 352 | 353 | token = new state.Token('footnote_close', '', -1); 354 | state.tokens.push(token); 355 | } 356 | 357 | token = new state.Token('footnote_block_close', '', -1); 358 | state.tokens.push(token); 359 | } 360 | 361 | md.block.ruler.before('reference', 'footnote_def', footnote_def, { alt: [ 'paragraph', 'reference' ] }); 362 | md.inline.ruler.after('image', 'footnote_inline', footnote_inline); 363 | md.inline.ruler.after('footnote_inline', 'footnote_ref', footnote_ref); 364 | md.core.ruler.after('inline', 'footnote_tail', footnote_tail); 365 | }; 366 | 367 | },{}]},{},[1])(1) 368 | }); -------------------------------------------------------------------------------- /markdowneditor/resources/markdown-it/mathjax.css: -------------------------------------------------------------------------------- 1 | /* This Source Code Form is subject to the terms of the Mozilla Public 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 | 5 | /* 6 | https://github.com/fred-wang/mathml.css 7 | 8 | This CSS stylesheet is a simplified version of the "MathML for CSS Profile" 9 | (http://www.w3.org/TR/mathml-for-css/) without CSS table rules that had only 10 | been implemented in Presto and using new CSS3 selectors and flexboxes. 11 | 12 | We know from Opera's experience that relying exclusively on a fixed set of 13 | CSS rules to do math layout is not reasonable. This stylesheet is only 14 | intended to provide some fallback to browsers without MathML support in order 15 | to make basic mathematical constructions readable, without claim of rendering 16 | quality. 17 | 18 | This stylesheet must not be loaded in browsers that have MathML support or 19 | it will mess up the native rendering. You can load this mathml.css file 20 | conditionally by doing some UA string sniffing: 21 | https://developer.mozilla.org/en-US/docs/Web/MathML/Authoring#noMathML 22 | */ 23 | 24 | @namespace "http://www.w3.org/1998/Math/MathML"; 25 | 26 | /* math */ 27 | math { 28 | display: inline; 29 | text-indent: 0; 30 | } 31 | math[display="block"] { 32 | display: block; 33 | text-align: center; 34 | } 35 | 36 | /* fraction */ 37 | mfrac { 38 | display: inline-table; 39 | vertical-align: middle; 40 | border-collapse: collapse; 41 | } 42 | mfrac > * { 43 | display: table-row; 44 | } 45 | mfrac:not([linethickness="0"]) > *:first-child { 46 | border-bottom: solid thin; 47 | } 48 | 49 | /* sub/sup scripts */ 50 | msub > *:nth-child(2), msubsup > *:nth-child(2), 51 | mmultiscripts > *:nth-child(2n+2), 52 | mmultiscripts > mprescripts ~ *:nth-child(2n+3) { 53 | font-size: 0.8em; 54 | vertical-align: sub; 55 | } 56 | msup > *:nth-child(2), msubsup > *:nth-child(3), 57 | mmultiscripts > *:nth-child(2n+3), 58 | mmultiscripts > mprescripts ~ *:nth-child(2n+2) { 59 | font-size: 0.8em; 60 | vertical-align: super; 61 | } 62 | mprescripts:after { 63 | content: ";"; 64 | } 65 | 66 | /* under/over scripts */ 67 | munder, mover, munderover { 68 | display: inline-flex; 69 | flex-direction: column; 70 | } 71 | munder > *:nth-child(2), munderover > *:nth-child(2) { 72 | font-size: 0.8em; 73 | order: +1; 74 | } 75 | mover > *:nth-child(2), munderover > *:nth-child(3) { 76 | font-size: 0.8em; 77 | order: -1; 78 | } 79 | munder { 80 | vertical-align: text-top; 81 | } 82 | mover { 83 | vertical-align: text-bottom; 84 | } 85 | munderover { 86 | vertical-align: middle; 87 | } 88 | 89 | /* roots */ 90 | msqrt, mroot { 91 | display: inline-flex; 92 | margin-left: .5em; 93 | vertical-align: middle; 94 | border-top: solid thin; 95 | } 96 | msqrt:before, mroot:before { 97 | margin-left: -.5em; 98 | content: "\221A"; 99 | } 100 | mroot > *:nth-child(2) { 101 | margin-right: .25em; 102 | margin-left: -.75em; 103 | font-size: 0.8em; 104 | order: -1; 105 | } 106 | 107 | /* menclose */ 108 | menclose { 109 | display: inline-table; 110 | border-collapse: separate; 111 | border-spacing: 0.4ex 0; 112 | } 113 | menclose[notation*="top"], menclose[notation*="actuarial"] { 114 | border-top: solid thin; 115 | } 116 | menclose[notation*="bottom"], menclose[notation*="madruwb"] { 117 | border-bottom: solid thin; 118 | } 119 | menclose[notation*="right"], menclose[notation*="actuarial"], 120 | menclose[notation*="madruwb"] { 121 | border-right: solid thin; 122 | } 123 | menclose[notation*="left"] { 124 | border-left: solid thin; 125 | } 126 | menclose[notation*="box"], menclose[notation*="roundedbox"], 127 | menclose[notation*="circle"] { 128 | border: solid thin; 129 | } 130 | menclose[notation*="roundedbox"] { 131 | border-radius: 15%; 132 | } 133 | menclose[notation*="circle"] { 134 | border-radius: 50%; 135 | } 136 | menclose[notation*="horizontalstrike"] { 137 | text-decoration: line-through; 138 | } 139 | 140 | /* table */ 141 | mtable { 142 | display: inline-table; 143 | vertical-align: middle; 144 | } 145 | mtr { 146 | display: table-row; 147 | } 148 | mtd { 149 | display: table-cell; 150 | padding: 0 0.5ex; 151 | } 152 | 153 | /* token elements */ 154 | mspace { 155 | margin: .2em; 156 | } 157 | mi { 158 | font-style: italic; 159 | } 160 | mo { 161 | margin-right: .2em; 162 | margin-left: .2em; 163 | } 164 | ms:before, ms:after { 165 | content:"\0022"; 166 | } 167 | ms[lquote]:before { 168 | content: attr(lquote); 169 | } 170 | ms[rquote]:after { 171 | content: attr(rquote); 172 | } 173 | 174 | /* mathvariants */ 175 | [mathvariant="bold"], [mathvariant="bold-italic"], 176 | [mathvariant="bold-sans-serif"], [mathvariant="sans-serif-bold-italic"] { 177 | font-weight: bold; 178 | font-style: normal; 179 | } 180 | [mathvariant="monospace"] { 181 | font-family: monospace; 182 | font-style: normal; 183 | } 184 | [mathvariant="sans-serif"], 185 | [mathvariant="bold-sans-serif"], [mathvariant="sans-serif-italic"], 186 | [mathvariant="sans-serif-bold-italic"] { 187 | font-family: sans-serif; 188 | font-style: normal; 189 | } 190 | [mathvariant="italic"], [mathvariant="bold-italic"], 191 | [mathvariant="sans-serif-italic"], [mathvariant="sans-serif-bold-italic"] { 192 | font-style: italic; 193 | } 194 | [mathvariant="normal"] { 195 | font-style: normal; 196 | } 197 | 198 | /* mphantom */ 199 | mphantom { 200 | visibility: hidden; 201 | } 202 | 203 | /* merror */ 204 | merror { 205 | outline: solid thin red; 206 | } 207 | merror:before { 208 | content: "Error: "; 209 | } 210 | 211 | /* annotations */ 212 | annotation, annotation-xml { 213 | font-family: monospace; 214 | display: none; 215 | } 216 | math:hover > semantics > *:first-child, 217 | math:hover > semantics > *:first-child { 218 | display: none; 219 | } 220 | math:hover annotation { 221 | display: inline; 222 | } 223 | -------------------------------------------------------------------------------- /markdowneditor/resources/markdowneditor.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | index.html 4 | qwebchannel.js 5 | 3rdparty/marked.min.js 6 | default.md 7 | 3rdparty/markdown.css 8 | 3rdparty/simple-markdown.css 9 | markdown-it/markdown-it.js 10 | markdown-it/markdown-it-footnote.js 11 | markdown-it/markdown-it-math.js 12 | markdown-it/mathjax.css 13 | 14 | 15 | -------------------------------------------------------------------------------- /markdowneditor/resources/qwebchannel.js: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2016 The Qt Company Ltd. 4 | ** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Milian Wolff 5 | ** Contact: https://www.qt.io/licensing/ 6 | ** 7 | ** This file is part of the QtWebChannel module of the Qt Toolkit. 8 | ** 9 | ** $QT_BEGIN_LICENSE:BSD$ 10 | ** Commercial License Usage 11 | ** Licensees holding valid commercial Qt licenses may use this file in 12 | ** accordance with the commercial license agreement provided with the 13 | ** Software or, alternatively, in accordance with the terms contained in 14 | ** a written agreement between you and The Qt Company. For licensing terms 15 | ** and conditions see https://www.qt.io/terms-conditions. For further 16 | ** information use the contact form at https://www.qt.io/contact-us. 17 | ** 18 | ** BSD License Usage 19 | ** Alternatively, you may use this file under the terms of the BSD license 20 | ** as follows: 21 | ** 22 | ** "Redistribution and use in source and binary forms, with or without 23 | ** modification, are permitted provided that the following conditions are 24 | ** met: 25 | ** * Redistributions of source code must retain the above copyright 26 | ** notice, this list of conditions and the following disclaimer. 27 | ** * Redistributions in binary form must reproduce the above copyright 28 | ** notice, this list of conditions and the following disclaimer in 29 | ** the documentation and/or other materials provided with the 30 | ** distribution. 31 | ** * Neither the name of The Qt Company Ltd nor the names of its 32 | ** contributors may be used to endorse or promote products derived 33 | ** from this software without specific prior written permission. 34 | ** 35 | ** 36 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 37 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 38 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 39 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 40 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 42 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 43 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 44 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 45 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 46 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 47 | ** 48 | ** $QT_END_LICENSE$ 49 | ** 50 | ****************************************************************************/ 51 | 52 | "use strict"; 53 | 54 | var QWebChannelMessageTypes = { 55 | signal: 1, 56 | propertyUpdate: 2, 57 | init: 3, 58 | idle: 4, 59 | debug: 5, 60 | invokeMethod: 6, 61 | connectToSignal: 7, 62 | disconnectFromSignal: 8, 63 | setProperty: 9, 64 | response: 10, 65 | }; 66 | 67 | var QWebChannel = function(transport, initCallback) 68 | { 69 | if (typeof transport !== "object" || typeof transport.send !== "function") { 70 | console.error("The QWebChannel expects a transport object with a send function and onmessage callback property." + 71 | " Given is: transport: " + typeof(transport) + ", transport.send: " + typeof(transport.send)); 72 | return; 73 | } 74 | 75 | var channel = this; 76 | this.transport = transport; 77 | 78 | this.send = function(data) 79 | { 80 | if (typeof(data) !== "string") { 81 | data = JSON.stringify(data); 82 | } 83 | channel.transport.send(data); 84 | } 85 | 86 | this.transport.onmessage = function(message) 87 | { 88 | var data = message.data; 89 | if (typeof data === "string") { 90 | data = JSON.parse(data); 91 | } 92 | switch (data.type) { 93 | case QWebChannelMessageTypes.signal: 94 | channel.handleSignal(data); 95 | break; 96 | case QWebChannelMessageTypes.response: 97 | channel.handleResponse(data); 98 | break; 99 | case QWebChannelMessageTypes.propertyUpdate: 100 | channel.handlePropertyUpdate(data); 101 | break; 102 | default: 103 | console.error("invalid message received:", message.data); 104 | break; 105 | } 106 | } 107 | 108 | this.execCallbacks = {}; 109 | this.execId = 0; 110 | this.exec = function(data, callback) 111 | { 112 | if (!callback) { 113 | // if no callback is given, send directly 114 | channel.send(data); 115 | return; 116 | } 117 | if (channel.execId === Number.MAX_VALUE) { 118 | // wrap 119 | channel.execId = Number.MIN_VALUE; 120 | } 121 | if (data.hasOwnProperty("id")) { 122 | console.error("Cannot exec message with property id: " + JSON.stringify(data)); 123 | return; 124 | } 125 | data.id = channel.execId++; 126 | channel.execCallbacks[data.id] = callback; 127 | channel.send(data); 128 | }; 129 | 130 | this.objects = {}; 131 | 132 | this.handleSignal = function(message) 133 | { 134 | var object = channel.objects[message.object]; 135 | if (object) { 136 | object.signalEmitted(message.signal, message.args); 137 | } else { 138 | console.warn("Unhandled signal: " + message.object + "::" + message.signal); 139 | } 140 | } 141 | 142 | this.handleResponse = function(message) 143 | { 144 | if (!message.hasOwnProperty("id")) { 145 | console.error("Invalid response message received: ", JSON.stringify(message)); 146 | return; 147 | } 148 | channel.execCallbacks[message.id](message.data); 149 | delete channel.execCallbacks[message.id]; 150 | } 151 | 152 | this.handlePropertyUpdate = function(message) 153 | { 154 | for (var i in message.data) { 155 | var data = message.data[i]; 156 | var object = channel.objects[data.object]; 157 | if (object) { 158 | object.propertyUpdate(data.signals, data.properties); 159 | } else { 160 | console.warn("Unhandled property update: " + data.object + "::" + data.signal); 161 | } 162 | } 163 | channel.exec({type: QWebChannelMessageTypes.idle}); 164 | } 165 | 166 | this.debug = function(message) 167 | { 168 | channel.send({type: QWebChannelMessageTypes.debug, data: message}); 169 | }; 170 | 171 | channel.exec({type: QWebChannelMessageTypes.init}, function(data) { 172 | for (var objectName in data) { 173 | var object = new QObject(objectName, data[objectName], channel); 174 | } 175 | // now unwrap properties, which might reference other registered objects 176 | for (var objectName in channel.objects) { 177 | channel.objects[objectName].unwrapProperties(); 178 | } 179 | if (initCallback) { 180 | initCallback(channel); 181 | } 182 | channel.exec({type: QWebChannelMessageTypes.idle}); 183 | }); 184 | }; 185 | 186 | function QObject(name, data, webChannel) 187 | { 188 | this.__id__ = name; 189 | webChannel.objects[name] = this; 190 | 191 | // List of callbacks that get invoked upon signal emission 192 | this.__objectSignals__ = {}; 193 | 194 | // Cache of all properties, updated when a notify signal is emitted 195 | this.__propertyCache__ = {}; 196 | 197 | var object = this; 198 | 199 | // ---------------------------------------------------------------------- 200 | 201 | this.unwrapQObject = function(response) 202 | { 203 | if (response instanceof Array) { 204 | // support list of objects 205 | var ret = new Array(response.length); 206 | for (var i = 0; i < response.length; ++i) { 207 | ret[i] = object.unwrapQObject(response[i]); 208 | } 209 | return ret; 210 | } 211 | if (!response 212 | || !response["__QObject*__"] 213 | || response.id === undefined) { 214 | return response; 215 | } 216 | 217 | var objectId = response.id; 218 | if (webChannel.objects[objectId]) 219 | return webChannel.objects[objectId]; 220 | 221 | if (!response.data) { 222 | console.error("Cannot unwrap unknown QObject " + objectId + " without data."); 223 | return; 224 | } 225 | 226 | var qObject = new QObject( objectId, response.data, webChannel ); 227 | qObject.destroyed.connect(function() { 228 | if (webChannel.objects[objectId] === qObject) { 229 | delete webChannel.objects[objectId]; 230 | // reset the now deleted QObject to an empty {} object 231 | // just assigning {} though would not have the desired effect, but the 232 | // below also ensures all external references will see the empty map 233 | // NOTE: this detour is necessary to workaround QTBUG-40021 234 | var propertyNames = []; 235 | for (var propertyName in qObject) { 236 | propertyNames.push(propertyName); 237 | } 238 | for (var idx in propertyNames) { 239 | delete qObject[propertyNames[idx]]; 240 | } 241 | } 242 | }); 243 | // here we are already initialized, and thus must directly unwrap the properties 244 | qObject.unwrapProperties(); 245 | return qObject; 246 | } 247 | 248 | this.unwrapProperties = function() 249 | { 250 | for (var propertyIdx in object.__propertyCache__) { 251 | object.__propertyCache__[propertyIdx] = object.unwrapQObject(object.__propertyCache__[propertyIdx]); 252 | } 253 | } 254 | 255 | function addSignal(signalData, isPropertyNotifySignal) 256 | { 257 | var signalName = signalData[0]; 258 | var signalIndex = signalData[1]; 259 | object[signalName] = { 260 | connect: function(callback) { 261 | if (typeof(callback) !== "function") { 262 | console.error("Bad callback given to connect to signal " + signalName); 263 | return; 264 | } 265 | 266 | object.__objectSignals__[signalIndex] = object.__objectSignals__[signalIndex] || []; 267 | object.__objectSignals__[signalIndex].push(callback); 268 | 269 | if (!isPropertyNotifySignal && signalName !== "destroyed") { 270 | // only required for "pure" signals, handled separately for properties in propertyUpdate 271 | // also note that we always get notified about the destroyed signal 272 | webChannel.exec({ 273 | type: QWebChannelMessageTypes.connectToSignal, 274 | object: object.__id__, 275 | signal: signalIndex 276 | }); 277 | } 278 | }, 279 | disconnect: function(callback) { 280 | if (typeof(callback) !== "function") { 281 | console.error("Bad callback given to disconnect from signal " + signalName); 282 | return; 283 | } 284 | object.__objectSignals__[signalIndex] = object.__objectSignals__[signalIndex] || []; 285 | var idx = object.__objectSignals__[signalIndex].indexOf(callback); 286 | if (idx === -1) { 287 | console.error("Cannot find connection of signal " + signalName + " to " + callback.name); 288 | return; 289 | } 290 | object.__objectSignals__[signalIndex].splice(idx, 1); 291 | if (!isPropertyNotifySignal && object.__objectSignals__[signalIndex].length === 0) { 292 | // only required for "pure" signals, handled separately for properties in propertyUpdate 293 | webChannel.exec({ 294 | type: QWebChannelMessageTypes.disconnectFromSignal, 295 | object: object.__id__, 296 | signal: signalIndex 297 | }); 298 | } 299 | } 300 | }; 301 | } 302 | 303 | /** 304 | * Invokes all callbacks for the given signalname. Also works for property notify callbacks. 305 | */ 306 | function invokeSignalCallbacks(signalName, signalArgs) 307 | { 308 | var connections = object.__objectSignals__[signalName]; 309 | if (connections) { 310 | connections.forEach(function(callback) { 311 | callback.apply(callback, signalArgs); 312 | }); 313 | } 314 | } 315 | 316 | this.propertyUpdate = function(signals, propertyMap) 317 | { 318 | // update property cache 319 | for (var propertyIndex in propertyMap) { 320 | var propertyValue = propertyMap[propertyIndex]; 321 | object.__propertyCache__[propertyIndex] = propertyValue; 322 | } 323 | 324 | for (var signalName in signals) { 325 | // Invoke all callbacks, as signalEmitted() does not. This ensures the 326 | // property cache is updated before the callbacks are invoked. 327 | invokeSignalCallbacks(signalName, signals[signalName]); 328 | } 329 | } 330 | 331 | this.signalEmitted = function(signalName, signalArgs) 332 | { 333 | invokeSignalCallbacks(signalName, signalArgs); 334 | } 335 | 336 | function addMethod(methodData) 337 | { 338 | var methodName = methodData[0]; 339 | var methodIdx = methodData[1]; 340 | object[methodName] = function() { 341 | var args = []; 342 | var callback; 343 | for (var i = 0; i < arguments.length; ++i) { 344 | if (typeof arguments[i] === "function") 345 | callback = arguments[i]; 346 | else 347 | args.push(arguments[i]); 348 | } 349 | 350 | webChannel.exec({ 351 | "type": QWebChannelMessageTypes.invokeMethod, 352 | "object": object.__id__, 353 | "method": methodIdx, 354 | "args": args 355 | }, function(response) { 356 | if (response !== undefined) { 357 | var result = object.unwrapQObject(response); 358 | if (callback) { 359 | (callback)(result); 360 | } 361 | } 362 | }); 363 | }; 364 | } 365 | 366 | function bindGetterSetter(propertyInfo) 367 | { 368 | var propertyIndex = propertyInfo[0]; 369 | var propertyName = propertyInfo[1]; 370 | var notifySignalData = propertyInfo[2]; 371 | // initialize property cache with current value 372 | // NOTE: if this is an object, it is not directly unwrapped as it might 373 | // reference other QObject that we do not know yet 374 | object.__propertyCache__[propertyIndex] = propertyInfo[3]; 375 | 376 | if (notifySignalData) { 377 | if (notifySignalData[0] === 1) { 378 | // signal name is optimized away, reconstruct the actual name 379 | notifySignalData[0] = propertyName + "Changed"; 380 | } 381 | addSignal(notifySignalData, true); 382 | } 383 | 384 | Object.defineProperty(object, propertyName, { 385 | configurable: true, 386 | get: function () { 387 | var propertyValue = object.__propertyCache__[propertyIndex]; 388 | if (propertyValue === undefined) { 389 | // This shouldn't happen 390 | console.warn("Undefined value in property cache for property \"" + propertyName + "\" in object " + object.__id__); 391 | } 392 | 393 | return propertyValue; 394 | }, 395 | set: function(value) { 396 | if (value === undefined) { 397 | console.warn("Property setter for " + propertyName + " called with undefined value!"); 398 | return; 399 | } 400 | object.__propertyCache__[propertyIndex] = value; 401 | webChannel.exec({ 402 | "type": QWebChannelMessageTypes.setProperty, 403 | "object": object.__id__, 404 | "property": propertyIndex, 405 | "value": value 406 | }); 407 | } 408 | }); 409 | 410 | } 411 | 412 | // ---------------------------------------------------------------------- 413 | 414 | data.methods.forEach(addMethod); 415 | 416 | data.properties.forEach(bindGetterSetter); 417 | 418 | data.signals.forEach(function(signal) { addSignal(signal, false); }); 419 | 420 | for (var name in data.enums) { 421 | object[name] = data.enums[name]; 422 | } 423 | } 424 | 425 | //required for use with nodejs 426 | if (typeof module === 'object') { 427 | module.exports = { 428 | QWebChannel: QWebChannel 429 | }; 430 | } 431 | -------------------------------------------------------------------------------- /markdowneditor/src/document.cpp: -------------------------------------------------------------------------------- 1 | #include "document.h" 2 | #include 3 | #include 4 | 5 | Document::Document(QObject *parent) 6 | :QObject(parent) 7 | { 8 | } 9 | 10 | void Document::setText(const QString &text) 11 | { 12 | if (text == m_text) 13 | return; 14 | m_text = text; 15 | emit textChanged(m_text); 16 | } 17 | -------------------------------------------------------------------------------- /markdowneditor/src/document.h: -------------------------------------------------------------------------------- 1 | #ifndef DOCUMENT_H 2 | #define DOCUMENT_H 3 | 4 | #include 5 | #include 6 | 7 | class Document : public QObject 8 | { 9 | Q_OBJECT 10 | Q_PROPERTY(QString text MEMBER m_text NOTIFY textChanged FINAL) 11 | public: 12 | explicit Document(QObject *parent = nullptr); 13 | 14 | void setText(const QString &text); 15 | 16 | signals: 17 | void textChanged(const QString &text); 18 | 19 | private: 20 | QString m_text; 21 | }; 22 | 23 | #endif // DOCUMENT_H 24 | -------------------------------------------------------------------------------- /markdowneditor/src/dragarea.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * * 3 | * author cxl * 4 | * * 5 | ***************************************************************************/ 6 | 7 | 8 | #include "dragarea.h" 9 | #include 10 | #include 11 | #include 12 | 13 | DragArea::DragArea(QQuickItem *parent) 14 | : QQuickItem(parent), 15 | m_accepting(true) 16 | { 17 | setAcceptedMouseButtons(Qt::AllButtons); 18 | setFlag(QQuickItem::ItemAcceptsDrops, m_accepting); 19 | } 20 | 21 | void DragArea::dragEnterEvent(QDragEnterEvent *event) 22 | { 23 | event->acceptProposedAction(); 24 | setCursor(Qt::DragMoveCursor); 25 | } 26 | 27 | void DragArea::dragLeaveEvent(QDragLeaveEvent *event) 28 | { 29 | Q_UNUSED(event) 30 | unsetCursor(); 31 | } 32 | 33 | void DragArea::dropEvent(QDropEvent *event) 34 | { 35 | qInfo()<mimeData()->hasUrls()) 37 | { 38 | QList urlList = event->mimeData()->urls(); 39 | emit fileDrop(urlList.first().toLocalFile()); 40 | }else if(event->mimeData()->hasText()){ 41 | emit textDrop(event->mimeData()->text()); 42 | } 43 | 44 | unsetCursor(); 45 | } 46 | 47 | void DragArea::setAcceptingDrops(bool accepting) 48 | { 49 | qInfo()< 12 | 13 | class DragArea : public QQuickItem 14 | { 15 | Q_OBJECT 16 | Q_PROPERTY(bool acceptingDrops READ isAcceptingDrops WRITE setAcceptingDrops NOTIFY acceptingDropsChanged) 17 | 18 | public: 19 | DragArea(QQuickItem *parent=nullptr); 20 | bool isAcceptingDrops() const { return m_accepting; } 21 | void setAcceptingDrops(bool accepting); 22 | 23 | signals: 24 | void textDrop(QString text); 25 | void fileDrop(QString file_path); 26 | void acceptingDropsChanged(); 27 | 28 | protected: 29 | void dragEnterEvent(QDragEnterEvent *event); 30 | void dragLeaveEvent(QDragLeaveEvent *event); 31 | void dropEvent(QDropEvent *event); 32 | 33 | private: 34 | bool m_accepting; 35 | 36 | }; 37 | 38 | #endif // DRAPAREA_H 39 | -------------------------------------------------------------------------------- /markdowneditor/src/filemodel.cpp: -------------------------------------------------------------------------------- 1 | #include "filemodel.h" 2 | #include "utils.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | FileModel::FileModel(QObject *parent) : QFileSystemModel(parent) 11 | { 12 | setDirPath( Utils::getSettingsValue(VARIABLE_SETTINGS_GROUP,"selectDir", 13 | QVariant::fromValue(QDir::currentPath())).toString() ); 14 | connect(this,&FileModel::rootPathChanged,[this](QString){ 15 | emit dirPathChanged(); 16 | }); 17 | } 18 | 19 | FileModel::~FileModel() 20 | { 21 | Utils::setSettingsValue(VARIABLE_SETTINGS_GROUP,"selectDir",QVariant::fromValue(getDirPath())); 22 | } 23 | 24 | void FileModel::setDirPath(const QString &new_path) 25 | { 26 | qInfo()<<"set dir path "<= SizeRole) { 41 | switch (role) { 42 | case SizeRole: 43 | return QVariant(sizeString(fileInfo(index))); 44 | case LastModifiedRole: 45 | return QVariant(fileInfo(index).lastModified().toString(Qt::SystemLocaleShortDate)); 46 | case UrlStringRole: 47 | return QVariant(QUrl::fromLocalFile(filePath(index)).toString()); 48 | case DirStringRole:{ 49 | QString dir_str; 50 | 51 | if(isDir(index)){ 52 | dir_str = filePath(index); 53 | }else{ 54 | dir_str = fileInfo(index).absoluteDir().absolutePath(); 55 | } 56 | 57 | return QVariant(QUrl::fromLocalFile(dir_str).toString()); 58 | } 59 | case BaseNameStringRole:{ 60 | QString base_name = fileInfo(index).baseName(); 61 | if(base_name.isEmpty()){ 62 | base_name = fileInfo(index).fileName(); 63 | } 64 | return QVariant(base_name); 65 | } 66 | case IsDirRole: 67 | return QVariant(fileInfo(index).isDir()); 68 | case IsMarkdownFileRole: 69 | return QVariant(fileInfo(index).suffix() == "md"); 70 | case IsValidRole: 71 | return QVariant(index.isValid()); 72 | default: 73 | break; 74 | } 75 | } 76 | return QFileSystemModel::data(index, role); 77 | } 78 | 79 | QString FileModel::sizeString(const QFileInfo &fi) 80 | { 81 | if (!fi.isFile()) 82 | return QString(); 83 | const qint64 size = fi.size(); 84 | if (size > 1024 * 1024 * 1024) 85 | return QString::number(size / (1024 * 1024 *1024)) + 'G'; 86 | if (size > 1024 * 1024) 87 | return QString::number(size / (1024 * 1024)) + 'M'; 88 | if (size > 1024) 89 | return QString::number(size / 1024) +'K'; 90 | return QString::number(size)+ 'B'; 91 | } 92 | 93 | -------------------------------------------------------------------------------- /markdowneditor/src/filemodel.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * * 3 | * author cxl * 4 | * * 5 | ***************************************************************************/ 6 | 7 | 8 | #ifndef FILEMODEL_H 9 | #define FILEMODEL_H 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | class FileModel : public QFileSystemModel 16 | { 17 | Q_OBJECT 18 | Q_PROPERTY(QString dirPath READ getDirPath WRITE setDirPath NOTIFY dirPathChanged ) 19 | Q_PROPERTY(QModelIndex rootIndex READ getRootIndex NOTIFY dirPathChanged ) 20 | 21 | public: 22 | explicit FileModel(QObject *parent = nullptr); 23 | ~FileModel() Q_DECL_OVERRIDE; 24 | 25 | enum Roles { 26 | SizeRole = Qt::UserRole + 4, 27 | LastModifiedRole = Qt::UserRole + 6, 28 | UrlStringRole = Qt::UserRole + 7, 29 | DirStringRole, 30 | BaseNameStringRole, 31 | IsDirRole, 32 | IsMarkdownFileRole, 33 | IsValidRole 34 | }; 35 | 36 | Q_ENUM(Roles) 37 | 38 | QString getDirPath(){ 39 | return rootPath(); 40 | } 41 | 42 | void setDirPath(const QString &new_path); 43 | 44 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; 45 | 46 | QHash roleNames() const Q_DECL_OVERRIDE 47 | { 48 | QHash result = QFileSystemModel::roleNames(); 49 | result.insert(SizeRole, QByteArrayLiteral("size")); 50 | result.insert(LastModifiedRole, QByteArrayLiteral("lastModified")); 51 | result.insert(IsMarkdownFileRole, QByteArrayLiteral("isMarkdownFile")); 52 | return result; 53 | } 54 | 55 | static QString sizeString(const QFileInfo &fi); 56 | 57 | QModelIndex getRootIndex(){ 58 | return index(getDirPath()); 59 | } 60 | 61 | Q_SIGNALS: 62 | void dirPathChanged(); 63 | void rootIndexChanged(); 64 | 65 | }; 66 | 67 | #endif // FILEMODEL_H 68 | -------------------------------------------------------------------------------- /markdowneditor/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "document.h" 2 | #include "utils.h" 3 | #include "filemodel.h" 4 | #include "dragarea.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | QGuiApplication::setAttribute(Qt::AA_UseDesktopOpenGL); 14 | QGuiApplication app(argc, argv); 15 | qInfo()<<"args:"<("cxl.normal", 1, 0, "Document"); 27 | qmlRegisterType("cxl.normal", 1, 0, "DragArea"); 28 | qmlRegisterType("cxl.normal", 1, 0, "Utils"); 29 | qmlRegisterUncreatableType("cxl.normal", 1, 0, 30 | "FileModel", "Cannot create a FileSystemModel instance."); 31 | 32 | FileModel *file_model = new FileModel(); 33 | engine.rootContext()->setContextProperty("fileModel", file_model); 34 | if(app.arguments().length() == 2){ 35 | engine.rootContext()->setContextProperty("argPath", app.arguments().last()); 36 | } 37 | 38 | engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); 39 | 40 | file_model->setParent(engine.rootObjects().first()); 41 | return app.exec(); 42 | } 43 | -------------------------------------------------------------------------------- /markdowneditor/src/utils.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * * 3 | * author cxl * 4 | * * 5 | ***************************************************************************/ 6 | 7 | 8 | #include "utils.h" 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | Utils::Utils(QQuickItem *parent) : QQuickItem(parent) 17 | { 18 | 19 | } 20 | 21 | QString Utils::getSettingsFilePath() 22 | { 23 | QString fileName = "./settings.ini"; 24 | 25 | QFile file(fileName); 26 | if(!file.exists(fileName)){ 27 | file.open(QFile::WriteOnly); 28 | file.close(); 29 | } 30 | 31 | return fileName; 32 | } 33 | 34 | QVariant Utils::getSettingsValue(const QString &group, const QString &key, const QVariant &defalutValue) 35 | { 36 | QVariant result = defalutValue; 37 | 38 | QString fileName = getSettingsFilePath(); 39 | if (QFile::exists(fileName)) 40 | { 41 | QSettings settings(fileName, QSettings::IniFormat); 42 | settings.beginGroup(group); 43 | result = settings.value(key,defalutValue); 44 | settings.endGroup(); 45 | } 46 | 47 | return result; 48 | } 49 | 50 | void Utils::setSettingsValue(const QString &group, const QString &key, const QVariant &value) 51 | { 52 | QString fileName = getSettingsFilePath(); 53 | if (QFile::exists(fileName)) 54 | { 55 | QSettings settings(fileName, QSettings::IniFormat); 56 | settings.beginGroup(group); 57 | settings.setValue(key,value); 58 | settings.endGroup(); 59 | } 60 | } 61 | 62 | QString Utils::readFile(const QString &file_dir) 63 | { 64 | QString path = filterNativeSeparators(file_dir); 65 | QFile file(path); 66 | if(!file.exists()){ 67 | qWarning()<<"File not exist! path:"<textDocument(); 101 | td->setDefaultStyleSheet(readFile(style_url)); 102 | } 103 | 104 | bool Utils::saveDocToFile(const QString &doc, const QString &file_path) 105 | { 106 | bool ret = false; 107 | QString file_path_t = filterNativeSeparators(file_path); 108 | qInfo()< 0){ 112 | ret = true; 113 | }else{ 114 | qCritical()<<"save file but write to file failed!"; 115 | } 116 | file.close(); 117 | }else{ 118 | qCritical()<<"save file but open failed"; 119 | } 120 | 121 | return ret; 122 | } 123 | -------------------------------------------------------------------------------- /markdowneditor/src/utils.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * * 3 | * author cxl * 4 | * * 5 | ***************************************************************************/ 6 | 7 | 8 | #ifndef UTILS_H 9 | #define UTILS_H 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #define VARIABLE_SETTINGS_GROUP "variable" 16 | 17 | class Utils : public QQuickItem 18 | { 19 | Q_OBJECT 20 | public: 21 | explicit Utils(QQuickItem *parent = nullptr); 22 | 23 | static QString getSettingsFilePath(); 24 | static QVariant getSettingsValue(const QString &group, const QString &key,const QVariant &defalutValue); 25 | static void setSettingsValue(const QString &group, const QString &key,const QVariant &value); 26 | 27 | Q_INVOKABLE QString readFile(const QString &file_dir); 28 | Q_INVOKABLE QString getBaseNameFromPath(const QString &file_path); 29 | Q_INVOKABLE QString filterNativeSeparators(const QString &file_path); 30 | Q_INVOKABLE void textAppendStyleSheet(QQuickTextDocument* qd,const QString &style_url); 31 | Q_INVOKABLE bool saveDocToFile(const QString &doc, const QString &file_path); 32 | 33 | signals: 34 | 35 | public slots: 36 | }; 37 | 38 | #endif // UTILS_H 39 | -------------------------------------------------------------------------------- /screenShot/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CrazyCxl/markdown-editor/9e563fe0bfab382064c002ad0cc00302904269aa/screenShot/home.png --------------------------------------------------------------------------------