Я не слишком хорошо знаком с Redactor, но, возможно, вы могли бы сделать это с помощью обратного вызова или чистого JavaScript после загрузки элемента.
<style>
.my-custom-class-1 {
background-color: red;
}
.my-custom-class-2 {
font-size: 16px;
}
.my-custom-class-3 {
font-family: Helvetica Neue, Helvetica, Arial;
}
</style>
Не знаете, что возвращается из ссылки, но если оно элемент html вы можете добавить классы с обратным вызовом.
$R('#content', {
callbacks: {
link: {
inserted: function(link) {
// use the classList API to remove and add classes
link.classList.remove("my-custom-class-1");
link.classList.add("my-custom-class-1");
// add or remove multiple classes
link.classList.add("my-custom-class-1", "my-custom-class-2", "my-custom-class-3");
link.classList.remove("my-custom-class-1", "my-custom-class-2", "my-custom-class-3");
}
}
}
});
Если ссылки имеют собственный идентификатор, вы можете сделать это в чистом JavaScript
const link_1 = document.getElementById('linkId_1');
const link_2 = document.getElementById('linkId_2');
const link_3 = document.getElementById('linkId_3');
// use the classList API to remove and add classes
link_1.classList.remove("my-custom-class-1");
link_1.classList.add("my-custom-class-1");
// add or remove multiple classes
link_1.classList.add("my-custom-class-1", "my-custom-class-2", "my-custom-class-3");
link_1.classList.remove("my-custom-class-1", "my-custom-class-2", "my-custom-class-3");
Надеюсь, это поможет! :)
Если вы просто сконструируете тело как строку и передадите его таким образом http.post()
, его следует отправить как есть, без каких-либо изменений. Этот код должен проиллюстрировать это, используя httpbin.org:
import http from "k6/http";
import crypto from "k6/crypto";
let payload = `http_request_duration_seconds_bucket{le="0.05"} 24054
http_request_duration_seconds_bucket{le="0.1"} 33444
http_request_duration_seconds_bucket{le="0.2"} 100392
`;
export default function (data) {
console.log(crypto.sha256(payload, "hex"));
let resp = http.post("https://httpbin.org/anything", payload);
console.log(crypto.sha256(resp.json().data, "hex"));
console.log(resp.body);
}
, он выведет что-то вроде этого:
INFO[0000] 773f0d81713fca0663ad7a01135bf674b93b0859854b2248368125af3f070d29
INFO[0001] 773f0d81713fca0663ad7a01135bf674b93b0859854b2248368125af3f070d29
INFO[0001] {
"args": {},
"data": "http_request_duration_seconds_bucket{le=\"0.05\"} 24054\nhttp_request_duration_seconds_bucket{le=\"0.1\"} 33444\nhttp_request_duration_seconds_bucket{le=\"0.2\"} 100392\n",
"files": {},
"form": {},
"headers": {
"Connection": "close",
"Content-Length": "161",
"Host": "httpbin.org",
"User-Agent": "k6/0.23.1 (https://k6.io/)"
},
"json": null,
"method": "POST",
"url": "https://httpbin.org/anything"
}