ФреймворкJavaScript
Ссылка: вставка и правка ссылок
Оборачивает выделенный текст в `<a href="...">`. Включается сочетанием Cmd/Ctrl+K. Клик по кнопке на уже связанном тексте открывает поле ввода URL, позволяя изменить или удалить ссылку. `target` и `rel` всегда пишутся рядом с `href` и берутся из `BlokConfig.link` — по умолчанию `_blank` и `nofollow`, причём для ссылок на ту же страницу принудительно ставится `target="_self"` (это `#anchor` или URL, который разрешается в текущие origin и pathname). `link.transform` может переопределить любое из href, target и rel.
Импорт
TypeScript
import { Link } from '@bloklabs/core/tools';Формат данных
TypeScript
// Stored as HTML inside the block's text field.
// target and rel are always present — these are the defaults:
// '<a href="https://example.com" target="_blank" rel="nofollow">Example</a>'JSON
{
"type": "paragraph",
"data": {
"text": "Visit <a href=\"https://example.com\" target=\"_blank\" rel=\"nofollow\">Example</a>"
}
}Пример использования
TypeScript
import { Blok } from '@bloklabs/core';
import { Link, Paragraph } from '@bloklabs/core/tools';
const editor = new Blok({
holder: 'editor',
tools: {
// Paragraph is the default block and is not bundled with the core —
// without it the editor starts with an "unsupported block" stub.
paragraph: Paragraph,
link: Link,
},
});