@sveltia/ui 0.80.0 → 0.80.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,6 +12,7 @@ import { createEmptyHistoryState, registerHistory } from '@lexical/history';
12
12
  import { $generateNodesFromDOM as generateNodesFromDOM } from '@lexical/html';
13
13
  import {
14
14
  $isLinkNode as isLinkNode,
15
+ LinkNode,
15
16
  TOGGLE_LINK_COMMAND,
16
17
  $toggleLink as toggleLink,
17
18
  } from '@lexical/link';
@@ -36,7 +37,11 @@ import {
36
37
  registerRichText,
37
38
  } from '@lexical/rich-text';
38
39
  import { TableCellNode, TableNode, TableRowNode } from '@lexical/table';
39
- import { $getNearestNodeOfType as getNearestNodeOfType, objectKlassEquals } from '@lexical/utils';
40
+ import {
41
+ $getNearestNodeOfType as getNearestNodeOfType,
42
+ objectKlassEquals,
43
+ $unwrapNode as unwrapNode,
44
+ } from '@lexical/utils';
40
45
  import { sleep } from '@sveltia/utils/misc';
41
46
  import { isURL } from '@sveltia/utils/string';
42
47
  import {
@@ -657,13 +662,22 @@ const registerCodeEditorCommands = (editor, defaultLanguage) =>
657
662
  );
658
663
 
659
664
  /**
660
- * Register the link command, and the paste handler that turns a pasted URL into a link.
665
+ * Register the link command, the paste handler that turns a pasted URL into a link, and the
666
+ * transform that removes a link with an unsafe URL.
661
667
  * @param {LexicalEditor} editor Editor instance.
662
668
  * @returns {() => void} Cleanup handler.
663
669
  * @see https://github.com/facebook/lexical/blob/main/packages/lexical-link/src/LexicalLinkExtension.ts
664
670
  */
665
671
  const registerLinkCommands = (editor) =>
666
672
  mergeUnregisters(
673
+ // A link can also be created by importing the value or pasting rich text, which bypass the
674
+ // command below. Unwrap a link with an unsafe URL, keeping its text, so the URL never reaches
675
+ // the Markdown or HTML value
676
+ editor.registerNodeTransform(LinkNode, (node) => {
677
+ if (!isSafeLinkURL(node.getURL())) {
678
+ unwrapNode(node);
679
+ }
680
+ }),
667
681
  editor.registerCommand(
668
682
  TOGGLE_LINK_COMMAND,
669
683
  (payload) => {
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Version of this package, used to resolve the prebuilt Shiki engine chunk from a CDN.
3
3
  */
4
- export const UI_VERSION: "0.80.0";
4
+ export const UI_VERSION: "0.80.1";
@@ -3,4 +3,4 @@
3
3
  /**
4
4
  * Version of this package, used to resolve the prebuilt Shiki engine chunk from a CDN.
5
5
  */
6
- export const UI_VERSION = '0.80.0';
6
+ export const UI_VERSION = '0.80.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltia/ui",
3
- "version": "0.80.0",
3
+ "version": "0.80.1",
4
4
  "description": "A collection of Svelte components and utilities for building user interfaces.",
5
5
  "repository": {
6
6
  "type": "git",