Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

Commit

Permalink
start working on hilighting
Browse files Browse the repository at this point in the history
  • Loading branch information
BaseMax committed Sep 15, 2024
1 parent 7248624 commit e179e84
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
</div>

<script>
const keywords = ['تمام'];
const commands = ['صفحه', 'قطعه', 'جعبه', 'پاراگراف'];
const arguments = ['منبع', 'مقصد', 'محتوا', 'موقعیت', 'اندازه', 'رنگ', 'پس‌زمینه', 'حاشیه', 'پهنا', 'ارتفاع', 'شکل', 'نوع', 'سبک', 'وزن', 'خط', 'خط‌کش', 'خط‌کشی', 'خط‌کشی‌ها', 'خط‌کشی‌های'];

const editor = document.querySelector('.editor');
const editor_code = editor.querySelector('.editor-code');
const editor_lines = editor.querySelector('.editor-lines');
Expand Down Expand Up @@ -131,7 +135,7 @@
console.log("newLine: ", newLine);

scrollIntoViewIfNeeded(newLine);

const newRange = document.createRange();
// newRange.setStart(newLine, 1);
// newRange.setEnd(newLine, 1);
Expand Down Expand Up @@ -163,16 +167,16 @@
console.log("splitLines");
const lines = editor_code.querySelectorAll(".line");

// lines.forEach((line) => {
// const textContent = line.textContent;
//
// const NotZeroWidthSpacesRegex = /^[\u200B-\u200D\uFEFF]*$/;
// const ZeroWidthSpacesRegex = /[\u200B-\u200D\uFEFF]*$/;
//
// if (ZeroWidthSpacesRegex.test(textContent) && NotZeroWidthSpacesRegex.test(textContent)) {
// line.innerHTML = line.innerHTML.replace(/[\u200B-\u200D\uFEFF]/g, '');
// }
// });
lines.forEach((line) => {
const textContent = line.textContent;

const NotZeroWidthSpacesRegex = /^[\u200B-\u200D\uFEFF]*$/;
const ZeroWidthSpacesRegex = /[\u200B-\u200D\uFEFF]*$/;

if (ZeroWidthSpacesRegex.test(textContent) && NotZeroWidthSpacesRegex.test(textContent)) {
line.innerHTML = line.innerHTML.replace(/[\u200B-\u200D\uFEFF]/g, '');
}
});

updateLineNumbers();
};
Expand All @@ -194,7 +198,9 @@
editor_code.addEventListener('scroll', synchronizeScroll);
editor_code.addEventListener('keydown', handleKey);
editor_code.addEventListener('input', splitLines);

editor_code.innerHTML = '<div class="line"><br></div>';
editor_code.focus();

splitLines();
</script>

0 comments on commit e179e84

Please sign in to comment.