summaryrefslogtreecommitdiff
path: root/www/crm/wp-content/plugins/civicrm/civicrm/bower_components/ckeditor/samples/old/codesnippet/codesnippet.html
blob: a67504f996863390e1c02ea346a42a09a2485f4a (plain)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<!DOCTYPE html>
<!--
Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
-->
<html>
<head>
	<meta charset="utf-8">
	<title>Code Snippet &mdash; CKEditor Sample</title>
	<script src="../../../ckeditor.js"></script>
	<link href="../../../samples/old/sample.css" rel="stylesheet">
	<link href="../../../plugins/codesnippet/lib/highlight/styles/monokai_sublime.css" rel="stylesheet">
	<meta name="ckeditor-sample-name" content="Code Snippet plugin">
	<meta name="ckeditor-sample-group" content="Plugins">
	<meta name="ckeditor-sample-description" content="View and modify code using the Code Snippet plugin.">
	<meta name="ckeditor-sample-isnew" content="1">
	<style>

		#editable
		{
			padding: 10px 20px;
		}

	</style>
</head>
<body>
	<h1 class="samples">
		<a href="../../../samples/old/index.html">CKEditor Samples</a> &raquo; Code Snippet Plugin
	</h1>
	<div class="warning deprecated">
		This sample is not maintained anymore. Check out its <a href="https://sdk.ckeditor.com/samples/codesnippet.html">brand new version in CKEditor SDK</a>.
	</div>

	<div class="description">
		<p>
			This editor is using the <strong><a href="https://ckeditor.com/cke4/addon/codesnippet">Code Snippet</a></strong> plugin which introduces beautiful code snippets.
			By default the <code>codesnippet</code> plugin depends on the built-in client-side syntax highlighting
			library <a href="http://highlightjs.org">highlight.js</a>.
		</p>
		<p>
			You can adjust the appearance of code snippets using the <code><a href="https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.config-cfg-codeSnippet_theme">codeSnippet_theme</a></code> configuration variable
			(see <a href="http://highlightjs.org/static/test.html">available themes</a>).
		</p>
		<p>
			Select theme: <select id="select"></select>
		</p>
		<p>
			The CKEditor instance below was created by using the following configuration settings:
		</p>

<pre class="samples" id="sampleConfig">
CKEDITOR.replace( 'editor1', {
	<strong>extraPlugins: 'codesnippet',</strong>
	codeSnippet_theme: 'monokai_sublime'
} );
</pre>

		<p id="ie8-warning">
			Please note that this plugin is not compatible with Internet Explorer 8.
		</p>
	</div>

	<textarea id="editor1">
&lt;p&gt;JavaScript code:&lt;/p&gt;

&lt;pre&gt;
&lt;code class="language-javascript"&gt;function isEmpty( object ) {
	for ( var i in object ) {
		if ( object.hasOwnProperty( i ) )
			return false;
	}
	return true;
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;SQL query:&lt;/p&gt;

&lt;pre&gt;
&lt;code class="language-sql"&gt;SELECT cust.id FROM cust LEFT JOIN loc ON ( cust.loc_id = loc.id ) WHERE cust.type IN ( 1, 2 );&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Unknown markup:&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt; ________________
/                \
| How about moo? |  ^__^
\________________/  (oo)\_______
                  \ (__)\       )\/\
                        ||----w |
                        ||     ||
&lt;/code&gt;&lt;/pre&gt;
	</textarea>

	<h2>Inline editor</h2>

	<div class="description">
		<p>
			The following sample shows the <strong>Code Snippet</strong> plugin running inside
			an inline CKEditor instance. The CKEditor instance below was created by using the following configuration settings:
		</p>

<pre class="samples">
CKEDITOR.inline( 'editable', {
	<strong>extraPlugins: 'codesnippet'</strong>
} );
</pre>

		<p>
			<strong>Note</strong>: The <a href="http://highlightjs.org/static/test.html">highlight.js themes</a>
			must be loaded manually to be applied inside an inline editor instance, as the
			<code>codeSnippet_theme</code> setting will not work in that case.
			You need to include the stylesheet in the <code>&lt;head&gt;</code> section of the page, for example:
		</p>

<pre class="samples">
&lt;head&gt;
	...
	&lt;link href="path/to/highlight.js/styles/monokai_sublime.css" rel="stylesheet"&gt;
&lt;/head&gt;
</pre>

	</div>

	<div id="editable" contenteditable="true">

<p>JavaScript code:</p>

<pre><code class="language-javascript">function isEmpty( object ) {
	for ( var i in object ) {
		if ( object.hasOwnProperty( i ) )
			return false;
	}
	return true;
}</code></pre>

<p>SQL query:</p>

<pre><code class="language-sql">SELECT cust.id, cust.name, loc.city FROM cust LEFT JOIN loc ON ( cust.loc_id = loc.id ) WHERE cust.type IN ( 1, 2 );</code></pre>

<p>Unknown markup:</p>

<pre><code> ________________
/                \
| How about moo? |  ^__^
\________________/  (oo)\_______
                  \ (__)\       )\/\
                        ||----w |
                        ||     ||
</code></pre>
	</div>

	<h2>Server-side Highlighting and Custom Highlighting Engines</h2>

	<p>
		The <a href="https://ckeditor.com/cke4/addon/codesnippetgeshi"><strong>Code Snippet GeSHi</strong></a> plugin is an
		extension of the <strong>Code Snippet</strong> plugin which uses a server-side highligter.
	</p>

	<p>
		It also is possible to replace the default highlighter with any library using
		the <a href="https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.plugins.codesnippet.highlighter">Highlighter API</a>
		and the <a href="https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.plugins.codesnippet-method-setHighlighter"><code>editor.plugins.codesnippet.setHighlighter()</code></a> method.
	</p>

	<script>
		( function() {
			CKEDITOR.disableAutoInline = true;

			var config = {
				extraPlugins: 'codesnippet',
				toolbar: [
					[ 'Source' ], [ 'Undo', 'Redo' ], [ 'Bold', 'Italic', 'Underline' ], [ 'CodeSnippet' ]
				],
				codeSnippet_theme: 'monokai_sublime',
				height: 400
			};

			CKEDITOR.replace( 'editor1', config );

			CKEDITOR.inline( 'editable', CKEDITOR.tools.extend( {}, config, {
				extraPlugins: 'codesnippet'
			}, true ) );

			initThemeChange();

			function initThemeChange() {
				var templates = [
						'monokai_sublime', 'default', 'arta', 'ascetic', 'atelier-dune.dark', 'atelier-dune.light', 'atelier-forest.dark', 'atelier-forest.light', 'atelier-heath.dark', 'atelier-heath.light', 'atelier-lakeside.dark', 'atelier-lakeside.light', 'atelier-seaside.dark', 'atelier-seaside.light', 'brown_paper', 'dark', 'docco', 'far', 'foundation', 'github', 'googlecode', 'idea', 'ir_black', 'magula', 'mono-blue', 'monokai', 'obsidian', 'paraiso.dark', 'paraiso.light', 'pojoaque', 'railscasts', 'rainbow', 'school_book', 'solarized_dark', 'solarized_light', 'sunburst', 'tomorrow-night-blue', 'tomorrow-night-bright', 'tomorrow-night-eighties', 'tomorrow-night', 'tomorrow', 'vs', 'xcode', 'zenburn'
					],
					pre = CKEDITOR.document.getById( 'sampleConfig' ),
					select = CKEDITOR.document.getById( 'select' ),
					codeTemplate = 'CKEDITOR.replace( \'editor1\', {\n' +
						'	<strong>extraPlugins: \'codesnippet\',</strong>\n' +
						'	codeSnippet_theme: \'{tpl}\'\n' +
					'} );',
					name, option;

				while ( ( name = templates.shift() ) ) {
					option = CKEDITOR.document.createElement( 'option', {
						attributes: {
							value: name
						}
					} );

					option.setText( name );
					select.append( option );
				}

				select.$.onchange = function() {
					if ( CKEDITOR.instances.editor1 )
						CKEDITOR.instances.editor1.destroy();

					CKEDITOR.replace( 'editor1', CKEDITOR.tools.extend( {}, config, {
						codeSnippet_theme: this.value
					}, true ) );

					pre.setHtml( codeTemplate.replace( '{tpl}', this.value ) );
				};
			}

			if ( CKEDITOR.env.ie && CKEDITOR.env.version == 8 )
				CKEDITOR.document.getById( 'ie8-warning' ).addClass( 'warning' );
		}() );
	</script>

	<div id="footer">
		<hr>
		<p>
			CKEditor - The text editor for the Internet - <a class="samples" href="https://ckeditor.com/">https://ckeditor.com</a>
		</p>
		<p id="copy">
			Copyright &copy; 2003-2018, <a class="samples" href="https://cksource.com/">CKSource</a> - Frederico
			Knabben. All rights reserved.
		</p>
	</div>
</body>
</html>