13 |
14 | #define TIMEOUT_SECONDS 600
15 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!"
16 |
17 | @interface exampleTests : XCTestCase
18 |
19 | @end
20 |
21 | @implementation exampleTests
22 |
23 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test
24 | {
25 | if (test(view)) {
26 | return YES;
27 | }
28 | for (UIView *subview in [view subviews]) {
29 | if ([self findSubviewInView:subview matching:test]) {
30 | return YES;
31 | }
32 | }
33 | return NO;
34 | }
35 |
36 | - (void)testRendersWelcomeScreen
37 | {
38 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController];
39 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
40 | BOOL foundElement = NO;
41 |
42 | __block NSString *redboxError = nil;
43 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
44 | if (level >= RCTLogLevelError) {
45 | redboxError = message;
46 | }
47 | });
48 |
49 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
50 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
51 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
52 |
53 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) {
54 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) {
55 | return YES;
56 | }
57 | return NO;
58 | }];
59 | }
60 |
61 | RCTSetLogFunction(RCTDefaultLogFunction);
62 |
63 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
64 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
65 | }
66 |
67 |
68 | @end
69 |
--------------------------------------------------------------------------------
/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/ios/example/MediaProvider.swift:
--------------------------------------------------------------------------------
1 | import Aztec
2 | import Foundation
3 |
4 | class MediaProvider: Aztec.TextViewAttachmentDelegate {
5 |
6 | func textView(_ textView: TextView, attachment: NSTextAttachment, imageAt url: URL, onSuccess success: @escaping (UIImage) -> Void, onFailure failure: @escaping () -> Void) {
7 |
8 | DispatchQueue.main.async {
9 | let image = UIImage(named: "aztec")!
10 |
11 | success(image)
12 | }
13 | }
14 |
15 | func textView(_ textView: TextView, urlFor imageAttachment: ImageAttachment) -> URL? {
16 | return URL(string: "www.google.com")
17 | }
18 |
19 | func textView(_ textView: TextView, placeholderFor attachment: NSTextAttachment) -> UIImage {
20 | return UIImage(named: "aztec")!
21 | }
22 |
23 | func textView(_ textView: TextView, deletedAttachment attachment: MediaAttachment) {
24 | textView.setNeedsDisplay()
25 | }
26 |
27 | func textView(_ textView: TextView, selected attachment: NSTextAttachment, atPosition position: CGPoint) {
28 | }
29 |
30 | func textView(_ textView: TextView, deselected attachment: NSTextAttachment, atPosition position: CGPoint) {
31 | }
32 |
33 |
34 | }
35 |
36 | extension MediaProvider: Aztec.TextViewAttachmentImageProvider {
37 | func textView(_ textView: TextView, shouldRender attachment: NSTextAttachment) -> Bool {
38 | return true
39 | }
40 |
41 | func textView(_ textView: TextView, boundsFor attachment: NSTextAttachment, with lineFragment: CGRect) -> CGRect {
42 | return CGRect(x: 0, y: 0, width: 20, height: 20)
43 | }
44 |
45 | func textView(_ textView: TextView, imageFor attachment: NSTextAttachment, with size: CGSize) -> UIImage? {
46 | let image = UIImage(named: "aztec")!
47 |
48 | return imageWithImage(image: image, scaledToSize: size)
49 | }
50 |
51 | func imageWithImage(image:UIImage, scaledToSize newSize:CGSize) -> UIImage{
52 | UIGraphicsBeginImageContextWithOptions(newSize, false, 0.0);
53 | image.draw(in: CGRect(origin: CGPoint.zero, size: CGSize(width: newSize.width, height: newSize.height)))
54 | let newImage:UIImage = UIGraphicsGetImageFromCurrentImageContext()!
55 | UIGraphicsEndImageContext()
56 | return newImage
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/ios/RNTAztecView/RCTAztecViewManager.swift:
--------------------------------------------------------------------------------
1 | import Aztec
2 | import Foundation
3 |
4 | @objc (RCTAztecViewManager)
5 | public class RCTAztecViewManager: RCTViewManager {
6 |
7 | public var attachmentDelegate: Aztec.TextViewAttachmentDelegate?
8 | public var imageProvider: Aztec.TextViewAttachmentImageProvider?
9 |
10 | public override static func requiresMainQueueSetup() -> Bool {
11 | return true
12 | }
13 |
14 | @objc
15 | func applyFormat(_ node: NSNumber, format: String) {
16 | executeBlock({ (aztecView) in
17 | aztecView.apply(format: format)
18 | }, onNode: node)
19 | }
20 |
21 | @objc
22 | func removeLink(_ node: NSNumber) {
23 | executeBlock({ (aztecView) in
24 | aztecView.removeLink()
25 | }, onNode: node)
26 | }
27 |
28 | @objc
29 | func setLink(_ node: NSNumber, url: String, title: String?) {
30 | executeBlock({ (aztecView) in
31 | aztecView.setLink(with: url, and: title)
32 | }, onNode: node)
33 | }
34 |
35 | @objc
36 | public override func view() -> UIView {
37 | let view = RCTAztecView(
38 | defaultFont: defaultFont,
39 | defaultParagraphStyle: .default,
40 | defaultMissingImage: UIImage())
41 |
42 | view.isScrollEnabled = false
43 |
44 | view.textAttachmentDelegate = attachmentDelegate
45 | if let imageProvider = imageProvider {
46 | view.registerAttachmentImageProvider(imageProvider)
47 | }
48 |
49 | return view
50 | }
51 |
52 | func executeBlock(_ block: @escaping (RCTAztecView) -> Void, onNode node: NSNumber) {
53 | self.bridge.uiManager.addUIBlock { (manager, viewRegistry) in
54 | let view = viewRegistry?[node]
55 | guard let aztecView = view as? RCTAztecView else {
56 | return
57 | }
58 | block(aztecView)
59 | }
60 | }
61 |
62 | private var defaultFont: UIFont {
63 | if let font = UIFont(name: "NotoSerif", size: 16) {
64 | return font
65 | }
66 |
67 | let defaultFont = UIFont.systemFont(ofSize: 16)
68 | guard let url = Bundle.main.url(forResource: "NotoSerif-Regular", withExtension: "ttf") else {
69 | return defaultFont
70 | }
71 | CTFontManagerRegisterFontsForURL(url as CFURL, CTFontManagerScope.process, nil)
72 | if let font = UIFont(name: "NotoSerif", size: 16) {
73 | return font
74 | }
75 |
76 | return defaultFont
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/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/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/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/ios/example/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 | import UIKit
3 |
4 | @UIApplicationMain
5 | class AppDelegate: UIResponder, UIApplicationDelegate {
6 |
7 | var window: UIWindow?
8 |
9 | let mediaProvider = MediaProvider()
10 |
11 | lazy var bridgeDelegate: BridgeDelegate = {
12 | let sourceURL = RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index", fallbackResource: nil)!
13 | return BridgeDelegate(sourceURL: sourceURL)
14 | }()
15 |
16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
17 |
18 | bridgeDelegate.aztecViewManager.attachmentDelegate = mediaProvider
19 | bridgeDelegate.aztecViewManager.imageProvider = mediaProvider
20 |
21 | let bridge = RCTBridge(delegate: bridgeDelegate, launchOptions: launchOptions)
22 | let rootView = RCTRootView(bridge: bridge, moduleName: "example", initialProperties: nil)
23 |
24 | rootView?.backgroundColor = .white
25 |
26 | window = UIWindow(frame: UIScreen.main.bounds)
27 |
28 | let rootViewController = UIViewController()
29 |
30 | rootViewController.view = rootView
31 | window?.rootViewController = rootViewController
32 | window?.makeKeyAndVisible()
33 |
34 | return true
35 | }
36 |
37 | func applicationWillResignActive(_ application: UIApplication) {
38 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
39 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
40 | }
41 |
42 | func applicationDidEnterBackground(_ application: UIApplication) {
43 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
44 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
45 | }
46 |
47 | func applicationWillEnterForeground(_ application: UIApplication) {
48 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
49 | }
50 |
51 | func applicationDidBecomeActive(_ application: UIApplication) {
52 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
53 | }
54 |
55 | func applicationWillTerminate(_ application: UIApplication) {
56 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/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 |
41 | console.log(event.nativeEvent) }
50 | onEnter= {(event) => console.log("asta") }
51 | onFocus= {(event) => console.log("onFocus") }
52 | onBlur= {(event) => console.log("onBlur") }
53 | onSelectionChange={ (start, end) => console.log(`selectionChange (${start}, ${end})`) }
54 | onBackspace= {(event) => console.log("Ciao") }
55 | onEndEditing= {(event) => console.log(event.nativeEvent) }
56 | onActiveFormatsChange = { this.onActiveFormatsChange }
57 | color = {'black'}
58 | maxImagesWidth = {200}
59 | />
60 |
61 | )
62 | }
63 | }
64 |
65 | var styles = StyleSheet.create({
66 | container: {
67 | flex: 1
68 | },
69 | aztec_editor: {
70 | minHeight: _minHeight,
71 | margin: 10,
72 | },
73 | });
74 |
--------------------------------------------------------------------------------
/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 = "- Ordered
- 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/ios/example/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
21 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/example/ios/example.xcodeproj/xcshareddata/xcschemes/example.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
29 |
35 |
36 |
37 |
43 |
49 |
50 |
51 |
52 |
53 |
58 |
59 |
61 |
67 |
68 |
69 |
70 |
71 |
77 |
78 |
79 |
80 |
81 |
82 |
92 |
94 |
100 |
101 |
102 |
103 |
104 |
105 |
111 |
113 |
119 |
120 |
121 |
122 |
124 |
125 |
128 |
129 |
130 |
--------------------------------------------------------------------------------
/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:
--------------------------------------------------------------------------------
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/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 |
--------------------------------------------------------------------------------
/src/AztecView.js:
--------------------------------------------------------------------------------
1 | import PropTypes from 'prop-types';
2 | import React from 'react';
3 | import ReactNative, {requireNativeComponent, ViewPropTypes, UIManager, ColorPropType, TouchableWithoutFeedback} from 'react-native';
4 | import TextInputState from 'react-native/lib/TextInputState';
5 |
6 | const AztecManager = UIManager.RCTAztecView;
7 |
8 | class AztecView extends React.Component {
9 | selectionEndCaretY: number;
10 |
11 | static propTypes = {
12 | isSelected: PropTypes.bool,
13 | disableGutenbergMode: PropTypes.bool,
14 | text: PropTypes.object,
15 | placeholder: PropTypes.string,
16 | placeholderTextColor: ColorPropType,
17 | color: ColorPropType,
18 | maxImagesWidth: PropTypes.number,
19 | minImagesWidth: PropTypes.number,
20 | onChange: PropTypes.func,
21 | onFocus: PropTypes.func,
22 | onBlur: PropTypes.func,
23 | onContentSizeChange: PropTypes.func,
24 | onEnter: PropTypes.func,
25 | onBackspace: PropTypes.func,
26 | onScroll: PropTypes.func,
27 | onActiveFormatsChange: PropTypes.func,
28 | onActiveFormatAttributesChange: PropTypes.func,
29 | onSelectionChange: PropTypes.func,
30 | onHTMLContentWithCursor: PropTypes.func,
31 | onCaretVerticalPositionChange: PropTypes.func,
32 | blockType: PropTypes.object,
33 | ...ViewPropTypes, // include the default view properties
34 | }
35 |
36 | dispatch(command, params) {
37 | params = params || [];
38 | UIManager.dispatchViewManagerCommand(
39 | ReactNative.findNodeHandle(this),
40 | command,
41 | params,
42 | );
43 | }
44 |
45 | applyFormat(format) {
46 | this.dispatch(AztecManager.Commands.applyFormat, [format])
47 | }
48 |
49 | removeLink() {
50 | this.dispatch(AztecManager.Commands.removeLink)
51 | }
52 |
53 | setLink(url, title) {
54 | this.dispatch(AztecManager.Commands.setLink, [url, title])
55 | }
56 |
57 | requestHTMLWithCursor() {
58 | this.dispatch(AztecManager.Commands.returnHTMLWithCursor)
59 | }
60 |
61 | _onActiveFormatsChange = (event) => {
62 | if (!this.props.onActiveFormatsChange) {
63 | return;
64 | }
65 | const formats = event.nativeEvent.formats;
66 | const { onActiveFormatsChange } = this.props;
67 | onActiveFormatsChange(formats);
68 | }
69 |
70 | _onActiveFormatAttributesChange = (event) => {
71 | if (!this.props.onActiveFormatAttributesChange) {
72 | return;
73 | }
74 | const attributes = event.nativeEvent.attributes;
75 | const { onActiveFormatAttributesChange } = this.props;
76 | onActiveFormatAttributesChange(attributes);
77 | }
78 |
79 | _onContentSizeChange = (event) => {
80 | if (!this.props.onContentSizeChange) {
81 | return;
82 | }
83 | const size = event.nativeEvent.contentSize;
84 | const { onContentSizeChange } = this.props;
85 | onContentSizeChange(size);
86 | }
87 |
88 | _onEnter = (event) => {
89 | if (!this.props.onEnter) {
90 | return;
91 | }
92 |
93 | const { onEnter } = this.props;
94 | onEnter(event);
95 | }
96 |
97 | _onBackspace = (event) => {
98 | if (!this.props.onBackspace) {
99 | return;
100 | }
101 |
102 | const { onBackspace } = this.props;
103 | onBackspace(event);
104 | }
105 |
106 | _onHTMLContentWithCursor = (event) => {
107 | if (!this.props.onHTMLContentWithCursor) {
108 | return;
109 | }
110 |
111 | const text = event.nativeEvent.text;
112 | const selectionStart = event.nativeEvent.selectionStart;
113 | const selectionEnd = event.nativeEvent.selectionEnd;
114 | const { onHTMLContentWithCursor } = this.props;
115 | onHTMLContentWithCursor(text, selectionStart, selectionEnd);
116 | }
117 |
118 | _onFocus = (event) => {
119 | if (!this.props.onFocus) {
120 | return;
121 | }
122 |
123 | const { onFocus } = this.props;
124 | onFocus(event);
125 | }
126 |
127 | _onBlur = (event) => {
128 | this.selectionEndCaretY = null;
129 | TextInputState.blurTextInput(ReactNative.findNodeHandle(this));
130 |
131 | if (!this.props.onBlur) {
132 | return;
133 | }
134 |
135 | const { onBlur } = this.props;
136 | onBlur(event);
137 | }
138 |
139 | _onSelectionChange = (event) => {
140 | if ( this.props.onSelectionChange ) {
141 | const { selectionStart, selectionEnd, text } = event.nativeEvent;
142 | const { onSelectionChange } = this.props;
143 | onSelectionChange( selectionStart, selectionEnd, text );
144 | }
145 |
146 | if ( this.props.onCaretVerticalPositionChange &&
147 | this.selectionEndCaretY != event.nativeEvent.selectionEndCaretY ) {
148 | const caretY = event.nativeEvent.selectionEndCaretY;
149 | this.props.onCaretVerticalPositionChange( event.target, caretY, this.selectionEndCaretY );
150 | this.selectionEndCaretY = caretY;
151 | }
152 | }
153 |
154 | blur = () => {
155 | TextInputState.blurTextInput(ReactNative.findNodeHandle(this));
156 | }
157 |
158 | focus = () => {
159 | TextInputState.focusTextInput(ReactNative.findNodeHandle(this));
160 | }
161 |
162 | isFocused = () => {
163 | const focusedField = TextInputState.currentlyFocusedField();
164 | return focusedField && ( focusedField === ReactNative.findNodeHandle(this) );
165 | }
166 |
167 | _onPress = (event) => {
168 | this.focus(event); // Call to move the focus in RN way (TextInputState)
169 | this._onFocus(event); // Check if there are listeners set on the focus event
170 | }
171 |
172 | render() {
173 | const { onActiveFormatsChange, ...otherProps } = this.props
174 | return (
175 |
176 | {} }
187 | onBlur = { this._onBlur }
188 | onBackspace = { this._onBackspace }
189 | />
190 |
191 | );
192 | }
193 | }
194 |
195 | const RCTAztecView = requireNativeComponent('RCTAztecView', AztecView);
196 |
197 | export default AztecView
--------------------------------------------------------------------------------
/ios/RNTAztecView/RCTAztecView.swift:
--------------------------------------------------------------------------------
1 | import Aztec
2 | import Foundation
3 | import UIKit
4 |
5 | class RCTAztecView: Aztec.TextView {
6 | @objc var onBackspace: RCTBubblingEventBlock? = nil
7 | @objc var onChange: RCTBubblingEventBlock? = nil
8 | @objc var onEnter: RCTBubblingEventBlock? = nil
9 | @objc var onFocus: RCTBubblingEventBlock? = nil
10 | @objc var onBlur: RCTBubblingEventBlock? = nil
11 | @objc var onContentSizeChange: RCTBubblingEventBlock? = nil
12 | @objc var onSelectionChange: RCTBubblingEventBlock? = nil
13 | @objc var onActiveFormatsChange: RCTBubblingEventBlock? = nil
14 | @objc var onActiveFormatAttributesChange: RCTBubblingEventBlock? = nil
15 | @objc var blockType: NSDictionary? = nil {
16 | didSet {
17 | guard let block = blockType, let tag = block["tag"] as? String else {
18 | return
19 | }
20 | blockModel = BlockModel(tag: tag)
21 | }
22 | }
23 |
24 | var blockModel = BlockModel(tag: "") {
25 | didSet {
26 | forceTypingAttributesIfNeeded()
27 | }
28 | }
29 |
30 | private var previousContentSize: CGSize = .zero
31 |
32 | private lazy var placeholderLabel: UILabel = {
33 | let label = UILabel(frame: .zero)
34 | return label
35 | }()
36 |
37 | private let formatStringMap: [FormattingIdentifier: String] = [
38 | .bold: "bold",
39 | .italic: "italic",
40 | .strikethrough: "strikethrough",
41 | .link: "link",
42 | ]
43 |
44 | override init(defaultFont: UIFont, defaultParagraphStyle: ParagraphStyle, defaultMissingImage: UIImage) {
45 | super.init(defaultFont: defaultFont, defaultParagraphStyle: defaultParagraphStyle, defaultMissingImage: defaultMissingImage)
46 | commonInit()
47 | }
48 |
49 | required init?(coder aDecoder: NSCoder) {
50 | super.init(coder: aDecoder)
51 | commonInit()
52 | }
53 |
54 | func commonInit() {
55 | delegate = self
56 | addSubview(placeholderLabel)
57 | placeholderLabel.textAlignment = .natural
58 | placeholderLabel.translatesAutoresizingMaskIntoConstraints = false
59 | placeholderLabel.font = font
60 | NSLayoutConstraint.activate([
61 | placeholderLabel.leadingAnchor.constraint(equalTo: leadingAnchor, constant: contentInset.left + textContainerInset.left + textContainer.lineFragmentPadding),
62 | placeholderLabel.topAnchor.constraint(equalTo: topAnchor, constant: contentInset.top + textContainerInset.top)
63 | ])
64 | }
65 |
66 | // MARK - View Height: Match to content height
67 |
68 | override func layoutSubviews() {
69 | super.layoutSubviews()
70 | updateContentSizeInRN()
71 | }
72 |
73 | func updateContentSizeInRN() {
74 | let newSize = sizeThatFits(frame.size)
75 |
76 | guard previousContentSize != newSize,
77 | let onContentSizeChange = onContentSizeChange else {
78 | return
79 | }
80 |
81 | previousContentSize = newSize
82 |
83 | let body = packForRN(newSize, withName: "contentSize")
84 | onContentSizeChange(body)
85 | }
86 |
87 | // MARK: - Edits
88 |
89 | open override func insertText(_ text: String) {
90 | guard !interceptEnter(text) else {
91 | return
92 | }
93 |
94 | super.insertText(text)
95 | updatePlaceholderVisibility()
96 | }
97 |
98 | open override func deleteBackward() {
99 | guard !interceptBackspace() else {
100 | return
101 | }
102 |
103 | super.deleteBackward()
104 | updatePlaceholderVisibility()
105 | }
106 |
107 | // MARK: - Custom Edit Intercepts
108 |
109 | private func interceptEnter(_ text: String) -> Bool {
110 | guard text == "\n",
111 | let onEnter = onEnter else {
112 | return false
113 | }
114 |
115 | let caretData = packCaretDataForRN()
116 | onEnter(caretData)
117 | return true
118 | }
119 |
120 | private func interceptBackspace() -> Bool {
121 | guard selectedRange.location == 0 && selectedRange.length == 0,
122 | let onBackspace = onBackspace else {
123 | return false
124 | }
125 |
126 | let caretData = packCaretDataForRN()
127 | onBackspace(caretData)
128 | return true
129 | }
130 |
131 | // MARK: - Native-to-RN Value Packing Logic
132 |
133 | func packForRN(_ text: String, withName name: String) -> [AnyHashable: Any] {
134 | return [name: text,
135 | "eventCount": 1]
136 | }
137 |
138 | func packForRN(_ size: CGSize, withName name: String) -> [AnyHashable: Any] {
139 |
140 | let size = ["width": size.width,
141 | "height": size.height]
142 |
143 | return [name: size]
144 | }
145 |
146 | func packCaretDataForRN() -> [AnyHashable: Any] {
147 | var start = selectedRange.location
148 | var end = selectedRange.location + selectedRange.length
149 | if selectionAffinity == .backward {
150 | (start, end) = (end, start)
151 | }
152 |
153 | var result: [String : Any] = [
154 | "text": getHTML(),
155 | "selectionStart": start,
156 | "selectionEnd": end
157 | ]
158 |
159 | if let selectedTextRange = selectedTextRange {
160 | let caretEndRect = caretRect(for: selectedTextRange.end)
161 | result["selectionEndCaretX"] = caretEndRect.origin.x
162 | result["selectionEndCaretY"] = caretEndRect.origin.y
163 | }
164 |
165 | return result
166 | }
167 |
168 | // MARK: - RN Properties
169 |
170 | @objc
171 | func setContents(_ contents: NSDictionary) {
172 | guard contents["eventCount"] == nil else {
173 | return
174 | }
175 |
176 | let html = contents["text"] as? String ?? ""
177 |
178 | setHTML(html)
179 | updatePlaceholderVisibility()
180 | }
181 |
182 | // MARK: - Placeholder
183 |
184 | @objc var placeholder: String {
185 | set {
186 | placeholderLabel.text = newValue
187 | }
188 |
189 | get {
190 | return placeholderLabel.text ?? ""
191 | }
192 | }
193 |
194 | @objc var placeholderTextColor: UIColor {
195 | set {
196 | placeholderLabel.textColor = newValue
197 | }
198 | get {
199 | return placeholderLabel.textColor
200 | }
201 | }
202 |
203 | func updatePlaceholderVisibility() {
204 | placeholderLabel.isHidden = !self.text.isEmpty
205 | }
206 |
207 | // MARK: - Formatting interface
208 |
209 | @objc func apply(format: String) {
210 | switch format {
211 | case "bold": toggleBold(range: selectedRange)
212 | case "italic": toggleItalic(range: selectedRange)
213 | case "strikethrough": toggleStrikethrough(range: selectedRange)
214 | default: print("Format not recognized")
215 | }
216 | }
217 |
218 | @objc
219 | func setLink(with url: String, and title: String?) {
220 | guard let url = URL(string: url) else {
221 | return
222 | }
223 | if let title = title {
224 | setLink(url, title: title, inRange: selectedRange)
225 | } else {
226 | setLink(url, inRange: selectedRange)
227 | }
228 | }
229 |
230 | @objc
231 | func removeLink() {
232 | guard let expandedRange = linkFullRange(forRange: selectedRange) else {
233 | return
234 | }
235 | removeLink(inRange: expandedRange)
236 | }
237 |
238 | func linkAttributes() -> [String: Any] {
239 | var attributes: [String: Any] = ["isActive": false]
240 | if let expandedRange = linkFullRange(forRange: selectedRange) {
241 | attributes["url"] = linkURL(forRange: expandedRange)?.absoluteString ?? ""
242 | attributes["isActive"] = true
243 | }
244 | return attributes
245 | }
246 |
247 | func forceTypingAttributesIfNeeded() {
248 | if let formatHandler = HeadingBlockFormatHandler(block: blockModel) {
249 | formatHandler.forceTypingFormat(on: self)
250 | }
251 | }
252 |
253 | // MARK: - Event Propagation
254 |
255 | func propagateContentChanges() {
256 | if let onChange = onChange {
257 | let text = packForRN(getHTML(), withName: "text")
258 | onChange(text)
259 | }
260 | }
261 |
262 | func propagateFormatChanges() {
263 | guard let onActiveFormatsChange = onActiveFormatsChange else {
264 | return
265 | }
266 | let identifiers: Set
267 | if selectedRange.length > 0 {
268 | identifiers = formattingIdentifiersSpanningRange(selectedRange)
269 | } else {
270 | identifiers = formattingIdentifiersForTypingAttributes()
271 | }
272 | let formats = identifiers.compactMap { formatStringMap[$0] }
273 | onActiveFormatsChange(["formats": formats])
274 | }
275 |
276 | func propagateAttributesChanges() {
277 | let attributes: [String: [String: Any]] = [
278 | "link": linkAttributes()
279 | ]
280 | onActiveFormatAttributesChange?(["attributes": attributes])
281 | }
282 |
283 | func propagateSelectionChanges() {
284 | guard let onSelectionChange = onSelectionChange else {
285 | return
286 | }
287 | let caretData = packCaretDataForRN()
288 | onSelectionChange(caretData)
289 | }
290 | }
291 |
292 | // MARK: UITextView Delegate Methods
293 | extension RCTAztecView: UITextViewDelegate {
294 |
295 | func textViewDidChangeSelection(_ textView: UITextView) {
296 | propagateAttributesChanges()
297 | propagateFormatChanges()
298 | propagateSelectionChanges()
299 | }
300 |
301 | func textViewDidChange(_ textView: UITextView) {
302 | forceTypingAttributesIfNeeded()
303 | propagateFormatChanges()
304 | propagateContentChanges()
305 | }
306 |
307 | func textViewDidBeginEditing(_ textView: UITextView) {
308 | onFocus?([:])
309 | }
310 |
311 | func textViewDidEndEditing(_ textView: UITextView) {
312 | onBlur?([:])
313 | }
314 | }
315 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/ios/RNTAztecView.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 50;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 7ECFA93C21C39B5000FC131B /* HeadingBlockFormatHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7ECFA93B21C39B5000FC131B /* HeadingBlockFormatHandler.swift */; };
11 | 7ECFA94021C39BA000FC131B /* BlockFormatHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7ECFA93F21C39BA000FC131B /* BlockFormatHandler.swift */; };
12 | 7ECFA94221C39BBB00FC131B /* BlockModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7ECFA94121C39BBB00FC131B /* BlockModel.swift */; };
13 | F121467D20ED2F81003DD17B /* RCTAztecViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F121467C20ED2F81003DD17B /* RCTAztecViewManager.m */; };
14 | F13BF4A020ECF5450047D3F9 /* RCTAztecViewManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = F13BF49F20ECF5450047D3F9 /* RCTAztecViewManager.swift */; };
15 | F166A38020EE6DF3008E7C9F /* Aztec.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F166A37B20EE6DD7008E7C9F /* Aztec.framework */; };
16 | F1A879D020EE90C000FABD31 /* RCTAztecView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1A879CF20EE90C000FABD31 /* RCTAztecView.swift */; };
17 | /* End PBXBuildFile section */
18 |
19 | /* Begin PBXContainerItemProxy section */
20 | F166A37A20EE6DD7008E7C9F /* PBXContainerItemProxy */ = {
21 | isa = PBXContainerItemProxy;
22 | containerPortal = F166A37420EE6DD7008E7C9F /* Aztec.xcodeproj */;
23 | proxyType = 2;
24 | remoteGlobalIDString = 5951CB8E1D8BC93600E1866F;
25 | remoteInfo = Aztec;
26 | };
27 | F166A37C20EE6DD7008E7C9F /* PBXContainerItemProxy */ = {
28 | isa = PBXContainerItemProxy;
29 | containerPortal = F166A37420EE6DD7008E7C9F /* Aztec.xcodeproj */;
30 | proxyType = 2;
31 | remoteGlobalIDString = 5951CB971D8BC93600E1866F;
32 | remoteInfo = AztecTests;
33 | };
34 | F166A37E20EE6DEE008E7C9F /* PBXContainerItemProxy */ = {
35 | isa = PBXContainerItemProxy;
36 | containerPortal = F166A37420EE6DD7008E7C9F /* Aztec.xcodeproj */;
37 | proxyType = 1;
38 | remoteGlobalIDString = 5951CB8D1D8BC93600E1866F;
39 | remoteInfo = Aztec;
40 | };
41 | /* End PBXContainerItemProxy section */
42 |
43 | /* Begin PBXCopyFilesBuildPhase section */
44 | F145CFC42087D16A006C159A /* CopyFiles */ = {
45 | isa = PBXCopyFilesBuildPhase;
46 | buildActionMask = 2147483647;
47 | dstPath = "include/$(PRODUCT_NAME)";
48 | dstSubfolderSpec = 16;
49 | files = (
50 | );
51 | runOnlyForDeploymentPostprocessing = 0;
52 | };
53 | /* End PBXCopyFilesBuildPhase section */
54 |
55 | /* Begin PBXFileReference section */
56 | 7ECFA93B21C39B5000FC131B /* HeadingBlockFormatHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadingBlockFormatHandler.swift; sourceTree = ""; };
57 | 7ECFA93F21C39BA000FC131B /* BlockFormatHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlockFormatHandler.swift; sourceTree = ""; };
58 | 7ECFA94121C39BBB00FC131B /* BlockModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlockModel.swift; sourceTree = ""; };
59 | F1017BCE20ED1B1A002B1024 /* libReact.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libReact.a; sourceTree = BUILT_PRODUCTS_DIR; };
60 | F121467C20ED2F81003DD17B /* RCTAztecViewManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCTAztecViewManager.m; sourceTree = ""; };
61 | F13BF49E20ECF5440047D3F9 /* RCTAztecView-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RCTAztecView-Bridging-Header.h"; sourceTree = ""; };
62 | F13BF49F20ECF5450047D3F9 /* RCTAztecViewManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RCTAztecViewManager.swift; sourceTree = ""; };
63 | F145CFC62087D16A006C159A /* libRNTAztecView.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNTAztecView.a; sourceTree = BUILT_PRODUCTS_DIR; };
64 | F166A37420EE6DD7008E7C9F /* Aztec.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Aztec.xcodeproj; path = "Carthage/Checkouts/AztecEditor-iOS/Aztec.xcodeproj"; sourceTree = SOURCE_ROOT; };
65 | F1A879CF20EE90C000FABD31 /* RCTAztecView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RCTAztecView.swift; sourceTree = ""; };
66 | /* End PBXFileReference section */
67 |
68 | /* Begin PBXFrameworksBuildPhase section */
69 | F145CFC32087D16A006C159A /* Frameworks */ = {
70 | isa = PBXFrameworksBuildPhase;
71 | buildActionMask = 2147483647;
72 | files = (
73 | F166A38020EE6DF3008E7C9F /* Aztec.framework in Frameworks */,
74 | );
75 | runOnlyForDeploymentPostprocessing = 0;
76 | };
77 | /* End PBXFrameworksBuildPhase section */
78 |
79 | /* Begin PBXGroup section */
80 | F145CFBD2087D169006C159A = {
81 | isa = PBXGroup;
82 | children = (
83 | F145CFC82087D16A006C159A /* RNTAztecView */,
84 | F166A37320EE6DC7008E7C9F /* Dependencies */,
85 | F145CFF92087D497006C159A /* Frameworks */,
86 | F145CFC72087D16A006C159A /* Products */,
87 | );
88 | sourceTree = "";
89 | };
90 | F145CFC72087D16A006C159A /* Products */ = {
91 | isa = PBXGroup;
92 | children = (
93 | F145CFC62087D16A006C159A /* libRNTAztecView.a */,
94 | );
95 | name = Products;
96 | sourceTree = "";
97 | };
98 | F145CFC82087D16A006C159A /* RNTAztecView */ = {
99 | isa = PBXGroup;
100 | children = (
101 | F13BF49E20ECF5440047D3F9 /* RCTAztecView-Bridging-Header.h */,
102 | F121467C20ED2F81003DD17B /* RCTAztecViewManager.m */,
103 | F13BF49F20ECF5450047D3F9 /* RCTAztecViewManager.swift */,
104 | F1A879CF20EE90C000FABD31 /* RCTAztecView.swift */,
105 | 7ECFA94121C39BBB00FC131B /* BlockModel.swift */,
106 | 7ECFA93B21C39B5000FC131B /* HeadingBlockFormatHandler.swift */,
107 | 7ECFA93F21C39BA000FC131B /* BlockFormatHandler.swift */,
108 | );
109 | path = RNTAztecView;
110 | sourceTree = "";
111 | };
112 | F145CFF92087D497006C159A /* Frameworks */ = {
113 | isa = PBXGroup;
114 | children = (
115 | F1017BCE20ED1B1A002B1024 /* libReact.a */,
116 | );
117 | path = Frameworks;
118 | sourceTree = "";
119 | };
120 | F166A37320EE6DC7008E7C9F /* Dependencies */ = {
121 | isa = PBXGroup;
122 | children = (
123 | F166A37420EE6DD7008E7C9F /* Aztec.xcodeproj */,
124 | );
125 | path = Dependencies;
126 | sourceTree = "";
127 | };
128 | F166A37520EE6DD7008E7C9F /* Products */ = {
129 | isa = PBXGroup;
130 | children = (
131 | F166A37B20EE6DD7008E7C9F /* Aztec.framework */,
132 | F166A37D20EE6DD7008E7C9F /* AztecTests.xctest */,
133 | );
134 | name = Products;
135 | sourceTree = "";
136 | };
137 | /* End PBXGroup section */
138 |
139 | /* Begin PBXNativeTarget section */
140 | F145CFC52087D16A006C159A /* RNTAztecView */ = {
141 | isa = PBXNativeTarget;
142 | buildConfigurationList = F145CFCD2087D16A006C159A /* Build configuration list for PBXNativeTarget "RNTAztecView" */;
143 | buildPhases = (
144 | F145CFC22087D16A006C159A /* Sources */,
145 | F145CFC32087D16A006C159A /* Frameworks */,
146 | F145CFC42087D16A006C159A /* CopyFiles */,
147 | );
148 | buildRules = (
149 | );
150 | dependencies = (
151 | F166A37F20EE6DEE008E7C9F /* PBXTargetDependency */,
152 | );
153 | name = RNTAztecView;
154 | productName = RNTAztecView;
155 | productReference = F145CFC62087D16A006C159A /* libRNTAztecView.a */;
156 | productType = "com.apple.product-type.library.static";
157 | };
158 | /* End PBXNativeTarget section */
159 |
160 | /* Begin PBXProject section */
161 | F145CFBE2087D169006C159A /* Project object */ = {
162 | isa = PBXProject;
163 | attributes = {
164 | LastSwiftUpdateCheck = 0930;
165 | LastUpgradeCheck = 0930;
166 | ORGANIZATIONNAME = "Automattic Inc.";
167 | TargetAttributes = {
168 | F145CFC52087D16A006C159A = {
169 | CreatedOnToolsVersion = 9.3;
170 | LastSwiftMigration = 0940;
171 | };
172 | };
173 | };
174 | buildConfigurationList = F145CFC12087D169006C159A /* Build configuration list for PBXProject "RNTAztecView" */;
175 | compatibilityVersion = "Xcode 9.3";
176 | developmentRegion = en;
177 | hasScannedForEncodings = 0;
178 | knownRegions = (
179 | en,
180 | );
181 | mainGroup = F145CFBD2087D169006C159A;
182 | productRefGroup = F145CFC72087D16A006C159A /* Products */;
183 | projectDirPath = "";
184 | projectReferences = (
185 | {
186 | ProductGroup = F166A37520EE6DD7008E7C9F /* Products */;
187 | ProjectRef = F166A37420EE6DD7008E7C9F /* Aztec.xcodeproj */;
188 | },
189 | );
190 | projectRoot = "";
191 | targets = (
192 | F145CFC52087D16A006C159A /* RNTAztecView */,
193 | );
194 | };
195 | /* End PBXProject section */
196 |
197 | /* Begin PBXReferenceProxy section */
198 | F166A37B20EE6DD7008E7C9F /* Aztec.framework */ = {
199 | isa = PBXReferenceProxy;
200 | fileType = wrapper.framework;
201 | path = Aztec.framework;
202 | remoteRef = F166A37A20EE6DD7008E7C9F /* PBXContainerItemProxy */;
203 | sourceTree = BUILT_PRODUCTS_DIR;
204 | };
205 | F166A37D20EE6DD7008E7C9F /* AztecTests.xctest */ = {
206 | isa = PBXReferenceProxy;
207 | fileType = wrapper.cfbundle;
208 | path = AztecTests.xctest;
209 | remoteRef = F166A37C20EE6DD7008E7C9F /* PBXContainerItemProxy */;
210 | sourceTree = BUILT_PRODUCTS_DIR;
211 | };
212 | /* End PBXReferenceProxy section */
213 |
214 | /* Begin PBXSourcesBuildPhase section */
215 | F145CFC22087D16A006C159A /* Sources */ = {
216 | isa = PBXSourcesBuildPhase;
217 | buildActionMask = 2147483647;
218 | files = (
219 | 7ECFA94021C39BA000FC131B /* BlockFormatHandler.swift in Sources */,
220 | 7ECFA93C21C39B5000FC131B /* HeadingBlockFormatHandler.swift in Sources */,
221 | F13BF4A020ECF5450047D3F9 /* RCTAztecViewManager.swift in Sources */,
222 | F1A879D020EE90C000FABD31 /* RCTAztecView.swift in Sources */,
223 | F121467D20ED2F81003DD17B /* RCTAztecViewManager.m in Sources */,
224 | 7ECFA94221C39BBB00FC131B /* BlockModel.swift in Sources */,
225 | );
226 | runOnlyForDeploymentPostprocessing = 0;
227 | };
228 | /* End PBXSourcesBuildPhase section */
229 |
230 | /* Begin PBXTargetDependency section */
231 | F166A37F20EE6DEE008E7C9F /* PBXTargetDependency */ = {
232 | isa = PBXTargetDependency;
233 | name = Aztec;
234 | targetProxy = F166A37E20EE6DEE008E7C9F /* PBXContainerItemProxy */;
235 | };
236 | /* End PBXTargetDependency section */
237 |
238 | /* Begin XCBuildConfiguration section */
239 | F145CFCB2087D16A006C159A /* Debug */ = {
240 | isa = XCBuildConfiguration;
241 | buildSettings = {
242 | ALWAYS_SEARCH_USER_PATHS = NO;
243 | CLANG_ANALYZER_NONNULL = YES;
244 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
245 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
246 | CLANG_CXX_LIBRARY = "libc++";
247 | CLANG_ENABLE_MODULES = YES;
248 | CLANG_ENABLE_OBJC_ARC = YES;
249 | CLANG_ENABLE_OBJC_WEAK = YES;
250 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
251 | CLANG_WARN_BOOL_CONVERSION = YES;
252 | CLANG_WARN_COMMA = YES;
253 | CLANG_WARN_CONSTANT_CONVERSION = YES;
254 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
255 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
256 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
257 | CLANG_WARN_EMPTY_BODY = YES;
258 | CLANG_WARN_ENUM_CONVERSION = YES;
259 | CLANG_WARN_INFINITE_RECURSION = YES;
260 | CLANG_WARN_INT_CONVERSION = YES;
261 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
262 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
263 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
264 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
265 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
266 | CLANG_WARN_STRICT_PROTOTYPES = YES;
267 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
268 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
269 | CLANG_WARN_UNREACHABLE_CODE = YES;
270 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
271 | CODE_SIGN_IDENTITY = "iPhone Developer";
272 | COPY_PHASE_STRIP = NO;
273 | DEBUG_INFORMATION_FORMAT = dwarf;
274 | ENABLE_STRICT_OBJC_MSGSEND = YES;
275 | ENABLE_TESTABILITY = YES;
276 | GCC_C_LANGUAGE_STANDARD = gnu11;
277 | GCC_DYNAMIC_NO_PIC = NO;
278 | GCC_NO_COMMON_BLOCKS = YES;
279 | GCC_OPTIMIZATION_LEVEL = 0;
280 | GCC_PREPROCESSOR_DEFINITIONS = (
281 | "DEBUG=1",
282 | "$(inherited)",
283 | );
284 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
285 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
286 | GCC_WARN_UNDECLARED_SELECTOR = YES;
287 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
288 | GCC_WARN_UNUSED_FUNCTION = YES;
289 | GCC_WARN_UNUSED_VARIABLE = YES;
290 | IPHONEOS_DEPLOYMENT_TARGET = 10.0;
291 | MTL_ENABLE_DEBUG_INFO = YES;
292 | ONLY_ACTIVE_ARCH = YES;
293 | SDKROOT = iphoneos;
294 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
295 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
296 | };
297 | name = Debug;
298 | };
299 | F145CFCC2087D16A006C159A /* Release */ = {
300 | isa = XCBuildConfiguration;
301 | buildSettings = {
302 | ALWAYS_SEARCH_USER_PATHS = NO;
303 | CLANG_ANALYZER_NONNULL = YES;
304 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
305 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
306 | CLANG_CXX_LIBRARY = "libc++";
307 | CLANG_ENABLE_MODULES = YES;
308 | CLANG_ENABLE_OBJC_ARC = YES;
309 | CLANG_ENABLE_OBJC_WEAK = YES;
310 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
311 | CLANG_WARN_BOOL_CONVERSION = YES;
312 | CLANG_WARN_COMMA = YES;
313 | CLANG_WARN_CONSTANT_CONVERSION = YES;
314 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
315 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
316 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
317 | CLANG_WARN_EMPTY_BODY = YES;
318 | CLANG_WARN_ENUM_CONVERSION = YES;
319 | CLANG_WARN_INFINITE_RECURSION = YES;
320 | CLANG_WARN_INT_CONVERSION = YES;
321 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
322 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
323 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
324 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
325 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
326 | CLANG_WARN_STRICT_PROTOTYPES = YES;
327 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
328 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
329 | CLANG_WARN_UNREACHABLE_CODE = YES;
330 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
331 | CODE_SIGN_IDENTITY = "iPhone Developer";
332 | COPY_PHASE_STRIP = NO;
333 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
334 | ENABLE_NS_ASSERTIONS = NO;
335 | ENABLE_STRICT_OBJC_MSGSEND = YES;
336 | GCC_C_LANGUAGE_STANDARD = gnu11;
337 | GCC_NO_COMMON_BLOCKS = YES;
338 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
339 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
340 | GCC_WARN_UNDECLARED_SELECTOR = YES;
341 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
342 | GCC_WARN_UNUSED_FUNCTION = YES;
343 | GCC_WARN_UNUSED_VARIABLE = YES;
344 | IPHONEOS_DEPLOYMENT_TARGET = 10.0;
345 | MTL_ENABLE_DEBUG_INFO = NO;
346 | SDKROOT = iphoneos;
347 | SWIFT_COMPILATION_MODE = wholemodule;
348 | SWIFT_OPTIMIZATION_LEVEL = "-O";
349 | VALIDATE_PRODUCT = YES;
350 | };
351 | name = Release;
352 | };
353 | F145CFCE2087D16A006C159A /* Debug */ = {
354 | isa = XCBuildConfiguration;
355 | buildSettings = {
356 | CLANG_ENABLE_MODULES = YES;
357 | CODE_SIGN_STYLE = Automatic;
358 | DEVELOPMENT_TEAM = PZYM8XX95Q;
359 | FRAMEWORK_SEARCH_PATHS = (
360 | "$(inherited)",
361 | "$(PROJECT_DIR)/Carthage/Build/iOS",
362 | );
363 | LD_RUNPATH_SEARCH_PATHS = (
364 | "$(inherited)",
365 | "@executable_path/Frameworks",
366 | "@loader_path/Frameworks",
367 | );
368 | OTHER_LDFLAGS = "-ObjC";
369 | PRODUCT_NAME = "$(TARGET_NAME)";
370 | SKIP_INSTALL = YES;
371 | SWIFT_OBJC_BRIDGING_HEADER = "RNTAztecView/RCTAztecView-Bridging-Header.h";
372 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
373 | SWIFT_VERSION = 4.0;
374 | TARGETED_DEVICE_FAMILY = "1,2";
375 | };
376 | name = Debug;
377 | };
378 | F145CFCF2087D16A006C159A /* Release */ = {
379 | isa = XCBuildConfiguration;
380 | buildSettings = {
381 | CLANG_ENABLE_MODULES = YES;
382 | CODE_SIGN_STYLE = Automatic;
383 | DEVELOPMENT_TEAM = PZYM8XX95Q;
384 | FRAMEWORK_SEARCH_PATHS = (
385 | "$(inherited)",
386 | "$(PROJECT_DIR)/Carthage/Build/iOS",
387 | );
388 | LD_RUNPATH_SEARCH_PATHS = (
389 | "$(inherited)",
390 | "@executable_path/Frameworks",
391 | "@loader_path/Frameworks",
392 | );
393 | OTHER_LDFLAGS = "-ObjC";
394 | PRODUCT_NAME = "$(TARGET_NAME)";
395 | SKIP_INSTALL = YES;
396 | SWIFT_OBJC_BRIDGING_HEADER = "RNTAztecView/RCTAztecView-Bridging-Header.h";
397 | SWIFT_VERSION = 4.0;
398 | TARGETED_DEVICE_FAMILY = "1,2";
399 | };
400 | name = Release;
401 | };
402 | /* End XCBuildConfiguration section */
403 |
404 | /* Begin XCConfigurationList section */
405 | F145CFC12087D169006C159A /* Build configuration list for PBXProject "RNTAztecView" */ = {
406 | isa = XCConfigurationList;
407 | buildConfigurations = (
408 | F145CFCB2087D16A006C159A /* Debug */,
409 | F145CFCC2087D16A006C159A /* Release */,
410 | );
411 | defaultConfigurationIsVisible = 0;
412 | defaultConfigurationName = Release;
413 | };
414 | F145CFCD2087D16A006C159A /* Build configuration list for PBXNativeTarget "RNTAztecView" */ = {
415 | isa = XCConfigurationList;
416 | buildConfigurations = (
417 | F145CFCE2087D16A006C159A /* Debug */,
418 | F145CFCF2087D16A006C159A /* Release */,
419 | );
420 | defaultConfigurationIsVisible = 0;
421 | defaultConfigurationName = Release;
422 | };
423 | /* End XCConfigurationList section */
424 | };
425 | rootObject = F145CFBE2087D169006C159A /* Project object */;
426 | }
427 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------