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