@paperbits/core
Advanced tools
Comparing version 0.1.43 to 0.1.44
@@ -19,2 +19,3 @@ import * as _ from "lodash"; | ||
constructor( | ||
@@ -35,3 +36,3 @@ private readonly viewManager: IViewManager, | ||
private isModelBeingEdited(binding: IWidgetBinding): boolean { | ||
const session = this.viewManager.getWidgetview(); | ||
const session = this.viewManager.getOpenView(); | ||
@@ -194,3 +195,4 @@ if (!session) { | ||
element: element, | ||
text: widgetBinding["displayName"] | ||
text: widgetBinding["displayName"], | ||
color: contextualEditor.color | ||
}; | ||
@@ -469,2 +471,3 @@ | ||
let highlightedText: string; | ||
let highlightColor: string; | ||
const tobeDeleted = Object.keys(this.actives); | ||
@@ -510,5 +513,7 @@ | ||
const contextualEditor = this.getContextualEditor(element, half); | ||
highlightColor = contextualEditor.color; | ||
if (!active || element !== active.element || half !== active.half) { | ||
const contextualEditor = this.getContextualEditor(element, half); | ||
this.viewManager.setContextualEditor(widgetBinding.name, contextualEditor); | ||
@@ -530,3 +535,3 @@ | ||
this.activeHighlightedElement = highlightedElement; | ||
this.viewManager.setHighlight({ element: highlightedElement, text: highlightedText }); | ||
this.viewManager.setHighlight({ element: highlightedElement, text: highlightedText, color: highlightColor }); | ||
} | ||
@@ -533,0 +538,0 @@ } |
import * as ko from "knockout"; | ||
import { IHighlightConfig } from "@paperbits/common/ui/IHighlightConfig"; | ||
import { IHighlightConfig } from "@paperbits/common/ui"; | ||
ko.bindingHandlers["highlight"] = { | ||
init(element: HTMLElement, valueAccessor: () => IHighlightConfig) { | ||
let config = valueAccessor(); | ||
const config = valueAccessor(); | ||
element["highlightConfig"] = config; | ||
let updatePosition = () => { | ||
let currentConfig = <IHighlightConfig>element["highlightConfig"]; | ||
const updatePosition = () => { | ||
const currentConfig = <IHighlightConfig>element["highlightConfig"]; | ||
@@ -17,6 +17,6 @@ if (!currentConfig || !currentConfig.element) { | ||
let parent = currentConfig.element.ownerDocument.defaultView.frameElement; | ||
let parentRect = parent.getBoundingClientRect(); | ||
const parent = currentConfig.element.ownerDocument.defaultView.frameElement; | ||
const parentRect = parent.getBoundingClientRect(); | ||
let rect = currentConfig.element.getBoundingClientRect(); | ||
const rect = currentConfig.element.getBoundingClientRect(); | ||
element.style.left = parentRect.left + rect.left + "px"; | ||
@@ -27,3 +27,3 @@ element.style.top = parentRect.top + rect.top + "px"; | ||
element.title = currentConfig.text || "Widget"; | ||
} | ||
}; | ||
element["highlightUpdate"] = updatePosition; | ||
@@ -42,3 +42,3 @@ | ||
update(element: HTMLElement, valueAccessor: () => IHighlightConfig) { | ||
let config = valueAccessor(); | ||
const config = valueAccessor(); | ||
@@ -45,0 +45,0 @@ element["highlightConfig"] = ko.unwrap(config); |
@@ -120,2 +120,4 @@ import * as ko from "knockout"; | ||
hostElement.contentDocument.addEventListener("mousedown", onPointerDown, true); | ||
this.viewManager["hostDocument"] = hostElement.contentDocument; | ||
}; | ||
@@ -122,0 +124,0 @@ |
@@ -1,4 +0,2 @@ | ||
import * as domino from "domino"; | ||
import * as XMLHttpRequest from "xhr2"; | ||
@@ -11,5 +9,4 @@ declare var global: any; | ||
global.navigator = window.navigator; | ||
global.XMLHttpRequest = XMLHttpRequest; | ||
return window.document; | ||
} |
@@ -21,3 +21,3 @@ import * as _ from "lodash"; | ||
declare let uploadDialog; | ||
declare let uploadDialog: HTMLInputElement; | ||
@@ -48,2 +48,3 @@ | ||
public viewport: KnockoutObservable<string>; | ||
public hostDocument: Document; | ||
@@ -346,3 +347,5 @@ public host: KnockoutObservable<IComponent>; | ||
uploadDialog.onchange = () => { | ||
resolve(Arrays.coerce(uploadDialog.files)); | ||
const selectedFiles = Arrays.coerce<File>(uploadDialog.files); | ||
uploadDialog.value = ""; | ||
resolve(selectedFiles); | ||
}; | ||
@@ -365,3 +368,3 @@ }); | ||
public getWidgetview(): IView { | ||
public getOpenView(): IView { | ||
return this.widgetEditor(); | ||
@@ -516,2 +519,6 @@ } | ||
} | ||
public getHostDocument(): Document { | ||
return this.hostDocument; | ||
} | ||
} |
{ | ||
"name": "@paperbits/core", | ||
"version": "0.1.43", | ||
"version": "0.1.44", | ||
"description": "Paperbits core components.", | ||
@@ -23,4 +23,4 @@ "author": "Paperbits", | ||
"dependencies": { | ||
"@paperbits/common": "0.1.43", | ||
"@paperbits/styles": "0.1.43", | ||
"@paperbits/common": "0.1.44", | ||
"@paperbits/styles": "0.1.44", | ||
"cropperjs": "^1.4.0", | ||
@@ -27,0 +27,0 @@ "file-saver": "^2.0.0", |
@@ -57,3 +57,3 @@ import * as ko from "knockout"; | ||
this.applyChangesCallback(); | ||
} s | ||
} | ||
} |
@@ -46,5 +46,3 @@ import * as ko from "knockout"; | ||
public async onNavigationUpdate(navigationItems: Array<NavigationItemContract>): Promise<void> { | ||
//this.navigationService.updateNavigationItem(topLevelMenus[0]); // TODO: For now user can have only one menu | ||
public async onNavigationUpdate(navigationItems: NavigationItemContract[]): Promise<void> { | ||
await this.navigationService.updateNavigation(navigationItems); | ||
@@ -68,3 +66,8 @@ } | ||
navigationItem: navigationItem, | ||
onDeleteCallback: () => { | ||
onDeleteCallback: (isRootItem: boolean) => { | ||
if (isRootItem) { | ||
this.navigationItemsTree().removeRootNode(navigationItem); | ||
this.viewManager.notifySuccess("Navigation", `Navigation item "${navigationItem.label()}" was deleted.`); | ||
this.viewManager.closeWorkshop("navigation-details-workshop"); | ||
} | ||
this.searchNavigationItems(); | ||
@@ -71,0 +74,0 @@ } |
@@ -18,3 +18,3 @@ import * as ko from "knockout"; | ||
@Event() | ||
public onDeleteCallback: () => void; | ||
public onDeleteCallback: (isRootItem: boolean) => void; | ||
@@ -66,11 +66,16 @@ @Param() | ||
public deleteNavigationItem(): void { | ||
this.navigationItem.remove(); | ||
let isRootItem = false; | ||
if (this.navigationItem.parent) { | ||
this.navigationItem.remove(); | ||
this.viewManager.notifySuccess("Navigation", `Navigation item "${this.navigationItem.label()}" was deleted.`); | ||
this.viewManager.closeWorkshop("navigation-details-workshop"); | ||
this.viewManager.notifySuccess("Navigation", `Navigation item "${this.navigationItem.label()}" was deleted.`); | ||
this.viewManager.closeWorkshop("navigation-details-workshop"); | ||
} else { | ||
isRootItem = true; | ||
} | ||
if (this.onDeleteCallback) { | ||
this.onDeleteCallback(); | ||
this.onDeleteCallback(isRootItem); | ||
} | ||
} | ||
} |
@@ -12,5 +12,5 @@ import * as ko from "knockout"; | ||
public focusedNode: KnockoutObservable<NavigationItemViewModel>; | ||
public onUpdate: KnockoutSubscribable<Array<NavigationItemContract>>; | ||
public onUpdate: KnockoutSubscribable<NavigationItemContract[]>; | ||
constructor(items: Array<NavigationItemContract>) { | ||
constructor(items: NavigationItemContract[]) { | ||
this.onFocusChange = this.onFocusChange.bind(this); | ||
@@ -47,5 +47,3 @@ this.addNode = this.addNode.bind(this); | ||
private dispatchUpdates(): void { | ||
const items = new Array<NavigationItemContract>(); | ||
this.nodes().forEach(n => items.push(n.toContract())); | ||
const items = this.getNavigationItems(); | ||
this.onUpdate.notifySubscribers(items); | ||
@@ -67,3 +65,3 @@ } | ||
navItem.navigationItems.forEach(child => { | ||
let childNode = this.modelToViewModel(child); | ||
const childNode = this.modelToViewModel(child); | ||
childNode.parent = viewModel; | ||
@@ -81,3 +79,3 @@ viewModel.nodes.push(childNode); | ||
label: label | ||
} | ||
}; | ||
@@ -109,3 +107,8 @@ const node = new NavigationItemViewModel(navitem); | ||
public getNavigationItems(): Array<NavigationItemContract> { | ||
public removeRootNode(item: NavigationItemViewModel): void { | ||
this.nodes.remove(item); | ||
this.dispatchUpdates(); | ||
} | ||
public getNavigationItems(): NavigationItemContract[] { | ||
const navigationItems = []; | ||
@@ -112,0 +115,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
636172
11841
+ Added@paperbits/common@0.1.44(transitive)
+ Added@paperbits/styles@0.1.44(transitive)
- Removed@paperbits/common@0.1.43(transitive)
- Removed@paperbits/styles@0.1.43(transitive)
Updated@paperbits/common@0.1.44
Updated@paperbits/styles@0.1.44