From d1369d2c5e7c5c5a71919c1789089009a5bf161b Mon Sep 17 00:00:00 2001 From: Geektree0101 Date: Fri, 18 Jan 2019 13:44:21 +0900 Subject: [PATCH] release v1.2.9 & Fix XMLParser Critical Issue --- Example/VEditorKit/content.xml | 2 +- VEditorKit.podspec | 2 +- VEditorKit/Classes/VEditorParser.swift | 15 +++++++++++++-- VEditorKit/Classes/VEditorXMLBuilder.swift | 11 +++++++++++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Example/VEditorKit/content.xml b/Example/VEditorKit/content.xml index c4ea4cc..f33d3c2 100644 --- a/Example/VEditorKit/content.xml +++ b/Example/VEditorKit/content.xml @@ -1 +1 @@ -

Welcome to VEditorKit

Lightweight and Powerful Editor Kit built on Texture(AsyncDisplayKit) https://github.com/texturegroup/texture. VEditorKit provides the most core functionality needed for the editor. Unfortunately, When combined words are entered then UITextView selectedRange will changed and typingAttribute will cleared. So, In combined words case, Users can't continue typing the style they want.

\n\n- Typing Attribute Test -
+

Welcome to VEditorKit

Lightweight and Powerful Editor Kit built on Texture(AsyncDisplayKit) https://github.com/texturegroup/texture. VEditorKit provides the most core functionality needed for the editor. Unfortunately, When combined words are entered then UITextView selectedRange will changed and typingAttribute will cleared. So, In combined words case, Users can't continue typing the style they want.

- Typing Attribute Test -

diff --git a/VEditorKit.podspec b/VEditorKit.podspec index 5bef060..894b155 100644 --- a/VEditorKit.podspec +++ b/VEditorKit.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'VEditorKit' - s.version = '1.2.8' + s.version = '1.2.9' s.summary = 'Lightweight and Powerful Editor Kit' s.description = 'Lightweight and Powerful Editor Kit built on Texture(AsyncDisplayKit)' diff --git a/VEditorKit/Classes/VEditorParser.swift b/VEditorKit/Classes/VEditorParser.swift index 3ca8cf5..6165d65 100644 --- a/VEditorKit/Classes/VEditorParser.swift +++ b/VEditorKit/Classes/VEditorParser.swift @@ -38,9 +38,20 @@ public final class VEditorParser: NSObject, XMLStyler { public func parseXML(_ xmlString: String, onSuccess: (([VEditorContent]) -> Void)? = nil, onError: ((Error?) -> Void)? = nil) { - let parser = VEditorContentParser(xmlString + var xmlString = xmlString .replacingOccurrences(of: "\\n", with: "\n") - .replacingOccurrences(of: "\\", with: ""), rule: self.parserRule) + .replacingOccurrences(of: "\\", with: "") + + // make newlink before block heading if needs + for blockXML in parserRule.blockStyleXMLTags { + let defaultCloseTag: String = "" + let blockOpenTag: String = "<\(blockXML)>" + let targetPairTag: String = defaultCloseTag + blockOpenTag + xmlString = xmlString.replacingOccurrences(of: targetPairTag, + with: "\n" + targetPairTag) + } + + let parser = VEditorContentParser(xmlString, rule: self.parserRule) switch parser.parseXMLContents() { case .success(let contents): diff --git a/VEditorKit/Classes/VEditorXMLBuilder.swift b/VEditorKit/Classes/VEditorXMLBuilder.swift index a4f6507..57a5982 100644 --- a/VEditorKit/Classes/VEditorXMLBuilder.swift +++ b/VEditorKit/Classes/VEditorXMLBuilder.swift @@ -33,6 +33,17 @@ public final class VEditorXMLBuilder { } xmlString = xmlString.squeezXMLString(rule) + + for xml in rule.allXML { + let open = self.generateXMLTag(xml, scope: .open(nil)) + let close = self.generateXMLTag(xml, scope: .close) + let emptyContent = open + close + let duplicatedPairedXMLTags = close + open + xmlString = xmlString + .replacingOccurrences(of: emptyContent, with: "") + .replacingOccurrences(of: duplicatedPairedXMLTags, with: "") + } + if xmlString.isEmpty { return nil } else if let packageTag = packageTag {