-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
219 lines (189 loc) · 6.68 KB
/
Copy pathindex.html
File metadata and controls
219 lines (189 loc) · 6.68 KB
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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>UEditor Plus Designer - Standalone Example</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html, body {
width: 100%;
height: 100%;
overflow: hidden;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
display: flex;
flex-direction: column;
}
.app-header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 1rem 2rem;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
flex-shrink: 0;
display: flex;
justify-content: space-between;
align-items: center;
}
.app-header h1 {
font-size: 1.5rem;
font-weight: 600;
margin: 0;
}
.app-actions {
display: flex;
gap: 0.5rem;
}
.btn {
padding: 0.5rem 1rem;
border: none;
border-radius: 4px;
background: white;
color: #667eea;
font-weight: 500;
cursor: pointer;
transition: all 0.2s;
}
.btn:hover {
transform: translateY(-1px);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.btn:disabled {
opacity: 0.5;
cursor: not-allowed;
transform: none;
}
.btn-secondary {
background: rgba(255, 255, 255, 0.2);
color: white;
border: 1px solid white;
}
.btn-secondary:hover {
background: rgba(255, 255, 255, 0.3);
}
.app-main {
flex: 1;
overflow: hidden;
}
#designer-container {
width: 100%;
height: 100%;
}
.loading {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
font-size: 18px;
color: #666;
}
.loading::before {
content: '';
display: inline-block;
width: 20px;
height: 20px;
border: 3px solid #667eea;
border-radius: 50%;
border-top-color: transparent;
animation: spin 1s linear infinite;
margin-right: 10px;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
</style>
<!-- Import UEditor Plus Designer Standalone -->
<link rel="stylesheet" href="../../dist/standalone/ueditor-plus-designer.standalone.css">
</head>
<body>
<header class="app-header">
<h1>UEditor Plus Designer - Standalone Example</h1>
<div class="app-actions">
<button id="btn-get-content" class="btn" disabled>
Get Content
</button>
<button id="btn-set-content" class="btn btn-secondary" disabled>
Set Sample Content
</button>
</div>
</header>
<main class="app-main">
<div id="designer-container">
<div class="loading">加载设计器中...</div>
</div>
</main>
<!-- Import UEditor Plus Designer Standalone JS -->
<script src="../../dist/standalone/ueditor-plus-designer.standalone.js"></script>
<script>
let designer = null;
let isReady = false;
// Initialize designer
function initDesigner() {
try {
// Create designer instance
designer = UEditorPlusDesigner.createDesigner({
// UEditor configuration
// ueditorPath: '/ueditor-plus', // Change this to your UEditor path
ueditorPath: 'https://open-cdn.modstart.com/ueditor-plus/dist-min/',
// UEditor configuration options
ueditorConfig: {
serverUrl: 'https://open.modstart.com/ueditor-plus/_demo_server/handle.php',
UEDITOR_CORS_URL: window.location.host==='open.modstart.com'?'https://open.modstart.com/ueditor-plus/dist-min/':'',
}
});
// Listen to events
designer.on('ready', function() {
console.log('✅ Designer is ready!');
isReady = true;
// Enable buttons
document.getElementById('btn-get-content').disabled = false;
document.getElementById('btn-set-content').disabled = false;
});
designer.on('change', function(content) {
console.log('📝 Content changed:', content.length, 'characters');
});
// Mount to container
designer.mount('#designer-container');
} catch (error) {
console.error('❌ Failed to initialize designer:', error);
}
}
// Handle Get Content button
function handleGetContent() {
if (!isReady) {
alert('Editor not ready yet! Please wait for the "Editor is ready" message.');
return;
}
if (designer) {
const content = designer.getContent();
console.log('Current content:', content);
alert('Content length: ' + content.length + ' characters. Check console for full content.');
}
}
// Handle Set Content button
function handleSetContent() {
if (!isReady) {
alert('Editor not ready yet! Please wait for the "Editor is ready" message.');
return;
}
if (designer) {
const sampleContent = '<div class="pb-section" style="padding: 20px; text-align: center;"><h2>Sample Content from HTML</h2><p>This content was set programmatically!</p></div>';
designer.setContent(sampleContent);
}
}
// Initialize on page load
window.addEventListener('DOMContentLoaded', function() {
console.log('🚀 Initializing UEditor Plus Designer...');
initDesigner();
// Add event listeners for buttons
document.getElementById('btn-get-content').addEventListener('click', handleGetContent);
document.getElementById('btn-set-content').addEventListener('click', handleSetContent);
});
</script>
</body>
</html>