How to use @ckeditor/ckeditor5-link - 2 common examples

To help you get started, we’ve selected a few @ckeditor/ckeditor5-link examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github neos / neos-ui / packages / neos-ui-ckeditor5-bindings / src / plugins / linkAttributeCommand.js View on Github external
model.change(writer => {
            if (toggleMode && !value) {
                const rangesToUnset = selection.isCollapsed ?
                    [findLinkRange(selection.getFirstPosition(), selection.getAttribute('linkHref'), model)] : selection.getRanges();
                for (const range of rangesToUnset) {
                    writer.removeAttribute(this.attributeKey, range);
                }
            } else if (selection.isCollapsed) {
                const position = selection.getFirstPosition();

                if (selection.hasAttribute('linkHref')) {
                    const linkRange = findLinkRange(selection.getFirstPosition(), selection.getAttribute('linkHref'), model);
                    if (value === false) {
                        writer.removeAttribute(this.attributeKey, linkRange);
                    } else {
                        writer.setAttribute(this.attributeKey, value, linkRange);
                        writer.setSelection(linkRange);
                    }
                } else if (value !== '') {
                    const attributes = toMap(selection.getAttributes());
github neos / neos-ui / packages / neos-ui-ckeditor5-bindings / src / plugins / linkAttributeCommand.js View on Github external
model.change(writer => {
            if (toggleMode && !value) {
                const rangesToUnset = selection.isCollapsed ?
                    [findLinkRange(selection.getFirstPosition(), selection.getAttribute('linkHref'), model)] : selection.getRanges();
                for (const range of rangesToUnset) {
                    writer.removeAttribute(this.attributeKey, range);
                }
            } else if (selection.isCollapsed) {
                const position = selection.getFirstPosition();

                if (selection.hasAttribute('linkHref')) {
                    const linkRange = findLinkRange(selection.getFirstPosition(), selection.getAttribute('linkHref'), model);
                    if (value === false) {
                        writer.removeAttribute(this.attributeKey, linkRange);
                    } else {
                        writer.setAttribute(this.attributeKey, value, linkRange);
                        writer.setSelection(linkRange);
                    }
                } else if (value !== '') {
                    const attributes = toMap(selection.getAttributes());
                    attributes.set(this.attributeKey, value);
                    const node = writer.createText(value, attributes);
                    writer.insert(node, position);
                    writer.setSelection(Range.createOn(node));
                }
            } else {
                const ranges = model.schema.getValidRanges(selection.getRanges(), this.attributeKey);

@ckeditor/ckeditor5-link

Link feature for CKEditor 5.

GPL-2.0-or-later
Latest version published 4 days ago

Package Health Score

91 / 100
Full package analysis

Popular @ckeditor/ckeditor5-link functions