feat(writekit): rename @robonen/editor to @robonen/writekit
Rename the rich-text editor package and all Editor* exports to Writekit*; remove the old vue/editor tree.
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import { defineMark } from '../registry';
|
||||
|
||||
export const bold = defineMark({
|
||||
type: 'bold',
|
||||
spec: {
|
||||
inclusive: true,
|
||||
rank: 1,
|
||||
toDOM: () => ['strong', 0],
|
||||
parseDOM: [{ tag: 'strong' }, { tag: 'b' }],
|
||||
},
|
||||
meta: { title: 'Bold', icon: 'bold', hotkey: 'Mod-b' },
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
import { defineMark } from '../registry';
|
||||
|
||||
export const code = defineMark({
|
||||
type: 'code',
|
||||
spec: {
|
||||
inclusive: false,
|
||||
rank: 9,
|
||||
excludes: '_all', // inline code wins: it strips every other mark on the range
|
||||
toDOM: () => ['code', 0],
|
||||
parseDOM: [{ tag: 'code' }],
|
||||
},
|
||||
meta: { title: 'Inline code', icon: 'code', hotkey: 'Mod-e' },
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
import { defineMark } from '../registry';
|
||||
|
||||
export const highlight = defineMark({
|
||||
type: 'highlight',
|
||||
spec: {
|
||||
inclusive: true,
|
||||
rank: 5,
|
||||
toDOM: () => ['mark', 0],
|
||||
parseDOM: [{ tag: 'mark' }],
|
||||
},
|
||||
meta: { title: 'Highlight', icon: 'highlighter' },
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
export { bold } from './bold';
|
||||
export { italic } from './italic';
|
||||
export { underline } from './underline';
|
||||
export { strike } from './strike';
|
||||
export { highlight } from './highlight';
|
||||
export { code } from './code';
|
||||
export { link } from './link';
|
||||
@@ -0,0 +1,12 @@
|
||||
import { defineMark } from '../registry';
|
||||
|
||||
export const italic = defineMark({
|
||||
type: 'italic',
|
||||
spec: {
|
||||
inclusive: true,
|
||||
rank: 2,
|
||||
toDOM: () => ['em', 0],
|
||||
parseDOM: [{ tag: 'em' }, { tag: 'i' }],
|
||||
},
|
||||
meta: { title: 'Italic', icon: 'italic', hotkey: 'Mod-i' },
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { Mark } from '../model';
|
||||
import { defineMark } from '../registry';
|
||||
|
||||
export const link = defineMark({
|
||||
type: 'link',
|
||||
spec: {
|
||||
inclusive: false, // typing past a link's end does not extend it
|
||||
rank: 10,
|
||||
attrs: {
|
||||
href: { default: '' },
|
||||
target: { default: '_blank' },
|
||||
},
|
||||
toDOM: (mark: Mark) => [
|
||||
'a',
|
||||
{
|
||||
href: String(mark.attrs?.['href'] ?? ''),
|
||||
target: String(mark.attrs?.['target'] ?? '_blank'),
|
||||
rel: 'noopener noreferrer',
|
||||
},
|
||||
0,
|
||||
],
|
||||
parseDOM: [{
|
||||
tag: 'a[href]',
|
||||
getAttrs: (el: HTMLElement) => ({
|
||||
href: el.getAttribute('href') ?? '',
|
||||
target: el.getAttribute('target') ?? '_blank',
|
||||
}),
|
||||
}],
|
||||
},
|
||||
meta: { title: 'Link', icon: 'link', hotkey: 'Mod-k' },
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
import { defineMark } from '../registry';
|
||||
|
||||
export const strike = defineMark({
|
||||
type: 'strike',
|
||||
spec: {
|
||||
inclusive: true,
|
||||
rank: 4,
|
||||
toDOM: () => ['s', 0],
|
||||
parseDOM: [{ tag: 's' }, { tag: 'del' }],
|
||||
},
|
||||
meta: { title: 'Strikethrough', icon: 'strikethrough', hotkey: 'Mod-Shift-s' },
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
import { defineMark } from '../registry';
|
||||
|
||||
export const underline = defineMark({
|
||||
type: 'underline',
|
||||
spec: {
|
||||
inclusive: true,
|
||||
rank: 3,
|
||||
toDOM: () => ['u', 0],
|
||||
parseDOM: [{ tag: 'u' }],
|
||||
},
|
||||
meta: { title: 'Underline', icon: 'underline', hotkey: 'Mod-u' },
|
||||
});
|
||||
Reference in New Issue
Block a user