@brightspace-ui/htmleditor
Advanced tools
Comparing version 2.102.7 to 2.102.8
@@ -1,2 +0,2 @@ | ||
import { EditorNode, EditorSelection } from './selection.js'; | ||
import { EditorNode, EditorRange, EditorSelection } from './selection.js'; | ||
import { requestInstance } from '@brightspace-ui/core/mixins/provider-mixin.js'; | ||
@@ -60,3 +60,3 @@ | ||
applyLinkFormatting(href, title) { | ||
applyLinkFormatting(href, title, text, target) { | ||
if (!this.#editor.selection) return; | ||
@@ -70,3 +70,34 @@ | ||
this.#editor.formatter.apply('link', { href: href, title: title }, anchor); | ||
const linkAttributes = { href: href }; | ||
if (title) linkAttributes.title = title; | ||
if (target) linkAttributes.target = target; | ||
this.#editor.formatter.apply('link', linkAttributes, anchor); | ||
if (!text) return; | ||
const nodeHasNonTextElements = node => { | ||
const inlineTextElements = this.getEditorInlineTextElements(); | ||
return node.nodeType === Node.ELEMENT_NODE && !Object.keys(inlineTextElements).includes(node.tagName); | ||
}; | ||
if (anchor) { | ||
const wrappedAnchor = new EditorNode(anchor, this.#editor.selection); | ||
if (!wrappedAnchor.searchDescendants(nodeHasNonTextElements) && anchor.innerText !== text) anchor.innerText = text; | ||
return; | ||
} | ||
const range = this.#editor.selection.getRng(); | ||
if (range.collapsed) { | ||
range.insertNode(document.createTextNode(text)); | ||
return; | ||
} | ||
const wrappedRange = new EditorRange(range, this.#editor.selection); | ||
if (!wrappedRange.searchContainedNodes(nodeHasNonTextElements) && range.toString() !== text) { | ||
range.deleteContents(); | ||
range.insertNode(document.createTextNode(text)); | ||
} | ||
} | ||
@@ -148,2 +179,6 @@ | ||
getEditorInlineTextElements() { | ||
return this.#editor.schema.getTextInlineElements(); | ||
} | ||
getFileUploadProperties() { | ||
@@ -150,0 +185,0 @@ return { |
{ | ||
"name": "@brightspace-ui/htmleditor", | ||
"description": "An HTML editor that integrates with Brightspace", | ||
"version": "2.102.7", | ||
"version": "2.102.8", | ||
"type": "module", | ||
@@ -6,0 +6,0 @@ "repository": "https://github.com/BrightspaceUI/htmleditor.git", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2092563
39316