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
6c1a6d16
Unverified
Commit
6c1a6d16
authored
Nov 05, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
editor: added textViewEdgeInsets / Preset to Editor
parent
14b5e11a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
1 deletions
+30
-1
Sources/iOS/Editor.swift
+30
-1
No files found.
Sources/iOS/Editor.swift
View file @
6c1a6d16
...
...
@@ -56,6 +56,11 @@ public protocol EditorDelegate {
}
open
class
Editor
:
View
{
/// Will layout the view.
open
var
willLayout
:
Bool
{
return
0
<
width
&&
0
<
height
&&
nil
!=
superview
}
/// TextStorage instance that is observed while editing.
open
fileprivate
(
set
)
var
textStorage
:
TextStorage
!
...
...
@@ -65,6 +70,21 @@ open class Editor: View {
/// A reference to the NSLayoutManager.
open
fileprivate
(
set
)
var
layoutManager
:
NSLayoutManager
!
/// A preset wrapper around textViewEdgeInsets.
open
var
textViewEdgeInsetsPreset
=
EdgeInsetsPreset
.
none
{
didSet
{
textViewEdgeInsets
=
EdgeInsetsPresetToValue
(
preset
:
textViewEdgeInsetsPreset
)
}
}
/// A reference to textViewEdgeInsets.
@IBInspectable
open
var
textViewEdgeInsets
=
EdgeInsets
.
zero
{
didSet
{
layoutSubviews
()
}
}
/// Reference to the TextView.
open
fileprivate
(
set
)
var
textView
:
TextView
!
...
...
@@ -102,6 +122,15 @@ open class Editor: View {
return
matches
.
filter
{
nil
==
seen
.
updateValue
(
true
,
forKey
:
$0
)
}
}
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
guard
willLayout
else
{
return
}
textView
.
frame
=
CGRect
(
x
:
textViewEdgeInsets
.
left
,
y
:
textViewEdgeInsets
.
top
,
width
:
width
-
textViewEdgeInsets
.
left
-
textViewEdgeInsets
.
right
,
height
:
height
-
textViewEdgeInsets
.
top
-
textViewEdgeInsets
.
bottom
)
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
...
...
@@ -141,7 +170,7 @@ extension Editor {
/// Prepares the textView.
fileprivate
func
prepareTextView
()
{
textView
=
TextView
(
textContainer
:
textContainer
)
layout
(
textView
)
.
edges
(
)
addSubview
(
textView
)
}
/// Prepares the regular expression for matching.
...
...
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