markupeditor 0.9.12 → 0.9.13

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.
@@ -16725,6 +16725,20 @@ function getDataImages() {
16725
16725
  return dataImages
16726
16726
  }
16727
16727
 
16728
+ /**
16729
+ * Return an array of `src` attributes for images that contain relative references, empty if there are none.
16730
+ *
16731
+ * @returns {Array<string>}
16732
+ */
16733
+ function getLocalImages() {
16734
+ const isAbsoluteURL = src => { try { return !!new URL(src) } catch { return false } };
16735
+ const isRelative = src =>
16736
+ !!src && !isAbsoluteURL(src) && !src.startsWith('data:') && !src.startsWith('/');
16737
+ return Array.from(activeEditorElement().getElementsByTagName('img'))
16738
+ .map(img => img.getAttribute('src'))
16739
+ .filter(isRelative)
16740
+ }
16741
+
16728
16742
  /**
16729
16743
  * We saved an image at a new location or translated it from data to a file reference,
16730
16744
  * so we need to update the document to reflect it.
@@ -17176,7 +17190,7 @@ function focusOn(id) {
17176
17190
  const view = activeView();
17177
17191
  const {node, pos} = _getNode(id);
17178
17192
  if (node && (node.attrs.id !== selectedID())) {
17179
- const selection = new TextSelection(view.state.doc.resolve(pos));
17193
+ const selection = TextSelection.near(view.state.tr.doc.resolve(pos));
17180
17194
  const transaction = view.state.tr.setSelection(selection).scrollIntoView();
17181
17195
  view.dispatch(transaction);
17182
17196
  }}
@@ -17451,7 +17465,7 @@ function toggleListItem$1(listType) {
17451
17465
  command(view.state, (transaction) => {
17452
17466
  const newState = view.state.apply(transaction);
17453
17467
  view.updateState(newState);
17454
- });
17468
+ }, view);
17455
17469
  }}
17456
17470
  /**
17457
17471
  * Return the type of list the selection is in, else null.
@@ -24891,6 +24905,7 @@ const MU = {
24891
24905
  focusOn,
24892
24906
  focused,
24893
24907
  getDataImages,
24908
+ getLocalImages,
24894
24909
  getHTML,
24895
24910
  getHeight,
24896
24911
  getImageAttributes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markupeditor",
3
- "version": "0.9.12",
3
+ "version": "0.9.13",
4
4
  "description": "A web component and API for WYSIWYG HTML editing.",
5
5
  "keywords": [
6
6
  "wysiwyg",