Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can this auto lock turned on automatically when I click the page on the left side tree node? #13

Open
caps424 opened this issue Oct 15, 2024 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@caps424
Copy link

caps424 commented Oct 15, 2024

Instead of clicking a lock icon every time, it would be handy to enable lock mode when I click the page from tree node on the left side.

This below is what I am doing for now but would be great to find out proper way to do that rather than this hack below.

    eventsService.on('editorState.changed', function (e, v) {
        setTimeout(function () {
            document.getElementById("boev_lock-icon-wrapper").click()
        }, 1500)
    });
@Rockerby
Copy link
Owner

Hey @caps424 - thanks for using the package and raising your feedback.

Sounds like this could be a good feature. I would suspect the best way to do this would be to have it as a configurable option to allow people to turn it on / off as they see fit.

@Rockerby Rockerby added enhancement New feature or request help wanted Extra attention is needed labels Oct 16, 2024
@caps424
Copy link
Author

caps424 commented Oct 16, 2024

Hi @Rockerby,

Thanks very much for your reply I didn't really expect to see that fast.

In the meantime I changed my code like below to check if this page is already locked or not.
Hope this will help you out to make this great plugin better.

    eventsService.on('editorState.changed', function (e, v) {
     
        let interval = setInterval(callback, 500);
        function callback() {
            if (document.querySelector("#boev_lock-icon-wrapper") != null) {
                clearInterval(interval);
                setTimeout(function () {
                    if (!document.querySelector("#boev_lock-icon-wrapper").classList.contains("active")) {
                        document.querySelector("#boev_lock-icon-wrapper").click();
                    }
                }, 1500);
            }
        }
    });

@Rockerby
Copy link
Owner

Awesome, thanks for sharing your code! The plugin does a call to the server to get the initial status of a page when you view it. My thinking was to multi-purpose that call and set it to lock if the setting is set to do so and the page isn't already locked.

@caps424
Copy link
Author

caps424 commented Oct 16, 2024

I think the auto lock should unlock the page when user leave the page so other users can edit the page afterward.
This is just my suggestion so you probably have a better option than I thought.

Many thanks!

Sonny

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants