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

Option to use target="_blank" in links + image links #72

Open
kristijorgji opened this issue Aug 14, 2023 · 8 comments
Open

Option to use target="_blank" in links + image links #72

kristijorgji opened this issue Aug 14, 2023 · 8 comments

Comments

@kristijorgji
Copy link

kristijorgji commented Aug 14, 2023

Hi all and congratulations for the great plugin.

I am using version
"@ckeditor/strapi-plugin-ckeditor": "^0.0.7",

and would love to have more features here such as

  1. Ability to select target for the link element.
    Screenshot 2023-08-14 at 13 25 59

I can only enter the link now but no target
2. The same issue is also for the Media Library. If I include one image and insert link into it cannot use target
Screenshot 2023-08-14 at 13 26 40

@kristijorgji kristijorgji changed the title Option to use target="_blank" in links Option to use target="_blank" in links + image links Aug 14, 2023
@kristijorgji
Copy link
Author

Thanks for the workaround @ksyp-7
That is a hack though and not adding support to the editor. You replace all <a with <a target="_blank even when you don't intend to have a new tab link!

I would like to have this option in the editor itself so we can have some links that open in new tabs other within same tab

@vr1e
Copy link

vr1e commented Sep 21, 2023

This one: #65

@kristijorgji
Copy link
Author

@vr1e thanks for the update. I like the PR there but would be better not to have noopener noref as sometimes you might link internally with target _blank (new tab) and still want to trust those pages.
In that case the plugin would be better to have option to override rel as well would be perfect to choose both target and rel manually if needed

@royanon
Copy link

royanon commented Dec 1, 2023

I think you can pass config to the options like so

        link : {
          defaultProtocol: 'https://',
          decorators: [
            {
              mode: 'manual',
              label: 'Open in a new tab',
              attributes: {
                target: '_blank',
                rel: 'noopener noreferrer'
              }
            }
          ],
        },

I put this in /admin/src/components/CKEditorInput/Configurator.js

image

@kristijorgji
Copy link
Author

kristijorgji commented Dec 8, 2023

@royanon

Are you using this npm package "@ckeditor/strapi-plugin-ckeditor": "^0.0.10",

I saw no documentation there for the config you provided above.

I am using Typescript by the way, so where should I put the config you put at /admin/src/components/CKEditorInput/Configurator.js

Thank you

@kristijorgji
Copy link
Author

kristijorgji commented Dec 11, 2023

@royanon please need more help as both the documented solution and your answer is not working for me.

I added the following config under myStrapiApp/config/ckeditor.txt as documented at https://market.strapi.io/plugins/@_sh-strapi-plugin-ckeditor#configuration

globalThis.CKEditorConfig = {
    configs: {
        markdown: {
            editorConfig: {
                link: {
                    defaultProtocol: 'https://',
                    decorators: [
                        {
                            mode: 'manual',
                            label: 'Open in a new tab',
                            attributes: {
                                target: '_blank',
                                rel: 'noopener noreferrer'
                            }
                        }
                    ],
                },
            }
        }
    }
}

then I do rm -rf dist && yarn build && yarn develop and nothing happens.

I still don't see the "Open in a new tab" in the UI.

@mauro-montano
Copy link

mauro-montano commented Mar 27, 2024

@royanon please need more help as both the documented solution and your answer is not working for me.

I added the following config under myStrapiApp/config/ckeditor.txt as documented at https://market.strapi.io/plugins/@_sh-strapi-plugin-ckeditor#configuration

globalThis.CKEditorConfig = {
    configs: {
        markdown: {
            editorConfig: {
                link: {
                    defaultProtocol: 'https://',
                    decorators: [
                        {
                            mode: 'manual',
                            label: 'Open in a new tab',
                            attributes: {
                                target: '_blank',
                                rel: 'noopener noreferrer'
                            }
                        }
                    ],
                },
            }
        }
    }
}

then I do rm -rf dist && yarn build && yarn develop and nothing happens.

I still don't see the "Open in a new tab" in the UI.

@kristijorgji Could you solve it? I have the same problem

@Arunjenson-ss
Copy link

any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants