Debian Codegraph @

closure-library/closure/goog/demos/editor/editor.html

raw
1 <html>
2 <!--
3 Copyright 2009 The Closure Library Authors. All Rights Reserved.
4
5 Use of this source code is governed by the Apache License, Version 2.0.
6 See the COPYING file for details.
7 -->
8 <!--
9 -->
10 <head>
11 <meta http-equiv="X-UA-Compatible" content="IE=edge">
12 <title>goog.editor Demo</title>
13 <script src="../../base.js"></script>
14 <script>
15 goog.require('goog.dom');
16 goog.require('goog.editor.Command');
17 goog.require('goog.editor.Field');
18 goog.require('goog.editor.plugins.BasicTextFormatter');
19 goog.require('goog.editor.plugins.EnterHandler');
20 goog.require('goog.editor.plugins.HeaderFormatter');
21 goog.require('goog.editor.plugins.LinkBubble');
22 goog.require('goog.editor.plugins.LinkDialogPlugin');
23 goog.require('goog.editor.plugins.ListTabHandler');
24 goog.require('goog.editor.plugins.LoremIpsum');
25 goog.require('goog.editor.plugins.RemoveFormatting');
26 goog.require('goog.editor.plugins.SpacesTabHandler');
27 goog.require('goog.editor.plugins.UndoRedo');
28 goog.require('goog.ui.editor.DefaultToolbar');
29 goog.require('goog.ui.editor.ToolbarController');
30 </script>
31
32 <link rel="stylesheet" href="../css/demo.css">
33
34 <link rel="stylesheet" href="../../css/button.css" />
35 <link rel="stylesheet" href="../../css/dialog.css" />
36 <link rel="stylesheet" href="../../css/linkbutton.css" />
37 <link rel="stylesheet" href="../../css/menu.css">
38 <link rel="stylesheet" href="../../css/menuitem.css">
39 <link rel="stylesheet" href="../../css/menuseparator.css">
40 <link rel="stylesheet" href="../../css/tab.css" />
41 <link rel="stylesheet" href="../../css/tabbar.css" />
42 <link rel="stylesheet" href="../../css/toolbar.css" />
43 <link rel="stylesheet" href="../../css/colormenubutton.css" />
44 <link rel="stylesheet" href="../../css/palette.css" />
45 <link rel="stylesheet" href="../../css/colorpalette.css" />
46
47 <link rel="stylesheet" href="../../css/editor/bubble.css" />
48 <link rel="stylesheet" href="../../css/editor/dialog.css" />
49 <link rel="stylesheet" href="../../css/editor/linkdialog.css" />
50 <link rel="stylesheet" href="../../css/editortoolbar.css" />
51
52 <style>
53 #editMe {
54 width: 600px;
55 height: 300px;
56 background-color: white;
57 border: 1px solid grey;
58 }
59 </style>
60 </head>
61
62 <body>
63 <h1>goog.editor Demo</h1>
64 <p>This is a demonstration of a editable field, with installed plugins,
65 hooked up to a toolbar.</p>
66 <br>
67 <div id='toolbar' style='width:602px'></div>
68 <div id='editMe'></div>
69 <hr>
70 <p><b>Current field contents</b>
71 (updates as contents of the editable field above change):<br>
72 <textarea id="fieldContents" style="height:100px;width:400px;"></textarea><br>
73 <input type="button" value="Set Field Contents"
74 onclick="myField.setHtml(false, goog.dom.getElement('fieldContents').value);" />
75 (Use to set contents of the editable field to the contents of this textarea)
76 </p>
77
78 <script>
79 function updateFieldContents() {
80 goog.dom.getElement('fieldContents').value = myField.getCleanContents();
81 }
82
83 // Create an editable field.
84 var myField = new goog.editor.Field('editMe');
85
86 // Create and register all of the editing plugins you want to use.
87 myField.registerPlugin(new goog.editor.plugins.BasicTextFormatter());
88 myField.registerPlugin(new goog.editor.plugins.RemoveFormatting());
89 myField.registerPlugin(new goog.editor.plugins.UndoRedo());
90 myField.registerPlugin(new goog.editor.plugins.ListTabHandler());
91 myField.registerPlugin(new goog.editor.plugins.SpacesTabHandler());
92 myField.registerPlugin(new goog.editor.plugins.EnterHandler());
93 myField.registerPlugin(new goog.editor.plugins.HeaderFormatter());
94 myField.registerPlugin(
95 new goog.editor.plugins.LoremIpsum('Click here to edit'));
96 myField.registerPlugin(
97 new goog.editor.plugins.LinkDialogPlugin());
98 myField.registerPlugin(new goog.editor.plugins.LinkBubble());
99
100 // Specify the buttons to add to the toolbar, using built in default buttons.
101 var buttons = [
102 goog.editor.Command.BOLD,
103 goog.editor.Command.ITALIC,
104 goog.editor.Command.UNDERLINE,
105 goog.editor.Command.FONT_COLOR,
106 goog.editor.Command.BACKGROUND_COLOR,
107 goog.editor.Command.FONT_FACE,
108 goog.editor.Command.FONT_SIZE,
109 goog.editor.Command.LINK,
110 goog.editor.Command.UNDO,
111 goog.editor.Command.REDO,
112 goog.editor.Command.UNORDERED_LIST,
113 goog.editor.Command.ORDERED_LIST,
114 goog.editor.Command.INDENT,
115 goog.editor.Command.OUTDENT,
116 goog.editor.Command.JUSTIFY_LEFT,
117 goog.editor.Command.JUSTIFY_CENTER,
118 goog.editor.Command.JUSTIFY_RIGHT,
119 goog.editor.Command.SUBSCRIPT,
120 goog.editor.Command.SUPERSCRIPT,
121 goog.editor.Command.STRIKE_THROUGH,
122 goog.editor.Command.REMOVE_FORMAT
123 ];
124 var myToolbar = goog.ui.editor.DefaultToolbar.makeToolbar(buttons,
125 goog.dom.getElement('toolbar'));
126
127 // Hook the toolbar into the field.
128 var myToolbarController =
129 new goog.ui.editor.ToolbarController(myField, myToolbar);
130
131 // Watch for field changes, to display below.
132 goog.events.listen(myField, goog.editor.Field.EventType.DELAYEDCHANGE,
133 updateFieldContents);
134
135 myField.makeEditable();
136 updateFieldContents();
137 </script>
138 </body>
139 </html>