@seafile/sdoc-editor 0.1.31 → 0.1.32

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.
@@ -5,6 +5,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
5
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
6
  import React from 'react';
7
7
  import Lightbox from '@seafile/react-image-lightbox';
8
+ import { getImageURL } from '../helpers';
8
9
  import '@seafile/react-image-lightbox/style.css';
9
10
  var ImagePreviewer = /*#__PURE__*/function (_React$Component) {
10
11
  _inherits(ImagePreviewer, _React$Component);
@@ -19,7 +20,8 @@ var ImagePreviewer = /*#__PURE__*/function (_React$Component) {
19
20
  while (nodes && nodeIndex <= nodes.length - 1) {
20
21
  var currentNode = nodes[nodeIndex];
21
22
  if (currentNode.type === 'image') {
22
- currentNode.data.src && list.push(currentNode.data.src);
23
+ var url = getImageURL(currentNode.data.src);
24
+ url && list.push(url);
23
25
  } else {
24
26
  list.push.apply(list, _toConsumableArray(_this.getImageNodes(currentNode.children)));
25
27
  }
@@ -1,8 +1,10 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
+ import urlJoin from 'url-join';
3
4
  import { Editor, Range, Transforms } from '@seafile/slate';
4
5
  import { BLOCKQUOTE, CODE_BLOCK, IMAGE, ORDERED_LIST, UNORDERED_LIST } from '../../constants';
5
6
  import { generateEmptyElement, getNodeType } from '../../core';
7
+ import context from '../../../../context';
6
8
  export var isInsertImageMenuDisabled = function isInsertImageMenuDisabled(editor) {
7
9
  var selection = editor.selection;
8
10
  if (selection === null) return true;
@@ -51,4 +53,10 @@ export var updateImage = function updateImage(editor, data) {
51
53
  at: editor.selection,
52
54
  voids: true
53
55
  });
56
+ };
57
+ export var getImageURL = function getImageURL(url) {
58
+ if (url && url.startsWith('http')) return url;
59
+ var serviceUrl = context.getSetting('serviceUrl');
60
+ var assetsUrl = context.getSetting('assetsUrl');
61
+ return urlJoin(serviceUrl, assetsUrl, url);
54
62
  };
@@ -7,10 +7,8 @@ import { useSelected } from '@seafile/slate-react';
7
7
  import React from 'react';
8
8
  import classNames from 'classnames';
9
9
  import { withTranslation } from 'react-i18next';
10
- import urlJoin from 'url-join';
11
- import { updateImage } from './helpers';
10
+ import { getImageURL, updateImage } from './helpers';
12
11
  import ImagePreviewer from './dialogs/image-previewer';
13
- import context from '../../../../context';
14
12
  var Image = /*#__PURE__*/function (_React$Component) {
15
13
  _inherits(Image, _React$Component);
16
14
  var _super = _createSuper(Image);
@@ -89,13 +87,6 @@ var Image = /*#__PURE__*/function (_React$Component) {
89
87
  return _this;
90
88
  }
91
89
  _createClass(Image, [{
92
- key: "getImageURL",
93
- value: function getImageURL(url) {
94
- var serviceUrl = context.getSetting('serviceUrl');
95
- var assetsUrl = context.getSetting('assetsUrl');
96
- return urlJoin(serviceUrl, assetsUrl, url);
97
- }
98
- }, {
99
90
  key: "render",
100
91
  value: function render() {
101
92
  var _this$props2 = this.props,
@@ -116,7 +107,7 @@ var Image = /*#__PURE__*/function (_React$Component) {
116
107
  }, attributes), /*#__PURE__*/React.createElement("img", {
117
108
  className: imageClassName,
118
109
  ref: this.setImageRef,
119
- src: this.getImageURL(data.src),
110
+ src: getImageURL(data.src),
120
111
  style: imageStyle,
121
112
  draggable: false,
122
113
  alt: ""
@@ -135,7 +126,7 @@ var Image = /*#__PURE__*/function (_React$Component) {
135
126
  className: "image-size",
136
127
  contentEditable: false
137
128
  }, /*#__PURE__*/React.createElement("span", null, t('width'), ':', parseInt(this.state.width || this.image.clientWidth)), /*#__PURE__*/React.createElement("span", null, "\xA0\xA0"), /*#__PURE__*/React.createElement("span", null, t('height'), ':', this.image.clientHeight)), children), isShowImagePreview && /*#__PURE__*/React.createElement(ImagePreviewer, {
138
- imageUrl: data.src,
129
+ imageUrl: getImageURL(data.src),
139
130
  editor: this.props.editor,
140
131
  toggleImagePreviewer: this.setFullScreen
141
132
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.1.31",
3
+ "version": "0.1.32",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",