Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const factory: UiSketcher.SingleSketchFactory = (detail) => {
// For using the alert banner as a standalone banner
const memBannerText = Memento.record({
dom: {
tag: 'p',
innerHtml: detail.translationProvider(detail.text)
},
behaviours: Behaviour.derive([
Replacing.config({ })
])
});
const renderPercentBar = (percent: number) => ({
dom: {
tag: 'div',
classes: [ 'tox-bar' ],
attributes: {
style: `width: ${percent}%`
}export const renderCustomEditor = (spec: CustomEditorSpec): SimpleSpec => {
const editorApi = Cell(Option.none());
const memReplaced = Memento.record({
dom: {
tag: spec.tag
}
});
const initialValue = Cell(Option.none());
return {
dom: {
tag: 'div',
classes: [ 'tox-custom-editor' ]
},
behaviours: Behaviour.derive([
AddEventsBehaviour.config('editor-foo-events', [
AlloyEvents.runOnAttached((component) => {
memReplaced.getOpt(component).each((ta) => {const renderImagePanel = (initialUrl: string) => {
const memBg = Memento.record(
{
dom: {
tag: 'div',
classes: [ 'tox-image-tools__image-bg' ],
attributes: {
role: 'presentation'
}
}
}
);
const zoomState = Cell(1);
const cropRect = Cell(Option.none());
const rectState = Cell({
x: 0,
y: 0,const transferEvent = se.event().raw() as DragEvent;
handleFiles(comp, transferEvent.dataTransfer.files);
}
};
const onSelect = (component, simulatedEvent) => {
const files = simulatedEvent.event().raw().target.files;
handleFiles(component, files);
};
const handleFiles = (component, files: FileList) => {
Representing.setValue(component, filterByExtension(files));
AlloyTriggers.emitWith(component, formChangeEvent, { name: spec.name });
};
const memInput = Memento.record(
{
dom: {
tag: 'input',
attributes: {
type: 'file',
accept: 'image/*'
},
styles: {
display: 'none'
}
},
behaviours: Behaviour.derive([
AddEventsBehaviour.config('input-file-events', [
AlloyEvents.cutter(NativeEvents.click()),
AlloyEvents.cutter(SystemEvents.tap())
])const checkboxSpec = (() => {
const memBodyPanel = Memento.record(
renderBodyPanel({
items: [
{ type: 'checkbox', name: 'checked', label: 'Checked', disabled: false },
{ type: 'checkbox', name: 'unchecked', label: 'Unchecked', disabled: false }
],
classes: []
}, {
shared: sharedBackstage
})
);
return {
dom: {
tag: 'div'
},
components: [ const optMemDisplayText = spec.text.map((text) => Memento.record(renderLabel(text, prefix, sharedBackstage.providers)));
const optMemDisplayIcon = spec.icon.map((iconName) => Memento.record(renderReplacableIconFromPack(iconName, sharedBackstage.providers.icons)));export const renderColorPicker = (spec: ColorPickerSpec): SimpleSpec => {
const getClass = (key: string) => 'tox-' + key;
const colourPickerFactory = ColourPicker.makeFactory(translate, getClass);
const onValidHex = (form) => {
AlloyTriggers.emitWith(form, formActionEvent, { name: 'hex-valid', value: true }, );
};
const onInvalidHex = (form) => {
AlloyTriggers.emitWith(form, formActionEvent, { name: 'hex-valid', value: false } );
};
const memPicker = Memento.record(
colourPickerFactory.sketch({
dom: {
tag: 'div',
classes: [getClass('color-picker-container')],
attributes: {
role: 'presentation'
}
},
onValidHex,
onInvalidHex
})
);
return {
dom: {
tag: 'div'const open = (message: string, callback: () => void) => {
const closeDialog = () => {
ModalDialog.hide(alertDialog);
callback();
};
const memFooterClose = Memento.record(
renderFooterButton({
name: 'close-alert',
text: 'OK',
primary: true,
align: 'end',
disabled: false,
icon: Option.none()
}, 'cancel', extras.backstage)
);
const alertDialog = GuiFactory.build(
Dialogs.renderDialog({
lazySink: () => sharedBackstage.getSink(),
headerOverride: Option.some(Dialogs.hiddenHeader),
partSpecs: {
title: Dialogs.pUntitled(),Unselecting.config({})
])
});
const makeIcon = (className: string) => {
const iconName = className === 'checked' ? 'selected' : 'unselected';
return {
dom: {
tag: 'span',
classes: ['tox-icon', 'tox-checkbox-icon__' + className],
innerHtml: Icons.get(iconName, providerBackstage.icons)
}
};
};
const memIcons = Memento.record(
{
dom: {
tag: 'div',
classes: ['tox-checkbox__icons']
},
components: [
makeIcon('checked'),
makeIcon('unchecked')
]
}
);
return AlloyFormField.sketch({
dom: {
tag: 'label',
classes: ['tox-checkbox'], const optMemDisplayIcon = spec.icon.map((iconName) => Memento.record(renderReplacableIconFromPack(iconName, sharedBackstage.providers.icons)));