├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ └── release.yml ├── .gitignore ├── LICENSE ├── README.md ├── assets ├── converted-file.png ├── docx-preview.png ├── logo-dark.svg └── logo-light.svg ├── esbuild.config.mjs ├── manifest.json ├── package-lock.json ├── package.json ├── src ├── convertable-file-views │ └── docx.ts ├── core │ ├── convertible-file-view.ts │ └── docxer-embed-component.ts ├── main.ts ├── settings.ts ├── styles.scss ├── styles │ ├── preview.scss │ └── settings.scss └── utils │ ├── file-utils.ts │ ├── mime-utils.ts │ └── obsidian-turndown.ts ├── styles.css └── tsconfig.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | insert_final_newline = true 8 | indent_style = tab 9 | indent_size = 4 10 | tab_width = 4 11 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | 3 | main.js 4 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "env": { "node": true }, 5 | "plugins": [ 6 | "@typescript-eslint" 7 | ], 8 | "extends": [ 9 | "eslint:recommended", 10 | "plugin:@typescript-eslint/eslint-recommended", 11 | "plugin:@typescript-eslint/recommended" 12 | ], 13 | "parserOptions": { 14 | "sourceType": "module" 15 | }, 16 | "rules": { 17 | "no-unused-vars": "off", 18 | "@typescript-eslint/no-unused-vars": ["error", { "args": "none" }], 19 | "@typescript-eslint/ban-ts-comment": "off", 20 | "no-prototype-builtins": "off", 21 | "@typescript-eslint/no-empty-function": "off" 22 | } 23 | } -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | ko_fi: mikadev 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Report an issue of Advanced Canvas. 4 | title: "[BUG]" 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Share your idea on how to improve Advanced Canvas. 4 | title: "[FR]" 5 | labels: feature request 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Add release assets 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | permissions: 8 | contents: write 9 | 10 | jobs: 11 | build-and-upload: 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - name: Checkout Code 16 | uses: actions/checkout@v4 17 | 18 | - name: Setup Node.js 19 | uses: actions/setup-node@v4 20 | with: 21 | node-version: 20 22 | 23 | - name: Install Dependencies 24 | run: npm install 25 | 26 | - name: Build in Production Mode 27 | run: npm run build 28 | 29 | - name: Verify Files Exist 30 | run: ls -la main.js styles.css manifest.json 31 | 32 | - name: Upload Release Assets (Original Names) 33 | uses: softprops/action-gh-release@v1 34 | with: 35 | files: | 36 | main.js 37 | styles.css 38 | manifest.json 39 | env: 40 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # vscode 2 | .vscode 3 | 4 | # Intellij 5 | *.iml 6 | .idea 7 | 8 | # npm 9 | node_modules 10 | 11 | # Don't include the compiled main.js/styles.css file in the repo. 12 | # They should be uploaded to GitHub releases instead. 13 | main.js 14 | styles.css 15 | 16 | # Exclude sourcemaps 17 | *.map 18 | 19 | # obsidian 20 | data.json 21 | 22 | # Exclude macOS Finder (System Explorer) View States 23 | .DS_Store 24 | 25 | # Exclude large mp4 files 26 | assets/*.mp4 -------------------------------------------------------------------------------- /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 | . -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | 4 | Logo 5 |

6 | Docxer for Obsidian.md 7 |

8 | 9 |

10 | GitHub star count 11 | Open issues on GitHub 12 | List of contributors 13 |
14 | 15 | GPL-3.0 license 16 |

17 | 🚀 Boost your productivity by previewing and converting Word files easily to markdown. 18 |

19 | 20 | ## Installation 21 | Open the Community Plugins tab in the settings and search for "Docxer" (or click [here](https://obsidian.md/plugins?id=docxer)). 22 | 23 |
24 | Other installation methods 25 |
26 |
    27 |
  • Install it using BRAT
  • 28 |
  • Manual folder creation 29 |
      30 |
    1. Create a folder named obsidian-docxer in your vault's plugins folder (<vault>/.obsidian/plugins/).
    2. 31 |
    3. Download main.js, styles.css and manifest.json from the latest release and put them in the obsidian-docxer folder.
    4. 32 |
    5. Enable the plugin in Settings -> Community plugins -> Installed plugins
    6. 33 |
    34 |
  • 35 |
36 |
37 | 38 | ## Usage 39 | 1. Add a .docx file to your vault. 40 | 2. Open the file in Obsidian. 41 | 3. Click the "Convert" button in the top right corner of the editor to convert the file to markdown. 42 | 43 | ## Support 44 | Please consider supporting the plugin. The two easiest ways to support the plugin are either by starring ⭐ the repository or by donating any amount on [Ko-fi](https://ko-fi.com/X8X27IA08) ❤️. Thank you! 45 | 46 | [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/X8X27IA08) 47 | 48 | ## Implementation 49 | Docxer uses [docx-preview](https://www.npmjs.com/package/docx-preview) to render the previews, [mammoth](https://www.npmjs.com/package/mammoth) to convert `docx` to `HTML` and [turndown](https://www.npmjs.com/package/turndown) to finally convert the `HTML` to Markdown. 50 | 51 | ## Screenshots 52 | ![Docx Preview](assets/docx-preview.png) 53 | ![Converted File](assets/converted-file.png) 54 | 55 | ## Contributing 56 | All contributions are welcome! Here's how you can help: 57 | - Create a fork of the repository 58 | - Create a branch with a descriptive name 59 | - Make your changes 60 | - Debug the plugin using `npm run dev` 61 | - Create a pull request 62 | - Wait for the review 63 | -------------------------------------------------------------------------------- /assets/converted-file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Developer-Mike/obsidian-docxer/28c105bfc294e2ed3720e28b54e63990b6e876f9/assets/converted-file.png -------------------------------------------------------------------------------- /assets/docx-preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Developer-Mike/obsidian-docxer/28c105bfc294e2ed3720e28b54e63990b6e876f9/assets/docx-preview.png -------------------------------------------------------------------------------- /assets/logo-dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /assets/logo-light.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /esbuild.config.mjs: -------------------------------------------------------------------------------- 1 | import esbuild from "esbuild"; 2 | import process from "process"; 3 | import builtins from "builtin-modules"; 4 | import { sassPlugin } from 'esbuild-sass-plugin'; 5 | 6 | const banner = 7 | `/* 8 | THIS IS A GENERATED/BUNDLED FILE BY ESBUILD 9 | if you want to view the source, please visit the github repository of this plugin 10 | */ 11 | `; 12 | 13 | const prod = (process.argv[2] === "production"); 14 | 15 | const context = await esbuild.context({ 16 | banner: { 17 | js: banner, 18 | }, 19 | entryPoints: ["src/main.ts", "src/styles.scss"], 20 | bundle: true, 21 | external: [ 22 | "obsidian", 23 | "electron", 24 | "@codemirror/autocomplete", 25 | "@codemirror/collab", 26 | "@codemirror/commands", 27 | "@codemirror/language", 28 | "@codemirror/lint", 29 | "@codemirror/search", 30 | "@codemirror/state", 31 | "@codemirror/view", 32 | "@lezer/common", 33 | "@lezer/highlight", 34 | "@lezer/lr", 35 | ...builtins], 36 | format: "cjs", 37 | target: "es2018", 38 | logLevel: "info", 39 | sourcemap: prod ? false : "inline", 40 | treeShaking: true, 41 | outdir: ".", 42 | plugins: [ 43 | sassPlugin({}), 44 | ], 45 | }); 46 | 47 | if (prod) { 48 | await context.rebuild(); 49 | process.exit(0); 50 | } else { 51 | await context.watch(); 52 | } -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "docxer", 3 | "name": "Docxer", 4 | "version": "2.2.2", 5 | "minAppVersion": "1.5.0", 6 | "description": "Import Word files easily. Adds a preview mode for .docx files and the ability to convert them to markdown (.md) files.", 7 | "author": "Developer-Mike", 8 | "authorUrl": "https://github.com/Developer-Mike", 9 | "isDesktopOnly": false 10 | } 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "src/main.js", 3 | "scripts": { 4 | "dev": "node esbuild.config.mjs", 5 | "build": "node esbuild.config.mjs production" 6 | }, 7 | "devDependencies": { 8 | "@types/node": "^16.11.6", 9 | "@types/turndown": "^5.0.4", 10 | "@typescript-eslint/eslint-plugin": "5.29.0", 11 | "@typescript-eslint/parser": "5.29.0", 12 | "builtin-modules": "3.3.0", 13 | "esbuild": "0.19.4", 14 | "obsidian": "latest", 15 | "tslib": "2.4.0", 16 | "typescript": "4.7.4" 17 | }, 18 | "dependencies": { 19 | "docx-preview": "^0.3.0", 20 | "esbuild-sass-plugin": "^2.6.0", 21 | "mammoth": "^1.6.0", 22 | "monkey-around": "^2.3.0", 23 | "sass": "^1.70.0", 24 | "turndown": "^7.2.0" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/convertable-file-views/docx.ts: -------------------------------------------------------------------------------- 1 | import * as mammoth from "mammoth" 2 | import { renderAsync } from 'docx-preview' 3 | import ConvertibleFileView from "src/core/convertible-file-view" 4 | import FileUtils from "src/utils/file-utils" 5 | import ObsidianTurndown from "src/utils/obsidian-turndown" 6 | import { htmlToMarkdown, TFile } from "obsidian" 7 | import MimeUtils from "src/utils/mime-utils" 8 | import DocxerPlugin from "src/main" 9 | 10 | export default class DocxFileView extends ConvertibleFileView { 11 | static readonly VIEW_TYPE_ID = "docx-view" 12 | 13 | getViewType(): string { 14 | return DocxFileView.VIEW_TYPE_ID 15 | } 16 | 17 | static async getFilePreview(plugin: DocxerPlugin, file: TFile | null): Promise { 18 | if (!file) return null 19 | 20 | const view = document.createElement("div") 21 | 22 | const fileBuffer = await plugin.app.vault.readBinary(file) 23 | await renderAsync(fileBuffer, view, view, { 24 | renderComments: plugin.settings.getSetting("importComments"), 25 | }) 26 | 27 | const docxWrapper = view.querySelector(".docx-wrapper") as HTMLElement | null 28 | if (!docxWrapper) return view 29 | 30 | const docx = docxWrapper.querySelector(".docx") as HTMLElement | null 31 | if (!docx) return view 32 | 33 | new ResizeObserver(() => { 34 | const scale = Math.min(1, view.clientWidth / docx.clientWidth) 35 | docxWrapper.style.transform = `scale(${scale})` 36 | }).observe(view) 37 | 38 | return view 39 | } 40 | 41 | async getFilePreview(): Promise { 42 | return DocxFileView.getFilePreview(this.plugin, this.file) 43 | } 44 | 45 | async getMarkdownContent(attachmentsDirectory: string): Promise { 46 | if (!this.file) return null 47 | 48 | // Convert DOCX to HTML 49 | const fileBuffer = await this.app.vault.readBinary(this.file) 50 | const html = await mammoth.convertToHtml({ arrayBuffer: fileBuffer }, { 51 | styleMap: this.plugin.settings.getSetting("importComments") ? ["comment-reference => sup"] : undefined, 52 | convertImage: mammoth.images.imgElement(async (image: any) => { 53 | console.debug(`Extracting image ${image.altText ?? ""}`) 54 | const imageBinary = await image.read() 55 | 56 | const fallbackFilename = this.plugin.settings.getSetting("fallbackAttachmentName") 57 | let attachmentFilename = this.file?.name.replace(/\.docx$/, "") ?? "" 58 | if (this.plugin.settings.getSetting("useImageAltAsFilename")) 59 | attachmentFilename = image.altText?.replace(/\n/g, " ") ?? "" 60 | const fileExtension = MimeUtils.EXTENSIONS[image.contentType] ?? "png" 61 | 62 | const path = await FileUtils.createBinary(this.app, attachmentsDirectory, attachmentFilename, fallbackFilename, fileExtension, imageBinary) 63 | console.debug(`Extracted image to ${path}`) 64 | 65 | return { src: path.contains(" ") ? `<${path}>` : path, alt: attachmentFilename } 66 | }) 67 | }) 68 | 69 | // Convert HTML to Markdown 70 | let markdown 71 | if (!this.plugin.settings.getSetting("importComments")) { 72 | markdown = htmlToMarkdown(html.value) 73 | } else { 74 | const turndownService = ObsidianTurndown.getService() 75 | 76 | turndownService.addRule('comments-sup', { 77 | filter: ['sup'], 78 | replacement: function (content) { 79 | // [[MS2]](#comment-1) -> MS 80 | const author = content.match(/\[\[(\D+)\d*\]/)?.[1] ?? "Unknown Author" 81 | // [[MS2]](#comment-1) -> 2 82 | const commentNumber = content.match(/(\d+)/)?.[1] ?? "1" 83 | // [[MS2]](#comment-1) -> comment-1 84 | const commentId = content.match(/#([^\)]+)/)?.[1] ?? "comment-0" 85 | 86 | return ` ([[#^${commentId}|Comment ${author} ${commentNumber}]])` 87 | } 88 | }) 89 | 90 | // Rule for internal TOC links (links starting with #) 91 | turndownService.addRule('internalLink', { 92 | filter: function (node, options) { 93 | // Check if it's an 'a' tag with an 'href' starting with '#' 94 | return !!(node.nodeName === 'A' && node.getAttribute('href')?.startsWith('#')) 95 | }, 96 | replacement: function (content, node: HTMLAnchorElement) { 97 | const linkText = content.trim() 98 | if (linkText) return `[[#${linkText}]]` 99 | 100 | // Fallback if link text is empty - try using the href target ID directly 101 | const href = node.getAttribute('href') || '' 102 | console.warn(`Internal link with href "${href}" has no text content. Creating link to target ID.`) 103 | return `[[${href}]]` // Link to the raw href target (e.g., [[#_Toc12345]]) 104 | } 105 | }) 106 | 107 | turndownService.addRule('comments-description-list', { 108 | filter: ['dl'], 109 | replacement: function (content) { 110 | console.log(content) 111 | /* 112 | Comment [MS1] 113 | 114 | Hey [↑](#comment-ref-0) 115 | 116 | Comment [AD2] 117 | 118 | Test comment 2 [↑](#comment-ref-1) 119 | */ 120 | const comments = content.match(/Comment \[(\D+)\d+\]\n\n[\s\S]+? \[.\]\(#comment-ref-(\d+)\)/g) 121 | if (!comments) return content 122 | 123 | const commentsCallouts = comments.map((comment) => { 124 | const author = comment.match(/Comment \[(\D+)\d+\]/)?.[1] ?? "Unknown Author" 125 | const number = comment.match(/Comment \[\D+(\d+)\]/)?.[1] ?? "1" 126 | const id = comment.match(/Comment \[\D+\d+\]\n\n[\s\S]+? \[.\]\(#comment-ref-(\d+)\)/)?.[1] ?? "0" 127 | const content = comment.match(/Comment \[\D+\d+\]\n\n([\s\S]+?) \[.\]\(#comment-ref-\d+\)/)?.[1] ?? "" 128 | 129 | return ( 130 | `>[!QUOTE] **Comment ${author} ${number}**\n` 131 | + `> ${content}\n` 132 | + `^comment-${id}` 133 | ) 134 | }) 135 | 136 | return "---" + "\n\n" + commentsCallouts.join("\n\n") 137 | } 138 | }) 139 | 140 | markdown = turndownService.turndown(html.value) 141 | } 142 | 143 | return markdown 144 | } 145 | } -------------------------------------------------------------------------------- /src/core/convertible-file-view.ts: -------------------------------------------------------------------------------- 1 | import { EditableFileView, Notice, TFile, TextFileView, WorkspaceLeaf } from "obsidian" 2 | import DocxerPlugin from "src/main" 3 | import FileUtils from "src/utils/file-utils" 4 | 5 | export default abstract class ConvertibleFileView extends EditableFileView { 6 | plugin: DocxerPlugin 7 | fileContent: string 8 | header: HTMLElement | null = null 9 | content: HTMLElement | null = null 10 | 11 | constructor(leaf: WorkspaceLeaf, plugin: DocxerPlugin) { 12 | super(leaf) 13 | this.plugin = plugin 14 | } 15 | 16 | getDisplayText(): string { 17 | return this.file?.basename ?? "???" 18 | } 19 | 20 | getContext(file?: TFile) { 21 | return file?.path ?? this.file?.path ?? "" 22 | } 23 | 24 | async onOpen() { 25 | await super.onOpen() 26 | 27 | this.header = document.createElement("div") 28 | this.header.id = "docxer-header" 29 | 30 | const text = document.createElement("span") 31 | text.innerText = "This is a preview. To edit, convert it to markdown." 32 | this.header.appendChild(text) 33 | 34 | const convertButton = document.createElement("button") 35 | convertButton.id = "docxer-convert-button" 36 | convertButton.innerText = "Convert" 37 | convertButton.onclick = () => this.convertFile() 38 | this.header.appendChild(convertButton) 39 | 40 | this.containerEl.insertAfter(this.header, this.containerEl.firstChild) 41 | } 42 | 43 | async onClose() { 44 | await super.onClose() 45 | if (this.header) this.header.remove() 46 | } 47 | 48 | abstract getFilePreview(): Promise 49 | async onLoadFile(file: TFile) { 50 | await super.onLoadFile(file) 51 | 52 | this.content = await this.getFilePreview() 53 | if (this.content) this.contentEl.appendChild(this.content) 54 | } 55 | 56 | async onUnloadFile(file: TFile) { 57 | await super.onUnloadFile(file) 58 | if (this.content) this.content.remove() 59 | } 60 | 61 | clear(): void {} 62 | 63 | setViewData(data: string): void { 64 | this.fileContent = data 65 | } 66 | 67 | getViewData(): string { 68 | return this.fileContent 69 | } 70 | 71 | abstract getMarkdownContent(attachmentsDirectory: string): Promise 72 | private async convertFile() { 73 | if (!this.file) return 74 | 75 | const convertedFilePath = FileUtils.toUnixPath(this.file.path).replace(/\.[^\.]*$/, ".md") 76 | if (this.app.vault.getAbstractFileByPath(convertedFilePath)) { 77 | new Notice("A file with the same name already exists.") 78 | return 79 | } 80 | 81 | // Get the directory where the attachments will be saved 82 | const attachmentsDirectory = { 83 | "vault": "", 84 | "custom": this.plugin.settings.getSetting("customAttachmentsFolder"), 85 | "same": FileUtils.dirname(this.file.path), 86 | "subfolder": FileUtils.joinPath(FileUtils.dirname(this.file.path), this.plugin.settings.getSetting("customAttachmentsFolder")) 87 | }[this.plugin.settings.getSetting("attachmentsFolder")] 88 | 89 | // Convert the file to markdown 90 | const markdown = await this.getMarkdownContent(attachmentsDirectory) 91 | if (!markdown) { 92 | new Notice("Error converting file to markdown.") 93 | return 94 | } 95 | 96 | // Create the converted markdown file 97 | const convertedFile = await this.app.vault.create(convertedFilePath, markdown) 98 | this.leaf.openFile(convertedFile) 99 | 100 | // Delete the original file if the setting is enabled 101 | if (this.plugin.settings.getSetting("deleteFileAfterConversion")) 102 | this.app.vault.delete(this.file) 103 | } 104 | } -------------------------------------------------------------------------------- /src/core/docxer-embed-component.ts: -------------------------------------------------------------------------------- 1 | import DocxerPlugin from "src/main" 2 | import ConvertibleFileView from "./convertible-file-view" 3 | import { Component, TFile, WorkspaceLeaf } from "obsidian" 4 | 5 | export default class DocxerEmbedComponent extends Component { 6 | plugin: DocxerPlugin 7 | view: new (leaf: WorkspaceLeaf, plugin: DocxerPlugin) => ConvertibleFileView 8 | 9 | info: any 10 | file: TFile 11 | subpath: string 12 | 13 | constructor(plugin: DocxerPlugin, view: new (leaf: WorkspaceLeaf, plugin: DocxerPlugin) => ConvertibleFileView, info: any, file: TFile, subpath: string) { 14 | super() 15 | 16 | this.plugin = plugin 17 | this.view = view 18 | 19 | this.info = info 20 | this.file = file 21 | this.subpath = subpath 22 | 23 | info.containerEl.addClass("docxer-embed") 24 | } 25 | 26 | // override 27 | async loadFile() { 28 | const preview = await (this.view as any).getFilePreview(this.plugin, this.file) 29 | if (!preview) return 30 | 31 | this.info.containerEl.appendChild(preview) 32 | } 33 | 34 | static isEmbeddable(view: new (leaf: WorkspaceLeaf, plugin: DocxerPlugin) => ConvertibleFileView) { 35 | return (view as any).getFilePreview !== undefined 36 | } 37 | } -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import DocxFileView from "./convertable-file-views/docx" 2 | import ConvertibleFileView from "./core/convertible-file-view" 3 | import DocxerEmbedComponent from "./core/docxer-embed-component" 4 | import SettingsManager from "./settings" 5 | import { Plugin, TFile, WorkspaceLeaf } from "obsidian" 6 | 7 | export const FILETYPE_MAP: { [key: string]: new(leaf: WorkspaceLeaf, plugin: DocxerPlugin) => ConvertibleFileView } = { 8 | "docx": DocxFileView 9 | } 10 | 11 | export default class DocxerPlugin extends Plugin { 12 | settings: SettingsManager 13 | 14 | async onload() { 15 | this.settings = new SettingsManager(this) 16 | await this.settings.loadSettings() 17 | this.settings.addSettingsTab() 18 | 19 | for (const [fileExtension, viewClass] of Object.entries(FILETYPE_MAP)) { 20 | this.registerView((viewClass as any).VIEW_TYPE_ID, (leaf) => new viewClass(leaf, this)) 21 | this.registerExtensions([fileExtension], (viewClass as any).VIEW_TYPE_ID) 22 | 23 | // Register embeds 24 | if (!DocxerEmbedComponent.isEmbeddable(viewClass)) continue 25 | 26 | ;(this.app as any).embedRegistry.unregisterExtension(fileExtension) 27 | ;(this.app as any).embedRegistry.registerExtension(fileExtension, (info: any, file: TFile, subpath: string) => new DocxerEmbedComponent(this, viewClass, info, file, subpath)) 28 | } 29 | } 30 | 31 | onunload() {} 32 | } -------------------------------------------------------------------------------- /src/settings.ts: -------------------------------------------------------------------------------- 1 | import { Notice, PluginSettingTab, Setting } from "obsidian" 2 | import DocxerPlugin from "./main" 3 | 4 | export interface DocxerPluginSettings { 5 | deleteFileAfterConversion: boolean 6 | importComments: boolean 7 | fallbackAttachmentName: string 8 | attachmentsFolder: "vault" | "custom" | "same" | "subfolder" 9 | customAttachmentsFolder: string 10 | useImageAltAsFilename: boolean 11 | } 12 | 13 | export const DEFAULT_SETTINGS: Partial = { 14 | deleteFileAfterConversion: false, 15 | importComments: false, 16 | fallbackAttachmentName: "Attachment", 17 | attachmentsFolder: "subfolder", 18 | customAttachmentsFolder: "Attachments", 19 | useImageAltAsFilename: false, 20 | } 21 | 22 | export default class SettingsManager { 23 | static SETTINGS_CHANGED_EVENT = 'docxer:settings-changed' 24 | 25 | private plugin: DocxerPlugin 26 | private settings: DocxerPluginSettings 27 | private settingsTab: DocxerPluginSettingTab 28 | 29 | constructor(plugin: DocxerPlugin) { 30 | this.plugin = plugin 31 | } 32 | 33 | async loadSettings() { 34 | this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.plugin.loadData()) 35 | this.plugin.app.workspace.trigger(SettingsManager.SETTINGS_CHANGED_EVENT) 36 | } 37 | 38 | async saveSettings() { 39 | await this.plugin.saveData(this.settings) 40 | } 41 | 42 | getSetting(key: T): DocxerPluginSettings[T] { 43 | return this.settings[key] 44 | } 45 | 46 | async setSetting(data: Partial) { 47 | this.settings = Object.assign(this.settings, data) 48 | await this.saveSettings() 49 | this.plugin.app.workspace.trigger(SettingsManager.SETTINGS_CHANGED_EVENT) 50 | } 51 | 52 | addSettingsTab() { 53 | this.settingsTab = new DocxerPluginSettingTab(this.plugin, this) 54 | this.plugin.addSettingTab(this.settingsTab) 55 | } 56 | } 57 | 58 | export class DocxerPluginSettingTab extends PluginSettingTab { 59 | settingsManager: SettingsManager 60 | 61 | constructor(plugin: DocxerPlugin, settingsManager: SettingsManager) { 62 | super(plugin.app, plugin) 63 | this.settingsManager = settingsManager 64 | } 65 | 66 | display(): void { 67 | let { containerEl } = this 68 | containerEl.empty() 69 | 70 | new Setting(containerEl) 71 | .setName("Delete source file after conversion") 72 | .setDesc("Delete source file after pressing the conversion button.") 73 | .addToggle((toggle) => 74 | toggle 75 | .setValue(this.settingsManager.getSetting('deleteFileAfterConversion')) 76 | .onChange(async (value) => await this.settingsManager.setSetting({ deleteFileAfterConversion: value })) 77 | ) 78 | 79 | new Setting(containerEl) 80 | .setName("Import docx comments") 81 | .setDesc("Import comments from docx files using reference links. Comments will be placed at the end of the markdown file.") 82 | .addToggle((toggle) => 83 | toggle 84 | .setValue(this.settingsManager.getSetting('importComments')) 85 | .onChange(async (value) => await this.settingsManager.setSetting({ importComments: value })) 86 | ) 87 | 88 | new Setting(containerEl) 89 | .setHeading() 90 | .setClass('docxer-settings-heading') 91 | .setName("Attachments") 92 | .setDesc("Settings related to attachments extracted during file conversion.") 93 | 94 | new Setting(containerEl) 95 | .setName("Fallback attachment name") 96 | .setDesc("Fallback name if the attachment file has no alt text or is written using only invalid characters.") 97 | .addText((text) => 98 | text 99 | .setValue(this.settingsManager.getSetting('fallbackAttachmentName')) 100 | .onChange(async (value) => await this.settingsManager.setSetting({ fallbackAttachmentName: value })) 101 | ) 102 | 103 | new Setting(containerEl) 104 | .setName("Attachments folder") 105 | .setDesc("Specify the destination for attachments extracted during file conversion.") 106 | .addDropdown((dropdown) => 107 | dropdown 108 | .addOptions({ 109 | "vault": "Vault folder", 110 | "custom": "In the folder specified below", 111 | "same": "Same folder as current file", 112 | "subfolder": "In subfolder under current folder" 113 | }) 114 | .setValue(this.settingsManager.getSetting('attachmentsFolder')) 115 | .onChange(async (value) => await this.settingsManager.setSetting({ attachmentsFolder: value as any })) 116 | ) 117 | 118 | new Setting(containerEl) 119 | .setName("Custom attachments folder") 120 | .setDesc("Specify the name of the folder where attachments will be extracted.") 121 | .addText((text) => 122 | text 123 | .setPlaceholder("Attachments") 124 | .setValue(this.settingsManager.getSetting('customAttachmentsFolder')) 125 | .onChange(async (value) => await this.settingsManager.setSetting({ customAttachmentsFolder: value })) 126 | ) 127 | 128 | new Setting(containerEl) 129 | .setName("Use image alt text as filename") 130 | .setDesc("Use the alt text of the image as the filename. If the alt text is empty, the fallback name will be used.") 131 | .addToggle((toggle) => 132 | toggle 133 | .setValue(this.settingsManager.getSetting('useImageAltAsFilename')) 134 | .onChange(async (value) => await this.settingsManager.setSetting({ useImageAltAsFilename: value })) 135 | ) 136 | 137 | this.addKofiButton(containerEl) 138 | } 139 | 140 | private addKofiButton(containerEl: HTMLElement) { 141 | const kofiButton = document.createElement('a') 142 | kofiButton.classList.add('kofi-button') 143 | kofiButton.href = 'https://ko-fi.com/X8X27IA08' 144 | kofiButton.target = '_blank' 145 | 146 | const kofiImage = document.createElement('img') 147 | kofiImage.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABNcAAAGVCAMAAADqnefWAAAA3lBMVEUAAAD/////////////////////////////////////////////////////////////////9fX/7Ozv7+//4uH/2dn/2djf39//zc3/ycj/w8P/wMDPz8//ubj/t7f/r6//qqq/v7//o6P/nZz/m5v/lpb/kZCvr6//ion/h4f/hob/hoX/hIP/gH//fXz/fHv/eXifn5//dXT/cXH/bm7/bm3/a2v/amn/aWj/aGf/ZmX/ZGT/Y2L/YWH/YGCPj4//X19/f39vb29fX19PT08/Pz8vLy8fHx8PDw8AAABHqlbKAAAAEHRSTlMAECAwQFBgcICQoLDA0ODwVOCoyAAALtpJREFUeNrs3Vtvm8oaxnGwMcaYw6uiyKpEpI4i1VIutkTUi0pRZGMMZr7/F9rZK90rTnMwzAFm8PO7X6lW7fw7wxxwAAAAAAAAAAAAAAAAAAAAAAAAAAAAwByu5/kBKLDwPG/uAMCYZotgHRMolkbRKvC9mQMAw5ot1wmBVkkULD3XAYAhLFZomgDhui0wdgPQa75KCQaWrJeeAwBauD4eqI0mCtA2AOVmAYZqI1svMScFUGgWEhggWWHYBqCGuyIwRRouHACQhRloZ0gbgBU87OswULrC6QQATEEnJ1li3y4ABmuTE2IVAaA3DNZMl/gYtAH04WIfrgXSFXa1AXQ2xzKoJUKUDaAbn8AaER60AXQQENgEZQO4COemrIOyASBr0xPhORsAsjY5WEEAQNYmJw2wnw0AWZuaxHcA4G9LAqtFOBIPgH1rk4PJKABOGUxOgj0fAK9cZG0a1hiyAfxfRDANKe7UBcDpqckJMWQDeDYnmBA8ZQNwHBe3407MCkM2uHq4HndyEuxlgyvnEUxP4ABcM1z7PUkR5qJwxXB+aqJSLB/A1cKO3OlaOgDXCYsGE4atbHCdZgQTFuPCSbhGuHRt2lJs+IDrg+Ha5OG+SVDK9bwgWEXP6EwaResg8DznIgzXADvZwBiut1xFCV2QRMFi5ozLJZi+0AGQ4i6CKKXuktD/sm2m3uPByqquWw7C6hdlWW5ZTr1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HhviB8QHDNUAbOUeEG0INYDNcfcngu9Oe4QawCb4RwzbvokClD8BtsTxg+iFuz+SEzINYJvcXXB6sZFbFIXBDpEGsHWefwjCaBWjt2iaMHjG/woraQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGDAnwEHEUGMH5vwcwAAAABJRU5ErkJggg==' 148 | 149 | kofiButton.appendChild(kofiImage) 150 | containerEl.appendChild(kofiButton) 151 | } 152 | } -------------------------------------------------------------------------------- /src/styles.scss: -------------------------------------------------------------------------------- 1 | @use "styles/settings"; 2 | @use "styles/preview"; -------------------------------------------------------------------------------- /src/styles/preview.scss: -------------------------------------------------------------------------------- 1 | #docxer-header { 2 | display: flex; 3 | align-items: center; 4 | justify-content: space-between; 5 | 6 | padding: 10px 20px; 7 | 8 | font-size: 1rem; 9 | background-color: var(--background-secondary); 10 | } 11 | 12 | .docxer-embed { 13 | max-height: 800px; 14 | overflow: auto; 15 | 16 | background-color: var(--background-primary); 17 | border: 1px solid var(--background-modifier-border); 18 | border-radius: var(--radius-s); 19 | } 20 | 21 | .docx-wrapper { 22 | padding: 0 !important; 23 | background-color: var(--background-primary) !important; 24 | 25 | transform-origin: center top; 26 | 27 | & article { 28 | user-select: text; 29 | } 30 | } -------------------------------------------------------------------------------- /src/styles/settings.scss: -------------------------------------------------------------------------------- 1 | .kofi-button { 2 | z-index: 999; 3 | 4 | position: absolute; 5 | bottom: var(--size-4-5); 6 | right: var(--size-4-5); 7 | 8 | height: 30px; 9 | 10 | img { 11 | height: 100%; 12 | } 13 | } 14 | 15 | .docxer-settings-heading { 16 | &:not(:first-child) { 17 | margin-top: var(--size-4-10) !important; 18 | } 19 | 20 | border-bottom: 1px solid var(--color-accent); 21 | } -------------------------------------------------------------------------------- /src/utils/file-utils.ts: -------------------------------------------------------------------------------- 1 | import { App } from "obsidian" 2 | 3 | export default class FileUtils { 4 | static toUnixPath(path: string): string { 5 | return path.replace(/\\/g, "/") 6 | } 7 | 8 | static joinPath(path1: string | null, path2: string | null): string { 9 | if (!path2) return FileUtils.toUnixPath(path1 ?? "") 10 | if (!path1) return FileUtils.toUnixPath(path2 ?? "") 11 | 12 | return `${FileUtils.toUnixPath(path1).replace(/\/$/, "")}/${FileUtils.toUnixPath(path2)}` 13 | } 14 | 15 | static dirname(path: string): string { 16 | return FileUtils.toUnixPath(path).replace(/[^\/]*\/?$/, "") 17 | } 18 | 19 | static filename(path: string, withExtension: boolean): string { 20 | const unixPath = FileUtils.toUnixPath(path) 21 | return withExtension ? unixPath.replace(/.*\//, "") : unixPath.replace(/.*\//, "").replace(/\.[^\.]*$/, "") 22 | } 23 | 24 | static toValidFilename(filename: string): string { 25 | // " * / : < > ? \ | + , . ; = [ ] ! @ 26 | return filename.replace(/[\/\\:*?"<>|+,.=;!@[\]\n]/g, "") 27 | } 28 | 29 | static async createMissingFolders(app: App, filepath: string) { 30 | const dirname = FileUtils.dirname(filepath) 31 | const folders = dirname.split("/").filter(folder => folder !== "") 32 | 33 | let currentFolder = null 34 | for (const folder of folders) { 35 | currentFolder = FileUtils.joinPath(currentFolder, folder) 36 | 37 | if (!app.vault.getAbstractFileByPath(currentFolder)) 38 | await app.vault.createFolder(currentFolder) 39 | } 40 | } 41 | 42 | static async createBinary(app: App, directory: string, filename: string, fallbackFilename: string, extension: string, binary: ArrayBuffer): Promise { 43 | let validFilename = FileUtils.toValidFilename(filename) 44 | if (validFilename === "") validFilename = fallbackFilename 45 | 46 | let filepath = FileUtils.joinPath(directory, `${validFilename}.${extension}`) 47 | 48 | let fallbackIndex = 1 49 | while (app.vault.getAbstractFileByPath(filepath)) { 50 | filepath = FileUtils.joinPath(directory, `${validFilename} ${fallbackIndex}.${extension}`) 51 | fallbackIndex++ 52 | } 53 | 54 | await FileUtils.createMissingFolders(app, filepath) 55 | await app.vault.createBinary(filepath, binary) 56 | 57 | return filepath 58 | } 59 | } -------------------------------------------------------------------------------- /src/utils/mime-utils.ts: -------------------------------------------------------------------------------- 1 | export default class MimeUtils { 2 | static readonly EXTENSIONS: { [key: string]: string } = { 3 | "audio/aac": "aac", 4 | "application/x-abiword": "abw", 5 | "image/apng": "apng", 6 | "application/x-freearc": "arc", 7 | "image/avif": "avif", 8 | "video/x-msvideo": "avi", 9 | "application/vnd.amazon.ebook": "azw", 10 | "application/octet-stream": "bin", 11 | "image/bmp": "bmp", 12 | "application/x-bzip": "bz", 13 | "application/x-bzip2": "bz2", 14 | "application/x-cdf": "cda", 15 | "application/x-csh": "csh", 16 | "text/css": "css", 17 | "text/csv": "csv", 18 | "application/msword": "doc", 19 | "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx", 20 | "application/vnd.ms-fontobject": "eot", 21 | "application/epub+zip": "epub", 22 | "application/gzip": "gz", 23 | "image/gif": "gif", 24 | "text/html": "html", 25 | "image/vnd.microsoft.icon": "ico", 26 | "text/calendar": "ics", 27 | "application/java-archive": "jar", 28 | "image/jpeg": "jpeg", 29 | "application/json": "json", 30 | "application/ld+json": "jsonld", 31 | "audio/x-midi": "mid", 32 | "text/javascript": "mjs", 33 | "audio/mpeg": "mp3", 34 | "video/mp4": "mp4", 35 | "video/mpeg": "mpeg", 36 | "application/vnd.apple.installer+xml": "mpkg", 37 | "application/vnd.oasis.opendocument.presentation": "odp", 38 | "application/vnd.oasis.opendocument.spreadsheet": "ods", 39 | "application/vnd.oasis.opendocument.text": "odt", 40 | "audio/ogg": "oga", 41 | "video/ogg": "ogv", 42 | "application/ogg": "ogx", 43 | "font/otf": "otf", 44 | "image/png": "png", 45 | "application/pdf": "pdf", 46 | "application/x-httpd-php": "php", 47 | "application/vnd.ms-powerpoint": "ppt", 48 | "application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx", 49 | "application/vnd.rar": "rar", 50 | "application/rtf": "rtf", 51 | "application/x-sh": "sh", 52 | "image/svg+xml": "svg", 53 | "application/x-tar": "tar", 54 | "image/tiff": "tif", 55 | "video/mp2t": "ts", 56 | "font/ttf": "ttf", 57 | "text/plain": "txt", 58 | "application/vnd.visio": "vsd", 59 | "audio/wav": "wav", 60 | "audio/webm": "weba", 61 | "video/webm": "webm", 62 | "image/webp": "webp", 63 | "font/woff": "woff", 64 | "font/woff2": "woff2", 65 | "application/xhtml+xml": "xhtml", 66 | "application/vnd.ms-excel": "xls", 67 | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx", 68 | "application/vnd.mozilla.xul+xml": "xul", 69 | "application/x-zip-compressed.": "zip", 70 | "application/x-7z-compressed": "7z" 71 | } 72 | } -------------------------------------------------------------------------------- /src/utils/obsidian-turndown.ts: -------------------------------------------------------------------------------- 1 | //@ts-nocheck 2 | import TurndownService from "turndown" 3 | 4 | export default class ObsidianTurndown { 5 | static getService() { 6 | const service = new TurndownService({ 7 | headingStyle: "atx", 8 | hr: "---", 9 | bulletListMarker: "-", 10 | codeBlockStyle: "fenced", 11 | fence: "```", 12 | linkStyle: "inlined" 13 | }) 14 | 15 | //#region app.js Imports 16 | service.remove(["script", "style", "title"]), 17 | service.addRule("strikethrough", { 18 | filter: ["del", "s"], 19 | replacement: function(e) { 20 | return "~~" + e + "~~" 21 | } 22 | }), 23 | service.addRule("highlight", { 24 | filter: ["mark"], 25 | replacement: function(e) { 26 | return "==" + e + "==" 27 | } 28 | }); 29 | var sb = /highlight-(?:text|source)-([a-z0-9]+)/; 30 | service.addRule("highlightedCodeBlock", { 31 | filter: function(e) { 32 | var t = e.firstChild; 33 | return "DIV" === e.nodeName && sb.test(e.className) && t && "PRE" === t.nodeName 34 | }, 35 | replacement: function(e, t, n) { 36 | var i = ((t.className || "").match(sb) || [null, ""])[1]; 37 | return "\n\n" + n.fence + i + "\n" + t.firstChild.textContent + "\n" + n.fence + "\n\n" 38 | } 39 | }), 40 | service.addRule("listItem", { 41 | filter: "li", 42 | replacement: function(e, t, n) { 43 | e = e.replace(/^\n+/, "").replace(/\n+$/, "\n").replace(/\n/gm, "\n "); 44 | var i = n.bulletListMarker + " " 45 | , r = t.parentNode; 46 | if ("OL" === r.nodeName) { 47 | var o = r.getAttr("start") 48 | , a = Array.prototype.indexOf.call(r.children, t); 49 | i = (o ? Number(o) + a : a + 1) + ". " 50 | } 51 | return i + e + (t.nextSibling && !/\n$/.test(e) ? "\n" : "") 52 | } 53 | }), 54 | service.addRule("taskListItems", { 55 | filter: function(e) { 56 | return e.instanceOf(HTMLInputElement) && "checkbox" === e.type && "LI" === e.parentNode.nodeName 57 | }, 58 | replacement: function(e, t) { 59 | return t.checked ? "[x] " : "[ ] " 60 | } 61 | }), 62 | service.addRule("tableCell", { 63 | filter: ["th", "td"], 64 | replacement: function(e, t) { 65 | return (0 === Array.prototype.indexOf.call(t.parentNode.childNodes, t) ? "|" : "") + function(e) { 66 | return (e = e.trim().replace(/\|+/g, "\\|").replace(/\n\r?/g, "
")) + "|" 67 | }(e) + hb(t, " |") 68 | } 69 | }); 70 | var lb = { 71 | left: ":--", 72 | right: "--:", 73 | center: ":-:" 74 | }; 75 | function cb(e) { 76 | if (!e) 77 | return !1; 78 | var t, n, i = e.parentNode; 79 | return "THEAD" === i.nodeName || i.firstChild === e && ("TABLE" === i.nodeName || (n = (t = i).previousSibling, 80 | "TBODY" === t.nodeName && (!n || "THEAD" === n.nodeName && /^\s*$/i.test(n.textContent)))) && Array.prototype.every.call(e.childNodes, (function(e) { 81 | return "TH" === e.nodeName 82 | } 83 | )) 84 | } 85 | function ub(e) { 86 | var t = e.getAttribute("colspan"); 87 | if (!t) 88 | return 0; 89 | var n = parseInt(t); 90 | return isNaN(n) ? 0 : Math.max(0, n - 1) 91 | } 92 | function hb(e, t) { 93 | return t.repeat(ub(e)) 94 | } 95 | function pb(e) { 96 | return service.turndown(e) 97 | } 98 | service.addRule("tableRow", { 99 | filter: "tr", 100 | replacement: function(e, t) { 101 | var n = ""; 102 | if (cb(t)) 103 | for (var i = 0; i < t.cells.length; i++) { 104 | var r = t.cells[i] 105 | , o = (r.getAttribute("align") || "").toLowerCase() 106 | , a = lb[o] || "---"; 107 | n += (0 === i ? "|" : "") + a + "|" + hb(r, a + "|") 108 | } 109 | return "\n" + e + (n ? "\n" + n : "") 110 | } 111 | }), 112 | service.addRule("table", { 113 | filter: "table", 114 | replacement: function(e, t) { 115 | var n = t.rows[0]; 116 | if (!cb(n)) { 117 | for (var i = n.cells.length, r = 0; r < n.cells.length; r++) 118 | i += ub(n.cells[r]); 119 | e = "|" + " |".repeat(i) + "\n|" + "---|".repeat(i) + "\n" + e.replace(/^[\r\n]+/, "") 120 | } 121 | return "\n\n" + (e = e.replace(/[\r\n]+/g, "\n")) + "\n\n" 122 | } 123 | }), 124 | service.addRule("tableSection", { 125 | filter: ["thead", "tbody", "tfoot"], 126 | replacement: function(e) { 127 | return e 128 | } 129 | }), 130 | service.escape = function(e) { 131 | return e 132 | } 133 | //#endregion 134 | 135 | return service 136 | } 137 | } -------------------------------------------------------------------------------- /styles.css: -------------------------------------------------------------------------------- 1 | /* src/styles.scss */ 2 | .kofi-button { 3 | z-index: 999; 4 | position: absolute; 5 | bottom: var(--size-4-5); 6 | right: var(--size-4-5); 7 | height: 30px; 8 | } 9 | .kofi-button img { 10 | height: 100%; 11 | } 12 | .docxer-settings-heading { 13 | border-bottom: 1px solid var(--color-accent); 14 | } 15 | .docxer-settings-heading:not(:first-child) { 16 | margin-top: var(--size-4-10) !important; 17 | } 18 | #docxer-header { 19 | display: flex; 20 | align-items: center; 21 | justify-content: space-between; 22 | padding: 10px 20px; 23 | font-size: 1rem; 24 | background-color: var(--background-secondary); 25 | } 26 | .docxer-embed { 27 | max-height: 800px; 28 | overflow: auto; 29 | background-color: var(--background-primary); 30 | border: 1px solid var(--background-modifier-border); 31 | border-radius: var(--radius-s); 32 | } 33 | .docx-wrapper { 34 | padding: 0 !important; 35 | background-color: var(--background-primary) !important; 36 | transform-origin: center top; 37 | } 38 | .docx-wrapper article { 39 | user-select: text; 40 | } 41 | /*# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsic3JjL3N0eWxlcy9zZXR0aW5ncy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XItYm9yZGVyKTtcclxuICBib3JkZXItcmFkaXVzOiB2YXIoLS1yYWRpdXMtcyk7XHJcbn1cclxuXHJcbi5kb2N4LXdyYXBwZXIge1xyXG4gIHBhZGRpbmc6IDAgIWltcG9ydGFudDtcclxuICBiYWNrZ3JvdW5kLWNvbG9yOiB2YXIoLS1iYWNrZ3JvdW5kLXByaW1hcnkpICFpbXBvcnRhbnQ7XHJcblxyXG4gIHRyYW5zZm9ybS1vcmlnaW46IGNlbnRlciB0b3A7XHJcblxyXG4gICYgYXJ0aWNsZSB7XHJcbiAgICB1c2VyLXNlbGVjdDogdGV4dDtcclxuICB9XHJcbn0iXSwKICAibWFwcGluZ3MiOiAiO0FBQUEsQ0FBQTtBQUNFLFdBQUE7QUFFQSxZQUFBO0FBQ0EsVUFBQSxJQUFBO0FBQ0EsU0FBQSxJQUFBO0FBRUEsVUFBQTs7QUFFQSxDQVRGLFlBU0U7QUFDRSxVQUFBOztBQUlKLENBQUE7QUFLRSxpQkFBQSxJQUFBLE1BQUEsSUFBQTs7QUFKQSxDQURGLHVCQUNFLEtBQUE7QUFDRSxjQUFBLElBQUE7O0FDaEJKLENBQUE7QUFDRSxXQUFBO0FBQ0EsZUFBQTtBQUNBLG1CQUFBO0FBRUEsV0FBQSxLQUFBO0FBRUEsYUFBQTtBQUNBLG9CQUFBLElBQUE7O0FBR0YsQ0FBQTtBQUNFLGNBQUE7QUFDQSxZQUFBO0FBRUEsb0JBQUEsSUFBQTtBQUNBLFVBQUEsSUFBQSxNQUFBLElBQUE7QUFDQSxpQkFBQSxJQUFBOztBQUdGLENBQUE7QUFDRSxXQUFBO0FBQ0Esb0JBQUEsSUFBQTtBQUVBLG9CQUFBLE9BQUE7O0FBRUEsQ0FORixhQU1FO0FBQ0UsZUFBQTs7IiwKICAibmFtZXMiOiBbXQp9Cg== */ 42 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "inlineSourceMap": true, 5 | "inlineSources": true, 6 | "module": "ESNext", 7 | "target": "ES6", 8 | "allowJs": true, 9 | "esModuleInterop": true, 10 | "noImplicitAny": true, 11 | "moduleResolution": "node", 12 | "importHelpers": true, 13 | "isolatedModules": true, 14 | "strictNullChecks": true, 15 | "lib": [ 16 | "DOM", 17 | "ES5", 18 | "ES6", 19 | "ES7" 20 | ] 21 | }, 22 | "include": [ 23 | "**/*.ts" 24 | ] 25 | } 26 | --------------------------------------------------------------------------------