<!DOCTYPE html>
<html lang="th">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Website Template Editor - ตัวอย่าง</title>
<!-- Material Icons -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&family=Kanit:wght@300;400;500;700&display=swap" rel="stylesheet">
<!-- Editor CSS -->
<style>
/* ฐานสีและแบบอักษร */
:root {
--primary-color: #2196F3;
--primary-dark: #1976D2;
--primary-light: #BBDEFB;
--secondary-color: #FF9800;
--secondary-dark: #F57C00;
--text-color: #333333;
--text-light: #757575;
--background-color: #f5f5f5;
--surface-color: #ffffff;
--border-color: #e0e0e0;
--shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
--shadow-large: 0 4px 8px rgba(0, 0, 0, 0.15);
}
/* รีเซ็ตและสไตล์พื้นฐาน */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Kanit', 'Roboto', sans-serif;
background-color: var(--background-color);
color: var(--text-color);
line-height: 1.6;
overflow-x: hidden;
}
/* คอนเทนเนอร์หลัก */
.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
}
/* สไตล์ตัวแก้ไข */
.editor-edit-mode [data-editable="true"] {
position: relative;
}
.editor-edit-mode [data-editable="true"]:hover {
outline: 1px dashed var(--primary-color);
outline-offset: 2px;
}
.editor-edit-mode .editor-draggable {
cursor: move;
}
.editor-edit-mode .editor-draggable:hover {
outline: 1px dashed var(--primary-color);
outline-offset: 2px;
}
.editor-edit-mode .editor-dragging {
opacity: 0.5;
}
.editor-edit-mode .editor-drop-zone {
position: relative;
}
.editor-edit-mode .editor-drop-zone:hover {
outline: 1px dashed var(--primary-color);
outline-offset: 2px;
}
.editor-edit-mode .editor-drop-over {
outline: 2px solid var(--primary-color);
outline-offset: 2px;
}
/* แถบเครื่องมือหลัก */
.editor-main-toolbar {
position: fixed;
top: 0;
left: 0;
right: 0;
background-color: var(--primary-color);
color: white;
padding: 10px 20px;
display: flex;
align-items: center;
justify-content: space-between;
z-index: 999;
box-shadow: var(--shadow);
height: 60px;
}
.editor-main-toolbar .toolbar-group {
display: flex;
align-items: center;
}
.editor-main-toolbar .toolbar-btn {
background: none;
border: none;
color: white;
padding: 8px 12px;
margin-right: 8px;
border-radius: 4px;
cursor: pointer;
display: flex;
align-items: center;
transition: background-color 0.2s;
font-family: 'Kanit', 'Roboto', sans-serif;
font-weight: 500;
}
.editor-main-toolbar .toolbar-btn:hover {
background-color: rgba(255, 255, 255, 0.2);
}
.editor-main-toolbar .toolbar-btn.active {
background-color: rgba(255, 255, 255, 0.3);
}
.editor-main-toolbar .toolbar-btn i {
margin-right: 6px;
}
/* แถบเครื่องมือข้อความ */
.editor-text-toolbar {
position: absolute;
display: none;
background-color: var(--surface-color);
border-radius: 4px;
box-shadow: var(--shadow-large);
padding: 8px;
z-index: 1000;
opacity: 0;
transform: translateY(-10px);
transition: opacity 0.2s, transform 0.2s;
}
.editor-text-toolbar.editor-toolbar-active {
opacity: 1;
transform: translateY(0);
}
.editor-toolbar-group {
display: inline-flex;
margin-right: 8px;
padding-right: 8px;
border-right: 1px solid var(--border-color);
}
.editor-toolbar-group:last-child {
margin-right: 0;
padding-right: 0;
border-right: none;
}
.editor-toolbar-btn {
background: none;
border: none;
width: 36px;
height: 36px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
border-radius: 4px;
color: var(--text-color);
transition: background-color 0.2s, color 0.2s;
}
.editor-toolbar-btn:hover {
background-color: var(--background-color);
color: var(--primary-color);
}
.editor-toolbar-btn:active {
background-color: var(--border-color);
}
.editor-toolbar-close {
background: none;
border: none;
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
border-radius: 50%;
color: var(--text-color);
margin-left: 8px;
font-size: 16px;
line-height: 1;
}
.editor-toolbar-close:hover {
background-color: var(--background-color);
color: #f44336;
}
/* แผงคุณสมบัติ */
.editor-property-panel {
position: fixed;
top: 60px;
right: 0;
width: 300px;
height: calc(100vh - 60px);
background-color: var(--surface-color);
box-shadow: -2px 0 4px rgba(0, 0, 0, 0.1);
padding: 20px;
overflow-y: auto;
transform: translateX(100%);
transition: transform 0.3s;
z-index: 998;
}
.editor-property-panel.editor-panel-open {
transform: translateX(0);
}
.editor-property-panel h3 {
margin-top: 0;
margin-bottom: 20px;
color: var(--text-color);
font-size: 18px;
}
.editor-property-group {
margin-bottom: 20px;
}
.editor-property-group h4 {
margin-bottom: 10px;
color: var(--text-color);
font-size: 16px;
}
.property-item {
margin-bottom: 10px;
}
.property-item label {
display: block;
margin-bottom: 5px;
font-weight: 500;
color: var(--text-color);
font-size: 14px;
}
.property-input {
width: 100%;
padding: 8px;
border: 1px solid var(--border-color);
border-radius: 4px;
font-size: 14px;
font-family: 'Kanit', 'Roboto', sans-serif;
}
.property-input:focus {
outline: none;
border-color: var(--primary-color);
}
.property-input[type="color"] {
height: 36px;
padding: 2px;
}
/* แผงคอมโพเนนต์ */
.editor-component-panel {
position: fixed;
top: 60px;
left: 0;
width: 250px;
height: calc(100vh - 60px);
background-color: var(--surface-color);
box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
padding: 20px;
overflow-y: auto;
transform: translateX(-100%);
transition: transform 0.3s;
z-index: 998;
}
.editor-component-panel.editor-panel-open {
transform: translateX(0);
}
.editor-component-panel h3 {
margin-top: 0;
margin-bottom: 20px;
color: var(--text-color);
font-size: 18px;
}
.component-tabs {
display: flex;
flex-wrap: wrap;
margin-bottom: 15px;
border-bottom: 1px solid var(--border-color);
}
.component-tab {
background: none;
border: none;
padding: 8px 12px;
cursor: pointer;
font-size: 14px;
color: var(--text-light);
border-bottom: 2px solid transparent;
transition: all 0.3s;
font-family: 'Kanit', 'Roboto', sans-serif;
}
.component-tab.active {
color: var(--primary-color);
border-bottom-color: var(--primary-color);
}
.component-tab:hover {
color: var(--primary-color);
}
.editor-component-item {
background-color: var(--background-color);
border: 1px solid var(--border-color);
border-radius: 4px;
padding: 12px;
margin-bottom: 10px;
cursor: move;
transition: background-color 0.2s, border-color 0.2s;
display: flex;
flex-direction: column;
}
.editor-component-item:hover {
background-color: var(--primary-light);
border-color: var(--primary-color);
}
.editor-component-item.dragging {
opacity: 0.5;
}
.editor-component-item i {
margin-bottom: 8px;
color: var(--primary-color);
}
.editor-component-item h4 {
margin: 0 0 5px 0;
font-size: 16px;
color: var(--text-color);
}
.editor-component-item p {
margin: 0;
font-size: 14px;
color: var(--text-light);
}
/* แผงจัดการเลย์เอาต์ */
.editor-layout-panel {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 200px;
background-color: var(--surface-color);
box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
padding: 15px;
overflow-y: auto;
transform: translateY(100%);
transition: transform 0.3s;
z-index: 998;
}
.editor-layout-panel.editor-panel-open {
transform: translateY(0);
}
.editor-layout-panel h3 {
margin-top: 0;
margin-bottom: 15px;
color: var(--text-color);
font-size: 18px;
}
.editor-layout-tree {
font-family: monospace;
font-size: 14px;
line-height: 1.5;
}
.editor-layout-tree-item {
padding: 5px 0;
position: relative;
display: flex;
align-items: center;
}
.editor-layout-tree-item:hover {
background-color: var(--background-color);
}
.editor-layout-tree-item.tree-selected {
background-color: var(--primary-light);
}
.tree-icon {
margin-right: 8px;
color: var(--primary-color);
font-size: 18px;
}
.tree-element-name {
flex-grow: 1;
}
.tree-actions {
display: flex;
margin-left: 10px;
}
.tree-action-btn {
background: none;
border: none;
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
border-radius: 50%;
color: var(--text-light);
margin-left: 2px;
font-size: 16px;
}
.tree-action-btn:hover {
background-color: var(--background-color);
color: var(--primary-color);
}
.tree-children {
margin-left: 20px;
}
/* ตัวบ่งชี้การวาง */
.editor-drop-indicator {
position: absolute;
background-color: var(--primary-color);
opacity: 0.7;
z-index: 997;
pointer-events: none;
display: none;
}
.editor-drop-indicator.horizontal {
height: 3px;
left: 0;
right: 0;
}
.editor-drop-indicator.vertical {
width: 3px;
top: 0;
bottom: 0;
}
/* การแจ้งเตือนการบันทึก */
.editor-save-notification {
position: fixed;
bottom: 20px;
right: 20px;
background-color: var(--primary-color);
color: white;
padding: 12px 20px;
border-radius: 4px;
box-shadow: var(--shadow-large);
transform: translateY(100px);
opacity: 0;
transition: transform 0.3s, opacity 0.3s;
z-index: 1000;
}
.editor-save-notification.editor-notification-show {
transform: translateY(0);
opacity: 1;
}
/* ปุ่ม */
.btn {
display: inline-block;
padding: 8px 16px;
border-radius: 4px;
font-weight: 500;
cursor: pointer;
transition: all 0.2s;
border: none;
text-decoration: none;
font-family: 'Kanit', 'Roboto', sans-serif;
}
.btn-primary {
background-color: var(--primary-color);
color: white;
}
.btn-primary:hover {
background-color: var(--primary-dark);
}
.btn-outline {
background-color: transparent;
border: 1px solid var(--primary-color);
color: var(--primary-color);
}
.btn-outline:hover {
background-color: var(--primary-color);
color: white;
}
/* การตอบสนอง */
@media (max-width: 768px) {
.editor-property-panel {
width: 100%;
}
.editor-component-panel {
width: 100%;
}
.editor-layout-panel {
height: 150px;
}
.editor-main-toolbar {
padding: 8px 15px;
height: 50px;
}
.editor-main-toolbar .toolbar-btn {
padding: 6px 10px;
margin-right: 5px;
font-size: 14px;
}
.editor-main-toolbar .toolbar-btn i {
margin-right: 4px;
font-size: 18px;
}
}
</style>
<!-- สไตล์ตัวอย่าง -->
<style>
/* สไตล์ส่วนหัว */
.header {
background-color: #ffffff;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
padding: 15px 0;
position: sticky;
top: 0;
z-index: 100;
}
.header .container {
display: flex;
align-items: center;
justify-content: space-between;
}
.header-logo h1 {
margin: 0;
font-size: 24px;
color: #333;
}
.header-nav ul {
display: flex;
list-style: none;
margin: 0;
padding: 0;
}
.header-nav li {
margin: 0 15px;
}
.header-nav a {
text-decoration: none;
color: #333;
font-weight: 500;
transition: color 0.2s;
}
.header-nav a:hover {
color: #2196F3;
}
.header-actions {
display: flex;
gap: 10px;
}
/* สไตล์ Hero Section */
.hero {
background-color: #f5f5f5;
padding: 80px 0;
text-align: center;
}
.hero h1 {
font-size: 48px;
margin-bottom: 20px;
color: #333;
}
.hero p {
font-size: 18px;
max-width: 600px;
margin: 0 auto 30px;
color: #666;
}
/* สไตล์ส่วนคุณสมบัติ */
.features {
padding: 60px 0;
}
.features h2 {
text-align: center;
font-size: 36px;
margin-bottom: 40px;
color: #333;
}
.features-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 30px;
}
.feature-card {
background-color: #ffffff;
border-radius: 8px;
padding: 30px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
text-align: center;
transition: transform 0.3s, box-shadow 0.3s;
}
.feature-card:hover {
transform: translateY(-5px);
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}
.feature-card i {
font-size: 48px;
color: #2196F3;
margin-bottom: 20px;
}
.feature-card h3 {
font-size: 24px;
margin-bottom: 15px;
color: #333;
}
.feature-card p {
color: #666;
line-height: 1.6;
}
/* สไตล์ส่วนท้าย */
.footer {
background-color: #333;
color: white;
padding: 40px 0;
}
.footer .container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 30px;
}
.footer h3 {
font-size: 20px;
margin-bottom: 20px;
}
.footer ul {
list-style: none;
padding: 0;
}
.footer li {
margin-bottom: 10px;
}
.footer a {
color: #ccc;
text-decoration: none;
transition: color 0.2s;
}
.footer a:hover {
color: white;
}
.footer-bottom {
text-align: center;
padding-top: 20px;
margin-top: 20px;
border-top: 1px solid #555;
color: #ccc;
}
/* การตอบสนอง */
@media (max-width: 768px) {
.header .container {
flex-direction: column;
gap: 15px;
}
.header-nav ul {
flex-wrap: wrap;
justify-content: center;
}
.header-nav li {
margin: 5px 10px;
}
.hero {
padding: 60px 0;
}
.hero h1 {
font-size: 36px;
}
.features {
padding: 40px 0;
}
.features h2 {
font-size: 28px;
}
}
</style>
</head>
<body>
<!-- คอนเทนเนอร์ตัวแก้ไข -->
<div id="editor-container">
<!-- ส่วนหัว -->
<header class="header editor-component" data-component="header">
<div class="container">
<div class="header-logo">
<h1 data-editable="true">Website Template Editor</h1>
</div>
<nav class="header-nav">
<ul>
<li><a href="#" data-editable="true">หน้าแรก</a></li>
<li><a href="#" data-editable="true">คุณสมบัติ</a></li>
<li><a href="#" data-editable="true">ตัวอย่าง</a></li>
<li><a href="#" data-editable="true">ติดต่อ</a></li>
</ul>
</nav>
<div class="header-actions">
<button class="btn btn-outline" data-editable="true">เข้าสู่ระบบ</button>
<button class="btn btn-primary" data-editable="true">สมัครสมาชิก</button>
</div>
</div>
</header>
<!-- Hero Section -->
<section class="hero editor-component" data-component="hero">
<div class="container">
<h1 data-editable="true">สร้างเว็บไซต์ด้วยตัวแก้ไขเทมเพลต</h1>
<p data-editable="true">ตัวแก้ไขเทมเพลตแบบอินไลน์ที่ช่วยให้คุณสร้างและแก้ไขเว็บไซต์ได้อย่างง่ายดาย</p>
<button class="btn btn-primary" data-editable="true">เริ่มต้นใช้งาน</button>
</div>
</section>
<!-- ส่วนคุณสมบัติ -->
<section class="features editor-component" data-component="features">
<div class="container">
<h2 data-editable="true">คุณสมบัติหลัก</h2>
<div class="features-grid">
<div class="feature-card editor-component" data-component="card">
<i class="material-icons">edit</i>
<h3 data-editable="true">แก้ไขแบบอินไลน์</h3>
<p data-editable="true">แก้ไขข้อความโดยตรงบนหน้าเว็บด้วยเครื่องมือแก้ไขที่ใช้งานง่าย</p>
</div>
<div class="feature-card editor-component" data-component="card">
<i class="material-icons">drag_indicator</i>
<h3 data-editable="true">ลากและวาง</h3>
<p data-editable="true">จัดเรียงอิลิเมนต์ด้วยการลากและวางที่ใช้งานง่าย</p>
</div>
<div class="feature-card editor-component" data-component="card">
<i class="material-icons">dashboard_customize</i>
<h3 data-editable="true">คอมโพเนนต์</h3>
<p data-editable="true">ใช้คอมโพเนนต์ที่สร้างไว้ล่วงหน้าเพื่อสร้างเว็บไซต์ได้เร็วยิ่งขึ้น</p>
</div>
</div>
</div>
</section>
<!-- ส่วนท้าย -->
<footer class="footer editor-component" data-component="footer">
<div class="container">
<div>
<h3 data-editable="true">เกี่ยวกับเรา</h3>
<p data-editable="true">Website Template Editor เป็นเครื่องมือสำหรับสร้างและแก้ไขเว็บไซต์แบบอินไลน์</p>
</div>
<div>
<h3 data-editable="true">ลิงก์ด่วน</h3>
<ul>
<li><a href="#" data-editable="true">หน้าแรก</a></li>
<li><a href="#" data-editable="true">คุณสมบัติ</a></li>
<li><a href="#" data-editable="true">ตัวอย่าง</a></li>
<li><a href="#" data-editable="true">ติดต่อ</a></li>
</ul>
</div>
<div>
<h3 data-editable="true">ติดต่อเรา</h3>
<p data-editable="true">อีเมล: info@templateeditor.com</p>
<p data-editable="true">โทร: 02-123-4567</p>
</div>
</div>
<div class="footer-bottom">
<p data-editable="true">© 2023 Website Template Editor. สงวนลิขสิทธิ์</p>
</div>
</footer>
</div>
<!-- สคริปต์หลัก -->
<script src="editor/core/eventBus.js"></script>
<script src="editor/core/moduleManager.js"></script>
<script src="editor/core/uiManager.js"></script>
<script src="editor/core/domUtils.js"></script>
<!-- สคริปต์บริการ -->
<script src="editor/services/templateLoader.js"></script>
<script src="editor/services/templateSaver.js"></script>
<script src="editor/services/storageService.js"></script>
<!-- สคริปต์โมดูล -->
<script src="editor/modules/contentEditor.js"></script>
<script src="editor/modules/dragDrop.js"></script>
<script src="editor/modules/propertyEditor.js"></script>
<script src="editor/modules/layoutManager.js"></script>
<script src="editor/modules/componentPanel.js"></script>
<script src="editor/modules/toolbar.js"></script>
<!-- สคริปต์ปลั๊กอิน -->
<script src="editor/plugins/header.js"></script>
<script src="editor/plugins/footer.js"></script>
<script src="editor/plugins/hero.js"></script>
<script src="editor/plugins/carousel.js"></script>
<script src="editor/plugins/card.js"></script>
<script src="editor/plugins/grid.js"></script>
<!-- สคริปต์ตัวแก้ไขหลัก -->
<script src="editor/editor.js"></script>
<!-- เริ่มต้นตัวแก้ไข -->
<script>
document.addEventListener('DOMContentLoaded', function() {
// สร้างอินสแตนซ์ตัวแก้ไข
const editor = new Editor({
container: '#editor-container',
autoSave: true,
debug: true
});
// เริ่มต้นตัวแก้ไข
editor.init();
// เพิ่ม event listeners สำหรับการสาธิต
editor.on('editor:ready', function() {
console.log('ตัวแก้ไขพร้อมใช้งานแล้ว!');
// แสดงข้อความต้อนรับ
setTimeout(() => {
const notification = document.createElement('div');
notification.className = 'editor-save-notification editor-notification-show';
notification.textContent = 'ยินดีต้อนรับสู่ Website Template Editor! คลิกที่ข้อความเพื่อเริ่มแก้ไข';
document.body.appendChild(notification);
setTimeout(() => {
notification.classList.remove('editor-notification-show');
setTimeout(() => {
document.body.removeChild(notification);
}, 300);
}, 5000);
}, 1000);
});
editor.on('content:editing-started', function(data) {
console.log('เริ่มแก้ไข:', data.element);
});
editor.on('template:saved', function() {
console.log('เทมเพลตถูกบันทึกแล้ว!');
});
});
</script>
</body>
</html>