enchanted_quill 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/enchanted_quill/label.rb +21 -14
- data/lib/enchanted_quill/parser.rb +1 -1
- data/lib/enchanted_quill/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 91177bce7fa1321490c18a528fa9008bb68be745
|
|
4
|
+
data.tar.gz: 488e366244ce71ed25bec2f29af7c85c5743c330
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 18b796b45e53b0f895c6e46d655cf39fe99595e105caf5ef2442e723baadea73fc2e87e1227b01c0eb7460ae9ac50e3f0c57079d3df8e28479670fd063c92588
|
|
7
|
+
data.tar.gz: 6db53c4284d5ffcba63aa54a38dfe3d150eb596060bfdc8f6652e8413f20a6846dc656a94b60138860c96d5053f12f0b7a0c3f5dc4d33e5fba0d33bd33628e88
|
|
@@ -19,6 +19,12 @@ module EnchantedQuill
|
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
def awakeFromNib
|
|
23
|
+
super.tap do
|
|
24
|
+
update_text_storage
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
22
28
|
def drawTextInRect(rect)
|
|
23
29
|
range = NSMakeRange(0, text_storage.length)
|
|
24
30
|
text_container.size = rect.size
|
|
@@ -326,7 +332,9 @@ module EnchantedQuill
|
|
|
326
332
|
|
|
327
333
|
attributed_text = attributedText
|
|
328
334
|
if attributed_text.nil? || attributed_text.length == 0
|
|
335
|
+
clear_active_elements
|
|
329
336
|
text_storage.setAttributedString(NSAttributedString.alloc.initWithString(''))
|
|
337
|
+
setNeedsDisplay
|
|
330
338
|
return
|
|
331
339
|
end
|
|
332
340
|
|
|
@@ -334,20 +342,14 @@ module EnchantedQuill
|
|
|
334
342
|
mut_attr_string = add_default_attributes(mut_attr_string)
|
|
335
343
|
|
|
336
344
|
if parse_text
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
Dispatch::Queue.main.async do
|
|
346
|
-
add_link_attribute(mut_attr_string)
|
|
347
|
-
text_storage.setAttributedString(mut_attr_string)
|
|
348
|
-
setNeedsDisplay
|
|
349
|
-
end
|
|
350
|
-
end
|
|
345
|
+
clear_active_elements
|
|
346
|
+
parse_text_and_extract_active_elements(mut_attr_string)
|
|
347
|
+
active_elements_values = @active_elements.values.flatten.compact
|
|
348
|
+
|
|
349
|
+
if active_elements_values.count > 0
|
|
350
|
+
add_link_attribute(mut_attr_string)
|
|
351
|
+
text_storage.setAttributedString(mut_attr_string)
|
|
352
|
+
setNeedsDisplay
|
|
351
353
|
end
|
|
352
354
|
end
|
|
353
355
|
|
|
@@ -355,6 +357,11 @@ module EnchantedQuill
|
|
|
355
357
|
setNeedsDisplay
|
|
356
358
|
end
|
|
357
359
|
|
|
360
|
+
def clear_active_elements
|
|
361
|
+
@selected_element = nil
|
|
362
|
+
@active_elements = {}
|
|
363
|
+
end
|
|
364
|
+
|
|
358
365
|
def text_origin(rect)
|
|
359
366
|
used_rect = layout_manager.usedRectForTextContainer(text_container)
|
|
360
367
|
@height_correction = (rect.size.height - used_rect.size.height) / 2
|
|
@@ -4,7 +4,7 @@ module EnchantedQuill
|
|
|
4
4
|
HASHTAG_REGEX = "(?:^|\\s|$)#[\\p{L}0-9_]*"
|
|
5
5
|
MENTION_REGEX = "(?:^|\\s|$|[.])@[\\p{L}0-9_]*"
|
|
6
6
|
URL_REGEX = "(^|[\\s.:;?\\-\\]<\\(])" +
|
|
7
|
-
"((https?://|www
|
|
7
|
+
"((https?://|www\\.|pic\\.)[-\\w;/?:@&=+$\\|\\_.!~*\\|'()\\[\\]%#,☺]+[\\w/#](\\(\\))?)" +
|
|
8
8
|
"(?=$|[\\s',\\|\\(\\).:;?\\-\\[\\]>\\)])"
|
|
9
9
|
|
|
10
10
|
TYPE_WITH_REGEX = {
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: enchanted_quill
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Elom Gomez
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-06-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|