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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e82c15520eb37dad77de33e4bc2c73aca9d7855
4
- data.tar.gz: 38318ca27d68557f57e53952a0995a993e5a6b5d
3
+ metadata.gz: 91177bce7fa1321490c18a528fa9008bb68be745
4
+ data.tar.gz: 488e366244ce71ed25bec2f29af7c85c5743c330
5
5
  SHA512:
6
- metadata.gz: 5d47b6625a959651a9a7cd06fb6d345431ac57c7e9648b4eb478a030c019d4532ab981c8e705682f6ae4ddc867193677ff29fcd5578c1522a58b5388147c2643
7
- data.tar.gz: 32438a3e4f8169319164a3b0e766143989c5002c35f2073d0469d683d87fed511c047636d79890afe11caef688a12acad69738ec1ed07b0eb955d1bda0095725
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
- @selected_element = nil
338
- @active_elements = {}
339
-
340
- Dispatch::Queue.concurrent.async do
341
- parse_text_and_extract_active_elements(mut_attr_string)
342
- active_elements_values = @active_elements.values.flatten.compact
343
-
344
- if active_elements_values.count > 0
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.|pic.)[-\\w;/?:@&=+$\\|\\_.!~*\\|'()\\[\\]%#,☺]+[\\w/#](\\(\\))?)" +
7
+ "((https?://|www\\.|pic\\.)[-\\w;/?:@&=+$\\|\\_.!~*\\|'()\\[\\]%#,☺]+[\\w/#](\\(\\))?)" +
8
8
  "(?=$|[\\s',\\|\\(\\).:;?\\-\\[\\]>\\)])"
9
9
 
10
10
  TYPE_WITH_REGEX = {
@@ -1,3 +1,3 @@
1
1
  module EnchantedQuill
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.6'
3
3
  end
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.5
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-04-11 00:00:00.000000000 Z
11
+ date: 2016-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake