Skip to content

Commit

Permalink
Release 19.1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
babich-a committed Sep 12, 2019
1 parent f741114 commit 0453e5f
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 42 deletions.
16 changes: 10 additions & 6 deletions js/ui/file_manager/file_provider/webapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,11 @@ class WebApiFileProvider extends FileProvider {
}

_executeRequest(command, args) {
const queryString = this._getQueryString({
command,
arguments: JSON.stringify(args)
});

const method = command === "GetDirContents" ? "GET" : "POST";

const deferred = new Deferred();
ajax.sendRequest({
url: this._endpointUrl + "?" + queryString,
url: this._getEndpointUrl(command, args),
method,
dataType: "json",
cache: false
Expand All @@ -149,6 +144,15 @@ class WebApiFileProvider extends FileProvider {
return deferred.promise();
}

_getEndpointUrl(command, args) {
const queryString = this._getQueryString({
command,
arguments: JSON.stringify(args)
});
const separator = this._endpointUrl && this._endpointUrl.indexOf("?") > 0 ? "&" : "?";
return this._endpointUrl + separator + queryString;
}

_getQueryString(params) {
const pairs = [];

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"dependencies": {
"devexpress-diagram": "0.0.30",
"jszip": "^2.0.0 || ^3.0.0",
"quill": "^1.3.6",
"quill": "^1.3.7",
"showdown": "^1.8.6",
"turndown": "^5.0.1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "ui/html_editor";
import fx from "animation/fx";

import keyboardMock from "../../../helpers/keyboardMock.js";
import { checkLink } from "./utils.js";

const TOOLBAR_CLASS = "dx-htmleditor-toolbar";
const TOOLBAR_WRAPPER_CLASS = "dx-htmleditor-toolbar-wrapper";
Expand Down Expand Up @@ -141,12 +142,14 @@ QUnit.module("Toolbar integration", {

test("Add a link via dialog", (assert) => {
const done = assert.async();
const expected = '<p><a href="http://test.com" target="_blank">te</a>st</p>';
const instance = $("#htmlEditor").dxHtmlEditor({
value: "<p>test</p>",
toolbar: { items: ["link"] },
onValueChanged: (e) => {
assert.equal(e.value, expected, "link has been added");
onValueChanged: ({ value }) => {
checkLink(assert, {
href: "http://test.test",
content: "te"
}, value);
done();
}
}).dxHtmlEditor("instance");
Expand All @@ -166,7 +169,7 @@ QUnit.module("Toolbar integration", {

$inputs
.first()
.val("http://test.com")
.val("http://test.test")
.change();

$(`.${DIALOG_CLASS} .${BUTTON_CLASS}`)
Expand Down Expand Up @@ -386,13 +389,15 @@ QUnit.module("Toolbar integration", {
test("link should be correctly set to an image", (assert) => {
const done = assert.async();
const $container = $("#htmlEditor");
const link = "http://test.com";
const expected = `<p><a href="${link}" target="_blank"><img src="${BLACK_PIXEL}"></a></p>`;
const link = "http://test.test";
const instance = $container.dxHtmlEditor({
toolbar: { items: ["link"] },
value: `<img src=${BLACK_PIXEL}>`,
onValueChanged: ({ value }) => {
assert.strictEqual(value, expected, "link was setted");
checkLink(assert, {
href: link,
content: `<img src="${BLACK_PIXEL}">`
}, value);
done();
}
}).dxHtmlEditor("instance");
Expand Down Expand Up @@ -436,7 +441,7 @@ QUnit.module("Toolbar integration", {
setTimeout(() => {
prepareLink();
$urlInput
.val("http://test2.com")
.val("http://test2.test")
.change();

$okDialogButton.trigger("dxclick");
Expand All @@ -445,13 +450,16 @@ QUnit.module("Toolbar integration", {
setTimeout(() => {
prepareLink();
$urlInput
.val("http://test3.com")
.val("http://test3.test")
.change();

$okDialogButton.trigger("dxclick");
});
} else {
assert.strictEqual(value, '<p><a href="http://test3.com" target="_blank">test</a></p>', "link was setted");
checkLink(assert, {
href: "http://test3.test",
content: "test"
}, value);
done();
}
});
Expand All @@ -464,7 +472,7 @@ QUnit.module("Toolbar integration", {

prepareLink();
$urlInput
.val("http://test1.com")
.val("http://test1.test")
.change();

$okDialogButton.trigger("dxclick");
Expand All @@ -474,12 +482,15 @@ QUnit.module("Toolbar integration", {

test("Add a link with empty text", (assert) => {
const done = assert.async();
const expected = '<p><a href="http://test.com" target="_blank">http://test.com</a>test</p>';
const instance = $("#htmlEditor").dxHtmlEditor({
value: "<p>test</p>",
toolbar: { items: ["link"] },
onValueChanged: (e) => {
assert.equal(e.value, expected, "link has been added");
onValueChanged: ({ value }) => {
checkLink(assert, {
href: "http://test.test",
content: "http://test.test",
afterLink: "test"
}, value);
done();
}
}).dxHtmlEditor("instance");
Expand All @@ -494,7 +505,7 @@ QUnit.module("Toolbar integration", {

$inputs
.first()
.val("http://test.com")
.val("http://test.test")
.change();

$(`.${DIALOG_CLASS} .${BUTTON_CLASS}`)
Expand All @@ -504,12 +515,15 @@ QUnit.module("Toolbar integration", {

test("Add a link and text without selection", (assert) => {
const done = assert.async();
const expected = '<p><a href="http://test.com" target="_blank">123</a>test</p>';
const instance = $("#htmlEditor").dxHtmlEditor({
value: "<p>test</p>",
toolbar: { items: ["link"] },
onValueChanged: (e) => {
assert.equal(e.value, expected, "link has been added");
onValueChanged: ({ value }) => {
checkLink(assert, {
href: "http://test.test",
content: "123",
afterLink: "test"
}, value);
done();
}
}).dxHtmlEditor("instance");
Expand All @@ -524,7 +538,7 @@ QUnit.module("Toolbar integration", {

$inputs
.first()
.val("http://test.com")
.val("http://test.test")
.change();

$inputs
Expand All @@ -539,12 +553,15 @@ QUnit.module("Toolbar integration", {

test("Add a link with empty text and selected range", (assert) => {
const done = assert.async();
const expected = '<p><a href="http://test.com" target="_blank">http://test.com</a>st</p>';
const instance = $("#htmlEditor").dxHtmlEditor({
value: "<p>test</p>",
toolbar: { items: ["link"] },
onValueChanged: (e) => {
assert.equal(e.value, expected, "link has been added");
onValueChanged: ({ value }) => {
checkLink(assert, {
href: "http://test.test",
content: "http://test.test",
afterLink: "st"
}, value);
done();
}
}).dxHtmlEditor("instance");
Expand All @@ -559,7 +576,7 @@ QUnit.module("Toolbar integration", {

$inputs
.first()
.val("http://test.com")
.val("http://test.test")
.change();

$inputs
Expand All @@ -575,13 +592,15 @@ QUnit.module("Toolbar integration", {
test("format image and text", (assert) => {
const done = assert.async();
const $container = $("#htmlEditor");
const link = "http://test.com";
const expected = `<p><a href="${link}" target="_blank"><img src="${BLACK_PIXEL}">12</a></p>`;
const link = "http://test.test";
const instance = $container.dxHtmlEditor({
toolbar: { items: ["link"] },
value: `<img src=${BLACK_PIXEL}>12`,
onValueChanged: ({ value }) => {
assert.strictEqual(value, expected, "link was setted");
checkLink(assert, {
href: link,
content: `<img src="${BLACK_PIXEL}">12`
}, value);
done();
}
}).dxHtmlEditor("instance");
Expand All @@ -605,13 +624,15 @@ QUnit.module("Toolbar integration", {
test("replace the text of the existed link", (assert) => {
const done = assert.async();
const $container = $("#htmlEditor");
const link = "http://test.com";
const expected = `<p><a href="${link}" target="_blank">123</a></p>`;
const link = "http://test.test";
const instance = $container.dxHtmlEditor({
toolbar: { items: ["link"] },
value: `<a href="${link}" target="_blank">test</a>`,
onValueChanged: ({ value }) => {
assert.strictEqual(value, expected, "text updated");
checkLink(assert, {
href: link,
content: "123"
}, value);
done();
}
}).dxHtmlEditor("instance");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const checkLink = (assert, { content, href, afterLink }, text) => {
if(href) {
const matcher = new RegExp(`href="${href}"`);
assert.ok(!!text.match(matcher), "HREF OK");
}

if(content) {
const matcher = new RegExp(`>${content}</a>`);
assert.ok(!!text.match(matcher), "Content OK");
}

if(afterLink) {
const matcher = new RegExp(`</a>${afterLink}</p>`);
assert.ok(!!text.match(matcher), "After link content OK");
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import $ from "jquery";
import "ui/html_editor";
import "ui/html_editor/converters/markdown";

import { checkLink } from "./utils.js";

const CONTENT_CLASS = "dx-htmleditor-content";
const HTML_EDITOR_SUBMIT_ELEMENT_CLASS = "dx-htmleditor-submit-element";

Expand Down Expand Up @@ -232,7 +234,7 @@ QUnit.module("Value as HTML markup", moduleConfig, () => {
const done = assert.async();
const instance = $("#htmlEditor")
.dxHtmlEditor({
value: "<a href='www.test.com'>test</a>",
value: "<a href='www.test.test'>test</a>",
onValueChanged: ({ value }) => {
const hasColor = /style=(".*?"|'.*?'|[^"'][^\s]*)/.test(value);

Expand Down Expand Up @@ -313,7 +315,7 @@ QUnit.module("Custom blots rendering", {
}, () => {
test("render image", (assert) => {
const testTag = /<img([\w\W]+?)/;
const testSrc = /src="http:\/\/test.com\/test.jpg"/g;
const testSrc = /src="http:\/\/test.test\/test.jpg"/g;
const testAlt = /alt="altering"/g;
const testWidth = /width="100"/g;
const testHeight = /height="100"/g;
Expand All @@ -330,22 +332,26 @@ QUnit.module("Custom blots rendering", {
})
.dxHtmlEditor("instance");

instance.insertEmbed(0, "extendedImage", { src: "http://test.com/test.jpg", width: 100, height: 100, alt: "altering" });
instance.insertEmbed(0, "extendedImage", { src: "http://test.test/test.jpg", width: 100, height: 100, alt: "altering" });
this.clock.tick();
});

test("render link", (assert) => {
const instance = $("#htmlEditor")
.dxHtmlEditor({
value: "test",
onValueChanged: (e) => {
assert.equal(e.value, '<p><a href="http://test.com" target="_blank">test</a>test</p>', "markup contains a link");
onValueChanged: ({ value }) => {
checkLink(assert, {
href: "http://test.test",
content: "test",
afterLink: "test"
}, value);
}
})
.dxHtmlEditor("instance");

instance.setSelection(0, 0);
instance.insertText(0, "test", "link", { href: "http://test.com", target: true });
instance.insertText(0, "test", "link", { href: "http://test.test", target: true });
});

test("render variable", (assert) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,16 @@ QUnit.module("Web API Provider", moduleConfig, () => {
});
});

test("generation end point", function(assert) {
let provider = new WebApiFileProvider({
endpointUrl: "myEndpoint"
});
assert.ok(provider._getEndpointUrl("myCommand", { }).indexOf("myEndpoint?command=myCommand") !== -1);

provider = new WebApiFileProvider({
endpointUrl: "myEndpoint?param1=value"
});
assert.ok(provider._getEndpointUrl("myCommand", { }).indexOf("myEndpoint?param1=value&command=myCommand") !== -1);
});

});

0 comments on commit 0453e5f

Please sign in to comment.