Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to integrate with WPiOS app. #69

Merged
merged 18 commits into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions RCTAztecView.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'json'

package = JSON.parse(File.read(File.join(__dir__, 'package.json')))

Pod::Spec.new do |s|
s.name = 'RNTAztecView'
s.version = package['version']
s.summary = 'Aztec editor for React Native'
s.license = package['license']
s.homepage = 'https://github.com/wordpress-mobile/react-native-aztec'
s.authors = 'Automattic'
s.source = { :git => 'https://github.com/wordpress-mobile/react-native-aztec.git' }
s.source_files = 'ios/**/*.{h,m,swift}'
s.public_header_files = 'ios/RNTAztecView/*.h'
s.requires_arc = true
s.platforms = { :ios => "10.0" }
s.xcconfig = {'OTHER_LDFLAGS' => '-lxml2',
'HEADER_SEARCH_PATHS' => '/usr/include/libxml2'}
s.dependency 'React'
s.dependency 'WordPress-Aztec-iOS'

end
6 changes: 5 additions & 1 deletion ios/RNTAztecView/RCTAztecViewManager.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#import "RCTAztecViewManager.h"
#import "RNTAztecView-Swift.h"
#import <React/RCTViewManager.h>

// USE "WordPress-Swift.h" to run on WPiOS, or "RNTAztecView-Swift.h" to run Example App.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a small hack to be able to build WPiOS app. I plan to remove this in the near future.

#import "RNTAztecView-Swift.h"
//#import "WordPress-Swift.h"


typedef void (^ActionBlock)(RCTAztecView *aztecView);

@implementation RCTAztecViewManager (RCTExternModule)
Expand Down
41 changes: 24 additions & 17 deletions ios/RNTAztecView/RCTAztecViewManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,38 @@ import Foundation

@objc (RCTAztecViewManager)
public class RCTAztecViewManager: RCTViewManager {

let attachmentDelegate: Aztec.TextViewAttachmentDelegate
let imageProvider: Aztec.TextViewAttachmentImageProvider

/// Customize the initializer to set up the Aztec delegate methods.
/// Then the example app should implement RCTBridgeDelegate
/// Then the example app should initialize this class and pass it to the bridge (since this class inherits from RCTBridgeModule
public required init(attachmentDelegate: Aztec.TextViewAttachmentDelegate, imageProvider: TextViewAttachmentImageProvider) {
self.attachmentDelegate = attachmentDelegate
self.imageProvider = imageProvider

super.init()

// NOTE:
// Removing temporarily images and attachment handling in favour of a simpler Bridge implementation.

// var attachmentDelegate: Aztec.TextViewAttachmentDelegate
// var imageProvider: Aztec.TextViewAttachmentImageProvider
//
// /// Customize the initializer to set up the Aztec delegate methods.
// /// Then the example app should implement RCTBridgeDelegate
// /// Then the example app should initialize this class and pass it to the bridge (since this class inherits from RCTBridgeModule
// public required init(attachmentDelegate: Aztec.TextViewAttachmentDelegate, imageProvider: TextViewAttachmentImageProvider) {
// self.attachmentDelegate = attachmentDelegate
// self.imageProvider = imageProvider
//
// super.init()
// }

public override static func requiresMainQueueSetup() -> Bool {
return true
}

@objc
public override func view() -> UIView {
let view = RCTAztecView(
defaultFont: .systemFont(ofSize: 12),
defaultParagraphStyle: .default,
defaultMissingImage: UIImage())

view.isScrollEnabled = false
view.textAttachmentDelegate = attachmentDelegate
view.registerAttachmentImageProvider(imageProvider)
// view.textAttachmentDelegate = attachmentDelegate
// view.registerAttachmentImageProvider(imageProvider)

return view
}
}