Commit ·
bf3ee58
1
Parent(s): a6ca7b7
Enhanced toolbar: tab icons, section labels, custom tooltips, lists, RTL/LTR, link, line height
Browse files- src/css/components.css +66 -0
- src/index.html +94 -90
- src/js/format.js +75 -0
src/css/components.css
CHANGED
|
@@ -359,6 +359,48 @@
|
|
| 359 |
box-shadow: 0 2px 10px rgba(107, 163, 224, 0.3);
|
| 360 |
}
|
| 361 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 362 |
/* ── Formatting Toolbar ── */
|
| 363 |
.format-toolbar {
|
| 364 |
display: flex;
|
|
@@ -384,6 +426,30 @@
|
|
| 384 |
overflow: hidden;
|
| 385 |
}
|
| 386 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 387 |
.fmt-group--font {
|
| 388 |
background: transparent;
|
| 389 |
gap: 5px;
|
|
|
|
| 359 |
box-shadow: 0 2px 10px rgba(107, 163, 224, 0.3);
|
| 360 |
}
|
| 361 |
|
| 362 |
+
/* ── Tab Icons ── */
|
| 363 |
+
.tab-icon {
|
| 364 |
+
margin-inline-end: 6px;
|
| 365 |
+
flex-shrink: 0;
|
| 366 |
+
opacity: 0.85;
|
| 367 |
+
}
|
| 368 |
+
.editor-tab.active .tab-icon {
|
| 369 |
+
opacity: 1;
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
/* ── Custom Tooltips ── */
|
| 373 |
+
[data-tooltip] {
|
| 374 |
+
position: relative;
|
| 375 |
+
}
|
| 376 |
+
[data-tooltip]::after {
|
| 377 |
+
content: attr(data-tooltip);
|
| 378 |
+
position: absolute;
|
| 379 |
+
bottom: calc(100% + 8px);
|
| 380 |
+
left: 50%;
|
| 381 |
+
transform: translateX(-50%) translateY(4px);
|
| 382 |
+
background: var(--color-surface-elevated);
|
| 383 |
+
color: var(--color-text-primary);
|
| 384 |
+
padding: 5px 10px;
|
| 385 |
+
border-radius: 6px;
|
| 386 |
+
font-size: 11px;
|
| 387 |
+
font-weight: 500;
|
| 388 |
+
white-space: nowrap;
|
| 389 |
+
pointer-events: none;
|
| 390 |
+
opacity: 0;
|
| 391 |
+
visibility: hidden;
|
| 392 |
+
transition: all 0.2s ease;
|
| 393 |
+
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
|
| 394 |
+
border: 1px solid var(--color-border);
|
| 395 |
+
z-index: 300;
|
| 396 |
+
font-family: inherit;
|
| 397 |
+
}
|
| 398 |
+
[data-tooltip]:hover::after {
|
| 399 |
+
opacity: 1;
|
| 400 |
+
visibility: visible;
|
| 401 |
+
transform: translateX(-50%) translateY(0);
|
| 402 |
+
}
|
| 403 |
+
|
| 404 |
/* ── Formatting Toolbar ── */
|
| 405 |
.format-toolbar {
|
| 406 |
display: flex;
|
|
|
|
| 426 |
overflow: hidden;
|
| 427 |
}
|
| 428 |
|
| 429 |
+
.fmt-section {
|
| 430 |
+
display: flex;
|
| 431 |
+
flex-direction: column;
|
| 432 |
+
align-items: center;
|
| 433 |
+
gap: 2px;
|
| 434 |
+
}
|
| 435 |
+
|
| 436 |
+
.fmt-label {
|
| 437 |
+
font-size: 9px;
|
| 438 |
+
font-weight: 600;
|
| 439 |
+
color: var(--color-text-secondary);
|
| 440 |
+
opacity: 0.6;
|
| 441 |
+
letter-spacing: 0.5px;
|
| 442 |
+
line-height: 1;
|
| 443 |
+
user-select: none;
|
| 444 |
+
white-space: nowrap;
|
| 445 |
+
}
|
| 446 |
+
|
| 447 |
+
/* Active state for format buttons */
|
| 448 |
+
.fmt-btn.fmt-active {
|
| 449 |
+
background: var(--color-primary) !important;
|
| 450 |
+
color: #fff !important;
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
.fmt-group--font {
|
| 454 |
background: transparent;
|
| 455 |
gap: 5px;
|
src/index.html
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
<!doctype html>
|
| 2 |
<html lang="ar" dir="rtl" class="h-full">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
|
@@ -673,110 +673,114 @@
|
|
| 673 |
<span id="auto-save-status" class="text-xs text-secondary" style="opacity:0;transition:opacity 0.3s;"></span>
|
| 674 |
</div>
|
| 675 |
<div class="editor-tabs-center">
|
| 676 |
-
<button id="write-tab" onclick="switchTab('write')" class="editor-tab active" type="button">كتابة</button>
|
| 677 |
-
<button id="summarize-tab" onclick="switchTab('summarize')" class="editor-tab" type="button">تلخيص</button>
|
| 678 |
-
<button id="dialect-tab" onclick="switchTab('dialect')" class="editor-tab" type="button">تحويل للفصحى</button>
|
| 679 |
-
<button id="quran-tab" onclick="switchTab('quran')" class="editor-tab" type="button">تدقيق النص القرآني</button>
|
| 680 |
</div>
|
| 681 |
<div class="flex items-center gap-2">
|
| 682 |
<span id="doc-current-title" class="doc-current-title" style="display:none;"></span>
|
| 683 |
</div>
|
| 684 |
</div>
|
| 685 |
<div class="format-toolbar" id="format-toolbar">
|
| 686 |
-
|
| 687 |
-
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
| 693 |
-
|
| 694 |
-
|
| 695 |
-
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
| 699 |
-
|
| 700 |
-
|
| 701 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 702 |
</div>
|
| 703 |
</div>
|
| 704 |
-
<div class="fmt-
|
| 705 |
-
|
| 706 |
-
|
| 707 |
-
<
|
| 708 |
-
|
| 709 |
-
|
| 710 |
-
<button
|
| 711 |
-
<button class="fmt-dropdown__item fmt-dropdown__item--active" data-size="16px" role="menuitem"><span class="fmt-size-preview" style="font-size:12px">بيان</span> 16</button>
|
| 712 |
-
<button class="fmt-dropdown__item" data-size="20px" role="menuitem"><span class="fmt-size-preview" style="font-size:14px">بيان</span> 20</button>
|
| 713 |
-
<button class="fmt-dropdown__item" data-size="24px" role="menuitem"><span class="fmt-size-preview" style="font-size:16px">بيان</span> 24</button>
|
| 714 |
-
<button class="fmt-dropdown__item" data-size="32px" role="menuitem"><span class="fmt-size-preview" style="font-size:18px">بيان</span> 32</button>
|
| 715 |
-
<button class="fmt-dropdown__item" data-size="48px" role="menuitem"><span class="fmt-size-preview" style="font-size:22px">بيان</span> 48</button>
|
| 716 |
</div>
|
| 717 |
</div>
|
| 718 |
-
|
| 719 |
-
|
| 720 |
-
|
| 721 |
-
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
<button id="fmt-underline" class="fmt-btn" onclick="formatUnderline()" type="button" title="تحته خط (Ctrl+U)"><u>U</u></button>
|
| 725 |
-
<button id="fmt-strikethrough" class="fmt-btn" onclick="formatStrikethrough()" type="button" title="يتوسطه خط"><s>S</s></button>
|
| 726 |
-
</div>
|
| 727 |
-
<div class="fmt-divider"></div>
|
| 728 |
-
<!-- Alignment group -->
|
| 729 |
-
<div class="fmt-group">
|
| 730 |
-
<button id="fmt-align-right" class="fmt-btn fmt-active" onclick="formatAlignRight()" type="button" title="محاذاة لليمين">
|
| 731 |
-
<svg width="16" height="16" fill="currentColor" viewBox="0 0 24 24"><path d="M3 5h18v2H3V5zm4 4h14v2H7V9zm-4 4h18v2H3v-2zm4 4h14v2H7v-2z"/></svg>
|
| 732 |
-
</button>
|
| 733 |
-
<button id="fmt-align-center" class="fmt-btn" onclick="formatAlignCenter()" type="button" title="توسيط">
|
| 734 |
-
<svg width="16" height="16" fill="currentColor" viewBox="0 0 24 24"><path d="M3 5h18v2H3V5zm3 4h12v2H6V9zm-3 4h18v2H3v-2zm3 4h12v2H6v-2z"/></svg>
|
| 735 |
-
</button>
|
| 736 |
-
<button id="fmt-align-left" class="fmt-btn" onclick="formatAlignLeft()" type="button" title="محاذاة لليسار">
|
| 737 |
-
<svg width="16" height="16" fill="currentColor" viewBox="0 0 24 24"><path d="M3 5h18v2H3V5zm0 4h14v2H3V9zm0 4h18v2H3v-2zm0 4h14v2H3v-2z"/></svg>
|
| 738 |
-
</button>
|
| 739 |
-
</div>
|
| 740 |
-
<div class="fmt-divider"></div>
|
| 741 |
-
<!-- Undo/Redo group -->
|
| 742 |
-
<div class="fmt-group">
|
| 743 |
-
<button class="fmt-btn" onclick="formatUndo()" type="button" title="تراجع (Ctrl+Z)">
|
| 744 |
-
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 10h10a5 5 0 015 5v2M3 10l4-4M3 10l4 4"/></svg>
|
| 745 |
-
</button>
|
| 746 |
-
<button class="fmt-btn" onclick="formatRedo()" type="button" title="إعادة (Ctrl+Y)">
|
| 747 |
-
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 10H11a5 5 0 00-5 5v2M21 10l-4-4M21 10l-4 4"/></svg>
|
| 748 |
-
</button>
|
| 749 |
-
</div>
|
| 750 |
-
<div class="fmt-divider"></div>
|
| 751 |
-
<!-- Item 8: Color pickers -->
|
| 752 |
-
<div class="fmt-group fmt-group--font">
|
| 753 |
-
<div class="fmt-dropdown" id="fmt-textcolor-wrap">
|
| 754 |
-
<button class="fmt-color-btn" type="button" id="fmt-textcolor-trigger" title="لون النص">
|
| 755 |
-
<svg width="16" height="16" fill="currentColor" viewBox="0 0 24 24"><path d="M11 2L5.5 16h2.25l1.12-3h6.25l1.12 3h2.25L13 2h-2zm-1.38 9L12 4.67 14.38 11H9.62z"/></svg>
|
| 756 |
-
<span class="fmt-color-indicator" id="fmt-textcolor-bar" style="background:#ECEEF2"></span>
|
| 757 |
-
</button>
|
| 758 |
-
<div class="fmt-dropdown__menu" id="fmt-textcolor-menu" role="menu">
|
| 759 |
-
<div class="fmt-color-grid" id="fmt-textcolor-grid"></div>
|
| 760 |
</div>
|
| 761 |
</div>
|
| 762 |
-
<div class="fmt-
|
| 763 |
-
|
| 764 |
-
|
| 765 |
-
<
|
| 766 |
-
|
| 767 |
-
<div class="fmt-dropdown__menu" id="fmt-highlight-menu" role="menu">
|
| 768 |
-
<div class="fmt-color-grid" id="fmt-highlight-grid"></div>
|
| 769 |
</div>
|
| 770 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 771 |
</div>
|
| 772 |
-
<div class="fmt-divider"></div>
|
| 773 |
-
<!-- Clear formatting -->
|
| 774 |
-
<div class="fmt-group">
|
| 775 |
-
<button class="fmt-btn" onclick="execFormat('removeFormat')" type="button" title="مسح التنسيق">
|
| 776 |
-
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 4h12v3M12 4v16"/><path stroke-linecap="round" stroke-width="2.5" stroke="currentColor" d="M5 19L19 5" opacity="0.6"/></svg>
|
| 777 |
-
</button>
|
| 778 |
-
</div>
|
| 779 |
-
</div>
|
| 780 |
<input type="file" id="doc-import-input" class="sr-only" accept=".txt,.docx,text/plain,application/vnd.openxmlformats-officedocument.wordprocessingml.document" aria-hidden="true">
|
| 781 |
<div id="write-area">
|
| 782 |
<div id="analysis-limit-banner" class="analysis-limit-banner is-hidden" role="status" aria-live="polite"></div>
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
<html lang="ar" dir="rtl" class="h-full">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
|
|
|
| 673 |
<span id="auto-save-status" class="text-xs text-secondary" style="opacity:0;transition:opacity 0.3s;"></span>
|
| 674 |
</div>
|
| 675 |
<div class="editor-tabs-center">
|
| 676 |
+
<button id="write-tab" onclick="switchTab('write')" class="editor-tab active" type="button"><svg class="tab-icon" width="15" height="15" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"/></svg>كتابة</button>
|
| 677 |
+
<button id="summarize-tab" onclick="switchTab('summarize')" class="editor-tab" type="button"><svg class="tab-icon" width="15" height="15" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/></svg>تلخيص</button>
|
| 678 |
+
<button id="dialect-tab" onclick="switchTab('dialect')" class="editor-tab" type="button"><svg class="tab-icon" width="15" height="15" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"/></svg>تحويل للفصحى</button>
|
| 679 |
+
<button id="quran-tab" onclick="switchTab('quran')" class="editor-tab" type="button"><svg class="tab-icon" width="15" height="15" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"/></svg>تدقيق النص القرآني</button>
|
| 680 |
</div>
|
| 681 |
<div class="flex items-center gap-2">
|
| 682 |
<span id="doc-current-title" class="doc-current-title" style="display:none;"></span>
|
| 683 |
</div>
|
| 684 |
</div>
|
| 685 |
<div class="format-toolbar" id="format-toolbar">
|
| 686 |
+
<div class="fmt-section"><span class="fmt-label">الخط</span>
|
| 687 |
+
<div class="fmt-group fmt-group--font">
|
| 688 |
+
<div class="fmt-dropdown" id="fmt-font-wrap">
|
| 689 |
+
<button class="fmt-dropdown__trigger" type="button" id="fmt-font-trigger" aria-haspopup="true" aria-expanded="false" data-tooltip="نوع الخط">
|
| 690 |
+
<svg class="fmt-dropdown__icon" width="14" height="14" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 7V4h16v3M9 20h6M12 4v16"/></svg>
|
| 691 |
+
<span id="fmt-font-label">Cairo</span>
|
| 692 |
+
<svg class="fmt-dropdown__chevron" width="10" height="10" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"/></svg>
|
| 693 |
+
</button>
|
| 694 |
+
<div class="fmt-dropdown__menu" id="fmt-font-menu" role="menu">
|
| 695 |
+
<button class="fmt-dropdown__item" data-font="Cairo" role="menuitem" style="font-family:Cairo">Cairo</button>
|
| 696 |
+
<button class="fmt-dropdown__item" data-font="Arial" role="menuitem" style="font-family:Arial">Arial</button>
|
| 697 |
+
<button class="fmt-dropdown__item" data-font="Times New Roman" role="menuitem" style="font-family:'Times New Roman'">Times New Roman</button>
|
| 698 |
+
<button class="fmt-dropdown__item" data-font="Tahoma" role="menuitem" style="font-family:Tahoma">Tahoma</button>
|
| 699 |
+
<button class="fmt-dropdown__item" data-font="Simplified Arabic" role="menuitem" style="font-family:'Simplified Arabic'">Simplified Arabic</button>
|
| 700 |
+
<button class="fmt-dropdown__item" data-font="Traditional Arabic" role="menuitem" style="font-family:'Traditional Arabic'">Traditional Arabic</button>
|
| 701 |
+
<button class="fmt-dropdown__item" data-font="Courier New" role="menuitem" style="font-family:'Courier New'">Courier New</button>
|
| 702 |
+
</div>
|
| 703 |
+
</div>
|
| 704 |
+
<div class="fmt-dropdown" id="fmt-size-wrap">
|
| 705 |
+
<button class="fmt-dropdown__trigger fmt-dropdown__trigger--size" type="button" id="fmt-size-trigger" aria-haspopup="true" aria-expanded="false" data-tooltip="حجم الخط">
|
| 706 |
+
<span id="fmt-size-label">16</span>
|
| 707 |
+
<svg class="fmt-dropdown__chevron" width="10" height="10" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"/></svg>
|
| 708 |
+
</button>
|
| 709 |
+
<div class="fmt-dropdown__menu fmt-dropdown__menu--size" id="fmt-size-menu" role="menu">
|
| 710 |
+
<button class="fmt-dropdown__item" data-size="12px" role="menuitem"><span class="fmt-size-preview" style="font-size:10px">بيان</span> 12</button>
|
| 711 |
+
<button class="fmt-dropdown__item fmt-dropdown__item--active" data-size="16px" role="menuitem"><span class="fmt-size-preview" style="font-size:12px">بيان</span> 16</button>
|
| 712 |
+
<button class="fmt-dropdown__item" data-size="20px" role="menuitem"><span class="fmt-size-preview" style="font-size:14px">بيان</span> 20</button>
|
| 713 |
+
<button class="fmt-dropdown__item" data-size="24px" role="menuitem"><span class="fmt-size-preview" style="font-size:16px">بيان</span> 24</button>
|
| 714 |
+
<button class="fmt-dropdown__item" data-size="32px" role="menuitem"><span class="fmt-size-preview" style="font-size:18px">بيان</span> 32</button>
|
| 715 |
+
<button class="fmt-dropdown__item" data-size="48px" role="menuitem"><span class="fmt-size-preview" style="font-size:22px">بيان</span> 48</button>
|
| 716 |
+
</div>
|
| 717 |
+
</div>
|
| 718 |
</div>
|
| 719 |
</div>
|
| 720 |
+
<div class="fmt-divider"></div>
|
| 721 |
+
<div class="fmt-section"><span class="fmt-label">التنسيق</span>
|
| 722 |
+
<div class="fmt-group">
|
| 723 |
+
<button id="fmt-bold" class="fmt-btn" onclick="formatBold()" type="button" data-tooltip="غامق (Ctrl+B)"><b>B</b></button>
|
| 724 |
+
<button id="fmt-italic" class="fmt-btn" onclick="formatItalic()" type="button" data-tooltip="مائل (Ctrl+I)"><i>I</i></button>
|
| 725 |
+
<button id="fmt-underline" class="fmt-btn" onclick="formatUnderline()" type="button" data-tooltip="تحته خط (Ctrl+U)"><u>U</u></button>
|
| 726 |
+
<button id="fmt-strikethrough" class="fmt-btn" onclick="formatStrikethrough()" type="button" data-tooltip="يتوسطه خط"><s>S</s></button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 727 |
</div>
|
| 728 |
</div>
|
| 729 |
+
<div class="fmt-divider"></div>
|
| 730 |
+
<div class="fmt-section"><span class="fmt-label">المحاذاة</span>
|
| 731 |
+
<div class="fmt-group">
|
| 732 |
+
<button id="fmt-align-right" class="fmt-btn fmt-active" onclick="formatAlignRight()" type="button" data-tooltip="محاذاة لليمين"><svg width="15" height="15" fill="currentColor" viewBox="0 0 24 24"><path d="M3 5h18v2H3V5zm4 4h14v2H7V9zm-4 4h18v2H3v-2zm4 4h14v2H7v-2z"/></svg></button>
|
| 733 |
+
<button id="fmt-align-center" class="fmt-btn" onclick="formatAlignCenter()" type="button" data-tooltip="توسيط"><svg width="15" height="15" fill="currentColor" viewBox="0 0 24 24"><path d="M3 5h18v2H3V5zm3 4h12v2H6V9zm-3 4h18v2H3v-2zm3 4h12v2H6v-2z"/></svg></button>
|
| 734 |
+
<button id="fmt-align-left" class="fmt-btn" onclick="formatAlignLeft()" type="button" data-tooltip="محاذاة لليسار"><svg width="15" height="15" fill="currentColor" viewBox="0 0 24 24"><path d="M3 5h18v2H3V5zm0 4h14v2H3V9zm0 4h18v2H3v-2zm0 4h14v2H3v-2z"/></svg></button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 735 |
</div>
|
| 736 |
</div>
|
| 737 |
+
<div class="fmt-divider"></div>
|
| 738 |
+
<div class="fmt-section"><span class="fmt-label">القوائم</span>
|
| 739 |
+
<div class="fmt-group">
|
| 740 |
+
<button id="fmt-ul" class="fmt-btn" onclick="execFormat('insertUnorderedList')" type="button" data-tooltip="قائمة نقطية"><svg width="15" height="15" fill="currentColor" viewBox="0 0 24 24"><path d="M4 6.5a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm0 7a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm0 7a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM8 5h13v2H8V5zm0 7h13v2H8v-2zm0 7h13v2H8v-2z"/></svg></button>
|
| 741 |
+
<button id="fmt-ol" class="fmt-btn" onclick="execFormat('insertOrderedList')" type="button" data-tooltip="قائمة مرقمة"><svg width="15" height="15" fill="currentColor" viewBox="0 0 24 24"><path d="M2 5h1V3h-.5v-.5h1V5h.5v.5H2V5zm0 5.5h1.5v.5H2v.5h2v-2H2.5V9H4V8H2v2.5zm0 5v.5h1v.5H2v.5h2V17H2.5v.5H4V14H2v1.5zM8 5h13v2H8V5zm0 7h13v2H8v-2zm0 7h13v2H8v-2z"/></svg></button>
|
|
|
|
|
|
|
| 742 |
</div>
|
| 743 |
</div>
|
| 744 |
+
<div class="fmt-divider"></div>
|
| 745 |
+
<div class="fmt-section"><span class="fmt-label">إضافي</span>
|
| 746 |
+
<div class="fmt-group">
|
| 747 |
+
<button id="fmt-rtl" class="fmt-btn" onclick="setDirection('rtl')" type="button" data-tooltip="يمين لليسار"><svg width="15" height="15" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5h6M11 5v14m4-14v14M3 8l4-3v6"/></svg></button>
|
| 748 |
+
<button id="fmt-ltr" class="fmt-btn" onclick="setDirection('ltr')" type="button" data-tooltip="يسار لليمين"><svg width="15" height="15" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 5H7a4 4 0 000 8h2m4-8v14m4-14v14M21 8l-4-3v6"/></svg></button>
|
| 749 |
+
<button id="fmt-link" class="fmt-btn" onclick="insertLink()" type="button" data-tooltip="إدراج رابط"><svg width="15" height="15" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"/></svg></button>
|
| 750 |
+
<button id="fmt-line-height" class="fmt-btn" onclick="cycleLineHeight()" type="button" data-tooltip="ارتفاع السطر"><svg width="15" height="15" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M20 4v4m0-4l-1.5 1.5M20 4l1.5 1.5M20 20v-4m0 4l-1.5-1.5M20 20l1.5-1.5"/></svg></button>
|
| 751 |
+
</div>
|
| 752 |
+
</div>
|
| 753 |
+
<div class="fmt-divider"></div>
|
| 754 |
+
<div class="fmt-section"><span class="fmt-label">التراجع</span>
|
| 755 |
+
<div class="fmt-group">
|
| 756 |
+
<button class="fmt-btn" onclick="formatUndo()" type="button" data-tooltip="تراجع (Ctrl+Z)"><svg width="15" height="15" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 10h10a5 5 0 015 5v2M3 10l4-4M3 10l4 4"/></svg></button>
|
| 757 |
+
<button class="fmt-btn" onclick="formatRedo()" type="button" data-tooltip="إعادة (Ctrl+Y)"><svg width="15" height="15" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 10H11a5 5 0 00-5 5v2M21 10l-4-4M21 10l-4 4"/></svg></button>
|
| 758 |
+
</div>
|
| 759 |
+
</div>
|
| 760 |
+
<div class="fmt-divider"></div>
|
| 761 |
+
<div class="fmt-section"><span class="fmt-label">الألوان</span>
|
| 762 |
+
<div class="fmt-group fmt-group--font">
|
| 763 |
+
<div class="fmt-dropdown" id="fmt-textcolor-wrap">
|
| 764 |
+
<button class="fmt-color-btn" type="button" id="fmt-textcolor-trigger" data-tooltip="لون النص">
|
| 765 |
+
<svg width="15" height="15" fill="currentColor" viewBox="0 0 24 24"><path d="M11 2L5.5 16h2.25l1.12-3h6.25l1.12 3h2.25L13 2h-2zm-1.38 9L12 4.67 14.38 11H9.62z"/></svg>
|
| 766 |
+
<span class="fmt-color-indicator" id="fmt-textcolor-bar" style="background:#ECEEF2"></span>
|
| 767 |
+
</button>
|
| 768 |
+
<div class="fmt-dropdown__menu" id="fmt-textcolor-menu" role="menu"><div class="fmt-color-grid" id="fmt-textcolor-grid"></div></div>
|
| 769 |
+
</div>
|
| 770 |
+
<div class="fmt-dropdown" id="fmt-highlight-wrap">
|
| 771 |
+
<button class="fmt-color-btn" type="button" id="fmt-highlight-trigger" data-tooltip="لون التظليل">
|
| 772 |
+
<svg width="15" height="15" fill="currentColor" viewBox="0 0 24 24"><path d="M16.56 8.94L7.62 0 6.21 1.41l2.38 2.38-5.15 5.15a1.49 1.49 0 000 2.12l5.5 5.5c.29.29.68.44 1.06.44s.77-.15 1.06-.44l5.5-5.5c.59-.58.59-1.53 0-2.12zM5.21 10L10 5.21 14.79 10H5.21zM19 11.5s-2 2.17-2 3.5c0 1.1.9 2 2 2s2-.9 2-2c0-1.33-2-3.5-2-3.5zM2 20h20v4H2v-4z"/></svg>
|
| 773 |
+
<span class="fmt-color-indicator" id="fmt-highlight-bar" style="background:transparent"></span>
|
| 774 |
+
</button>
|
| 775 |
+
<div class="fmt-dropdown__menu" id="fmt-highlight-menu" role="menu"><div class="fmt-color-grid" id="fmt-highlight-grid"></div></div>
|
| 776 |
+
</div>
|
| 777 |
+
</div>
|
| 778 |
+
</div>
|
| 779 |
+
<div class="fmt-divider"></div>
|
| 780 |
+
<div class="fmt-group">
|
| 781 |
+
<button class="fmt-btn" onclick="execFormat('removeFormat')" type="button" data-tooltip="مسح التنسيق"><svg width="15" height="15" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 4h12v3M12 4v16"/><path stroke-linecap="round" stroke-width="2.5" d="M5 19L19 5" opacity="0.6"/></svg></button>
|
| 782 |
+
</div>
|
| 783 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 784 |
<input type="file" id="doc-import-input" class="sr-only" accept=".txt,.docx,text/plain,application/vnd.openxmlformats-officedocument.wordprocessingml.document" aria-hidden="true">
|
| 785 |
<div id="write-area">
|
| 786 |
<div id="analysis-limit-banner" class="analysis-limit-banner is-hidden" role="status" aria-live="polite"></div>
|
src/js/format.js
CHANGED
|
@@ -39,6 +39,69 @@ function formatAlignRight() { execFormat('justifyRight'); }
|
|
| 39 |
function formatAlignCenter() { execFormat('justifyCenter'); }
|
| 40 |
function formatAlignLeft() { execFormat('justifyLeft'); }
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
/* ── Font family ── */
|
| 44 |
function formatFont(fontName) {
|
|
@@ -134,6 +197,18 @@ function updateFormatState() {
|
|
| 134 |
btn.classList.toggle('fmt-active', document.queryCommandState(command));
|
| 135 |
}
|
| 136 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
}
|
| 138 |
|
| 139 |
/**
|
|
|
|
| 39 |
function formatAlignCenter() { execFormat('justifyCenter'); }
|
| 40 |
function formatAlignLeft() { execFormat('justifyLeft'); }
|
| 41 |
|
| 42 |
+
/* ── Text Direction (RTL/LTR) ── */
|
| 43 |
+
function setDirection(dir) {
|
| 44 |
+
const editor = getEditorElement();
|
| 45 |
+
if (!editor) return;
|
| 46 |
+
const sel = window.getSelection();
|
| 47 |
+
if (sel && sel.rangeCount > 0) {
|
| 48 |
+
const range = sel.getRangeAt(0);
|
| 49 |
+
let block = range.startContainer;
|
| 50 |
+
if (block.nodeType === 3) block = block.parentNode;
|
| 51 |
+
while (block && block !== editor && !['DIV','P','H1','H2','H3','H4','H5','H6','LI','BLOCKQUOTE'].includes(block.tagName)) {
|
| 52 |
+
block = block.parentNode;
|
| 53 |
+
}
|
| 54 |
+
if (block && block !== editor) {
|
| 55 |
+
block.setAttribute('dir', dir);
|
| 56 |
+
block.style.direction = dir;
|
| 57 |
+
block.style.textAlign = dir === 'rtl' ? 'right' : 'left';
|
| 58 |
+
} else {
|
| 59 |
+
editor.setAttribute('dir', dir);
|
| 60 |
+
editor.style.direction = dir;
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
updateFormatState();
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
/* ── Insert Link ── */
|
| 67 |
+
function insertLink() {
|
| 68 |
+
const sel = window.getSelection();
|
| 69 |
+
if (!sel || !sel.rangeCount) return;
|
| 70 |
+
const selectedText = sel.toString();
|
| 71 |
+
const url = prompt('أدخل الرابط (URL):', 'https://');
|
| 72 |
+
if (!url || url === 'https://') return;
|
| 73 |
+
if (selectedText) {
|
| 74 |
+
execFormat('createLink', url);
|
| 75 |
+
} else {
|
| 76 |
+
const link = document.createElement('a');
|
| 77 |
+
link.href = url;
|
| 78 |
+
link.textContent = url;
|
| 79 |
+
link.target = '_blank';
|
| 80 |
+
const range = sel.getRangeAt(0);
|
| 81 |
+
range.insertNode(link);
|
| 82 |
+
range.setStartAfter(link);
|
| 83 |
+
range.collapse(true);
|
| 84 |
+
sel.removeAllRanges();
|
| 85 |
+
sel.addRange(range);
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
/* ── Line Height Cycling ── */
|
| 90 |
+
var _currentLineHeight = 1.8;
|
| 91 |
+
function cycleLineHeight() {
|
| 92 |
+
const editor = getEditorElement();
|
| 93 |
+
if (!editor) return;
|
| 94 |
+
const heights = [1.5, 2.0, 2.5, 1.8];
|
| 95 |
+
const idx = heights.indexOf(_currentLineHeight);
|
| 96 |
+
_currentLineHeight = heights[(idx + 1) % heights.length];
|
| 97 |
+
editor.style.lineHeight = _currentLineHeight;
|
| 98 |
+
// Show brief notification
|
| 99 |
+
const btn = document.getElementById('fmt-line-height');
|
| 100 |
+
if (btn) {
|
| 101 |
+
btn.setAttribute('data-tooltip', 'ارتفاع السطر: ' + _currentLineHeight);
|
| 102 |
+
}
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
|
| 106 |
/* ── Font family ── */
|
| 107 |
function formatFont(fontName) {
|
|
|
|
| 197 |
btn.classList.toggle('fmt-active', document.queryCommandState(command));
|
| 198 |
}
|
| 199 |
});
|
| 200 |
+
|
| 201 |
+
// Lists
|
| 202 |
+
const listMap = {
|
| 203 |
+
'fmt-ul': 'insertUnorderedList',
|
| 204 |
+
'fmt-ol': 'insertOrderedList',
|
| 205 |
+
};
|
| 206 |
+
Object.entries(listMap).forEach(([id, command]) => {
|
| 207 |
+
const btn = document.getElementById(id);
|
| 208 |
+
if (btn) {
|
| 209 |
+
btn.classList.toggle('fmt-active', document.queryCommandState(command));
|
| 210 |
+
}
|
| 211 |
+
});
|
| 212 |
}
|
| 213 |
|
| 214 |
/**
|