-
-
Notifications
You must be signed in to change notification settings - Fork 353
/
SpRichTextPresenter.class.st
102 lines (78 loc) · 1.86 KB
/
SpRichTextPresenter.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
"
@@TODO
!! Transmissions
- #inputTextPort (default)
- #outputTextChangedPort (default)
"
Class {
#name : #SpRichTextPresenter,
#superclass : #SpTextPresenter,
#instVars : [
'#textStyler => SpObservableSlot',
'#model'
],
#category : #'Spec2-Core-Widgets-Text'
}
{ #category : #specs }
SpRichTextPresenter class >> adapterName [
^ #RichTextAdapter
]
{ #category : #examples }
SpRichTextPresenter class >> example [
<sampleInstance>
^ self new
openWithSpec;
text:
'some method: 42'
]
{ #category : #specs }
SpRichTextPresenter class >> title [
^ 'Rich Text'
]
{ #category : #accessing }
SpRichTextPresenter >> defaultTextStyler [
self subclassResponsibility
]
{ #category : #rendering }
SpRichTextPresenter >> formatString [
^ self textStyler value writeFormatString: self model
]
{ #category : #rendering }
SpRichTextPresenter >> formatString: formatString [
model := self textStyler value parseFormatString: formatString
]
{ #category : #initialization }
SpRichTextPresenter >> initialize [
super initialize
]
{ #category : #rendering }
SpRichTextPresenter >> model [
^ model
]
{ #category : #'as yet unclassified' }
SpRichTextPresenter >> plaintext [
^ self textStyler writePlaintextString: self model
]
{ #category : #rendering }
SpRichTextPresenter >> renderTree [
"^ SpRenderTreeBuilderVisitor new
styleProvider: self styleAttributes;
render: self model"
]
{ #category : #initialization }
SpRichTextPresenter >> styleAttributes [
^ self textStyler value styles
]
{ #category : #accessing }
SpRichTextPresenter >> textStyler [
^ textStyler ifNil: [
textStyler := self defaultTextStyler ]
]
{ #category : #accessing }
SpRichTextPresenter >> textStyler: aTextStyler [
textStyler := aTextStyler
]
{ #category : #'api-events' }
SpRichTextPresenter >> whenTextStylerChangedDo: aBlock [
self property: #textStyler whenChangedDo: aBlock
]