Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
b001898d
Unverified
Commit
b001898d
authored
Nov 07, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
editor: added Editor delegation methods
parent
6c1a6d16
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
122 additions
and
0 deletions
+122
-0
Sources/iOS/Editor.swift
+122
-0
No files found.
Sources/iOS/Editor.swift
View file @
b001898d
...
@@ -53,6 +53,75 @@ public protocol EditorDelegate {
...
@@ -53,6 +53,75 @@ public protocol EditorDelegate {
*/
*/
@objc
@objc
optional
func
editor
(
editor
:
Editor
,
didProcessEditing
textStorage
:
TextStorage
,
text
:
String
,
range
:
NSRange
)
optional
func
editor
(
editor
:
Editor
,
didProcessEditing
textStorage
:
TextStorage
,
text
:
String
,
range
:
NSRange
)
/**
A delegation method that is executed when the textView should begin editing.
- Parameter editor: An Editor.
- Parameter shouldBeginEditing textView: A UITextView.
- Returns: A boolean indicating if the textView should begin editing, true if
yes, false otherwise.
*/
@objc
optional
func
editor
(
editor
:
Editor
,
shouldBeginEditing
textView
:
UITextView
)
->
Bool
/**
A delegation method that is executed when the textView should end editing.
- Parameter editor: An Editor.
- Parameter shouldEndEditing textView: A UITextView.
- Returns: A boolean indicating if the textView should end editing, true if
yes, false otherwise.
*/
@objc
optional
func
editor
(
editor
:
Editor
,
shouldEndEditing
textView
:
UITextView
)
->
Bool
/**
A delegation method that is executed when the textView did begin editing.
- Parameter editor: An Editor.
- Parameter didBeginEditing textView: A UITextView.
- Returns: A boolean indicating if the textView did begin editing, true if
yes, false otherwise.
*/
@objc
optional
func
editor
(
editor
:
Editor
,
didBeginEditing
textView
:
UITextView
)
->
Bool
/**
A delegation method that is executed when the textView did begin editing.
- Parameter editor: An Editor.
- Parameter didBeginEditing textView: A UITextView.
- Returns: A boolean indicating if the textView did begin editing, true if
yes, false otherwise.
*/
@objc
optional
func
editor
(
editor
:
Editor
,
didEndEditing
textView
:
UITextView
)
->
Bool
/**
A delegation method that is executed when the textView should change text in
a given range with replacement text.
- Parameter editor: An Editor.
- Parameter textView: A UITextView.
- Parameter shouldChangeTextIn range: A NSRange.
- Parameter replacementText text: A String.
- Returns: A boolean indicating if the textView should change text in a given
range with the given replacement text, true if yes, false otherwise.
*/
@objc
optional
func
editor
(
editor
:
Editor
,
textView
:
UITextView
,
shouldChangeTextIn
range
:
NSRange
,
replacementText
text
:
String
)
->
Bool
/**
A delegation method that is executed when the textView did change.
- Parameter editor: An Editor.
- Parameter didChange textView: A UITextView.
*/
@objc
optional
func
editor
(
editor
:
Editor
,
didChange
textView
:
UITextView
)
/**
A delegation method that is executed when the textView did change a selection.
- Parameter editor: An Editor.
- Parameter didChangeSelection textView: A UITextView.
*/
@objc
optional
func
editor
(
editor
:
Editor
,
didChangeSelection
textView
:
UITextView
)
}
}
open
class
Editor
:
View
{
open
class
Editor
:
View
{
...
@@ -170,6 +239,7 @@ extension Editor {
...
@@ -170,6 +239,7 @@ extension Editor {
/// Prepares the textView.
/// Prepares the textView.
fileprivate
func
prepareTextView
()
{
fileprivate
func
prepareTextView
()
{
textView
=
TextView
(
textContainer
:
textContainer
)
textView
=
TextView
(
textContainer
:
textContainer
)
textView
.
delegate
=
self
addSubview
(
textView
)
addSubview
(
textView
)
}
}
...
@@ -192,3 +262,55 @@ extension Editor: TextStorageDelegate {
...
@@ -192,3 +262,55 @@ extension Editor: TextStorageDelegate {
delegate
?
.
editor
?(
editor
:
self
,
didProcessEditing
:
textStorage
,
text
:
string
,
range
:
range
)
delegate
?
.
editor
?(
editor
:
self
,
didProcessEditing
:
textStorage
,
text
:
string
,
range
:
range
)
}
}
}
}
extension
Editor
:
TextViewDelegate
{
open
func
textViewShouldBeginEditing
(
_
textView
:
UITextView
)
->
Bool
{
return
delegate
?
.
editor
?(
editor
:
self
,
shouldBeginEditing
:
textView
)
??
true
}
open
func
textViewShouldEndEditing
(
_
textView
:
UITextView
)
->
Bool
{
return
delegate
?
.
editor
?(
editor
:
self
,
shouldEndEditing
:
textView
)
??
true
}
open
func
textViewDidBeginEditing
(
_
textView
:
UITextView
)
{
delegate
?
.
editor
?(
editor
:
self
,
didBeginEditing
:
textView
)
}
open
func
textViewDidEndEditing
(
_
textView
:
UITextView
)
{
delegate
?
.
editor
?(
editor
:
self
,
didEndEditing
:
textView
)
}
open
func
textView
(
_
textView
:
UITextView
,
shouldChangeTextIn
range
:
NSRange
,
replacementText
text
:
String
)
->
Bool
{
return
delegate
?
.
editor
?(
editor
:
self
,
textView
:
textView
,
shouldChangeTextIn
:
range
,
replacementText
:
text
)
??
true
}
open
func
textViewDidChange
(
_
textView
:
UITextView
)
{
delegate
?
.
editor
?(
editor
:
self
,
didChange
:
textView
)
}
open
func
textViewDidChangeSelection
(
_
textView
:
UITextView
)
{
delegate
?
.
editor
?(
editor
:
self
,
didChangeSelection
:
textView
)
}
}
@available(iOS 8.0, *)
extension
Editor
{
open
func
textView
(
_
textView
:
UITextView
,
shouldInteractWith
URL
:
URL
,
in
characterRange
:
NSRange
)
->
Bool
{
return
true
}
open
func
textView
(
_
textView
:
UITextView
,
shouldInteractWith
textAttachment
:
NSTextAttachment
,
in
characterRange
:
NSRange
)
->
Bool
{
return
true
}
}
@available(iOS 10.0, *)
extension
Editor
{
open
func
textView
(
_
textView
:
UITextView
,
shouldInteractWith
URL
:
URL
,
in
characterRange
:
NSRange
,
interaction
:
UITextItemInteraction
)
->
Bool
{
return
true
}
open
func
textView
(
_
textView
:
UITextView
,
shouldInteractWith
textAttachment
:
NSTextAttachment
,
in
characterRange
:
NSRange
,
interaction
:
UITextItemInteraction
)
->
Bool
{
return
true
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment