isaka-james / dhiwise-copy-extension

Use this chrome extension to copy codes from your converted application in dhiwise website. Never Pay money again!
MIT License
5 stars 1 forks source link

the copied code seems to be reordered ramdomly #1

Closed ty1135 closed 5 months ago

ty1135 commented 5 months ago

the copied code seems to be reordered ramdomly...uh oh

isaka-james commented 5 months ago

Thank you for reaching out about the issue with the code copying functionality in this Dhiwise extension.

I understand the frustration caused by the mixed-up lines when copying code. It appears that this problem is related to display settings and screen size. Zooming out until the full code is visible can often resolve this issue for sure 100%, it can really work very good especially for users with larger screens. However, I recognize that this may not be an ideal solution for users with smaller screens. But I was manage even to use small screen PC by zooming out -50% up to -80% and copy the code it really worked fine

Also you may face that the spaces are not in UTF-8, please when you copy the code, copy a single space from the code you copied and replace the whole document with your keyboard space. I apologize for any confusion.

Your feedback is incredibly valuable as I continue to improve the extension to provide a smoother experience for all users. I will take your suggestions into consideration as I work on enhancements to prevent similar frustrations in the future.

If you have any further questions or suggestions, please don't hesitate to let me know. I'm here to assist you.

Best regards, @isaka-james

ty1135 commented 5 months ago

function getAllTextContent(element) { let elements = [];

// Function to collect "view-line" elements with their top values
function collectViewLineElements(node) {
    for (let child of node.childNodes) {
        if (child.nodeType === Node.ELEMENT_NODE) {
            if (child.classList.contains('view-line')) {
                let topValue = parseFloat(child.style.top);
                elements.push({ element: child, top: topValue });
            }
            // Recursively collect from child nodes
            collectViewLineElements(child);
        }
    }
}

collectViewLineElements(element);

// Sort elements by their top values
elements.sort((a, b) => a.top - b.top);

// Concatenate the text content in sorted order
let textContent = '';
for (let item of elements) {
    textContent += item.element.textContent + '\n';
}

return textContent;

}

isaka-james commented 5 months ago

please provide the full information for your issue. I am struggling understanding you. You just posted code and what am I supposed to do?

isaka-james commented 5 months ago

But I said the you should zoom out max, and click the copy button, It should work.

tq1102 commented 5 months ago

function getAllTextContent(element) { let elements = [];

// Function to collect "view-line" elements with their top values
function collectViewLineElements(node) {
    for (let child of node.childNodes) {
        if (child.nodeType === Node.ELEMENT_NODE) {
            if (child.classList.contains('view-line')) {
                let topValue = parseFloat(child.style.top);
                elements.push({ element: child, top: topValue });
            }
            // Recursively collect from child nodes
            collectViewLineElements(child);
        }
    }
}

collectViewLineElements(element);

// Sort elements by their top values
elements.sort((a, b) => a.top - b.top);

// Concatenate the text content in sorted order
let textContent = '';
for (let item of elements) {
    textContent += item.element.textContent + '\n';
}

return textContent;

}

replace with this function everything works perfectly.

isaka-james commented 5 months ago

can you make a pull request please?