From 46cb7ea44b2ae17c599e281fd01188f913185439 Mon Sep 17 00:00:00 2001 From: hansemannn Date: Sat, 17 Aug 2019 20:04:31 +0200 Subject: [PATCH 1/5] chore: use Swift 5, resolve Xcode warnings --- RichEditorView.xcodeproj/project.pbxproj | 11 +++++++---- RichEditorView/Classes/RichEditorView.swift | 4 +--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/RichEditorView.xcodeproj/project.pbxproj b/RichEditorView.xcodeproj/project.pbxproj index c421cf52..60b3cc34 100644 --- a/RichEditorView.xcodeproj/project.pbxproj +++ b/RichEditorView.xcodeproj/project.pbxproj @@ -400,6 +400,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = FBA6AAEF1AD3EC9F00721644; @@ -560,6 +561,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -602,6 +604,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -624,7 +627,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -642,7 +645,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.cjwirth.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -658,7 +661,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.cjwirth.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -670,7 +673,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.cjwirth.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/RichEditorView/Classes/RichEditorView.swift b/RichEditorView/Classes/RichEditorView.swift index 527b81c7..dffc0571 100644 --- a/RichEditorView/Classes/RichEditorView.swift +++ b/RichEditorView/Classes/RichEditorView.swift @@ -135,7 +135,6 @@ import UIKit } private func setup() { - backgroundColor = .red webView.frame = bounds webView.delegate = self @@ -143,7 +142,6 @@ import UIKit webView.scalesPageToFit = false webView.autoresizingMask = [.flexibleWidth, .flexibleHeight] webView.dataDetectorTypes = UIDataDetectorTypes() - webView.backgroundColor = .white webView.scrollView.isScrollEnabled = isScrollEnabled webView.scrollView.bounces = false @@ -368,7 +366,7 @@ import UIKit // MARK: UIWebViewDelegate - public func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool { + public func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebView.NavigationType) -> Bool { // Handle pre-defined editor actions let callbackPrefix = "re-callback://" From 74d7212e9f40e980ed641956e30d8cef735e71e6 Mon Sep 17 00:00:00 2001 From: hansemannn Date: Sat, 17 Aug 2019 20:04:53 +0200 Subject: [PATCH 2/5] feat: support dark mode, set background-color properly --- RichEditorView/Assets/editor/rich_editor.js | 3 ++- RichEditorView/Assets/editor/style.css | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/RichEditorView/Assets/editor/rich_editor.js b/RichEditorView/Assets/editor/rich_editor.js index 6fc55d4e..9a53bfbe 100644 --- a/RichEditorView/Assets/editor/rich_editor.js +++ b/RichEditorView/Assets/editor/rich_editor.js @@ -21,6 +21,7 @@ window.onload = function() { RE.callback("ready"); }; +RE.body = document.getElementsByTagName('body')[0]; RE.editor = document.getElementById('editor'); // Not universally supported, but seems to work in iOS 7 and 8 @@ -138,7 +139,7 @@ RE.setFontSize = function(size) { }; RE.setBackgroundColor = function(color) { - RE.editor.style.backgroundColor = color; + RE.body.style.backgroundColor = color; }; RE.setHeight = function(size) { diff --git a/RichEditorView/Assets/editor/style.css b/RichEditorView/Assets/editor/style.css index f7484847..493ebd4f 100644 --- a/RichEditorView/Assets/editor/style.css +++ b/RichEditorView/Assets/editor/style.css @@ -23,6 +23,13 @@ html { body { min-height: 100%; overflow: auto; + background-color: white; +} + +@media (prefers-color-scheme: dark) { + body { + background-color: black; + } } body, h1, p { @@ -59,3 +66,9 @@ div { color:#666666; font-size: 12pt; } + +@media (prefers-color-scheme: dark) { + #editor { + color: white; + } +} \ No newline at end of file From 9e68b6e8c717374d5bdad937b39cd51532b14bbb Mon Sep 17 00:00:00 2001 From: hansemannn Date: Sat, 17 Aug 2019 20:06:23 +0200 Subject: [PATCH 3/5] build: bump version --- RichEditorView.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RichEditorView.podspec b/RichEditorView.podspec index 7ae3a6ed..9c3a88f7 100644 --- a/RichEditorView.podspec +++ b/RichEditorView.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "RichEditorView" - s.version = "5.0.0" + s.version = "6.0.0" s.summary = "Rich Text Editor for iOS written in Swift" s.homepage = "https://github.com/cjwirth/RichEditorView" s.license = 'BSD 3-clause' @@ -9,7 +9,7 @@ Pod::Spec.new do |s| s.social_media_url = 'https://twitter.com/cjwirth' s.platform = :ios, '8.0' - s.swift_version = '4.0' + s.swift_version = '5.0' s.requires_arc = true s.source_files = 'RichEditorView/Classes/*' From 074fc1da7c0bcb4bcbc69eda9bfa6159bee1f1b2 Mon Sep 17 00:00:00 2001 From: hansemannn Date: Sat, 5 Oct 2019 22:14:17 +0200 Subject: [PATCH 4/5] chore: add more color fixes --- RichEditorView/Assets/editor/style.css | 4 ++-- RichEditorView/Classes/RichEditorView.swift | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/RichEditorView/Assets/editor/style.css b/RichEditorView/Assets/editor/style.css index 493ebd4f..d4af0cdd 100644 --- a/RichEditorView/Assets/editor/style.css +++ b/RichEditorView/Assets/editor/style.css @@ -62,7 +62,7 @@ div { height: 100%; overflow: auto; display: block; - font-family: 'HelveticaNeue'; + font-family: '-apple-system', 'HelveticaNeue'; color:#666666; font-size: 12pt; } @@ -71,4 +71,4 @@ div { #editor { color: white; } -} \ No newline at end of file +} diff --git a/RichEditorView/Classes/RichEditorView.swift b/RichEditorView/Classes/RichEditorView.swift index dffc0571..5269458c 100644 --- a/RichEditorView/Classes/RichEditorView.swift +++ b/RichEditorView/Classes/RichEditorView.swift @@ -142,12 +142,14 @@ import UIKit webView.scalesPageToFit = false webView.autoresizingMask = [.flexibleWidth, .flexibleHeight] webView.dataDetectorTypes = UIDataDetectorTypes() + webView.backgroundColor = UIColor.red webView.scrollView.isScrollEnabled = isScrollEnabled webView.scrollView.bounces = false webView.scrollView.delegate = self webView.scrollView.clipsToBounds = false - + webView.scrollView.backgroundColor = UIColor.green + webView.cjw_inputAccessoryView = nil self.addSubview(webView) From 75c3a216d54ed327ce4a2b5df1690040bafae725 Mon Sep 17 00:00:00 2001 From: hansemannn Date: Sun, 6 Oct 2019 12:46:38 +0200 Subject: [PATCH 5/5] chore: set parent views background color as well --- RichEditorView/Classes/RichEditorView.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/RichEditorView/Classes/RichEditorView.swift b/RichEditorView/Classes/RichEditorView.swift index 5269458c..ff22709a 100644 --- a/RichEditorView/Classes/RichEditorView.swift +++ b/RichEditorView/Classes/RichEditorView.swift @@ -142,13 +142,11 @@ import UIKit webView.scalesPageToFit = false webView.autoresizingMask = [.flexibleWidth, .flexibleHeight] webView.dataDetectorTypes = UIDataDetectorTypes() - webView.backgroundColor = UIColor.red webView.scrollView.isScrollEnabled = isScrollEnabled webView.scrollView.bounces = false webView.scrollView.delegate = self webView.scrollView.clipsToBounds = false - webView.scrollView.backgroundColor = UIColor.green webView.cjw_inputAccessoryView = nil @@ -234,6 +232,9 @@ import UIKit } public func setEditorBackgroundColor(_ color: UIColor) { + webView.backgroundColor = color + webView.scrollView.backgroundColor = color + runJS("RE.setBackgroundColor('\(color.hex)');") }