├── .flowconfig ├── .gitignore ├── GPL-2.0.md ├── LICENSE.md ├── MPL-2.0.md ├── README.md ├── RNTAztecView.podspec ├── android ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── org │ │ └── wordpress │ │ └── mobile │ │ └── ReactNativeAztec │ │ ├── ReactAztecBackSpaceEvent.java │ │ ├── ReactAztecBlurEvent.java │ │ ├── ReactAztecEndEditingEvent.java │ │ ├── ReactAztecEnterEvent.java │ │ ├── ReactAztecFocusEvent.java │ │ ├── ReactAztecFormattingChangeEvent.java │ │ ├── ReactAztecManager.java │ │ ├── ReactAztecPackage.java │ │ ├── ReactAztecSelectionChangeEvent.java │ │ └── ReactAztecText.java │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxhdpi │ └── ic_launcher.png │ └── values │ ├── bools.xml │ ├── integers.xml │ ├── strings.xml │ └── template-dimens.xml ├── example ├── .babelrc ├── App.js ├── android │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── android │ │ │ │ ├── MainActivity.java │ │ │ │ ├── MyFragment.java │ │ │ │ └── common │ │ │ │ └── activities │ │ │ │ └── SampleRNBaseActivity.java │ │ │ └── res │ │ │ ├── drawable-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── tile.9.png │ │ │ ├── drawable-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable │ │ │ └── ic_reorder_black_24dp.xml │ │ │ ├── layout-w720dp │ │ │ └── activity_main.xml │ │ │ ├── layout │ │ │ └── activity_main.xml │ │ │ ├── menu │ │ │ └── main.xml │ │ │ ├── values-sw600dp │ │ │ ├── template-dimens.xml │ │ │ └── template-styles.xml │ │ │ └── values │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── fragmentview_strings.xml │ │ │ ├── strings.xml │ │ │ ├── styles.xml │ │ │ ├── template-dimens.xml │ │ │ └── template-styles.xml │ ├── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── app.json ├── content.js ├── editor.js ├── iOS │ └── example.xcodeproj │ │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings ├── index.js ├── ios │ ├── example-Bridging-Header.h │ ├── example.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── example.xcscheme │ ├── example │ │ ├── AppDelegate.swift │ │ ├── Base.lproj │ │ │ └── LaunchScreen.xib │ │ ├── BridgeDelegate.swift │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ ├── Contents.json │ │ │ └── aztec.imageset │ │ │ │ ├── Contents.json │ │ │ │ └── aztec.png │ │ ├── Info.plist │ │ └── MediaProvider.swift │ └── exampleTests │ │ ├── Info.plist │ │ └── exampleTests.m ├── package.json ├── rn-cli.config.js └── yarn.lock ├── index.js ├── ios ├── Cartfile ├── Cartfile.resolved ├── RNTAztecView.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── RNTAztecView │ ├── BlockFormatHandler.swift │ ├── BlockModel.swift │ ├── HeadingBlockFormatHandler.swift │ ├── RCTAztecView-Bridging-Header.h │ ├── RCTAztecView.swift │ ├── RCTAztecViewManager.m │ └── RCTAztecViewManager.swift ├── package.json ├── src └── AztecView.js └── yarn.lock /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [lints] 8 | 9 | [options] 10 | 11 | [strict] 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X generated file 2 | .DS_Store 3 | 4 | # built application files 5 | *.apk 6 | *.ap_ 7 | 8 | # files for the dex VM 9 | *.dex 10 | 11 | # Java class files 12 | *.class 13 | 14 | # generated files 15 | bin/ 16 | gen/ 17 | build/ 18 | 19 | # Local configuration file (sdk path, etc) 20 | local.properties 21 | 22 | # Eclipse project files 23 | .settings/ 24 | .classpath 25 | .project 26 | 27 | # Intellij project files 28 | *.iml 29 | *.ipr 30 | *.iws 31 | .idea/ 32 | 33 | # Gradle 34 | .gradle/ 35 | gradle.properties 36 | 37 | # Generated by gradle 38 | crashlytics.properties 39 | 40 | # npm 41 | node_modules/ 42 | 43 | # yarn 44 | yarn-error.log 45 | 46 | ### 47 | ### Starting at this point, the Swift .gitignore rules from https://github.com/github/gitignore/blob/master/Swift.gitignore 48 | ### 49 | 50 | # Xcode 51 | # 52 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 53 | 54 | ## Build generated 55 | build/ 56 | DerivedData/ 57 | 58 | ## Various settings 59 | *.pbxuser 60 | !default.pbxuser 61 | *.mode1v3 62 | !default.mode1v3 63 | *.mode2v3 64 | !default.mode2v3 65 | *.perspectivev3 66 | !default.perspectivev3 67 | xcuserdata/ 68 | 69 | ## Other 70 | *.moved-aside 71 | *.xccheckout 72 | *.xcscmblueprint 73 | 74 | ## Obj-C/Swift specific 75 | *.hmap 76 | *.ipa 77 | *.dSYM.zip 78 | *.dSYM 79 | 80 | ## Playgrounds 81 | timeline.xctimeline 82 | playground.xcworkspace 83 | 84 | # Swift Package Manager 85 | # 86 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 87 | # Packages/ 88 | # Package.pins 89 | # Package.resolved 90 | .build/ 91 | 92 | # CocoaPods 93 | # 94 | # We recommend against adding the Pods directory to your .gitignore. However 95 | # you should judge for yourself, the pros and cons are mentioned at: 96 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 97 | # 98 | Pods/ 99 | 100 | # Carthage 101 | # 102 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 103 | 104 | ios/Carthage 105 | Carthage/Checkouts 106 | Carthage/Build 107 | 108 | # fastlane 109 | # 110 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 111 | # screenshots whenever they are needed. 112 | # For more information about the recommended setup visit: 113 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 114 | 115 | fastlane/report.xml 116 | fastlane/Preview.html 117 | fastlane/screenshots/**/*.png 118 | fastlane/test_output 119 | 120 | -------------------------------------------------------------------------------- /GPL-2.0.md: -------------------------------------------------------------------------------- 1 | ### GNU GENERAL PUBLIC LICENSE 2 | 3 | Version 2, June 1991 4 | 5 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 6 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 7 | 8 | Everyone is permitted to copy and distribute verbatim copies 9 | of this license document, but changing it is not allowed. 10 | 11 | ### Preamble 12 | 13 | The licenses for most software are designed to take away your freedom 14 | to share and change it. By contrast, the GNU General Public License is 15 | intended to guarantee your freedom to share and change free 16 | software--to make sure the software is free for all its users. This 17 | General Public License applies to most of the Free Software 18 | Foundation's software and to any other program whose authors commit to 19 | using it. (Some other Free Software Foundation software is covered by 20 | the GNU Lesser General Public License instead.) You can apply it to 21 | your programs, too. 22 | 23 | When we speak of free software, we are referring to freedom, not 24 | price. Our General Public Licenses are designed to make sure that you 25 | have the freedom to distribute copies of free software (and charge for 26 | this service if you wish), that you receive source code or can get it 27 | if you want it, that you can change the software or use pieces of it 28 | in new free programs; and that you know you can do these things. 29 | 30 | To protect your rights, we need to make restrictions that forbid 31 | anyone to deny you these rights or to ask you to surrender the rights. 32 | These restrictions translate to certain responsibilities for you if 33 | you distribute copies of the software, or if you modify it. 34 | 35 | For example, if you distribute copies of such a program, whether 36 | gratis or for a fee, you must give the recipients all the rights that 37 | you have. You must make sure that they, too, receive or can get the 38 | source code. And you must show them these terms so they know their 39 | rights. 40 | 41 | We protect your rights with two steps: (1) copyright the software, and 42 | (2) offer you this license which gives you legal permission to copy, 43 | distribute and/or modify the software. 44 | 45 | Also, for each author's protection and ours, we want to make certain 46 | that everyone understands that there is no warranty for this free 47 | software. If the software is modified by someone else and passed on, 48 | we want its recipients to know that what they have is not the 49 | original, so that any problems introduced by others will not reflect 50 | on the original authors' reputations. 51 | 52 | Finally, any free program is threatened constantly by software 53 | patents. We wish to avoid the danger that redistributors of a free 54 | program will individually obtain patent licenses, in effect making the 55 | program proprietary. To prevent this, we have made it clear that any 56 | patent must be licensed for everyone's free use or not licensed at 57 | all. 58 | 59 | The precise terms and conditions for copying, distribution and 60 | modification follow. 61 | 62 | ### TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 63 | 64 | **0.** This License applies to any program or other work which 65 | contains a notice placed by the copyright holder saying it may be 66 | distributed under the terms of this General Public License. The 67 | "Program", below, refers to any such program or work, and a "work 68 | based on the Program" means either the Program or any derivative work 69 | under copyright law: that is to say, a work containing the Program or 70 | a portion of it, either verbatim or with modifications and/or 71 | translated into another language. (Hereinafter, translation is 72 | included without limitation in the term "modification".) Each licensee 73 | is addressed as "you". 74 | 75 | Activities other than copying, distribution and modification are not 76 | covered by this License; they are outside its scope. The act of 77 | running the Program is not restricted, and the output from the Program 78 | is covered only if its contents constitute a work based on the Program 79 | (independent of having been made by running the Program). Whether that 80 | is true depends on what the Program does. 81 | 82 | **1.** You may copy and distribute verbatim copies of the Program's 83 | source code as you receive it, in any medium, provided that you 84 | conspicuously and appropriately publish on each copy an appropriate 85 | copyright notice and disclaimer of warranty; keep intact all the 86 | notices that refer to this License and to the absence of any warranty; 87 | and give any other recipients of the Program a copy of this License 88 | along with the Program. 89 | 90 | You may charge a fee for the physical act of transferring a copy, and 91 | you may at your option offer warranty protection in exchange for a 92 | fee. 93 | 94 | **2.** You may modify your copy or copies of the Program or any 95 | portion of it, thus forming a work based on the Program, and copy and 96 | distribute such modifications or work under the terms of Section 1 97 | above, provided that you also meet all of these conditions: 98 | 99 | 100 | **a)** You must cause the modified files to carry prominent notices 101 | stating that you changed the files and the date of any change. 102 | 103 | 104 | **b)** You must cause any work that you distribute or publish, that in 105 | whole or in part contains or is derived from the Program or any part 106 | thereof, to be licensed as a whole at no charge to all third parties 107 | under the terms of this License. 108 | 109 | 110 | **c)** If the modified program normally reads commands interactively 111 | when run, you must cause it, when started running for such interactive 112 | use in the most ordinary way, to print or display an announcement 113 | including an appropriate copyright notice and a notice that there is 114 | no warranty (or else, saying that you provide a warranty) and that 115 | users may redistribute the program under these conditions, and telling 116 | the user how to view a copy of this License. (Exception: if the 117 | Program itself is interactive but does not normally print such an 118 | announcement, your work based on the Program is not required to print 119 | an announcement.) 120 | 121 | These requirements apply to the modified work as a whole. If 122 | identifiable sections of that work are not derived from the Program, 123 | and can be reasonably considered independent and separate works in 124 | themselves, then this License, and its terms, do not apply to those 125 | sections when you distribute them as separate works. But when you 126 | distribute the same sections as part of a whole which is a work based 127 | on the Program, the distribution of the whole must be on the terms of 128 | this License, whose permissions for other licensees extend to the 129 | entire whole, and thus to each and every part regardless of who wrote 130 | it. 131 | 132 | Thus, it is not the intent of this section to claim rights or contest 133 | your rights to work written entirely by you; rather, the intent is to 134 | exercise the right to control the distribution of derivative or 135 | collective works based on the Program. 136 | 137 | In addition, mere aggregation of another work not based on the Program 138 | with the Program (or with a work based on the Program) on a volume of 139 | a storage or distribution medium does not bring the other work under 140 | the scope of this License. 141 | 142 | **3.** You may copy and distribute the Program (or a work based on it, 143 | under Section 2) in object code or executable form under the terms of 144 | Sections 1 and 2 above provided that you also do one of the following: 145 | 146 | 147 | **a)** Accompany it with the complete corresponding machine-readable 148 | source code, which must be distributed under the terms of Sections 1 149 | and 2 above on a medium customarily used for software interchange; or, 150 | 151 | 152 | **b)** Accompany it with a written offer, valid for at least three 153 | years, to give any third party, for a charge no more than your cost of 154 | physically performing source distribution, a complete machine-readable 155 | copy of the corresponding source code, to be distributed under the 156 | terms of Sections 1 and 2 above on a medium customarily used for 157 | software interchange; or, 158 | 159 | 160 | **c)** Accompany it with the information you received as to the offer 161 | to distribute corresponding source code. (This alternative is allowed 162 | only for noncommercial distribution and only if you received the 163 | program in object code or executable form with such an offer, in 164 | accord with Subsection b above.) 165 | 166 | The source code for a work means the preferred form of the work for 167 | making modifications to it. For an executable work, complete source 168 | code means all the source code for all modules it contains, plus any 169 | associated interface definition files, plus the scripts used to 170 | control compilation and installation of the executable. However, as a 171 | special exception, the source code distributed need not include 172 | anything that is normally distributed (in either source or binary 173 | form) with the major components (compiler, kernel, and so on) of the 174 | operating system on which the executable runs, unless that component 175 | itself accompanies the executable. 176 | 177 | If distribution of executable or object code is made by offering 178 | access to copy from a designated place, then offering equivalent 179 | access to copy the source code from the same place counts as 180 | distribution of the source code, even though third parties are not 181 | compelled to copy the source along with the object code. 182 | 183 | **4.** You may not copy, modify, sublicense, or distribute the Program 184 | except as expressly provided under this License. Any attempt otherwise 185 | to copy, modify, sublicense or distribute the Program is void, and 186 | will automatically terminate your rights under this License. However, 187 | parties who have received copies, or rights, from you under this 188 | License will not have their licenses terminated so long as such 189 | parties remain in full compliance. 190 | 191 | **5.** You are not required to accept this License, since you have not 192 | signed it. However, nothing else grants you permission to modify or 193 | distribute the Program or its derivative works. These actions are 194 | prohibited by law if you do not accept this License. Therefore, by 195 | modifying or distributing the Program (or any work based on the 196 | Program), you indicate your acceptance of this License to do so, and 197 | all its terms and conditions for copying, distributing or modifying 198 | the Program or works based on it. 199 | 200 | **6.** Each time you redistribute the Program (or any work based on 201 | the Program), the recipient automatically receives a license from the 202 | original licensor to copy, distribute or modify the Program subject to 203 | these terms and conditions. You may not impose any further 204 | restrictions on the recipients' exercise of the rights granted herein. 205 | You are not responsible for enforcing compliance by third parties to 206 | this License. 207 | 208 | **7.** If, as a consequence of a court judgment or allegation of 209 | patent infringement or for any other reason (not limited to patent 210 | issues), conditions are imposed on you (whether by court order, 211 | agreement or otherwise) that contradict the conditions of this 212 | License, they do not excuse you from the conditions of this License. 213 | If you cannot distribute so as to satisfy simultaneously your 214 | obligations under this License and any other pertinent obligations, 215 | then as a consequence you may not distribute the Program at all. For 216 | example, if a patent license would not permit royalty-free 217 | redistribution of the Program by all those who receive copies directly 218 | or indirectly through you, then the only way you could satisfy both it 219 | and this License would be to refrain entirely from distribution of the 220 | Program. 221 | 222 | If any portion of this section is held invalid or unenforceable under 223 | any particular circumstance, the balance of the section is intended to 224 | apply and the section as a whole is intended to apply in other 225 | circumstances. 226 | 227 | It is not the purpose of this section to induce you to infringe any 228 | patents or other property right claims or to contest validity of any 229 | such claims; this section has the sole purpose of protecting the 230 | integrity of the free software distribution system, which is 231 | implemented by public license practices. Many people have made 232 | generous contributions to the wide range of software distributed 233 | through that system in reliance on consistent application of that 234 | system; it is up to the author/donor to decide if he or she is willing 235 | to distribute software through any other system and a licensee cannot 236 | impose that choice. 237 | 238 | This section is intended to make thoroughly clear what is believed to 239 | be a consequence of the rest of this License. 240 | 241 | **8.** If the distribution and/or use of the Program is restricted in 242 | certain countries either by patents or by copyrighted interfaces, the 243 | original copyright holder who places the Program under this License 244 | may add an explicit geographical distribution limitation excluding 245 | those countries, so that distribution is permitted only in or among 246 | countries not thus excluded. In such case, this License incorporates 247 | the limitation as if written in the body of this License. 248 | 249 | **9.** The Free Software Foundation may publish revised and/or new 250 | versions of the General Public License from time to time. Such new 251 | versions will be similar in spirit to the present version, but may 252 | differ in detail to address new problems or concerns. 253 | 254 | Each version is given a distinguishing version number. If the Program 255 | specifies a version number of this License which applies to it and 256 | "any later version", you have the option of following the terms and 257 | conditions either of that version or of any later version published by 258 | the Free Software Foundation. If the Program does not specify a 259 | version number of this License, you may choose any version ever 260 | published by the Free Software Foundation. 261 | 262 | **10.** If you wish to incorporate parts of the Program into other 263 | free programs whose distribution conditions are different, write to 264 | the author to ask for permission. For software which is copyrighted by 265 | the Free Software Foundation, write to the Free Software Foundation; 266 | we sometimes make exceptions for this. Our decision will be guided by 267 | the two goals of preserving the free status of all derivatives of our 268 | free software and of promoting the sharing and reuse of software 269 | generally. 270 | 271 | **NO WARRANTY** 272 | 273 | **11.** BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO 274 | WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 275 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 276 | OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY 277 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 278 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 279 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 280 | PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME 281 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 282 | 283 | **12.** IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 284 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 285 | AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU 286 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 287 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 288 | PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 289 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 290 | FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF 291 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 292 | DAMAGES. 293 | 294 | ### END OF TERMS AND CONDITIONS 295 | 296 | ### How to Apply These Terms to Your New Programs 297 | 298 | If you develop a new program, and you want it to be of the greatest 299 | possible use to the public, the best way to achieve this is to make it 300 | free software which everyone can redistribute and change under these 301 | terms. 302 | 303 | To do so, attach the following notices to the program. It is safest to 304 | attach them to the start of each source file to most effectively 305 | convey the exclusion of warranty; and each file should have at least 306 | the "copyright" line and a pointer to where the full notice is found. 307 | 308 | one line to give the program's name and an idea of what it does. 309 | Copyright (C) yyyy name of author 310 | 311 | This program is free software; you can redistribute it and/or 312 | modify it under the terms of the GNU General Public License 313 | as published by the Free Software Foundation; either version 2 314 | of the License, or (at your option) any later version. 315 | 316 | This program is distributed in the hope that it will be useful, 317 | but WITHOUT ANY WARRANTY; without even the implied warranty of 318 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 319 | GNU General Public License for more details. 320 | 321 | You should have received a copy of the GNU General Public License 322 | along with this program; if not, write to the Free Software 323 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 324 | 325 | Also add information on how to contact you by electronic and paper 326 | mail. 327 | 328 | If the program is interactive, make it output a short notice like this 329 | when it starts in an interactive mode: 330 | 331 | Gnomovision version 69, Copyright (C) year name of author 332 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details 333 | type `show w'. This is free software, and you are welcome 334 | to redistribute it under certain conditions; type `show c' 335 | for details. 336 | 337 | The hypothetical commands \`show w' and \`show c' should show the 338 | appropriate parts of the General Public License. Of course, the 339 | commands you use may be called something other than \`show w' and 340 | \`show c'; they could even be mouse-clicks or menu items--whatever 341 | suits your program. 342 | 343 | You should also get your employer (if you work as a programmer) or 344 | your school, if any, to sign a "copyright disclaimer" for the program, 345 | if necessary. Here is a sample; alter the names: 346 | 347 | Yoyodyne, Inc., hereby disclaims all copyright 348 | interest in the program `Gnomovision' 349 | (which makes passes at compilers) written 350 | by James Hacker. 351 | 352 | signature of Ty Coon, 1 April 1989 353 | Ty Coon, President of Vice 354 | 355 | This General Public License does not permit incorporating your program 356 | into proprietary programs. If your program is a subroutine library, 357 | you may consider it more useful to permit linking proprietary 358 | applications with the library. If this is what you want to do, use the 359 | [GNU Lesser General Public 360 | License](https://www.gnu.org/licenses/lgpl.html) instead of this 361 | License. 362 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | This work is dual licensed under the [Mozilla Public License version 2.0 (MPL-2.0)](MPL-2.0.md) or the [GNU General Public License v2.0 or later (GPL-2.0)](GPL-2.0.md). 2 | 3 | You can choose between one of them, or both if you use this work. 4 | -------------------------------------------------------------------------------- /MPL-2.0.md: -------------------------------------------------------------------------------- 1 | Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | ### 1. Definitions 5 | 6 | **1.1. “Contributor”** 7 | means each individual or legal entity that creates, contributes to 8 | the creation of, or owns Covered Software. 9 | 10 | **1.2. “Contributor Version”** 11 | means the combination of the Contributions of others (if any) used 12 | by a Contributor and that particular Contributor's Contribution. 13 | 14 | **1.3. “Contribution”** 15 | means Covered Software of a particular Contributor. 16 | 17 | **1.4. “Covered Software”** 18 | means Source Code Form to which the initial Contributor has attached 19 | the notice in Exhibit A, the Executable Form of such Source Code 20 | Form, and Modifications of such Source Code Form, in each case 21 | including portions thereof. 22 | 23 | **1.5. “Incompatible With Secondary Licenses”** 24 | means 25 | 26 | * **(a)** that the initial Contributor has attached the notice described 27 | in Exhibit B to the Covered Software; or 28 | * **(b)** that the Covered Software was made available under the terms of 29 | version 1.1 or earlier of the License, but not also under the 30 | terms of a Secondary License. 31 | 32 | **1.6. “Executable Form”** 33 | means any form of the work other than Source Code Form. 34 | 35 | **1.7. “Larger Work”** 36 | means a work that combines Covered Software with other material, in 37 | a separate file or files, that is not Covered Software. 38 | 39 | **1.8. “License”** 40 | means this document. 41 | 42 | **1.9. “Licensable”** 43 | means having the right to grant, to the maximum extent possible, 44 | whether at the time of the initial grant or subsequently, any and 45 | all of the rights conveyed by this License. 46 | 47 | **1.10. “Modifications”** 48 | means any of the following: 49 | 50 | * **(a)** any file in Source Code Form that results from an addition to, 51 | deletion from, or modification of the contents of Covered 52 | Software; or 53 | * **(b)** any new file in Source Code Form that contains any Covered 54 | Software. 55 | 56 | **1.11. “Patent Claims” of a Contributor** 57 | means any patent claim(s), including without limitation, method, 58 | process, and apparatus claims, in any patent Licensable by such 59 | Contributor that would be infringed, but for the grant of the 60 | License, by the making, using, selling, offering for sale, having 61 | made, import, or transfer of either its Contributions or its 62 | Contributor Version. 63 | 64 | **1.12. “Secondary License”** 65 | means either the GNU General Public License, Version 2.0, the GNU 66 | Lesser General Public License, Version 2.1, the GNU Affero General 67 | Public License, Version 3.0, or any later versions of those 68 | licenses. 69 | 70 | **1.13. “Source Code Form”** 71 | means the form of the work preferred for making modifications. 72 | 73 | **1.14. “You” (or “Your”)** 74 | means an individual or a legal entity exercising rights under this 75 | License. For legal entities, “You” includes any entity that 76 | controls, is controlled by, or is under common control with You. For 77 | purposes of this definition, “control” means **(a)** the power, direct 78 | or indirect, to cause the direction or management of such entity, 79 | whether by contract or otherwise, or **(b)** ownership of more than 80 | fifty percent (50%) of the outstanding shares or beneficial 81 | ownership of such entity. 82 | 83 | 84 | ### 2. License Grants and Conditions 85 | 86 | #### 2.1. Grants 87 | 88 | Each Contributor hereby grants You a world-wide, royalty-free, 89 | non-exclusive license: 90 | 91 | * **(a)** under intellectual property rights (other than patent or trademark) 92 | Licensable by such Contributor to use, reproduce, make available, 93 | modify, display, perform, distribute, and otherwise exploit its 94 | Contributions, either on an unmodified basis, with Modifications, or 95 | as part of a Larger Work; and 96 | * **(b)** under Patent Claims of such Contributor to make, use, sell, offer 97 | for sale, have made, import, and otherwise transfer either its 98 | Contributions or its Contributor Version. 99 | 100 | #### 2.2. Effective Date 101 | 102 | The licenses granted in Section 2.1 with respect to any Contribution 103 | become effective for each Contribution on the date the Contributor first 104 | distributes such Contribution. 105 | 106 | #### 2.3. Limitations on Grant Scope 107 | 108 | The licenses granted in this Section 2 are the only rights granted under 109 | this License. No additional rights or licenses will be implied from the 110 | distribution or licensing of Covered Software under this License. 111 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 112 | Contributor: 113 | 114 | * **(a)** for any code that a Contributor has removed from Covered Software; 115 | or 116 | * **(b)** for infringements caused by: **(i)** Your and any other third party's 117 | modifications of Covered Software, or **(ii)** the combination of its 118 | Contributions with other software (except as part of its Contributor 119 | Version); or 120 | * **(c)** under Patent Claims infringed by Covered Software in the absence of 121 | its Contributions. 122 | 123 | This License does not grant any rights in the trademarks, service marks, 124 | or logos of any Contributor (except as may be necessary to comply with 125 | the notice requirements in Section 3.4). 126 | 127 | #### 2.4. Subsequent Licenses 128 | 129 | No Contributor makes additional grants as a result of Your choice to 130 | distribute the Covered Software under a subsequent version of this 131 | License (see Section 10.2) or under the terms of a Secondary License (if 132 | permitted under the terms of Section 3.3). 133 | 134 | #### 2.5. Representation 135 | 136 | Each Contributor represents that the Contributor believes its 137 | Contributions are its original creation(s) or it has sufficient rights 138 | to grant the rights to its Contributions conveyed by this License. 139 | 140 | #### 2.6. Fair Use 141 | 142 | This License is not intended to limit any rights You have under 143 | applicable copyright doctrines of fair use, fair dealing, or other 144 | equivalents. 145 | 146 | #### 2.7. Conditions 147 | 148 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 149 | in Section 2.1. 150 | 151 | 152 | ### 3. Responsibilities 153 | 154 | #### 3.1. Distribution of Source Form 155 | 156 | All distribution of Covered Software in Source Code Form, including any 157 | Modifications that You create or to which You contribute, must be under 158 | the terms of this License. You must inform recipients that the Source 159 | Code Form of the Covered Software is governed by the terms of this 160 | License, and how they can obtain a copy of this License. You may not 161 | attempt to alter or restrict the recipients' rights in the Source Code 162 | Form. 163 | 164 | #### 3.2. Distribution of Executable Form 165 | 166 | If You distribute Covered Software in Executable Form then: 167 | 168 | * **(a)** such Covered Software must also be made available in Source Code 169 | Form, as described in Section 3.1, and You must inform recipients of 170 | the Executable Form how they can obtain a copy of such Source Code 171 | Form by reasonable means in a timely manner, at a charge no more 172 | than the cost of distribution to the recipient; and 173 | 174 | * **(b)** You may distribute such Executable Form under the terms of this 175 | License, or sublicense it under different terms, provided that the 176 | license for the Executable Form does not attempt to limit or alter 177 | the recipients' rights in the Source Code Form under this License. 178 | 179 | #### 3.3. Distribution of a Larger Work 180 | 181 | You may create and distribute a Larger Work under terms of Your choice, 182 | provided that You also comply with the requirements of this License for 183 | the Covered Software. If the Larger Work is a combination of Covered 184 | Software with a work governed by one or more Secondary Licenses, and the 185 | Covered Software is not Incompatible With Secondary Licenses, this 186 | License permits You to additionally distribute such Covered Software 187 | under the terms of such Secondary License(s), so that the recipient of 188 | the Larger Work may, at their option, further distribute the Covered 189 | Software under the terms of either this License or such Secondary 190 | License(s). 191 | 192 | #### 3.4. Notices 193 | 194 | You may not remove or alter the substance of any license notices 195 | (including copyright notices, patent notices, disclaimers of warranty, 196 | or limitations of liability) contained within the Source Code Form of 197 | the Covered Software, except that You may alter any license notices to 198 | the extent required to remedy known factual inaccuracies. 199 | 200 | #### 3.5. Application of Additional Terms 201 | 202 | You may choose to offer, and to charge a fee for, warranty, support, 203 | indemnity or liability obligations to one or more recipients of Covered 204 | Software. However, You may do so only on Your own behalf, and not on 205 | behalf of any Contributor. You must make it absolutely clear that any 206 | such warranty, support, indemnity, or liability obligation is offered by 207 | You alone, and You hereby agree to indemnify every Contributor for any 208 | liability incurred by such Contributor as a result of warranty, support, 209 | indemnity or liability terms You offer. You may include additional 210 | disclaimers of warranty and limitations of liability specific to any 211 | jurisdiction. 212 | 213 | 214 | ### 4. Inability to Comply Due to Statute or Regulation 215 | 216 | If it is impossible for You to comply with any of the terms of this 217 | License with respect to some or all of the Covered Software due to 218 | statute, judicial order, or regulation then You must: **(a)** comply with 219 | the terms of this License to the maximum extent possible; and **(b)** 220 | describe the limitations and the code they affect. Such description must 221 | be placed in a text file included with all distributions of the Covered 222 | Software under this License. Except to the extent prohibited by statute 223 | or regulation, such description must be sufficiently detailed for a 224 | recipient of ordinary skill to be able to understand it. 225 | 226 | 227 | ### 5. Termination 228 | 229 | **5.1.** The rights granted under this License will terminate automatically 230 | if You fail to comply with any of its terms. However, if You become 231 | compliant, then the rights granted under this License from a particular 232 | Contributor are reinstated **(a)** provisionally, unless and until such 233 | Contributor explicitly and finally terminates Your grants, and **(b)** on an 234 | ongoing basis, if such Contributor fails to notify You of the 235 | non-compliance by some reasonable means prior to 60 days after You have 236 | come back into compliance. Moreover, Your grants from a particular 237 | Contributor are reinstated on an ongoing basis if such Contributor 238 | notifies You of the non-compliance by some reasonable means, this is the 239 | first time You have received notice of non-compliance with this License 240 | from such Contributor, and You become compliant prior to 30 days after 241 | Your receipt of the notice. 242 | 243 | **5.2.** If You initiate litigation against any entity by asserting a patent 244 | infringement claim (excluding declaratory judgment actions, 245 | counter-claims, and cross-claims) alleging that a Contributor Version 246 | directly or indirectly infringes any patent, then the rights granted to 247 | You by any and all Contributors for the Covered Software under Section 248 | 2.1 of this License shall terminate. 249 | 250 | **5.3.** In the event of termination under Sections 5.1 or 5.2 above, all 251 | end user license agreements (excluding distributors and resellers) which 252 | have been validly granted by You or Your distributors under this License 253 | prior to termination shall survive termination. 254 | 255 | 256 | ### 6. Disclaimer of Warranty 257 | 258 | > Covered Software is provided under this License on an “as is” 259 | > basis, without warranty of any kind, either expressed, implied, or 260 | > statutory, including, without limitation, warranties that the 261 | > Covered Software is free of defects, merchantable, fit for a 262 | > particular purpose or non-infringing. The entire risk as to the 263 | > quality and performance of the Covered Software is with You. 264 | > Should any Covered Software prove defective in any respect, You 265 | > (not any Contributor) assume the cost of any necessary servicing, 266 | > repair, or correction. This disclaimer of warranty constitutes an 267 | > essential part of this License. No use of any Covered Software is 268 | > authorized under this License except under this disclaimer. 269 | 270 | ### 7. Limitation of Liability 271 | 272 | > Under no circumstances and under no legal theory, whether tort 273 | > (including negligence), contract, or otherwise, shall any 274 | > Contributor, or anyone who distributes Covered Software as 275 | > permitted above, be liable to You for any direct, indirect, 276 | > special, incidental, or consequential damages of any character 277 | > including, without limitation, damages for lost profits, loss of 278 | > goodwill, work stoppage, computer failure or malfunction, or any 279 | > and all other commercial damages or losses, even if such party 280 | > shall have been informed of the possibility of such damages. This 281 | > limitation of liability shall not apply to liability for death or 282 | > personal injury resulting from such party's negligence to the 283 | > extent applicable law prohibits such limitation. Some 284 | > jurisdictions do not allow the exclusion or limitation of 285 | > incidental or consequential damages, so this exclusion and 286 | > limitation may not apply to You. 287 | 288 | 289 | ### 8. Litigation 290 | 291 | Any litigation relating to this License may be brought only in the 292 | courts of a jurisdiction where the defendant maintains its principal 293 | place of business and such litigation shall be governed by laws of that 294 | jurisdiction, without reference to its conflict-of-law provisions. 295 | Nothing in this Section shall prevent a party's ability to bring 296 | cross-claims or counter-claims. 297 | 298 | 299 | ### 9. Miscellaneous 300 | 301 | This License represents the complete agreement concerning the subject 302 | matter hereof. If any provision of this License is held to be 303 | unenforceable, such provision shall be reformed only to the extent 304 | necessary to make it enforceable. Any law or regulation which provides 305 | that the language of a contract shall be construed against the drafter 306 | shall not be used to construe this License against a Contributor. 307 | 308 | 309 | ### 10. Versions of the License 310 | 311 | #### 10.1. New Versions 312 | 313 | Mozilla Foundation is the license steward. Except as provided in Section 314 | 10.3, no one other than the license steward has the right to modify or 315 | publish new versions of this License. Each version will be given a 316 | distinguishing version number. 317 | 318 | #### 10.2. Effect of New Versions 319 | 320 | You may distribute the Covered Software under the terms of the version 321 | of the License under which You originally received the Covered Software, 322 | or under the terms of any subsequent version published by the license 323 | steward. 324 | 325 | #### 10.3. Modified Versions 326 | 327 | If you create software not governed by this License, and you want to 328 | create a new license for such software, you may create and use a 329 | modified version of this License if you rename the license and remove 330 | any references to the name of the license steward (except to note that 331 | such modified license differs from this License). 332 | 333 | #### 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses 334 | 335 | If You choose to distribute Source Code Form that is Incompatible With 336 | Secondary Licenses under the terms of this version of the License, the 337 | notice described in Exhibit B of this License must be attached. 338 | 339 | ## Exhibit A - Source Code Form License Notice 340 | 341 | This Source Code Form is subject to the terms of the Mozilla Public 342 | License, v. 2.0. If a copy of the MPL was not distributed with this 343 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 344 | 345 | If it is not possible or desirable to put the notice in a particular 346 | file, then You may include the notice in a location (such as a LICENSE 347 | file in a relevant directory) where a recipient would be likely to look 348 | for such a notice. 349 | 350 | You may add additional accurate notices of copyright ownership. 351 | 352 | ## Exhibit B - “Incompatible With Secondary Licenses” Notice 353 | 354 | This Source Code Form is "Incompatible With Secondary Licenses", as 355 | defined by the Mozilla Public License, v. 2.0. 356 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-native-aztec 2 | ## Notice: This repo is no longer maintained. The code from this repo was moved to [the Gutenberg repository](https://github.com/WordPress/gutenberg/tree/trunk/packages/react-native-aztec) and is now maintained there. If you would like to use a Rich Text Editor in your app, please consider using [Gutenberg Mobile](https://github.com/wordpress-mobile/gutenberg-mobile). 3 | 4 | Wrapping Aztec Android and Aztec iOS in a React Native component 5 | 6 | # License 7 | 8 | This work is dual licensed under the [Mozilla Public License version 2.0 (MPL-2.0)](MPL-2.0.md) or the [GNU General Public License v2.0 or later (GPL-2.0)](GPL-2.0.md). 9 | 10 | You can choose between one of them, or both if you use this work. 11 | 12 | ## Android: Run the example app 13 | 14 | Make sure to have an emulator running or an Android device connected, and then: 15 | 16 | ``` 17 | $ cd example/ 18 | $ yarn clean:install 19 | $ yarn android 20 | ``` 21 | 22 | This will build the Android library (via `gradle`) and example app, then launch the main example activity on your connected device and run the Metro bundler at the same time. 23 | 24 | ## iOS: Run the example app 25 | 26 | Before being able to run the Example App, you'll need to install [Carthage](https://github.com/Carthage/Carthage) and the dependencies for this project: 27 | ``` 28 | cd ios 29 | carthage bootstrap --platform iOS 30 | ``` 31 | 32 | Then go back to the root directory of the project and do: 33 | ``` 34 | $ cd example/ 35 | $ yarn clean:install 36 | $ yarn ios 37 | ``` 38 | 39 | This will compile the example project, launch metro, run the simulator and run the app. 40 | 41 | ## FAQ / Troubleshooting 42 | 43 | Q: The example app doesn't run 44 | 45 | A: Make sure you have yarn and babel installed (https://yarnpkg.com/lang/en/docs/install/) 46 | 47 | 48 | Q: The example app gets compiled but ReactNative cannot connect to Metro bundler (I'm on a real device attached through USB) 49 | 50 | A: To debug on the device through USB, remember to revert ports before launching metro: 51 | `adb reverse tcp:8081 tcp:8081` 52 | 53 | 54 | Q: The example app gets compiled but ReactNative shows an error 55 | 56 | A: try running, from the root folder in the project 57 | ``` 58 | $ cd example/ 59 | $ yarn start --reset-cache 60 | ``` 61 | 62 | Open a new shell window and run either of these depending on the platform: 63 | 64 | ``` 65 | $ yarn android 66 | ``` 67 | 68 | or 69 | 70 | ``` 71 | $ yarn ios 72 | ``` 73 | 74 | -------------------------------------------------------------------------------- /RNTAztecView.podspec: -------------------------------------------------------------------------------- 1 | require 'json' 2 | 3 | package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) 4 | 5 | Pod::Spec.new do |s| 6 | s.name = 'RNTAztecView' 7 | s.version = package['version'] 8 | s.summary = 'Aztec editor for React Native' 9 | s.license = package['license'] 10 | s.homepage = 'https://github.com/wordpress-mobile/react-native-aztec' 11 | s.authors = 'Automattic' 12 | s.source = { :git => 'https://github.com/wordpress-mobile/react-native-aztec.git' } 13 | s.source_files = 'ios/RNTAztecView/*.{h,m,swift}' 14 | s.public_header_files = 'ios/RNTAztecView/*.h' 15 | s.requires_arc = true 16 | s.platforms = { :ios => "10.0" } 17 | s.xcconfig = {'OTHER_LDFLAGS' => '-lxml2', 18 | 'HEADER_SEARCH_PATHS' => '/usr/include/libxml2'} 19 | s.dependency 'React' 20 | s.dependency 'WordPress-Aztec-iOS' 21 | 22 | end 23 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | gradlePluginVersion = '3.0.1' 4 | kotlinVersion = '1.2.31' 5 | supportLibVersion = '27.1.1' 6 | tagSoupVersion = '1.2.1' 7 | glideVersion = '3.7.0' 8 | picassoVersion = '2.5.2' 9 | robolectricVersion = '3.5.1' 10 | jUnitVersion = '4.12' 11 | jSoupVersion = '1.10.3' 12 | wordpressUtilsVersion = '1.22' 13 | espressoVersion = '3.0.1' 14 | 15 | aztecVersion = 'v1.3.14' 16 | } 17 | 18 | repositories { 19 | jcenter() 20 | google() 21 | } 22 | 23 | dependencies { 24 | classpath 'com.android.tools.build:gradle:3.1.4' 25 | } 26 | } 27 | 28 | apply plugin: 'com.android.library' 29 | 30 | // import the `readReactNativeVersion()` function 31 | apply from: 'https://gist.githubusercontent.com/hypest/742448b9588b3a0aa580a5e80ae95bdf/raw/8eb62d40ee7a5104d2fcaeff21ce6f29bd93b054/readReactNativeVersion.gradle' 32 | 33 | // The sample build uses multiple directories to 34 | // keep boilerplate and common code separate from 35 | // the main sample code. 36 | List dirs = [ 37 | 'main', // main sample code; look here for the interesting stuff. 38 | 'common', // components that are reused by multiple samples 39 | 'template'] // boilerplate code that is generated by the sample template process 40 | 41 | android { 42 | compileSdkVersion 27 43 | 44 | buildToolsVersion "27.0.3" 45 | 46 | defaultConfig { 47 | minSdkVersion 16 48 | targetSdkVersion 26 49 | 50 | ndk { 51 | abiFilters "armeabi-v7a", "x86" 52 | } 53 | } 54 | 55 | compileOptions { 56 | sourceCompatibility JavaVersion.VERSION_1_7 57 | targetCompatibility JavaVersion.VERSION_1_7 58 | } 59 | 60 | sourceSets { 61 | main { 62 | dirs.each { dir -> 63 | java.srcDirs "src/${dir}/java" 64 | res.srcDirs "src/${dir}/res" 65 | } 66 | } 67 | 68 | androidTest.setRoot('tests') 69 | androidTest.java.srcDirs = ['tests/src'] 70 | } 71 | 72 | lintOptions { 73 | disable 'GradleCompatible' 74 | } 75 | } 76 | 77 | repositories { 78 | jcenter() 79 | google() 80 | 81 | maven { url "https://jitpack.io" } 82 | 83 | if (project == rootProject) { 84 | // if we are the root project, use a remote RN maven repo so jitpack can build this lib without local RN setup 85 | def reactNativeRepo = 'https://dl.bintray.com/wordpress-mobile/react-native-mirror/' 86 | println "Will use the RN maven repo at ${reactNativeRepo}" 87 | maven { url reactNativeRepo } 88 | } 89 | } 90 | 91 | dependencies { 92 | api ("com.github.wordpress-mobile.WordPress-Aztec-Android:aztec:$aztecVersion") 93 | api ("com.github.wordpress-mobile.WordPress-Aztec-Android:wordpress-shortcodes:$aztecVersion") 94 | api ("com.github.wordpress-mobile.WordPress-Aztec-Android:wordpress-comments:$aztecVersion") 95 | api ("com.github.wordpress-mobile.WordPress-Aztec-Android:glide-loader:$aztecVersion") 96 | 97 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" 98 | 99 | implementation "com.android.support:appcompat-v7:$supportLibVersion" 100 | implementation "org.wordpress:utils:$wordpressUtilsVersion" 101 | 102 | implementation "com.android.support:support-v4:$supportLibVersion" 103 | implementation "com.android.support:gridlayout-v7:$supportLibVersion" 104 | implementation "com.android.support:cardview-v7:$supportLibVersion" 105 | implementation "com.android.support:appcompat-v7:$supportLibVersion" 106 | implementation "com.android.support:recyclerview-v7:$supportLibVersion" 107 | 108 | if (project == rootProject) { 109 | def rnVersion = readReactNativeVersion('../package.json', 'peerDependencies') 110 | implementation "com.facebook.react:react-native:${rnVersion}" // From Maven repo 111 | } else { 112 | implementation "com.facebook.react:react-native:+" // From node_modules. 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-aztec/eb7989f8287219b8fff28c5f942bfb1ba4605572/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Sep 08 13:53:18 PDT 2014 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 20 | 21 | -------------------------------------------------------------------------------- /android/src/main/java/org/wordpress/mobile/ReactNativeAztec/ReactAztecBackSpaceEvent.java: -------------------------------------------------------------------------------- 1 | package org.wordpress.mobile.ReactNativeAztec; 2 | 3 | import com.facebook.react.bridge.Arguments; 4 | import com.facebook.react.bridge.WritableMap; 5 | import com.facebook.react.uimanager.events.Event; 6 | import com.facebook.react.uimanager.events.RCTEventEmitter; 7 | 8 | /** 9 | * Event emitted by Aztec native view when Backspace is detected. 10 | */ 11 | class ReactAztecBackspaceEvent extends Event { 12 | 13 | private static final String EVENT_NAME = "topTextInputBackspace"; 14 | 15 | private String mText; 16 | private int mSelectionStart; 17 | private int mSelectionEnd; 18 | 19 | public ReactAztecBackspaceEvent(int viewId, String text, int selectionStart, int selectionEnd) { 20 | super(viewId); 21 | mText = text; 22 | mSelectionStart = selectionStart; 23 | mSelectionEnd = selectionEnd; 24 | } 25 | 26 | @Override 27 | public String getEventName() { 28 | return EVENT_NAME; 29 | } 30 | 31 | @Override 32 | public boolean canCoalesce() { 33 | return false; 34 | } 35 | 36 | @Override 37 | public void dispatch(RCTEventEmitter rctEventEmitter) { 38 | rctEventEmitter.receiveEvent(getViewTag(), getEventName(), serializeEventData()); 39 | } 40 | 41 | private WritableMap serializeEventData() { 42 | WritableMap eventData = Arguments.createMap(); 43 | eventData.putInt("target", getViewTag()); 44 | eventData.putString("text", mText); 45 | eventData.putInt("selectionStart", mSelectionStart); 46 | eventData.putInt("selectionEnd", mSelectionEnd); 47 | return eventData; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /android/src/main/java/org/wordpress/mobile/ReactNativeAztec/ReactAztecBlurEvent.java: -------------------------------------------------------------------------------- 1 | package org.wordpress.mobile.ReactNativeAztec; 2 | 3 | import com.facebook.react.bridge.Arguments; 4 | import com.facebook.react.bridge.WritableMap; 5 | import com.facebook.react.uimanager.events.Event; 6 | import com.facebook.react.uimanager.events.RCTEventEmitter; 7 | 8 | /** 9 | * Event emitted by Aztec native view when it loses focus. 10 | */ 11 | class ReactAztecBlurEvent extends Event { 12 | 13 | private static final String EVENT_NAME = "topBlur"; 14 | 15 | public ReactAztecBlurEvent(int viewId) { 16 | super(viewId); 17 | } 18 | 19 | @Override 20 | public String getEventName() { 21 | return EVENT_NAME; 22 | } 23 | 24 | @Override 25 | public boolean canCoalesce() { 26 | return false; 27 | } 28 | 29 | @Override 30 | public void dispatch(RCTEventEmitter rctEventEmitter) { 31 | rctEventEmitter.receiveEvent(getViewTag(), getEventName(), serializeEventData()); 32 | } 33 | 34 | private WritableMap serializeEventData() { 35 | WritableMap eventData = Arguments.createMap(); 36 | eventData.putInt("target", getViewTag()); 37 | return eventData; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /android/src/main/java/org/wordpress/mobile/ReactNativeAztec/ReactAztecEndEditingEvent.java: -------------------------------------------------------------------------------- 1 | package org.wordpress.mobile.ReactNativeAztec; 2 | 3 | import com.facebook.react.bridge.Arguments; 4 | import com.facebook.react.bridge.WritableMap; 5 | import com.facebook.react.uimanager.events.Event; 6 | import com.facebook.react.uimanager.events.RCTEventEmitter; 7 | 8 | /** 9 | * Event emitted by AztecText native view when text editing ends, 10 | * because of the user leaving the text input. 11 | */ 12 | class ReactAztecEndEditingEvent extends Event { 13 | 14 | private static final String EVENT_NAME = "topEndEditing"; 15 | 16 | private String mText; 17 | 18 | public ReactAztecEndEditingEvent( 19 | int viewId, 20 | String text) { 21 | super(viewId); 22 | mText = text; 23 | } 24 | 25 | @Override 26 | public String getEventName() { 27 | return EVENT_NAME; 28 | } 29 | 30 | @Override 31 | public boolean canCoalesce() { 32 | return false; 33 | } 34 | 35 | @Override 36 | public void dispatch(RCTEventEmitter rctEventEmitter) { 37 | rctEventEmitter.receiveEvent(getViewTag(), getEventName(), serializeEventData()); 38 | } 39 | 40 | private WritableMap serializeEventData() { 41 | WritableMap eventData = Arguments.createMap(); 42 | eventData.putInt("target", getViewTag()); 43 | eventData.putString("text", mText); 44 | return eventData; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /android/src/main/java/org/wordpress/mobile/ReactNativeAztec/ReactAztecEnterEvent.java: -------------------------------------------------------------------------------- 1 | package org.wordpress.mobile.ReactNativeAztec; 2 | 3 | import com.facebook.react.bridge.Arguments; 4 | import com.facebook.react.bridge.WritableMap; 5 | import com.facebook.react.uimanager.events.Event; 6 | import com.facebook.react.uimanager.events.RCTEventEmitter; 7 | 8 | /** 9 | * Event emitted by Aztec native view when KEYCODE_ENTER is detected. 10 | */ 11 | class ReactAztecEnterEvent extends Event { 12 | 13 | private static final String EVENT_NAME = "topTextInputEnter"; 14 | 15 | private String mText; 16 | private int mSelectionStart; 17 | private int mSelectionEnd; 18 | 19 | public ReactAztecEnterEvent(int viewId, String text, int selectionStart, int selectionEnd) { 20 | super(viewId); 21 | mText = text; 22 | mSelectionStart = selectionStart; 23 | mSelectionEnd = selectionEnd; 24 | } 25 | 26 | @Override 27 | public String getEventName() { 28 | return EVENT_NAME; 29 | } 30 | 31 | @Override 32 | public boolean canCoalesce() { 33 | return false; 34 | } 35 | 36 | @Override 37 | public void dispatch(RCTEventEmitter rctEventEmitter) { 38 | rctEventEmitter.receiveEvent(getViewTag(), getEventName(), serializeEventData()); 39 | } 40 | 41 | private WritableMap serializeEventData() { 42 | WritableMap eventData = Arguments.createMap(); 43 | eventData.putInt("target", getViewTag()); 44 | eventData.putString("text", mText); 45 | eventData.putInt("selectionStart", mSelectionStart); 46 | eventData.putInt("selectionEnd", mSelectionEnd); 47 | return eventData; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /android/src/main/java/org/wordpress/mobile/ReactNativeAztec/ReactAztecFocusEvent.java: -------------------------------------------------------------------------------- 1 | package org.wordpress.mobile.ReactNativeAztec; 2 | 3 | import com.facebook.react.bridge.Arguments; 4 | import com.facebook.react.bridge.WritableMap; 5 | import com.facebook.react.uimanager.events.Event; 6 | import com.facebook.react.uimanager.events.RCTEventEmitter; 7 | 8 | /** 9 | * Event emitted by Aztec native view when it receives focus. 10 | */ 11 | class ReactAztecFocusEvent extends Event { 12 | 13 | private static final String EVENT_NAME = "topFocus"; 14 | 15 | public ReactAztecFocusEvent(int viewId) { 16 | super(viewId); 17 | } 18 | 19 | @Override 20 | public String getEventName() { 21 | return EVENT_NAME; 22 | } 23 | 24 | @Override 25 | public boolean canCoalesce() { 26 | return false; 27 | } 28 | 29 | @Override 30 | public void dispatch(RCTEventEmitter rctEventEmitter) { 31 | rctEventEmitter.receiveEvent(getViewTag(), getEventName(), serializeEventData()); 32 | } 33 | 34 | private WritableMap serializeEventData() { 35 | WritableMap eventData = Arguments.createMap(); 36 | eventData.putInt("target", getViewTag()); 37 | return eventData; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /android/src/main/java/org/wordpress/mobile/ReactNativeAztec/ReactAztecFormattingChangeEvent.java: -------------------------------------------------------------------------------- 1 | package org.wordpress.mobile.ReactNativeAztec; 2 | 3 | import com.facebook.react.bridge.Arguments; 4 | import com.facebook.react.bridge.WritableArray; 5 | import com.facebook.react.bridge.WritableMap; 6 | import com.facebook.react.uimanager.events.Event; 7 | import com.facebook.react.uimanager.events.RCTEventEmitter; 8 | 9 | /** 10 | * Event emitted by Aztec native view when it receives focus. 11 | */ 12 | class ReactAztecFormattingChangeEvent extends Event { 13 | 14 | private static final String EVENT_NAME = "topFormatsChanges"; 15 | 16 | private String[] mFormats; 17 | 18 | public ReactAztecFormattingChangeEvent(int viewId, String[] formats) { 19 | super(viewId); 20 | this.mFormats = formats; 21 | } 22 | 23 | @Override 24 | public String getEventName() { 25 | return EVENT_NAME; 26 | } 27 | 28 | @Override 29 | public boolean canCoalesce() { 30 | return false; 31 | } 32 | 33 | @Override 34 | public void dispatch(RCTEventEmitter rctEventEmitter) { 35 | rctEventEmitter.receiveEvent(getViewTag(), getEventName(), serializeEventData()); 36 | } 37 | 38 | private WritableMap serializeEventData() { 39 | WritableMap eventData = Arguments.createMap(); 40 | eventData.putInt("target", getViewTag()); 41 | WritableArray newFormats = Arguments.fromArray(mFormats); 42 | eventData.putArray("formats", newFormats); 43 | return eventData; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /android/src/main/java/org/wordpress/mobile/ReactNativeAztec/ReactAztecPackage.java: -------------------------------------------------------------------------------- 1 | package org.wordpress.mobile.ReactNativeAztec; 2 | 3 | 4 | import com.facebook.react.ReactPackage; 5 | import com.facebook.react.bridge.NativeModule; 6 | import com.facebook.react.bridge.ReactApplicationContext; 7 | import com.facebook.react.uimanager.ViewManager; 8 | 9 | import java.util.ArrayList; 10 | import java.util.Collections; 11 | import java.util.List; 12 | 13 | public class ReactAztecPackage implements ReactPackage { 14 | 15 | @Override 16 | public List createViewManagers(ReactApplicationContext reactContext) { 17 | List views = new ArrayList<>(); 18 | views.add(new ReactAztecManager()); 19 | return views; 20 | } 21 | 22 | @Override 23 | public List createNativeModules(ReactApplicationContext reactContext) { 24 | return Collections.emptyList(); 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /android/src/main/java/org/wordpress/mobile/ReactNativeAztec/ReactAztecSelectionChangeEvent.java: -------------------------------------------------------------------------------- 1 | package org.wordpress.mobile.ReactNativeAztec; 2 | 3 | import com.facebook.react.bridge.Arguments; 4 | import com.facebook.react.bridge.WritableArray; 5 | import com.facebook.react.bridge.WritableMap; 6 | import com.facebook.react.uimanager.events.Event; 7 | import com.facebook.react.uimanager.events.RCTEventEmitter; 8 | 9 | /** 10 | * Event emitted by Aztec native view when selection changes. 11 | */ 12 | class ReactAztecSelectionChangeEvent extends Event { 13 | 14 | private static final String EVENT_NAME = "topSelectionChange"; 15 | 16 | private String mText; 17 | private int mSelectionStart; 18 | private int mSelectionEnd; 19 | 20 | public ReactAztecSelectionChangeEvent(int viewId, String text, int selectionStart, int selectionEnd) { 21 | super(viewId); 22 | mText = text; 23 | mSelectionStart = selectionStart; 24 | mSelectionEnd = selectionEnd; 25 | } 26 | 27 | @Override 28 | public String getEventName() { 29 | return EVENT_NAME; 30 | } 31 | 32 | @Override 33 | public boolean canCoalesce() { 34 | return false; 35 | } 36 | 37 | @Override 38 | public void dispatch(RCTEventEmitter rctEventEmitter) { 39 | rctEventEmitter.receiveEvent(getViewTag(), getEventName(), serializeEventData()); 40 | } 41 | 42 | private WritableMap serializeEventData() { 43 | WritableMap eventData = Arguments.createMap(); 44 | eventData.putInt("target", getViewTag()); 45 | eventData.putString("text", mText); 46 | eventData.putInt("selectionStart", mSelectionStart); 47 | eventData.putInt("selectionEnd", mSelectionEnd); 48 | return eventData; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /android/src/main/java/org/wordpress/mobile/ReactNativeAztec/ReactAztecText.java: -------------------------------------------------------------------------------- 1 | package org.wordpress.mobile.ReactNativeAztec; 2 | 3 | import android.content.Context; 4 | import android.graphics.Rect; 5 | import android.support.annotation.Nullable; 6 | import android.text.Editable; 7 | import android.text.InputType; 8 | import android.text.TextWatcher; 9 | import android.view.inputmethod.InputMethodManager; 10 | 11 | import com.facebook.infer.annotation.Assertions; 12 | import com.facebook.react.bridge.ReactContext; 13 | import com.facebook.react.uimanager.ThemedReactContext; 14 | import com.facebook.react.uimanager.UIManagerModule; 15 | import com.facebook.react.uimanager.events.EventDispatcher; 16 | import com.facebook.react.views.textinput.ContentSizeWatcher; 17 | import com.facebook.react.views.textinput.ReactTextChangedEvent; 18 | import com.facebook.react.views.textinput.ReactTextInputLocalData; 19 | import com.facebook.react.views.textinput.ScrollWatcher; 20 | 21 | import org.wordpress.aztec.AztecText; 22 | import org.wordpress.aztec.AztecTextFormat; 23 | import org.wordpress.aztec.ITextFormat; 24 | import org.wordpress.aztec.plugins.IAztecPlugin; 25 | import org.wordpress.aztec.plugins.IToolbarButton; 26 | 27 | import java.util.ArrayList; 28 | import java.util.LinkedList; 29 | 30 | public class ReactAztecText extends AztecText { 31 | 32 | private final InputMethodManager mInputMethodManager; 33 | // This flag is set to true when we set the text of the EditText explicitly. In that case, no 34 | // *TextChanged events should be triggered. This is less expensive than removing the text 35 | // listeners and adding them back again after the text change is completed. 36 | private boolean mIsSettingTextFromJS = false; 37 | // This component is controlled, so we want it to get focused only when JS ask it to do so. 38 | // Whenever android requests focus (which it does for random reasons), it will be ignored. 39 | private boolean mIsJSSettingFocus = false; 40 | private @Nullable ArrayList mListeners; 41 | private @Nullable TextWatcherDelegator mTextWatcherDelegator; 42 | private @Nullable ContentSizeWatcher mContentSizeWatcher; 43 | private @Nullable ScrollWatcher mScrollWatcher; 44 | 45 | // FIXME: Used in `incrementAndGetEventCounter` but never read. I guess we can get rid of it, but before this 46 | // check when it's used in EditText in RN. (maybe tests?) 47 | int mNativeEventCount = 0; 48 | 49 | String lastSentFormattingOptionsEventString = ""; 50 | boolean shouldHandleOnEnter = false; 51 | boolean shouldHandleOnBackspace = false; 52 | boolean shouldHandleOnSelectionChange = false; 53 | boolean shouldHandleActiveFormatsChange = false; 54 | 55 | public ReactAztecText(ThemedReactContext reactContext) { 56 | super(reactContext); 57 | this.setAztecKeyListener(new ReactAztecText.OnAztecKeyListener() { 58 | @Override 59 | public boolean onEnterKey() { 60 | if (shouldHandleOnEnter) { 61 | return onEnter(); 62 | } 63 | return false; 64 | } 65 | @Override 66 | public boolean onBackspaceKey() { 67 | if (shouldHandleOnBackspace) { 68 | return onBackspace(); 69 | } 70 | return false; 71 | } 72 | }); 73 | mInputMethodManager = (InputMethodManager) 74 | Assertions.assertNotNull(getContext().getSystemService(Context.INPUT_METHOD_SERVICE)); 75 | this.setOnSelectionChangedListener(new OnSelectionChangedListener() { 76 | @Override 77 | public void onSelectionChanged(int selStart, int selEnd) { 78 | ReactAztecText.this.updateToolbarButtons(selStart, selEnd); 79 | ReactAztecText.this.propagateSelectionChanges(selStart, selEnd); 80 | } 81 | }); 82 | this.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE); 83 | } 84 | 85 | @Override 86 | public void refreshText() { 87 | super.refreshText(); 88 | onContentSizeChange(); 89 | } 90 | 91 | void addPlugin(IAztecPlugin plugin) { 92 | super.getPlugins().add(plugin); 93 | if (plugin instanceof IToolbarButton && getToolbar() != null ) { 94 | getToolbar().addButton((IToolbarButton)plugin); 95 | } 96 | } 97 | 98 | // VisibleForTesting from {@link TextInputEventsTestCase}. 99 | public void requestFocusFromJS() { 100 | mIsJSSettingFocus = true; 101 | requestFocus(); 102 | mIsJSSettingFocus = false; 103 | } 104 | 105 | void clearFocusFromJS() { 106 | clearFocus(); 107 | } 108 | 109 | @Override 110 | public void clearFocus() { 111 | setFocusableInTouchMode(false); 112 | super.clearFocus(); 113 | hideSoftKeyboard(); 114 | } 115 | 116 | @Override 117 | public boolean requestFocus(int direction, Rect previouslyFocusedRect) { 118 | // Always return true if we are already focused. This is used by android in certain places, 119 | // such as text selection. 120 | if (isFocused()) { 121 | return true; 122 | } 123 | //TODO check why it's needed - doesn't seem to work fine with this in it, since each focus call 124 | // from the Android FW is skipped here. 125 | /*if (!mIsJSSettingFocus) { 126 | return false; 127 | }*/ 128 | setFocusableInTouchMode(true); 129 | boolean focused = super.requestFocus(direction, previouslyFocusedRect); 130 | showSoftKeyboard(); 131 | return focused; 132 | } 133 | 134 | private boolean showSoftKeyboard() { 135 | return mInputMethodManager.showSoftInput(this, 0); 136 | } 137 | 138 | private void hideSoftKeyboard() { 139 | mInputMethodManager.hideSoftInputFromWindow(getWindowToken(), 0); 140 | } 141 | 142 | public void setScrollWatcher(ScrollWatcher scrollWatcher) { 143 | mScrollWatcher = scrollWatcher; 144 | } 145 | 146 | @Override 147 | protected void onScrollChanged(int horiz, int vert, int oldHoriz, int oldVert) { 148 | super.onScrollChanged(horiz, vert, oldHoriz, oldVert); 149 | 150 | if (mScrollWatcher != null) { 151 | mScrollWatcher.onScrollChanged(horiz, vert, oldHoriz, oldVert); 152 | } 153 | } 154 | 155 | public void setContentSizeWatcher(ContentSizeWatcher contentSizeWatcher) { 156 | mContentSizeWatcher = contentSizeWatcher; 157 | } 158 | 159 | private void onContentSizeChange() { 160 | if (mContentSizeWatcher != null) { 161 | new java.util.Timer().schedule( 162 | new java.util.TimerTask() { 163 | @Override 164 | public void run() { 165 | if (mContentSizeWatcher != null) { 166 | mContentSizeWatcher.onLayout(); 167 | 168 | } 169 | } 170 | }, 171 | 500 172 | ); 173 | } 174 | setIntrinsicContentSize(); 175 | } 176 | 177 | private void updateToolbarButtons(int selStart, int selEnd) { 178 | ArrayList appliedStyles = getAppliedStyles(selStart, selEnd); 179 | updateToolbarButtons(appliedStyles); 180 | } 181 | 182 | private void updateToolbarButtons(ArrayList appliedStyles) { 183 | // Read the applied styles and get the String list of formatting options 184 | LinkedList formattingOptions = new LinkedList<>(); 185 | for (ITextFormat currentStyle : appliedStyles) { 186 | if ((currentStyle == AztecTextFormat.FORMAT_STRONG || currentStyle == AztecTextFormat.FORMAT_BOLD) 187 | && !formattingOptions.contains("bold")) { 188 | formattingOptions.add("bold"); 189 | } 190 | if ((currentStyle == AztecTextFormat.FORMAT_ITALIC || currentStyle == AztecTextFormat.FORMAT_CITE) 191 | && !formattingOptions.contains("italic")) { 192 | formattingOptions.add("italic"); 193 | } 194 | if (currentStyle == AztecTextFormat.FORMAT_STRIKETHROUGH) { 195 | formattingOptions.add("strikethrough"); 196 | } 197 | } 198 | 199 | // Check if the same formatting event was already sent 200 | String newOptionsAsString = ""; 201 | for (String currentFormatting: formattingOptions) { 202 | newOptionsAsString += currentFormatting; 203 | } 204 | if (newOptionsAsString.equals(lastSentFormattingOptionsEventString)) { 205 | // no need to send any event now 206 | return; 207 | } 208 | lastSentFormattingOptionsEventString = newOptionsAsString; 209 | 210 | if (shouldHandleActiveFormatsChange) { 211 | ReactContext reactContext = (ReactContext) getContext(); 212 | EventDispatcher eventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher(); 213 | eventDispatcher.dispatchEvent( 214 | new ReactAztecFormattingChangeEvent( 215 | getId(), 216 | formattingOptions.toArray(new String[formattingOptions.size()]) 217 | ) 218 | ); 219 | } 220 | } 221 | 222 | private void propagateSelectionChanges(int selStart, int selEnd) { 223 | if (!shouldHandleOnSelectionChange) { 224 | return; 225 | } 226 | String content = toHtml(false); 227 | ReactContext reactContext = (ReactContext) getContext(); 228 | EventDispatcher eventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher(); 229 | eventDispatcher.dispatchEvent( 230 | new ReactAztecSelectionChangeEvent(getId(), content, selStart, selEnd) 231 | ); 232 | } 233 | 234 | @Override 235 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) { 236 | onContentSizeChange(); 237 | } 238 | 239 | private void setIntrinsicContentSize() { 240 | ReactContext reactContext = (ReactContext) getContext(); 241 | UIManagerModule uiManager = reactContext.getNativeModule(UIManagerModule.class); 242 | final ReactTextInputLocalData localData = new ReactTextInputLocalData(this); 243 | uiManager.setViewLocalData(getId(), localData); 244 | } 245 | 246 | //// Text changed events 247 | 248 | public int incrementAndGetEventCounter() { 249 | return ++mNativeEventCount; 250 | } 251 | 252 | @Override 253 | public void addTextChangedListener(TextWatcher watcher) { 254 | if (mListeners == null) { 255 | mListeners = new ArrayList<>(); 256 | super.addTextChangedListener(getTextWatcherDelegator()); 257 | } 258 | 259 | mListeners.add(watcher); 260 | } 261 | 262 | @Override 263 | public void removeTextChangedListener(TextWatcher watcher) { 264 | if (mListeners != null) { 265 | mListeners.remove(watcher); 266 | 267 | if (mListeners.isEmpty()) { 268 | mListeners = null; 269 | super.removeTextChangedListener(getTextWatcherDelegator()); 270 | } 271 | } 272 | } 273 | 274 | private TextWatcherDelegator getTextWatcherDelegator() { 275 | if (mTextWatcherDelegator == null) { 276 | mTextWatcherDelegator = new TextWatcherDelegator(); 277 | } 278 | return mTextWatcherDelegator; 279 | } 280 | 281 | public void setIsSettingTextFromJS(boolean mIsSettingTextFromJS) { 282 | this.mIsSettingTextFromJS = mIsSettingTextFromJS; 283 | } 284 | 285 | private boolean onEnter() { 286 | disableTextChangedListener(); 287 | String content = toHtml(false); 288 | int cursorPositionStart = getSelectionStart(); 289 | int cursorPositionEnd = getSelectionEnd(); 290 | enableTextChangedListener(); 291 | ReactContext reactContext = (ReactContext) getContext(); 292 | EventDispatcher eventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher(); 293 | eventDispatcher.dispatchEvent( 294 | new ReactAztecEnterEvent(getId(), content, cursorPositionStart, cursorPositionEnd) 295 | ); 296 | return true; 297 | } 298 | 299 | private boolean onBackspace() { 300 | int cursorPositionStart = getSelectionStart(); 301 | int cursorPositionEnd = getSelectionEnd(); 302 | // Make sure to report backspace at the beginning only, with no selection. 303 | if (cursorPositionStart != 0 || cursorPositionEnd != 0) { 304 | return false; 305 | } 306 | 307 | disableTextChangedListener(); 308 | String content = toHtml(false); 309 | enableTextChangedListener(); 310 | ReactContext reactContext = (ReactContext) getContext(); 311 | EventDispatcher eventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher(); 312 | // TODO: isRTL? Should be passed here? 313 | eventDispatcher.dispatchEvent( 314 | new ReactAztecBackspaceEvent(getId(), content, cursorPositionStart, cursorPositionEnd) 315 | ); 316 | return true; 317 | } 318 | 319 | public void applyFormat(String format) { 320 | ArrayList newFormats = new ArrayList<>(); 321 | switch (format) { 322 | case ("bold"): 323 | case ("strong"): 324 | newFormats.add(AztecTextFormat.FORMAT_STRONG); 325 | newFormats.add(AztecTextFormat.FORMAT_BOLD); 326 | break; 327 | case ("italic"): 328 | newFormats.add(AztecTextFormat.FORMAT_ITALIC); 329 | newFormats.add(AztecTextFormat.FORMAT_CITE); 330 | break; 331 | case ("strikethrough"): 332 | newFormats.add(AztecTextFormat.FORMAT_STRIKETHROUGH); 333 | break; 334 | } 335 | 336 | if (newFormats.size() == 0) { 337 | return; 338 | } 339 | 340 | if (!isTextSelected()) { 341 | final ArrayList newStylesList = getNewStylesList(newFormats); 342 | setSelectedStyles(newStylesList); 343 | // Update the toolbar state 344 | updateToolbarButtons(newStylesList); 345 | } else { 346 | toggleFormatting(newFormats.get(0)); 347 | // Update the toolbar state 348 | updateToolbarButtons(getSelectionStart(), getSelectionEnd()); 349 | } 350 | 351 | // emit onChange because the underlying HTML has changed applying the style 352 | ReactContext reactContext = (ReactContext) getContext(); 353 | EventDispatcher eventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher(); 354 | eventDispatcher.dispatchEvent( 355 | new ReactTextChangedEvent( 356 | getId(), 357 | toHtml(false), 358 | incrementAndGetEventCounter()) 359 | ); 360 | } 361 | 362 | // Removes all formats in the list but if none found, applies the first one 363 | private ArrayList getNewStylesList(ArrayList newFormats) { 364 | ArrayList textFormats = new ArrayList<>(); 365 | textFormats.addAll(getSelectedStyles()); 366 | boolean wasRemoved = false; 367 | for (ITextFormat newFormat : newFormats) { 368 | if (textFormats.contains(newFormat)) { 369 | wasRemoved = true; 370 | textFormats.remove(newFormat); 371 | } 372 | } 373 | 374 | if (!wasRemoved) { 375 | textFormats.add(newFormats.get(0)); 376 | } 377 | 378 | return textFormats; 379 | } 380 | 381 | /** 382 | * This class will redirect *TextChanged calls to the listeners only in the case where the text 383 | * is changed by the user, and not explicitly set by JS. 384 | */ 385 | private class TextWatcherDelegator implements TextWatcher { 386 | @Override 387 | public void beforeTextChanged(CharSequence s, int start, int count, int after) { 388 | if (!mIsSettingTextFromJS && mListeners != null) { 389 | for (TextWatcher listener : mListeners) { 390 | listener.beforeTextChanged(s, start, count, after); 391 | } 392 | } 393 | } 394 | 395 | @Override 396 | public void onTextChanged(CharSequence s, int start, int before, int count) { 397 | if (!mIsSettingTextFromJS && mListeners != null) { 398 | for (TextWatcher listener : mListeners) { 399 | listener.onTextChanged(s, start, before, count); 400 | } 401 | } 402 | 403 | onContentSizeChange(); 404 | } 405 | 406 | @Override 407 | public void afterTextChanged(Editable s) { 408 | if (!mIsSettingTextFromJS && mListeners != null) { 409 | for (TextWatcher listener : mListeners) { 410 | listener.afterTextChanged(s); 411 | } 412 | } 413 | } 414 | } 415 | } 416 | -------------------------------------------------------------------------------- /android/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-aztec/eb7989f8287219b8fff28c5f942bfb1ba4605572/android/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-aztec/eb7989f8287219b8fff28c5f942bfb1ba4605572/android/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-aztec/eb7989f8287219b8fff28c5f942bfb1ba4605572/android/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-aztec/eb7989f8287219b8fff28c5f942bfb1ba4605572/android/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/src/main/res/values/bools.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | false 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/src/main/res/values/integers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 0 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | Aztec React Native example 20 | -------------------------------------------------------------------------------- /android/src/main/res/values/template-dimens.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 8dp 22 | 16dp 23 | 32dp 24 | 25 | 26 | -------------------------------------------------------------------------------- /example/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["module:metro-react-native-babel-preset"] 3 | } 4 | -------------------------------------------------------------------------------- /example/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {AppRegistry, StyleSheet, TextInput, FlatList, KeyboardAvoidingView, SafeAreaView, Platform} from 'react-native'; 3 | import {example_content} from './content'; 4 | import Editor from './editor' 5 | 6 | const _minHeight = 100; 7 | 8 | const sampleContent = example_content(); 9 | 10 | const elements = [ 11 | {key: '1', text: sampleContent, height: _minHeight}, 12 | {key: '2', text: sampleContent, height: _minHeight}, 13 | {key: '3', text: sampleContent, height: _minHeight}, 14 | {key: '4', text: sampleContent, height: _minHeight}, 15 | {key: '5', text: sampleContent, height: _minHeight}, 16 | {key: '6', text: sampleContent, height: _minHeight}, 17 | ] 18 | 19 | export default class example extends React.Component { 20 | constructor(props) { 21 | super(props); 22 | this.renderItem = this.renderItem.bind(this) 23 | this.renderItemAsTextInput = this.renderItemAsTextInput.bind(this) 24 | this.state = {isShowingText: true, data: elements}; 25 | } 26 | 27 | renderItem( { item } ) { 28 | const key = item.key; 29 | return ( 30 | { 33 | let newHeight = contentSize.height; 34 | const newElements = this.state.data.map( searchItem => { 35 | if (searchItem.key == key) { 36 | return {...searchItem, height: newHeight}; 37 | } else { 38 | return searchItem; 39 | } 40 | }) 41 | this.setState( { data: newElements}) 42 | }} 43 | /> 44 | ) 45 | } 46 | 47 | renderItemAsTextInput( { item } ) { 48 | return ( 52 | ) 53 | } 54 | 55 | render() { 56 | const data = this.state.data; 57 | const mainContent = ( 58 | 59 | 63 | 64 | ); 65 | if (Platform.OS === "ios") { 66 | return ({mainContent}) 67 | } else { 68 | return mainContent 69 | } 70 | } 71 | } 72 | 73 | var styles = StyleSheet.create({ 74 | container: { 75 | flex: 1 76 | }, 77 | aztec_editor: { 78 | minHeight: _minHeight, 79 | margin: 10, 80 | }, 81 | }); 82 | 83 | AppRegistry.registerComponent('example', () => example); 84 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | /** 4 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 5 | * and bundleReleaseJsAndAssets). 6 | * These basically call `react-native bundle` with the correct arguments during the Android build 7 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 8 | * bundle directly from the development server. Below you can see all the possible configurations 9 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 10 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 11 | * 12 | * project.ext.react = [ 13 | * // the name of the generated asset file containing your JS bundle 14 | * bundleAssetName: "index.android.bundle", 15 | * 16 | * // the entry file for bundle generation 17 | * entryFile: "index.android.js", 18 | * 19 | * // whether to bundle JS and assets in debug mode 20 | * bundleInDebug: false, 21 | * 22 | * // whether to bundle JS and assets in release mode 23 | * bundleInRelease: true, 24 | * 25 | * // whether to bundle JS and assets in another build variant (if configured). 26 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 27 | * // The configuration property can be in the following formats 28 | * // 'bundleIn${productFlavor}${buildType}' 29 | * // 'bundleIn${buildType}' 30 | * // bundleInFreeDebug: true, 31 | * // bundleInPaidRelease: true, 32 | * // bundleInBeta: true, 33 | * 34 | * // whether to disable dev mode in custom build variants (by default only disabled in release) 35 | * // for example: to disable dev mode in the staging build type (if configured) 36 | * devDisabledInStaging: true, 37 | * // The configuration property can be in the following formats 38 | * // 'devDisabledIn${productFlavor}${buildType}' 39 | * // 'devDisabledIn${buildType}' 40 | * 41 | * // the root of your project, i.e. where "package.json" lives 42 | * root: "../../", 43 | * 44 | * // where to put the JS bundle asset in debug mode 45 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 46 | * 47 | * // where to put the JS bundle asset in release mode 48 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 49 | * 50 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 51 | * // require('./image.png')), in debug mode 52 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 53 | * 54 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 55 | * // require('./image.png')), in release mode 56 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 57 | * 58 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 59 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 60 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 61 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 62 | * // for example, you might want to remove it from here. 63 | * inputExcludes: ["android/**", "ios/**"], 64 | * 65 | * // override which node gets called and with what additional arguments 66 | * nodeExecutableAndArgs: ["node"], 67 | * 68 | * // supply additional arguments to the packager 69 | * extraPackagerArgs: [] 70 | * ] 71 | */ 72 | 73 | project.ext.react = [ 74 | entryFile: "index.js" 75 | ] 76 | 77 | apply from: "../../node_modules/react-native/react.gradle" 78 | 79 | // The sample build uses multiple directories to 80 | // keep boilerplate and common code separate from 81 | // the main sample code. 82 | List dirs = [ 83 | 'main', // main sample code; look here for the interesting stuff. 84 | 'common', // components that are reused by multiple samples 85 | 'template'] // boilerplate code that is generated by the sample template process 86 | 87 | android { 88 | compileSdkVersion 27 89 | 90 | buildToolsVersion "27.0.3" 91 | 92 | defaultConfig { 93 | minSdkVersion 16 94 | targetSdkVersion 26 95 | 96 | ndk { 97 | abiFilters "armeabi-v7a", "x86" 98 | } 99 | } 100 | 101 | compileOptions { 102 | sourceCompatibility JavaVersion.VERSION_1_7 103 | targetCompatibility JavaVersion.VERSION_1_7 104 | } 105 | 106 | sourceSets { 107 | main { 108 | dirs.each { dir -> 109 | java.srcDirs "src/${dir}/java" 110 | res.srcDirs "src/${dir}/res" 111 | } 112 | } 113 | 114 | androidTest.setRoot('tests') 115 | androidTest.java.srcDirs = ['tests/src'] 116 | } 117 | 118 | lintOptions { 119 | disable 'GradleCompatible' 120 | } 121 | } 122 | 123 | buildscript { 124 | repositories { 125 | jcenter() 126 | google() 127 | } 128 | 129 | dependencies { 130 | classpath 'com.android.tools.build:gradle:3.1.4' 131 | } 132 | } 133 | 134 | repositories { 135 | jcenter() 136 | google() 137 | maven { url "https://jitpack.io" } 138 | } 139 | 140 | dependencies { 141 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" 142 | 143 | implementation "com.android.support:appcompat-v7:$supportLibVersion" 144 | implementation "org.wordpress:utils:$wordpressUtilsVersion" 145 | 146 | implementation project(':react-native-aztec') 147 | 148 | implementation "com.android.support:support-v4:$supportLibVersion" 149 | implementation "com.android.support:gridlayout-v7:$supportLibVersion" 150 | implementation "com.android.support:cardview-v7:$supportLibVersion" 151 | implementation "com.android.support:appcompat-v7:$supportLibVersion" 152 | implementation "com.android.support:recyclerview-v7:$supportLibVersion" 153 | 154 | implementation "com.facebook.react:react-native:+" // From node_modules. 155 | } 156 | 157 | 158 | 159 | 160 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 31 | 32 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/example/android/MainActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | package com.example.android; 19 | 20 | import android.os.Bundle; 21 | import android.support.v4.app.FragmentTransaction; 22 | import android.view.KeyEvent; 23 | 24 | import com.example.android.common.activities.SampleRNBaseActivity; 25 | 26 | /** 27 | * A simple launcher activity containing a summary sample description, sample log and a custom 28 | * {@link android.support.v4.app.Fragment} which can display a view. 29 | *

30 | * For devices with displays with a width of 720dp or greater, the sample log is always visible, 31 | * on other devices it's visibility is controlled by an item on the Action Bar. 32 | */ 33 | public class MainActivity extends SampleRNBaseActivity { 34 | 35 | public static final String TAG = "MainActivity"; 36 | 37 | @Override 38 | protected void onCreate(Bundle savedInstanceState) { 39 | super.onCreate(savedInstanceState); 40 | setContentView(R.layout.activity_main); 41 | 42 | if (savedInstanceState == null) { 43 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); 44 | MyFragment fragment = new MyFragment(); 45 | transaction.replace(R.id.sample_content_fragment, fragment); 46 | transaction.commit(); 47 | } 48 | } 49 | 50 | @Override 51 | public boolean onKeyUp(int keyCode, KeyEvent event) { 52 | if (keyCode == KeyEvent.KEYCODE_MENU && mReactInstanceManager != null) { 53 | mReactInstanceManager.showDevOptionsDialog(); 54 | return true; 55 | } 56 | return super.onKeyUp(keyCode, event); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/example/android/MyFragment.java: -------------------------------------------------------------------------------- 1 | package com.example.android; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import com.example.android.common.activities.SampleRNBaseActivity; 11 | import com.facebook.react.ReactInstanceManager; 12 | import com.facebook.react.ReactRootView; 13 | 14 | public class MyFragment extends Fragment { 15 | 16 | private static final String TAG = "MyFragment"; 17 | 18 | private ReactInstanceManager mReactInstanceManager; 19 | 20 | @Override 21 | public void onAttach(Activity activity) { 22 | super.onAttach(activity); 23 | try { 24 | mReactInstanceManager = ((SampleRNBaseActivity) activity).getReactInstanceManager(); 25 | } catch (ClassCastException e) { 26 | throw new ClassCastException(activity.toString() + " must extends SampleRNBaseActivity"); 27 | } 28 | } 29 | 30 | @Override 31 | public void onCreate(Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | } 34 | 35 | @Override 36 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 37 | if (mReactInstanceManager == null) { 38 | try { 39 | mReactInstanceManager = ((SampleRNBaseActivity) getActivity()).getReactInstanceManager(); 40 | } catch (ClassCastException e) { 41 | throw new ClassCastException(getActivity().toString() + " must extends SampleRNBaseActivity"); 42 | } 43 | } 44 | 45 | ReactRootView reactRootView = new ReactRootView(getContext()); 46 | reactRootView.startReactApplication(mReactInstanceManager, "example", null); 47 | return reactRootView; 48 | } 49 | 50 | @Override 51 | public void onSaveInstanceState(Bundle savedInstanceState) { 52 | super.onSaveInstanceState(savedInstanceState); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/example/android/common/activities/SampleRNBaseActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.android.common.activities; 18 | 19 | import android.os.Bundle; 20 | import android.support.v4.app.FragmentActivity; 21 | 22 | import org.wordpress.mobile.ReactNativeAztec.ReactAztecPackage; 23 | import org.wordpress.mobile.ReactNativeAztec.BuildConfig; 24 | import com.facebook.react.ReactInstanceManager; 25 | import com.facebook.react.common.LifecycleState; 26 | import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler; 27 | import com.facebook.react.shell.MainReactPackage; 28 | 29 | /** 30 | * Base launcher activity, to handle most of the common plumbing for samples. 31 | */ 32 | public class SampleRNBaseActivity extends FragmentActivity implements DefaultHardwareBackBtnHandler { 33 | 34 | public static final String TAG = "SampleRNBaseActivity"; 35 | protected ReactInstanceManager mReactInstanceManager; 36 | 37 | @Override 38 | protected void onCreate(Bundle savedInstanceState) { 39 | super.onCreate(savedInstanceState); 40 | mReactInstanceManager = ReactInstanceManager.builder() 41 | .setApplication(getApplication()) 42 | .setBundleAssetName("index.android.bundle") 43 | .setJSMainModulePath("index") 44 | .addPackage(new MainReactPackage()) 45 | .addPackage(new ReactAztecPackage()) 46 | .setUseDeveloperSupport(BuildConfig.DEBUG) 47 | .setInitialLifecycleState(LifecycleState.RESUMED) 48 | .build(); 49 | } 50 | 51 | public ReactInstanceManager getReactInstanceManager() { 52 | return mReactInstanceManager; 53 | } 54 | 55 | @Override 56 | protected void onPause() { 57 | super.onPause(); 58 | 59 | if (mReactInstanceManager != null) { 60 | mReactInstanceManager.onHostPause(this); 61 | } 62 | } 63 | 64 | @Override 65 | protected void onResume() { 66 | super.onResume(); 67 | 68 | if (mReactInstanceManager != null) { 69 | mReactInstanceManager.onHostResume(this, this); 70 | } 71 | } 72 | 73 | @Override 74 | protected void onDestroy() { 75 | super.onDestroy(); 76 | 77 | if (mReactInstanceManager != null) { 78 | mReactInstanceManager.onHostDestroy(this); 79 | } 80 | } 81 | 82 | @Override 83 | public void invokeDefaultOnBackPressed() { 84 | super.onBackPressed(); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-aztec/eb7989f8287219b8fff28c5f942bfb1ba4605572/example/android/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-hdpi/tile.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-aztec/eb7989f8287219b8fff28c5f942bfb1ba4605572/example/android/app/src/main/res/drawable-hdpi/tile.9.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-aztec/eb7989f8287219b8fff28c5f942bfb1ba4605572/example/android/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-aztec/eb7989f8287219b8fff28c5f942bfb1ba4605572/example/android/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-aztec/eb7989f8287219b8fff28c5f942bfb1ba4605572/example/android/app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/ic_reorder_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/layout-w720dp/activity_main.xml: -------------------------------------------------------------------------------- 1 | 16 | 22 | 23 | 27 | 28 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 16 | 22 | 23 | 27 | 28 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 |

20 | 23 | 24 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values-sw600dp/template-dimens.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | @dimen/margin_huge 22 | @dimen/margin_medium 23 | 24 | 25 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values-sw600dp/template-styles.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | #00BCD4 21 | #00838F 22 | 23 | 24 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 100dp 20 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/fragmentview_strings.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | Show Log 18 | Hide Log 19 | 20 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | Aztec React Native example 20 | Element 21 | Grid Layout Manager 22 | Linear Layout Manager 23 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/template-dimens.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 4dp 22 | 8dp 23 | 16dp 24 | 32dp 25 | 64dp 26 | 27 | 28 | 29 | @dimen/margin_medium 30 | @dimen/margin_medium 31 | 32 | 33 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/template-styles.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 25 | 26 | 37 | 38 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | gradlePluginVersion = '3.0.1' 4 | kotlinVersion = '1.2.61' 5 | supportLibVersion = '27.1.1' 6 | tagSoupVersion = '1.2.1' 7 | glideVersion = '3.7.0' 8 | picassoVersion = '2.5.2' 9 | robolectricVersion = '3.5.1' 10 | jUnitVersion = '4.12' 11 | jSoupVersion = '1.10.3' 12 | wordpressUtilsVersion = '1.22' 13 | espressoVersion = '3.0.1' 14 | } 15 | 16 | repositories { 17 | jcenter() 18 | google() 19 | } 20 | 21 | dependencies { 22 | classpath 'com.android.tools.build:gradle:3.1.4' 23 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" 24 | } 25 | 26 | repositories { 27 | jcenter() 28 | } 29 | dependencies { 30 | classpath 'com.android.tools.build:gradle:2.2.3' 31 | 32 | // NOTE: Do not place your application dependencies here; they belong 33 | // in the individual module build.gradle files 34 | } 35 | } 36 | 37 | allprojects { 38 | repositories { 39 | mavenLocal() 40 | jcenter() 41 | maven { 42 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 43 | url "$rootDir/../node_modules/react-native/android" 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-aztec/eb7989f8287219b8fff28c5f942bfb1ba4605572/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Sep 08 13:53:18 PDT 2014 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip -------------------------------------------------------------------------------- /example/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /example/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'example' 2 | 3 | include ':react-native-aztec' 4 | project(':react-native-aztec').projectDir = new File(rootProject.projectDir, '../../android') 5 | 6 | include ':app' 7 | 8 | -------------------------------------------------------------------------------- /example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "displayName": "example" 4 | } -------------------------------------------------------------------------------- /example/content.js: -------------------------------------------------------------------------------- 1 | 2 | HEADING = 3 | "

Heading 1

" + 4 | "

Heading 2

" + 5 | "

Heading 3

" + 6 | "

Heading 4

" + 7 | "
Heading 5
" + 8 | "
Heading 6
"; 9 | BOLD = "Bold
"; 10 | ITALIC = "Italic
"; 11 | UNDERLINE = "Underline
"; 12 | STRIKETHROUGH = "Strikethrough
" ;// or or 13 | ORDERED = "
  1. Ordered
  2. should have color
"; 14 | LINE = "
"; 15 | UNORDERED = "
  • Unordered
  • Should not have color
"; 16 | QUOTE = "
Quote
"; 17 | LINK = "Link
"; 18 | UNKNOWN = "
"; 19 | COMMENT = "
"; 20 | COMMENT_MORE = "
"; 21 | COMMENT_PAGE = "
"; 22 | HIDDEN = 23 | "" + 24 | "
" + 25 | "
" + 26 | "
" + 27 | " Div
Span
Hidden" + 28 | "
" + 29 | "
" + 30 | "
" + 31 | "
" + 32 | " " + 33 | "
" + 34 | "
"; 35 | GUTENBERG_CODE_BLOCK = "\n" + 36 | "
\"\"
\n" + 37 | ""; 38 | PREFORMAT = 39 | "
" +
40 |         "when (person) {
" + 41 | " MOCTEZUMA -> {
" + 42 | " print (\"friend\")
" + 43 | " }
" + 44 | " CORTES -> {
" + 45 | " print (\"foe\")
" + 46 | " }
" + 47 | "}" + 48 | "
"; 49 | CODE = "if (Stringue == 5) printf(Stringue)
"; 50 | IMG = "[caption align=\"alignright\"]Caption[/caption]"; 51 | EMOJI = "👍"; 52 | NON_LATIN_TEXT = "测试一个"; 53 | LONG_TEXT = "

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "; 54 | VIDEO = "[video src=\"https://examplebloge.files.wordpress.com/2017/06/d7d88643-88e6-d9b5-11e6-92e03def4804.mp4\"]"; 55 | AUDIO = "[audio src=\"https://upload.wikimedia.org/wikipedia/commons/9/94/H-Moll.ogg\"]"; 56 | VIDEOPRESS = "[wpvideo OcobLTqC]"; 57 | VIDEOPRESS_2 = "[wpvideo OcobLTqC w=640 h=400 autoplay=true html5only=true3]"; 58 | QUOTE_RTL = "
לְצַטֵט
same quote but LTR
"; 59 | 60 | EXAMPLE_CONTENT = 61 | IMG + 62 | HEADING + 63 | BOLD + 64 | ITALIC + 65 | UNDERLINE + 66 | STRIKETHROUGH + 67 | ORDERED + 68 | LINE + 69 | UNORDERED + 70 | QUOTE + 71 | PREFORMAT + 72 | LINK + 73 | HIDDEN + 74 | COMMENT + 75 | COMMENT_MORE + 76 | COMMENT_PAGE + 77 | CODE + 78 | UNKNOWN + 79 | EMOJI + 80 | NON_LATIN_TEXT + 81 | LONG_TEXT + 82 | VIDEO + 83 | VIDEOPRESS + 84 | VIDEOPRESS_2 + 85 | AUDIO + 86 | GUTENBERG_CODE_BLOCK + 87 | QUOTE_RTL; 88 | 89 | export function example_content() { 90 | return EXAMPLE_CONTENT; 91 | } 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /example/editor.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import {StyleSheet, Button, View} from 'react-native'; 3 | import AztecView from 'react-native-aztec' 4 | 5 | const _minHeight = 100; 6 | 7 | export default class Editor extends Component { 8 | constructor(props) { 9 | super(props); 10 | this.onFormatPress = this.onFormatPress.bind(this) 11 | this.onActiveFormatsChange = this.onActiveFormatsChange.bind(this) 12 | this.isFormatActive = this.isFormatActive.bind(this) 13 | this.state = { activeFormats: [] }; 14 | } 15 | 16 | onFormatPress( format ) { 17 | const { _aztec } = this.refs; 18 | _aztec.applyFormat(format); 19 | } 20 | 21 | onActiveFormatsChange( formats ) { 22 | this.setState({activeFormats: formats }); 23 | } 24 | 25 | isFormatActive( format ) { 26 | const { activeFormats } = this.state; 27 | console.log(activeFormats); 28 | return activeFormats.indexOf(format) != -1; 29 | } 30 | 31 | render() { 32 | const { item, onContentSizeChange } = this.props; 33 | let myMinHeight = Math.max(_minHeight, item.height); 34 | return ( 35 | 36 | 37 |