@limetech/lime-elements 37.46.1 → 37.47.0
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.
- package/CHANGELOG.md +8 -0
- package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +84 -6
- package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js.map +1 -1
- package/dist/collection/components/text-editor/prosemirror-adapter/plugins/image-remover-plugin.js +78 -0
- package/dist/collection/components/text-editor/prosemirror-adapter/plugins/image-remover-plugin.js.map +1 -0
- package/dist/collection/components/text-editor/prosemirror-adapter/plugins/link-plugin.js +5 -4
- package/dist/collection/components/text-editor/prosemirror-adapter/plugins/link-plugin.js.map +1 -1
- package/dist/collection/components/text-editor/prosemirror-adapter/prosemirror-adapter.js +2 -0
- package/dist/collection/components/text-editor/prosemirror-adapter/prosemirror-adapter.js.map +1 -1
- package/dist/esm/limel-prosemirror-adapter.entry.js +84 -6
- package/dist/esm/limel-prosemirror-adapter.entry.js.map +1 -1
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/{p-8d71c9e5.entry.js → p-8db40f25.entry.js} +2 -2
- package/dist/lime-elements/p-8db40f25.entry.js.map +1 -0
- package/dist/types/components/text-editor/prosemirror-adapter/plugins/image-remover-plugin.d.ts +4 -0
- package/package.json +1 -1
- package/dist/lime-elements/p-8d71c9e5.entry.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [37.47.0](https://github.com/Lundalogik/lime-elements/compare/v37.46.1...v37.47.0) (2024-06-05)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
* **text editor:** block pasted inline images ([28d562c](https://github.com/Lundalogik/lime-elements/commit/28d562c7ade5f36ef77772ffcd16aa82b733441c))
|
|
8
|
+
|
|
1
9
|
## [37.46.1](https://github.com/Lundalogik/lime-elements/compare/v37.46.0...v37.46.1) (2024-06-04)
|
|
2
10
|
|
|
3
11
|
|
|
@@ -25739,17 +25739,18 @@ const processDoubleClickEvent = (view, event) => {
|
|
|
25739
25739
|
}, DOUBLE_CLICK_DELAY);
|
|
25740
25740
|
return true;
|
|
25741
25741
|
};
|
|
25742
|
-
const processPasteEvent = (view, event) => {
|
|
25742
|
+
const processPasteEvent$1 = (view, event) => {
|
|
25743
25743
|
const clipboardData = event.clipboardData;
|
|
25744
25744
|
if (!clipboardData) {
|
|
25745
25745
|
return false;
|
|
25746
25746
|
}
|
|
25747
25747
|
const text = clipboardData.getData('text/plain');
|
|
25748
|
-
if
|
|
25749
|
-
|
|
25748
|
+
// Process as a link if the text is a valid URL
|
|
25749
|
+
if (isValidUrl(text)) {
|
|
25750
|
+
pasteAsLink(view, text);
|
|
25751
|
+
return true;
|
|
25750
25752
|
}
|
|
25751
|
-
|
|
25752
|
-
return true;
|
|
25753
|
+
return false;
|
|
25753
25754
|
};
|
|
25754
25755
|
const pasteAsLink = (view, href) => {
|
|
25755
25756
|
const { state, dispatch } = view;
|
|
@@ -25770,7 +25771,7 @@ const createLinkPlugin = (updateLinkCallback) => {
|
|
|
25770
25771
|
key: linkPluginKey,
|
|
25771
25772
|
props: {
|
|
25772
25773
|
handlePaste: (view, event) => {
|
|
25773
|
-
return processPasteEvent(view, event);
|
|
25774
|
+
return processPasteEvent$1(view, event);
|
|
25774
25775
|
},
|
|
25775
25776
|
handleDOMEvents: {
|
|
25776
25777
|
mousedown: (view, event) => {
|
|
@@ -25790,6 +25791,82 @@ const createLinkPlugin = (updateLinkCallback) => {
|
|
|
25790
25791
|
});
|
|
25791
25792
|
};
|
|
25792
25793
|
|
|
25794
|
+
const pluginKey = new PluginKey('imageRemoverPlugin');
|
|
25795
|
+
const createImageRemoverPlugin = () => {
|
|
25796
|
+
return new Plugin({
|
|
25797
|
+
key: pluginKey,
|
|
25798
|
+
props: {
|
|
25799
|
+
handlePaste: (view, event, slice) => {
|
|
25800
|
+
return processPasteEvent(view, event, slice);
|
|
25801
|
+
},
|
|
25802
|
+
},
|
|
25803
|
+
});
|
|
25804
|
+
};
|
|
25805
|
+
/**
|
|
25806
|
+
* Check if a given ProseMirror node or fragment contains any image nodes.
|
|
25807
|
+
* @param node - The ProseMirror node or fragment to check.
|
|
25808
|
+
* @returns A boolean indicating whether the node contains any image nodes.
|
|
25809
|
+
*/
|
|
25810
|
+
const isImageNode = (node) => {
|
|
25811
|
+
if (node instanceof Node$1) {
|
|
25812
|
+
if (node.type.name === 'image') {
|
|
25813
|
+
return true;
|
|
25814
|
+
}
|
|
25815
|
+
let found = false;
|
|
25816
|
+
node.content.forEach((child) => {
|
|
25817
|
+
if (isImageNode(child)) {
|
|
25818
|
+
found = true;
|
|
25819
|
+
}
|
|
25820
|
+
});
|
|
25821
|
+
return found;
|
|
25822
|
+
}
|
|
25823
|
+
else if (node instanceof Fragment) {
|
|
25824
|
+
let found = false;
|
|
25825
|
+
node.forEach((child) => {
|
|
25826
|
+
if (isImageNode(child)) {
|
|
25827
|
+
found = true;
|
|
25828
|
+
}
|
|
25829
|
+
});
|
|
25830
|
+
return found;
|
|
25831
|
+
}
|
|
25832
|
+
return false;
|
|
25833
|
+
};
|
|
25834
|
+
/**
|
|
25835
|
+
* Filter out image nodes from a ProseMirror fragment.
|
|
25836
|
+
* @param fragment - The ProseMirror fragment to filter.
|
|
25837
|
+
* @returns A new fragment with image nodes removed.
|
|
25838
|
+
*/
|
|
25839
|
+
const filterImageNodes = (fragment) => {
|
|
25840
|
+
const filteredChildren = [];
|
|
25841
|
+
fragment.forEach((child) => {
|
|
25842
|
+
if (!isImageNode(child)) {
|
|
25843
|
+
if (child.content.size > 0) {
|
|
25844
|
+
const filteredContent = filterImageNodes(child.content);
|
|
25845
|
+
const newNode = child.copy(filteredContent);
|
|
25846
|
+
filteredChildren.push(newNode);
|
|
25847
|
+
}
|
|
25848
|
+
else {
|
|
25849
|
+
filteredChildren.push(child);
|
|
25850
|
+
}
|
|
25851
|
+
}
|
|
25852
|
+
});
|
|
25853
|
+
return Fragment.fromArray(filteredChildren);
|
|
25854
|
+
};
|
|
25855
|
+
const processPasteEvent = (view, event, slice) => {
|
|
25856
|
+
const clipboardData = event.clipboardData;
|
|
25857
|
+
if (!clipboardData) {
|
|
25858
|
+
return false;
|
|
25859
|
+
}
|
|
25860
|
+
const filteredSlice = new Slice(filterImageNodes(slice.content), slice.openStart, slice.openEnd);
|
|
25861
|
+
if (filteredSlice.content.childCount < slice.content.childCount) {
|
|
25862
|
+
const { state, dispatch } = view;
|
|
25863
|
+
const tr = state.tr.replaceSelection(filteredSlice);
|
|
25864
|
+
dispatch(tr);
|
|
25865
|
+
return true;
|
|
25866
|
+
}
|
|
25867
|
+
return false;
|
|
25868
|
+
};
|
|
25869
|
+
|
|
25793
25870
|
const prosemirrorAdapterCss = "@charset \"UTF-8\";:host{--mdc-theme-primary:var(\n --lime-primary-color,\n rgb(var(--color-teal-default))\n );--mdc-theme-secondary:var(\n --lime-secondary-color,\n rgb(var(--contrast-1100))\n );--mdc-theme-on-primary:var(\n --lime-on-primary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-secondary:var(\n --lime-on-secondary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-text-disabled-on-background:var(\n --lime-text-disabled-on-background-color,\n rgba(var(--contrast-1700), 0.38)\n );--mdc-theme-text-primary-on-background:var(\n --lime-text-primary-on-background-color,\n rgba(var(--contrast-1700), 0.87)\n );--mdc-theme-text-secondary-on-background:var(\n --lime-text-secondary-on-background-color,\n rgba(var(--contrast-1700), 0.54)\n );--mdc-theme-error:var(\n --lime-error-background-color,\n rgb(var(--color-red-dark))\n );--lime-error-text-color:rgb(var(--color-red-darker));--mdc-theme-surface:var(\n --lime-surface-background-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-surface:var(\n --lime-on-surface-color,\n rgb(var(--contrast-1500))\n )}:host(limel-prosemirror-adapter){display:flex;flex-direction:column}:host(limel-prosemirror-adapter) limel-action-bar{order:1}:host(limel-prosemirror-adapter) div#editor{order:2;height:100%}:host(limel-prosemirror-adapter) div[contenteditable=true]{height:100%}*{box-sizing:border-box}.ProseMirror-menubar-wrapper{display:grid;grid-template-rows:auto 1fr}.ProseMirror-textblock-dropdown{min-width:3em}.ProseMirror-tooltip .ProseMirror-menu{width:-webkit-fit-content;width:fit-content;white-space:pre}limel-action-bar{--action-bar-border-radius:0.25rem;position:sticky;z-index:1;top:1px;background-color:rgba(var(--contrast-200), 0.5);backdrop-filter:blur(0.5rem);-webkit-backdrop-filter:blur(0.5rem);opacity:0.6;transition:opacity 0.5s ease;margin:0 1px;width:calc(100% - 2px)}:host(limel-prosemirror-adapter:focus-within) limel-action-bar,:host(limel-prosemirror-adapter:hover) limel-action-bar{opacity:1}.ProseMirror{position:relative;word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;-webkit-font-variant-ligatures:none;font-variant-ligatures:none;font-feature-settings:\"liga\" 0;padding:var(--limel-text-editor-padding)}.ProseMirror [draggable][contenteditable=false]{user-select:text}.ProseMirror:focus-visible{outline:none}.ProseMirror-hideselection{caret-color:transparent}.ProseMirror-hideselection *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-selectednode{outline:0.125rem solid rgb(var(--color-sky-light))}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:\"\";position:absolute;left:-2rem;right:-0.125rem;top:-0.125rem;bottom:-0.125rem;border:0.125rem solid rgb(var(--color-sky-light));pointer-events:none}img.ProseMirror-separator{display:inline !important;border:none !important;margin:0 !important}limel-portal{width:25rem}blockquote{position:relative;font-weight:100;font-size:0.875rem;max-width:100%;line-height:1.4;margin:0;padding:0.5rem 1.25rem;border-radius:0.05rem 0.75rem;background-color:rgb(var(--contrast-300))}blockquote:before,blockquote:after{position:absolute;font-size:2.75rem;opacity:0.4}blockquote:before{content:\"“\";left:0;top:-0.75rem}blockquote:after{content:\"”\";right:0;bottom:-2rem}:host(limel-markdown.truncate-paragraphs) p{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}p,li{font-size:0.875rem;word-break:break-word;hyphens:auto;-webkit-hyphens:auto}a{word-break:break-all}p{margin-top:0;margin-bottom:0.5rem}p:only-child{margin-bottom:0}a{transition:color 0.2s ease;color:var(--markdown-hyperlink-color, rgb(var(--color-blue-dark)));text-decoration:none}a:hover{color:var(--markdown-hyperlink-color--hovered, rgb(var(--color-blue-default)))}hr{margin:1.75rem 0 2rem 0;border-width:0;border-top:1px solid rgb(var(--contrast-500))}dl{display:grid;grid-template-columns:1fr 2fr;grid-template-rows:1fr;margin-bottom:2rem;border:1px solid rgb(var(--contrast-400));border-radius:0.375rem;background-color:rgb(var(--contrast-200))}dl dt,dl dd{padding:0.375rem 0.5rem;font-size:0.875rem;margin:0}dl dt:nth-of-type(even),dl dd:nth-of-type(even){background-color:rgb(var(--contrast-300))}dl dt:first-child{border-top-left-radius:0.375rem}dl dt:last-child{border-bottom-left-radius:0.375rem}dl dd:first-child{border-top-right-radius:0.375rem}dl dd:last-child{border-bottom-right-radius:0.375rem}h1{font-size:1.5rem}h2{font-size:1.25rem}h3{font-size:1.125rem}h4{font-size:1rem}h5{font-size:0.875rem}h6{font-size:0.75rem}h1,h2{margin-top:0.5rem;margin-bottom:0.5rem;letter-spacing:-0.03125rem;font-weight:500}h3,h4{margin-top:0.75rem;margin-bottom:0.25rem;font-weight:600}h5,h6{margin-top:0.5rem;margin-bottom:0.125rem;font-weight:600}h1,h2,h3,h4,h5,h6{word-break:break-word;hyphens:auto;-webkit-hyphens:auto}:not([contenteditable=true]) h1,:not([contenteditable=true]) h2,:not([contenteditable=true]) h3,:not([contenteditable=true]) h4,:not([contenteditable=true]) h5,:not([contenteditable=true]) h6{text-wrap:balance}[contenteditable=true] h1,[contenteditable=true] h2,[contenteditable=true] h3,[contenteditable=true] h4,[contenteditable=true] h5,[contenteditable=true] h6{text-wrap:initial}ul{list-style:none}ul li{position:relative;margin-left:0.75rem}ul li:before{content:\"\";position:absolute;left:-0.5rem;top:0.5rem;width:0.25rem;height:0.25rem;border-radius:50%;background-color:rgb(var(--contrast-700));display:block}ol{margin-top:0.25rem;padding-left:1rem}ul{margin-top:0.25rem;padding-left:0}ul ul,ul ol,ol ol,ol ul{margin-left:0}li{margin-bottom:0.25rem}code{font-family:ui-monospace, \"Cascadia Code\", \"Source Code Pro\", Menlo, Consolas, \"DejaVu Sans Mono\", monospace;font-size:0.8125rem;letter-spacing:-0.0125rem;color:rgb(var(--contrast-1300));-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;display:inline-block;border-radius:0.25rem;padding:0.03125rem 0.25rem;background-color:rgb(var(--contrast-600))}pre>code{display:block;margin:0.5rem 0;padding:0.5rem 0.75rem;overflow:auto;white-space:pre-wrap}:host(limel-markdown:not(.no-table-styles)) table{table-layout:auto;min-width:100%;border-collapse:collapse;border-spacing:0;background:transparent;margin:0.75rem 0;border:1px solid rgb(var(--contrast-400))}:host(limel-markdown:not(.no-table-styles)) th,:host(limel-markdown:not(.no-table-styles)) td{text-align:left;vertical-align:top;transition:background-color 0.2s ease;font-size:0.875rem}:host(limel-markdown:not(.no-table-styles)) td{padding:0.5rem 0.375rem 0.75rem 0.375rem}:host(limel-markdown:not(.no-table-styles)) tr th{background-color:rgb(var(--contrast-400));padding:0.25rem 0.375rem;font-weight:normal}:host(limel-markdown:not(.no-table-styles)) tr th:only-child{text-align:center}:host(limel-markdown:not(.no-table-styles)) tbody tr:nth-child(odd) td{background-color:rgb(var(--contrast-200))}:host(limel-markdown:not(.no-table-styles)) tbody tr:hover td{background-color:rgb(var(--contrast-300))}";
|
|
25794
25871
|
|
|
25795
25872
|
const ProsemirrorAdapter = class {
|
|
@@ -25983,6 +26060,7 @@ const ProsemirrorAdapter = class {
|
|
|
25983
26060
|
keymap(this.menuCommandFactory.buildKeymap()),
|
|
25984
26061
|
this.createMenuStateTrackingPlugin(this.actionBarItems),
|
|
25985
26062
|
createLinkPlugin(this.handleNewLinkSelection),
|
|
26063
|
+
createImageRemoverPlugin(),
|
|
25986
26064
|
],
|
|
25987
26065
|
});
|
|
25988
26066
|
}
|