1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

Got link insert/editor working

This commit is contained in:
Dan Brown
2022-01-16 14:37:58 +00:00
parent 7703face52
commit 89194a3f85
6 changed files with 107 additions and 66 deletions

View File

@ -12,6 +12,8 @@ import {removeMarks} from "../commands";
import DialogForm from "./DialogForm";
import DialogInput from "./DialogInput";
import itemAnchorButtonItem from "./item-anchor-button";
function cmdItem(cmd, options) {
const passedOptions = {
@ -149,6 +151,7 @@ const lists = [
];
const inserts = [
itemAnchorButtonItem(),
insertBlockBeforeItem(schema.nodes.horizontal_rule, {
title: "Horizontal Rule",
icon: icons.horizontal_rule,
@ -164,37 +167,6 @@ const utilities = [
}),
];
function getMarkAttribute(markType, attribute) {
return function(state) {
const marks = state.selection.$head.marks();
for (const mark of marks) {
if (mark.type === markType) {
return mark.attrs[attribute];
}
}
return null;
};
}
let box = new DialogBox([
new DialogForm([
new DialogInput({
label: 'URL',
id: 'url',
value: getMarkAttribute(schema.marks.link, 'href'),
}),
new DialogInput({
label: 'Title',
id: 'title',
value: getMarkAttribute(schema.marks.link, 'title'),
})
], {
canceler: () => box.close(),
action: (data) => console.log('submit', data),
}),
], {label: 'Insert Link', closer: () => {console.log('close')}});
const menu = menuBar({
floating: false,
content: [
@ -206,7 +178,6 @@ const menu = menuBar({
lists,
inserts,
utilities,
[box]
],
});