@empoleon/tiptap
Version:
Rich text editor based on tiptap
328 lines (325 loc) • 8.17 kB
JavaScript
import { createComponent } from 'solid-js/web';
import { IconBold, IconItalic, IconStrikethrough, IconUnderline, IconClearFormatting, IconH1, IconH2, IconH3, IconH4, IconH5, IconH6, IconList, IconListNumbers, IconUnlink, IconBlockquote, IconAlignLeft, IconAlignRight, IconAlignCenter, IconAlignJustified, IconSuperscript, IconSubscript, IconCode, IconHighlight, IconLineDashed, IconCircleOff, IconArrowBackUp, IconArrowForwardUp, IconListCheck, IconIndentIncrease, IconIndentDecrease } from '../icons/Icons.mjs';
import { createControl } from './RichTextEditorControl.mjs';
const BoldControl = createControl({
label: "boldControlLabel",
icon: props => createComponent(IconBold, props),
isActive: {
name: "bold"
},
operation: {
name: "toggleBold"
}
});
const ItalicControl = createControl({
label: "italicControlLabel",
icon: props => createComponent(IconItalic, props),
isActive: {
name: "italic"
},
operation: {
name: "toggleItalic"
}
});
const UnderlineControl = createControl({
label: "underlineControlLabel",
icon: props => createComponent(IconUnderline, props),
isActive: {
name: "underline"
},
operation: {
name: "toggleUnderline"
}
});
const StrikeThroughControl = createControl({
label: "strikeControlLabel",
icon: props => createComponent(IconStrikethrough, props),
isActive: {
name: "strike"
},
operation: {
name: "toggleStrike"
}
});
const ClearFormattingControl = createControl({
label: "clearFormattingControlLabel",
icon: props => createComponent(IconClearFormatting, props),
operation: {
name: "unsetAllMarks"
}
});
const UnlinkControl = createControl({
label: "unlinkControlLabel",
icon: props => createComponent(IconUnlink, props),
operation: {
name: "unsetLink"
}
});
const BulletListControl = createControl({
label: "bulletListControlLabel",
icon: props => createComponent(IconList, props),
isActive: {
name: "bulletList"
},
operation: {
name: "toggleBulletList"
}
});
const OrderedListControl = createControl({
label: "orderedListControlLabel",
icon: props => createComponent(IconListNumbers, props),
isActive: {
name: "orderedList"
},
operation: {
name: "toggleOrderedList"
}
});
const H1Control = createControl({
label: "h1ControlLabel",
icon: props => createComponent(IconH1, props),
isActive: {
name: "heading",
attributes: {
level: 1
}
},
operation: {
name: "toggleHeading",
attributes: {
level: 1
}
}
});
const H2Control = createControl({
label: "h2ControlLabel",
icon: props => createComponent(IconH2, props),
isActive: {
name: "heading",
attributes: {
level: 2
}
},
operation: {
name: "toggleHeading",
attributes: {
level: 2
}
}
});
const H3Control = createControl({
label: "h3ControlLabel",
icon: props => createComponent(IconH3, props),
isActive: {
name: "heading",
attributes: {
level: 3
}
},
operation: {
name: "toggleHeading",
attributes: {
level: 3
}
}
});
const H4Control = createControl({
label: "h4ControlLabel",
icon: props => createComponent(IconH4, props),
isActive: {
name: "heading",
attributes: {
level: 4
}
},
operation: {
name: "toggleHeading",
attributes: {
level: 4
}
}
});
const H5Control = createControl({
label: "h5ControlLabel",
icon: props => createComponent(IconH5, props),
isActive: {
name: "heading",
attributes: {
level: 5
}
},
operation: {
name: "toggleHeading",
attributes: {
level: 5
}
}
});
const H6Control = createControl({
label: "h6ControlLabel",
icon: props => createComponent(IconH6, props),
isActive: {
name: "heading",
attributes: {
level: 6
}
},
operation: {
name: "toggleHeading",
attributes: {
level: 6
}
}
});
const BlockquoteControl = createControl({
label: "blockquoteControlLabel",
icon: props => createComponent(IconBlockquote, props),
isActive: {
name: "blockquote"
},
operation: {
name: "toggleBlockquote"
}
});
const AlignLeftControl = createControl({
label: "alignLeftControlLabel",
icon: props => createComponent(IconAlignLeft, props),
operation: {
name: "setTextAlign",
attributes: "left"
}
});
const AlignRightControl = createControl({
label: "alignRightControlLabel",
icon: props => createComponent(IconAlignRight, props),
operation: {
name: "setTextAlign",
attributes: "right"
}
});
const AlignCenterControl = createControl({
label: "alignCenterControlLabel",
icon: props => createComponent(IconAlignCenter, props),
operation: {
name: "setTextAlign",
attributes: "center"
}
});
const AlignJustifyControl = createControl({
label: "alignJustifyControlLabel",
icon: props => createComponent(IconAlignJustified, props),
operation: {
name: "setTextAlign",
attributes: "justify"
}
});
const SubscriptControl = createControl({
label: "subscriptControlLabel",
icon: props => createComponent(IconSubscript, props),
isActive: {
name: "subscript"
},
operation: {
name: "toggleSubscript"
}
});
const SuperscriptControl = createControl({
label: "superscriptControlLabel",
icon: props => createComponent(IconSuperscript, props),
isActive: {
name: "superscript"
},
operation: {
name: "toggleSuperscript"
}
});
const CodeControl = createControl({
label: "codeControlLabel",
icon: props => createComponent(IconCode, props),
isActive: {
name: "code"
},
operation: {
name: "toggleCode"
}
});
const CodeBlockControl = createControl({
label: "codeBlockControlLabel",
icon: props => createComponent(IconCode, props),
isActive: {
name: "codeBlock"
},
operation: {
name: "toggleCodeBlock"
}
});
const HighlightControl = createControl({
label: "highlightControlLabel",
icon: props => createComponent(IconHighlight, props),
isActive: {
name: "highlight"
},
operation: {
name: "toggleHighlight"
}
});
const HrControl = createControl({
label: "hrControlLabel",
icon: props => createComponent(IconLineDashed, props),
operation: {
name: "setHorizontalRule"
}
});
const UnsetColorControl = createControl({
label: "unsetColorControlLabel",
icon: props => createComponent(IconCircleOff, props),
operation: {
name: "unsetColor"
}
});
const UndoControl = createControl({
label: "undoControlLabel",
icon: props => createComponent(IconArrowBackUp, props),
isDisabled: editor => !editor?.can().undo(),
operation: {
name: "undo"
}
});
const RedoControl = createControl({
label: "redoControlLabel",
icon: props => createComponent(IconArrowForwardUp, props),
isDisabled: editor => !editor?.can().redo(),
operation: {
name: "redo"
}
});
const TaskListControl = createControl({
label: "tasksControlLabel",
icon: props => createComponent(IconListCheck, props),
isActive: {
name: "taskList"
},
operation: {
name: "toggleTaskList"
}
});
const TaskListSinkControl = createControl({
label: "tasksSinkLabel",
icon: props => createComponent(IconIndentIncrease, props),
operation: {
name: "sinkListItem",
attributes: "taskItem"
},
isDisabled: editor => !editor?.can().sinkListItem("taskItem")
});
const TaskListLiftControl = createControl({
label: "tasksLiftLabel",
icon: props => createComponent(IconIndentDecrease, props),
operation: {
name: "liftListItem",
attributes: "taskItem"
},
isDisabled: editor => !editor?.can().liftListItem("taskItem")
});
export { AlignCenterControl, AlignJustifyControl, AlignLeftControl, AlignRightControl, BlockquoteControl, BoldControl, BulletListControl, ClearFormattingControl, CodeBlockControl, CodeControl, H1Control, H2Control, H3Control, H4Control, H5Control, H6Control, HighlightControl, HrControl, ItalicControl, OrderedListControl, RedoControl, StrikeThroughControl, SubscriptControl, SuperscriptControl, TaskListControl, TaskListLiftControl, TaskListSinkControl, UnderlineControl, UndoControl, UnlinkControl, UnsetColorControl };
//# sourceMappingURL=controls.mjs.map