Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Can't just fireDismissalEvent formCloseEvent, because it is on the parent component of the dialog
AlloyEvents.run(SystemEvents.dismissRequested(), (comp, se) => {
AlloyTriggers.emit(dialogUi.dialog, formCancelEvent);
}),
]),
...inlineAdditionalBehaviours(editor, isStickyToolbar)
])
}));
inlineDialog.set(inlineDialogComp);
// Position the inline dialog
InlineView.showWithin(
inlineDialogComp,
anchor,
GuiFactory.premade(dialogUi.dialog),
Option.some(Body.body())
);
// Refresh the docking position if not using a sticky toolbar
if (!isStickyToolbar) {
Docking.refresh(inlineDialogComp);
// Bind to the editor resize event and update docking as needed. We don't need to worry about
// 'ResizeWindow` as that's handled by docking already.
editor.on('ResizeEditor', refreshDocking);
}
// Set the initial data in the dialog and focus the first focusable item
dialogUi.instanceApi.setData(initialData);
Keying.focusIn(dialogUi.dialog);
return dialogUi.instanceApi;
const fixedContainerElement = (editor): Option<element> => {
const selector = fixedContainerSelector(editor);
// If we have a valid selector and are in inline mode, try to get the fixed_toolbar_container
return selector.length > 0 && editor.inline ? SelectorFind.descendant(Body.body(), selector) : Option.none();
};
</element>
const maxWidth = editorMaxWidthOpt.getOrThunk(() => {
// No max width, so use the body width, minus the left pos as the maximum
const bodyMargin = Utils.parseToInt(Css.get(Body.body(), 'margin-left')).getOr(0);
return Width.get(Body.body()) - location.left() + bodyMargin;
});
Css.set(floatContainer.element(), 'max-width', maxWidth + 'px');
const setup = function (bag) {
const cWin = bag.cWin();
const ceBody = bag.ceBody();
const socket = bag.socket();
const toolstrip = bag.toolstrip();
const toolbar = bag.toolbar();
const contentElement = bag.contentElement();
const keyboardType = bag.keyboardType();
const outerWindow = bag.outerWindow();
const dropup = bag.dropup();
const structure = IosViewport.takeover(socket, ceBody, toolstrip, dropup);
const keyboardModel = keyboardType(bag.outerBody(), cWin, Body.body(), contentElement, toolstrip, toolbar);
const toEditing = function () {
// Consider inlining, though it will make it harder to follow the API
keyboardModel.toEditing();
clearSelection();
};
const toReading = function () {
keyboardModel.toReading();
};
const onToolbarTouch = function (event) {
keyboardModel.onToolbarTouch(event);
};
const onOrientation = Orientation.onChange(outerWindow, {
const destroy = function () {
structure.restore();
onOrientation.destroy();
onScroll.unbind();
onResize.unbind();
keyboardModel.destroy();
unfocusedSelection.destroy();
// Try and dismiss the keyboard on close, as they have no input focus.
CaptureBin.input(Body.body(), Focus.blur);
};
const maxWidth = editorMaxWidthOpt.getOrThunk(() => {
// No max width, so use the body width, minus the left pos as the maximum
const bodyMargin = Utils.parseToInt(Css.get(Body.body(), 'margin-left')).getOr(0);
return Width.get(Body.body()) - location.left() + bodyMargin;
});
Css.set(floatContainer.element(), 'max-width', maxWidth + 'px');
const script = Element.fromTag('script');
Attr.set(script, 'referrerpolicy', 'origin');
Attr.set(script, 'src', url);
const onLoad = DomEvent.bind(script, 'load', () => {
onLoad.unbind();
onError.unbind();
resolve(Result.value(url));
});
const onError = DomEvent.bind(script, 'error', () => {
onLoad.unbind();
onError.unbind();
resolve(Result.error(new Error('Failed to load script: ' + url)));
});
Insert.append(Body.body(), script);
});
};
const render = (editor: Editor, uiComponents: RenderUiComponents, rawUiConfig: RenderUiConfig, backstage: UiFactoryBackstage, args: RenderArgs): ModeRenderInfo => {
const lastToolbarWidth = Cell(0);
loadIframeSkin(editor);
Attachment.attachSystemAfter(Element.fromDom(args.targetNode), uiComponents.mothership);
Attachment.attachSystem(Body.body(), uiComponents.uiMothership);
editor.on('init', () => {
setToolbar(editor, uiComponents, rawUiConfig, backstage);
lastToolbarWidth.set(editor.getWin().innerWidth);
OuterContainer.setMenubar(
uiComponents.outerContainer,
identifyMenus(editor, rawUiConfig)
);
OuterContainer.setSidebar(
uiComponents.outerContainer,
rawUiConfig.sidebar
);
setupEvents(editor);
const getUiContainer = (editor): Element => {
const fixedContainer = fixedContainerElement(editor);
return fixedContainer.getOr(Body.body());
};