youssefreda9 commited on
Commit
9751dc0
·
1 Parent(s): 3ab9b46

fix: format toolbar wrapping and ignore all button logic

Browse files
Files changed (3) hide show
  1. src/css/components.css +2 -8
  2. src/js/editor.js +32 -0
  3. src/js/format.js +2 -32
src/css/components.css CHANGED
@@ -413,13 +413,11 @@
413
  /* ── Formatting Toolbar ── */
414
  .format-toolbar {
415
  display: flex;
416
- flex-wrap: nowrap;
417
  align-items: center;
418
  justify-content: flex-start;
419
- gap: 3px;
420
  padding: 6px 10px;
421
- overflow-x: auto;
422
- scrollbar-width: none; /* Hide scrollbar Firefox */
423
  border-bottom: 1px solid var(--color-border);
424
  background: var(--color-surface);
425
  position: relative;
@@ -427,10 +425,6 @@
427
  flex-shrink: 0;
428
  }
429
 
430
- .format-toolbar::-webkit-scrollbar {
431
- display: none;
432
- }
433
-
434
  .fmt-group {
435
  display: flex;
436
  flex-wrap: nowrap;
 
413
  /* ── Formatting Toolbar ── */
414
  .format-toolbar {
415
  display: flex;
416
+ flex-wrap: wrap;
417
  align-items: center;
418
  justify-content: flex-start;
419
+ gap: 6px 3px; /* vertical and horizontal gaps */
420
  padding: 6px 10px;
 
 
421
  border-bottom: 1px solid var(--color-border);
422
  background: var(--color-surface);
423
  position: relative;
 
425
  flex-shrink: 0;
426
  }
427
 
 
 
 
 
428
  .fmt-group {
429
  display: flex;
430
  flex-wrap: nowrap;
src/js/editor.js CHANGED
@@ -666,6 +666,38 @@ function dismissSuggestion(suggestion) {
666
  const _ed3 = getEditorElement(); if (_ed3) _ed3.focus();
667
  }
668
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
669
  function applySuggestionById(id) {
670
  // Pipeline Hardening v3.3: UUID-based lookup
671
  const suggestion = findSuggestionById(id);
 
666
  const _ed3 = getEditorElement(); if (_ed3) _ed3.focus();
667
  }
668
 
669
+ window.dismissAndReRenderAll = function(type) {
670
+ if (!window.currentSuggestions || window.currentSuggestions.length === 0) return;
671
+ pushUndoState();
672
+ const toDismiss = type === 'all' ? window.currentSuggestions : window.currentSuggestions.filter(s => s.type === type);
673
+
674
+ toDismiss.forEach(s => {
675
+ if (s.original) _dismissedWords.add(s.original);
676
+ });
677
+ _saveDismissedWords();
678
+
679
+ window.currentSuggestions = window.currentSuggestions.filter(s =>
680
+ type === 'all' ? false : s.type !== type
681
+ );
682
+
683
+ const editor = getEditorElement();
684
+ clearOverlays(editor);
685
+ overlaySuggestions(editor, window.currentSuggestions);
686
+
687
+ const spellingCount = window.currentSuggestions.filter(s => s.type === 'spelling').length;
688
+ const grammarCount = window.currentSuggestions.filter(s => s.type === 'grammar').length;
689
+ const punctuationCount = window.currentSuggestions.filter(s => s.type === 'punctuation').length;
690
+
691
+ updateSuggestionCounts(spellingCount, grammarCount, punctuationCount);
692
+ updateWritingScore(spellingCount, grammarCount, punctuationCount);
693
+ updateSuggestionsList(window.currentSuggestions);
694
+
695
+ // Update sidebar button visibility via global format.js function if it exists
696
+ if (typeof window.renderSuggestionsSidebar === 'function') {
697
+ window.renderSuggestionsSidebar(window.currentSuggestions);
698
+ }
699
+ };
700
+
701
  function applySuggestionById(id) {
702
  // Pipeline Hardening v3.3: UUID-based lookup
703
  const suggestion = findSuggestionById(id);
src/js/format.js CHANGED
@@ -866,39 +866,9 @@ function filterErrors(type) {
866
 
867
  function dismissAllFiltered() {
868
  const type = window._currentErrorFilter || 'all';
869
- if (!window.currentSuggestions || window.currentSuggestions.length === 0) return;
870
-
871
- if (typeof window.pushUndoState === 'function') {
872
- window.pushUndoState();
873
- }
874
-
875
- // Get suggestions to dismiss
876
- const toDismiss = type === 'all' ? window.currentSuggestions : window.currentSuggestions.filter(s => s.type === type);
877
-
878
- // Add originals to whitelist
879
- let dismissed = [];
880
- try {
881
- dismissed = JSON.parse(localStorage.getItem('bayan_dismissed_words') || '[]');
882
- } catch(e) {}
883
-
884
- toDismiss.forEach(s => {
885
- const cleanWord = s.original.trim().replace(/[.,!?،؛؟"]/g, '');
886
- if (cleanWord.length > 0 && !dismissed.includes(cleanWord)) {
887
- dismissed.push(cleanWord);
888
- }
889
- });
890
- localStorage.setItem('bayan_dismissed_words', JSON.stringify(dismissed));
891
-
892
- // Update suggestions array
893
- if (type === 'all') {
894
- window.currentSuggestions = [];
895
- } else {
896
- window.currentSuggestions = window.currentSuggestions.filter(s => s.type !== type);
897
  }
898
-
899
- // Re-render UI
900
- if (typeof window.renderEditorHighlights === 'function') window.renderEditorHighlights();
901
- if (typeof window.renderSuggestionsSidebar === 'function') window.renderSuggestionsSidebar(window.currentSuggestions);
902
  }
903
 
904
  /* ── Error Breakdown Chart (SVG Donut) ── */
 
866
 
867
  function dismissAllFiltered() {
868
  const type = window._currentErrorFilter || 'all';
869
+ if (typeof window.dismissAndReRenderAll === 'function') {
870
+ window.dismissAndReRenderAll(type);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
871
  }
 
 
 
 
872
  }
873
 
874
  /* ── Error Breakdown Chart (SVG Donut) ── */