1 | <?php |
||
10 | abstract class Wysiwyg |
||
11 | { |
||
12 | /** |
||
13 | * @var RawTqContext |
||
14 | */ |
||
15 | private $context; |
||
16 | /** |
||
17 | * @var string |
||
18 | * JS code that return an instance of WYSIWYG editor. |
||
19 | */ |
||
20 | private $object = ''; |
||
21 | /** |
||
22 | * @var string |
||
23 | * Field selector. |
||
24 | */ |
||
25 | private $selector = ''; |
||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | private $instances = []; |
||
30 | |||
31 | /** |
||
32 | * @param RawTqContext $context |
||
33 | * Context of page. Needs to interact with browser. |
||
34 | */ |
||
35 | protected function setContext(RawTqContext $context) |
||
39 | |||
40 | /** |
||
41 | * @see TinyMCE::__construct() |
||
42 | * @see CKEditor::__construct() |
||
43 | * |
||
44 | * @param string $javascript |
||
45 | * Must a string of JS code that return an instance of editor. String will be |
||
46 | * processed by sprintf() and "%s" placeholder will be replaced by field ID. |
||
47 | */ |
||
48 | protected function setObject($javascript) |
||
52 | |||
53 | /** |
||
54 | * @param string $selector |
||
55 | */ |
||
56 | public function setSelector($selector) |
||
62 | |||
63 | /** |
||
64 | * @return string |
||
65 | */ |
||
66 | public function getSelector() |
||
70 | |||
71 | /** |
||
72 | * Get the editor instance for use in Javascript. |
||
73 | * |
||
74 | * @param string $selector |
||
75 | * Any selector of a form field. |
||
76 | * |
||
77 | * @throws \RuntimeException |
||
78 | * @throws \Exception |
||
79 | * @throws \WebDriver\Exception\NoSuchElement |
||
80 | * |
||
81 | * @return string |
||
82 | * A Javascript expression that representing WYSIWYG instance. |
||
83 | */ |
||
84 | protected function getInstance($selector = '') |
||
109 | |||
110 | /** |
||
111 | * @param string $method |
||
112 | * WYSIWYG editor method. |
||
113 | * @param string $selector |
||
114 | * Editor selector. |
||
115 | * @param array $arguments |
||
116 | * Arguments for method of WYSIWYG editor. |
||
117 | * |
||
118 | * @throws \Exception |
||
119 | * Throws an exception if the editor does not exist. |
||
120 | * |
||
121 | * @return string |
||
122 | * Result of JS evaluation. |
||
123 | */ |
||
124 | protected function execute($method, $selector = '', array $arguments = []) |
||
132 | |||
133 | /** |
||
134 | * @param string $wysiwyg |
||
135 | * @param array $arguments |
||
136 | * |
||
137 | * @throws \Exception |
||
138 | * |
||
139 | * @return self |
||
140 | */ |
||
141 | public static function instantiate($wysiwyg, array $arguments = []) |
||
156 | |||
157 | /** |
||
158 | * @param string $text |
||
159 | * Text to insert. |
||
160 | * @param string $selector |
||
161 | * Editor selector. |
||
162 | */ |
||
163 | abstract public function fill($text, $selector = ''); |
||
164 | |||
165 | /** |
||
166 | * @param string $text |
||
167 | * Text to insert. |
||
168 | * @param string $selector |
||
169 | * Editor selector. |
||
170 | */ |
||
171 | abstract public function type($text, $selector = ''); |
||
172 | |||
173 | /** |
||
174 | * @param string $selector |
||
175 | * Editor selector. |
||
176 | * |
||
177 | * @return string |
||
178 | * Editor content. |
||
179 | */ |
||
180 | abstract public function read($selector = ''); |
||
181 | } |
||
182 |