Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const getPartToolbar = () => {
if (hasMultipleToolbar) {
return [ partMultipleToolbar ];
} else if (hasToolbar) {
return [ partToolbar ];
} else {
return [ ];
}
};
const partHeader = OuterContainer.parts().header({
dom: {
tag: 'div',
classes: ['tox-editor-header']
},
components: Arr.flatten([
hasMenubar ? [ partMenubar ] : [ ],
getPartToolbar(),
// fixed_toolbar_container anchors to the editable area, else add an anchor bar
useFixedContainer(editor) ? [ ] : [ memAnchorBar.asSpec() ]
]),
sticky: isStickyToolbar(editor),
editor,
getSink: lazySink,
});
// We need the statusbar to be separate to everything else so resizing works properly
const editorComponents = Arr.flatten([
[ partHeader ],
// Inline mode does not have a socket/sidebar
isInline ? [ ] : [ socketSidebarContainer ]
]);
// We need the statusbar to be separate to everything else so resizing works properly
const editorComponents = Arr.flatten([
[ partHeader ],
// Inline mode does not have a socket/sidebar
isInline ? [ ] : [ socketSidebarContainer ]
]);
const editorContainer = {
dom: {
tag: 'div',
classes: ['tox-editor-container']
},
components: editorComponents,
};
const containerComponents = Arr.flatten([
[editorContainer],
// Inline mode does not have a status bar
isInline ? [ ] : statusbar.toArray(),
[ partThrobber ]
]);
// Hide the outer container if using inline mode and there's no menubar or toolbar
const isHidden = isDistractionFree(editor);
const attributes = {
role: 'application',
...I18n.isRtl() ? { dir: 'rtl' } : {},
...isHidden ? { 'aria-hidden': 'true' } : {}
};
const outerContainer = GuiFactory.build(
tag: 'div',
classes: ['tox-editor-header']
},
components: Arr.flatten([
hasMenubar ? [ partMenubar ] : [ ],
getPartToolbar(),
// fixed_toolbar_container anchors to the editable area, else add an anchor bar
useFixedContainer(editor) ? [ ] : [ memAnchorBar.asSpec() ]
]),
sticky: isStickyToolbar(editor),
editor,
getSink: lazySink,
});
// We need the statusbar to be separate to everything else so resizing works properly
const editorComponents = Arr.flatten([
[ partHeader ],
// Inline mode does not have a socket/sidebar
isInline ? [ ] : [ socketSidebarContainer ]
]);
const editorContainer = {
dom: {
tag: 'div',
classes: ['tox-editor-container']
},
components: editorComponents,
};
const containerComponents = Arr.flatten([
[editorContainer],
// Inline mode does not have a status bar
completer(err);
} else {
const val = Result.value(validation.message);
completer(val);
}
});
});
},
validateOnLoad: false
}
})
).toArray(),
[
Disabling.config({ disabled: spec.disabled }),
Tabstopping.config({}),
AddEventsBehaviour.config('urlinput-events', Arr.flatten([
// We want to get fast feedback for the link dialog, but not sure about others
spec.filetype === 'file' ? [
AlloyEvents.run(NativeEvents.input(), (comp) => {
AlloyTriggers.emitWith(comp, formChangeEvent, { name: spec.name });
})
] : [ ],
[
AlloyEvents.run(NativeEvents.change(), (comp) => {
AlloyTriggers.emitWith(comp, formChangeEvent, { name: spec.name });
updateHistory(comp);
}),
AlloyEvents.run(SystemEvents.postPaste(), (comp) => {
AlloyTriggers.emitWith(comp, formChangeEvent, { name: spec.name });
updateHistory(comp);
})
]
{
name: 'title',
type: 'input',
label: 'Title'
}
] : [];
const defaultTarget: Option = Settings.hasDefaultLinkTarget(editorSettings) ? Option.some(Settings.getDefaultLinkTarget(editorSettings)) : Option.none();
const initialData = getInitialData(settings, defaultTarget);
const dialogDelta = DialogChanges.init(initialData, settings);
const catalogs = settings.catalogs;
const body: Types.Dialog.PanelApi = {
type: 'panel',
items: Arr.flatten([
urlInput,
displayText,
titleText,
Options.cat([
catalogs.anchor.map(ListOptions.createUi('anchor', 'Anchors')),
catalogs.rels.map(ListOptions.createUi('rel', 'Rel')),
catalogs.targets.map(ListOptions.createUi('target', 'Open link in...')),
catalogs.link.map(ListOptions.createUi('link', 'Link list')),
catalogs.classes.map(ListOptions.createUi('linkClass', 'Class'))
])
])
};
return {
title: 'Insert/Edit Link',
size: 'normal',
body,
});
const selectWrap: SimpleSpec = {
dom: {
tag: 'div',
classes: ['tox-selectfield']
},
components: Arr.flatten([[pField], chevron.toArray()])
};
return AlloyFormField.sketch({
dom: {
tag: 'div',
classes: ['tox-form__group']
},
components: Arr.flatten([pLabel.toArray(), [selectWrap]]),
fieldBehaviours: Behaviour.derive([
Disabling.config({
disabled: spec.disabled,
onDisabled: (comp) => {
AlloyFormField.getField(comp).each(Disabling.disable);
},
onEnabled: (comp) => {
AlloyFormField.getField(comp).each(Disabling.enable);
}
})
])
});
};
name: 'source1',
type: 'urlinput',
filetype: 'media',
label: 'Source'
}];
const sizeInput: Types.Dialog.BodyComponentApi[] = !Settings.hasDimensions(editor) ? [] : [{
type: 'sizeinput',
name: 'dimensions',
label: 'Constrain proportions',
constrain: true
}];
const generalTab = {
title: 'General',
name: 'general',
items: Arr.flatten([ mediaInput, sizeInput ])
};
const embedTextarea: Types.Dialog.BodyComponentApi = {
type: 'textarea',
name: 'embed',
label: 'Paste your embed code below:'
};
const embedTab = {
title: 'Embed',
items: [
embedTextarea
]
};
const advancedFormItems: Types.Dialog.BodyComponentApi[] = [];
return Future.pure(result === true ? Result.value(v) : Result.error(result));
},
validateOnLoad: vl.validateOnLoad
}
});
}).toArray();
const pField = AlloyFormField.parts().field({
tag: spec.multiline === true ? 'textarea' : 'input',
inputAttributes: spec.placeholder.fold(
() => {},
(placeholder) => ({ placeholder: providersBackstage.translate(placeholder) })
),
inputClasses: [spec.classname],
inputBehaviours: Behaviour.derive(
Arr.flatten>([
baseInputBehaviours,
validatingBehaviours
])
),
selectOnFocus: false,
factory: AlloyInput
});
const extraClasses = spec.flex ? ['tox-form__group--stretched'] : [];
const extraClasses2 = extraClasses.concat(spec.maximized ? ['tox-form-group--maximize'] : []);
const extraBehaviours = [
Disabling.config({
disabled: spec.disabled,
onDisabled: (comp) => {
AlloyFormField.getField(comp).each(Disabling.disable);
const updateText: NotificationSketchApis['updateText'] = (comp, text) => {
if (comp.getSystem().isConnected()) {
const banner = memBannerText.get(comp);
Replacing.set(banner, [
GuiFactory.text(text)
]);
}
};
const apis: NotificationSketchApis = {
updateProgress,
updateText
};
const iconChoices = Arr.flatten([
detail.icon.toArray(),
detail.level.toArray(),
detail.level.bind((level) => Option.from(notificationIconMap[level])).toArray()
]);
return {
uid: detail.uid,
dom: {
tag: 'div',
attributes: {
role: 'alert'
},
classes: detail.level.map((level) => [ 'tox-notification', 'tox-notification--in', `tox-notification--${level}` ]).getOr(
[ 'tox-notification', 'tox-notification--in' ]
)
},
const makeDialogBody = (info: ImageDialogInfo) => {
if (info.hasAdvTab || info.hasUploadUrl || info.hasUploadHandler) {
const tabPanel: Types.Dialog.TabPanelApi = {
type: 'tabpanel',
tabs: Arr.flatten([
[MainTab.makeTab(info)],
info.hasAdvTab ? [AdvTab.makeTab(info)] : [],
info.hasUploadTab && (info.hasUploadUrl || info.hasUploadHandler) ? [UploadTab.makeTab(info)] : []
])
};
return tabPanel;
} else {
const panel: Types.Dialog.PanelApi = {
type: 'panel',
items: MainTab.makeItems(info)
};
return panel;
}
};