>;
-export declare class PureViewCtrl {
- props: P;
- $timeout: ng.ITimeoutService;
- /** Passed through templates */
- application: WebApplication;
- state: S;
- private unsubApp;
- private unsubState;
- private stateTimeout?;
- /**
- * Subclasses can optionally add an ng-if=ctrl.templateReady to make sure that
- * no Angular handlebars/syntax render in the UI before display data is ready.
- */
- protected templateReady: boolean;
- constructor($timeout: ng.ITimeoutService, props?: P);
- $onInit(): void;
- deinit(): void;
- $onDestroy(): void;
- get appState(): import("../../ui_models/app_state").AppState;
- /** @private */
- resetState(): Promise;
- /** @override */
- getInitialState(): S;
- setState(state: Partial): Promise;
- /** @returns a promise that resolves after the UI has been updated. */
- flushUI(): import("angular").IPromise;
- initProps(props: CtrlProps): void;
- addAppStateObserver(): void;
- onAppStateEvent(eventName: any, data: any): void;
- addAppEventObserver(): void;
- onAppEvent(eventName: ApplicationEvent): void;
- /** @override */
- onAppStart(): Promise;
- onLocalDataLoaded(): void;
- onAppLaunch(): Promise;
- onAppKeyChange(): Promise;
- onAppIncrementalSync(): void;
- onAppFullSync(): void;
-}
diff --git a/dist/@types/app/assets/javascripts/views/account_switcher/account_switcher.d.ts b/dist/@types/app/assets/javascripts/views/account_switcher/account_switcher.d.ts
deleted file mode 100644
index 8974f7f1d..000000000
--- a/dist/@types/app/assets/javascripts/views/account_switcher/account_switcher.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { WebDirective } from '@/types';
-export declare class AccountSwitcher extends WebDirective {
- constructor();
-}
diff --git a/dist/@types/app/assets/javascripts/views/application/application_view.d.ts b/dist/@types/app/assets/javascripts/views/application/application_view.d.ts
deleted file mode 100644
index 92b407034..000000000
--- a/dist/@types/app/assets/javascripts/views/application/application_view.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { WebDirective } from '@/types';
-export declare class ApplicationView extends WebDirective {
- constructor();
-}
diff --git a/dist/@types/app/assets/javascripts/views/application_group/application_group.d.ts b/dist/@types/app/assets/javascripts/views/application_group/application_group.d.ts
deleted file mode 100644
index ecb3b7d0e..000000000
--- a/dist/@types/app/assets/javascripts/views/application_group/application_group.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { WebDirective } from '@/types';
-export declare class ApplicationGroupView extends WebDirective {
- constructor();
-}
diff --git a/dist/@types/app/assets/javascripts/views/application_group/application_group_view.d.ts b/dist/@types/app/assets/javascripts/views/application_group/application_group_view.d.ts
deleted file mode 100644
index ecb3b7d0e..000000000
--- a/dist/@types/app/assets/javascripts/views/application_group/application_group_view.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { WebDirective } from '@/types';
-export declare class ApplicationGroupView extends WebDirective {
- constructor();
-}
diff --git a/dist/@types/app/assets/javascripts/views/challenge_modal/challenge_modal.d.ts b/dist/@types/app/assets/javascripts/views/challenge_modal/challenge_modal.d.ts
deleted file mode 100644
index be099756c..000000000
--- a/dist/@types/app/assets/javascripts/views/challenge_modal/challenge_modal.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { WebDirective } from '@/types';
-export declare class ChallengeModal extends WebDirective {
- constructor();
-}
diff --git a/dist/@types/app/assets/javascripts/views/constants.d.ts b/dist/@types/app/assets/javascripts/views/constants.d.ts
deleted file mode 100644
index 3eadaa31f..000000000
--- a/dist/@types/app/assets/javascripts/views/constants.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export declare const PANEL_NAME_NOTES = "notes";
-export declare const PANEL_NAME_TAGS = "tags";
diff --git a/dist/@types/app/assets/javascripts/views/editor/editor_view.d.ts b/dist/@types/app/assets/javascripts/views/editor/editor_view.d.ts
deleted file mode 100644
index 5061db325..000000000
--- a/dist/@types/app/assets/javascripts/views/editor/editor_view.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { WebDirective } from '@/types';
-export declare class EditorView extends WebDirective {
- constructor();
-}
diff --git a/dist/@types/app/assets/javascripts/views/editor_group/editor_group.d.ts b/dist/@types/app/assets/javascripts/views/editor_group/editor_group.d.ts
deleted file mode 100644
index 4c185c250..000000000
--- a/dist/@types/app/assets/javascripts/views/editor_group/editor_group.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { WebDirective } from './../../types';
-export declare class EditorGroupView extends WebDirective {
- constructor();
-}
diff --git a/dist/@types/app/assets/javascripts/views/editor_group/editor_group_view.d.ts b/dist/@types/app/assets/javascripts/views/editor_group/editor_group_view.d.ts
deleted file mode 100644
index 4c185c250..000000000
--- a/dist/@types/app/assets/javascripts/views/editor_group/editor_group_view.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { WebDirective } from './../../types';
-export declare class EditorGroupView extends WebDirective {
- constructor();
-}
diff --git a/dist/@types/app/assets/javascripts/views/footer/footer_view.d.ts b/dist/@types/app/assets/javascripts/views/footer/footer_view.d.ts
deleted file mode 100644
index 27f2ce800..000000000
--- a/dist/@types/app/assets/javascripts/views/footer/footer_view.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { WebDirective } from '@/types';
-export declare class FooterView extends WebDirective {
- constructor();
-}
diff --git a/dist/@types/app/assets/javascripts/views/index.d.ts b/dist/@types/app/assets/javascripts/views/index.d.ts
deleted file mode 100644
index fc5b9525f..000000000
--- a/dist/@types/app/assets/javascripts/views/index.d.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-export { PureViewCtrl } from './abstract/pure_view_ctrl';
-export { ApplicationGroupView } from './application_group/application_group_view';
-export { ApplicationView } from './application/application_view';
-export { EditorGroupView } from './editor_group/editor_group_view';
-export { EditorView } from './editor/editor_view';
-export { FooterView } from './footer/footer_view';
-export { NotesView } from './notes/notes_view';
-export { TagsView } from './tags/tags_view';
-export { ChallengeModal } from './challenge_modal/challenge_modal';
diff --git a/dist/@types/app/assets/javascripts/views/notes/note_utils.d.ts b/dist/@types/app/assets/javascripts/views/notes/note_utils.d.ts
deleted file mode 100644
index 3b23a9c69..000000000
--- a/dist/@types/app/assets/javascripts/views/notes/note_utils.d.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { SNNote } from 'snjs';
-export declare enum NoteSortKey {
- CreatedAt = "created_at",
- UserUpdatedAt = "userModifiedDate",
- Title = "title",
- /** @legacy Use UserUpdatedAt instead */
- UpdatedAt = "updated_at",
- /** @legacy Use UserUpdatedAt instead */
- ClientUpdatedAt = "client_updated_at"
-}
-export declare function notePassesFilter(note: SNNote, showArchived: boolean, hidePinned: boolean, filterText: string): boolean;
diff --git a/dist/@types/app/assets/javascripts/views/notes/notes_view.d.ts b/dist/@types/app/assets/javascripts/views/notes/notes_view.d.ts
deleted file mode 100644
index 2b50a2911..000000000
--- a/dist/@types/app/assets/javascripts/views/notes/notes_view.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { WebDirective } from './../../types';
-export declare class NotesView extends WebDirective {
- constructor();
-}
diff --git a/dist/@types/app/assets/javascripts/views/tags/tags_view.d.ts b/dist/@types/app/assets/javascripts/views/tags/tags_view.d.ts
deleted file mode 100644
index e11577d22..000000000
--- a/dist/@types/app/assets/javascripts/views/tags/tags_view.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { WebDirective } from '@/types';
-export declare class TagsView extends WebDirective {
- constructor();
-}
diff --git a/dist/@types/app/assets/javascripts/web_device_interface.d.ts b/dist/@types/app/assets/javascripts/web_device_interface.d.ts
deleted file mode 100644
index 2460a4b20..000000000
--- a/dist/@types/app/assets/javascripts/web_device_interface.d.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import { DeviceInterface, SNApplication, ApplicationIdentifier } from 'snjs';
-import { Bridge } from './services/bridge';
-export declare class WebDeviceInterface extends DeviceInterface {
- private bridge;
- private databases;
- constructor(timeout: any, bridge: Bridge);
- setApplication(application: SNApplication): void;
- private databaseForIdentifier;
- deinit(): void;
- getRawStorageValue(key: string): Promise;
- getAllRawStorageKeyValues(): Promise<{
- key: string;
- value: any;
- }[]>;
- setRawStorageValue(key: string, value: any): Promise;
- removeRawStorageValue(key: string): Promise;
- removeAllRawStorageValues(): Promise;
- openDatabase(identifier: ApplicationIdentifier): Promise<{
- isNewDatabase?: boolean | undefined;
- } | undefined>;
- getAllRawDatabasePayloads(identifier: ApplicationIdentifier): Promise;
- saveRawDatabasePayload(payload: any, identifier: ApplicationIdentifier): Promise;
- saveRawDatabasePayloads(payloads: any[], identifier: ApplicationIdentifier): Promise;
- removeRawDatabasePayloadWithId(id: string, identifier: ApplicationIdentifier): Promise;
- removeAllRawDatabasePayloads(identifier: ApplicationIdentifier): Promise;
- getNamespacedKeychainValue(identifier: ApplicationIdentifier): Promise;
- setNamespacedKeychainValue(value: any, identifier: ApplicationIdentifier): Promise;
- clearNamespacedKeychainValue(identifier: ApplicationIdentifier): Promise;
- getRawKeychainValue(): Promise;
- clearRawKeychainValue(): Promise;
- openUrl(url: string): void;
-}
diff --git a/dist/@types/vendor/assets/javascripts/angular-sanitize.d.ts b/dist/@types/vendor/assets/javascripts/angular-sanitize.d.ts
deleted file mode 100644
index 6d93f46fa..000000000
--- a/dist/@types/vendor/assets/javascripts/angular-sanitize.d.ts
+++ /dev/null
@@ -1,242 +0,0 @@
-/**
- * @ngdoc module
- * @name ngSanitize
- * @description
- *
- * The `ngSanitize` module provides functionality to sanitize HTML.
- *
- * See {@link ngSanitize.$sanitize `$sanitize`} for usage.
- */
-/**
- * @ngdoc service
- * @name $sanitize
- * @kind function
- *
- * @description
- * Sanitizes an html string by stripping all potentially dangerous tokens.
- *
- * The input is sanitized by parsing the HTML into tokens. All safe tokens (from a whitelist) are
- * then serialized back to a properly escaped HTML string. This means that no unsafe input can make
- * it into the returned string.
- *
- * The whitelist for URL sanitization of attribute values is configured using the functions
- * `aHrefSanitizationWhitelist` and `imgSrcSanitizationWhitelist` of {@link $compileProvider}.
- *
- * The input may also contain SVG markup if this is enabled via {@link $sanitizeProvider}.
- *
- * @param {string} html HTML input.
- * @returns {string} Sanitized HTML.
- *
- * @example
-
-
-
-
- Snippet:
-
-
- | Directive |
- How |
- Source |
- Rendered |
-
-
- | ng-bind-html |
- Automatically uses $sanitize |
- <div ng-bind-html="snippet"> </div> |
- |
-
-
- | ng-bind-html |
- Bypass $sanitize by explicitly trusting the dangerous value |
-
- <div ng-bind-html="deliberatelyTrustDangerousSnippet()">
-</div>
- |
- |
-
-
- | ng-bind |
- Automatically escapes |
- <div ng-bind="snippet"> </div> |
- |
-
-
-
-
-
- it('should sanitize the html snippet by default', function() {
- expect(element(by.css('#bind-html-with-sanitize div')).getAttribute('innerHTML')).
- toBe('an html\nclick here\nsnippet
');
- });
-
- it('should inline raw snippet if bound to a trusted value', function() {
- expect(element(by.css('#bind-html-with-trust div')).getAttribute('innerHTML')).
- toBe("an html\n" +
- "click here\n" +
- "snippet
");
- });
-
- it('should escape snippet without any filter', function() {
- expect(element(by.css('#bind-default div')).getAttribute('innerHTML')).
- toBe("<p style=\"color:blue\">an html\n" +
- "<em onmouseover=\"this.textContent='PWN3D!'\">click here</em>\n" +
- "snippet</p>");
- });
-
- it('should update', function() {
- element(by.model('snippet')).clear();
- element(by.model('snippet')).sendKeys('new text');
- expect(element(by.css('#bind-html-with-sanitize div')).getAttribute('innerHTML')).
- toBe('new text');
- expect(element(by.css('#bind-html-with-trust div')).getAttribute('innerHTML')).toBe(
- 'new text');
- expect(element(by.css('#bind-default div')).getAttribute('innerHTML')).toBe(
- "new <b onclick=\"alert(1)\">text</b>");
- });
-
-
- */
-/**
- * @ngdoc provider
- * @name $sanitizeProvider
- * @this
- *
- * @description
- * Creates and configures {@link $sanitize} instance.
- */
-declare function $SanitizeProvider(): void;
-declare class $SanitizeProvider {
- $get: (string | (($$sanitizeUri: any) => (html: any) => string))[];
- /**
- * @ngdoc method
- * @name $sanitizeProvider#enableSvg
- * @kind function
- *
- * @description
- * Enables a subset of svg to be supported by the sanitizer.
- *
- *
- *
By enabling this setting without taking other precautions, you might expose your
- * application to click-hijacking attacks. In these attacks, sanitized svg elements could be positioned
- * outside of the containing element and be rendered over other elements on the page (e.g. a login
- * link). Such behavior can then result in phishing incidents.
- *
- *
To protect against these, explicitly setup `overflow: hidden` css rule for all potential svg
- * tags within the sanitized content:
- *
- *
- *
- *
- * .rootOfTheIncludedContent svg {
- * overflow: hidden !important;
- * }
- *
- *
- *
- * @param {boolean=} flag Enable or disable SVG support in the sanitizer.
- * @returns {boolean|$sanitizeProvider} Returns the currently configured value if called
- * without an argument or self for chaining otherwise.
- */
- enableSvg: (enableSvg: any) => boolean | any;
- /**
- * @ngdoc method
- * @name $sanitizeProvider#addValidElements
- * @kind function
- *
- * @description
- * Extends the built-in lists of valid HTML/SVG elements, i.e. elements that are considered safe
- * and are not stripped off during sanitization. You can extend the following lists of elements:
- *
- * - `htmlElements`: A list of elements (tag names) to extend the current list of safe HTML
- * elements. HTML elements considered safe will not be removed during sanitization. All other
- * elements will be stripped off.
- *
- * - `htmlVoidElements`: This is similar to `htmlElements`, but marks the elements as
- * "void elements" (similar to HTML
- * [void elements](https://rawgit.com/w3c/html/html5.1-2/single-page.html#void-elements)). These
- * elements have no end tag and cannot have content.
- *
- * - `svgElements`: This is similar to `htmlElements`, but for SVG elements. This list is only
- * taken into account if SVG is {@link ngSanitize.$sanitizeProvider#enableSvg enabled} for
- * `$sanitize`.
- *
- *
- * This method must be called during the {@link angular.Module#config config} phase. Once the
- * `$sanitize` service has been instantiated, this method has no effect.
- *
- *
- *
- * Keep in mind that extending the built-in lists of elements may expose your app to XSS or
- * other vulnerabilities. Be very mindful of the elements you add.
- *
- *
- * @param {Array|Object} elements - A list of valid HTML elements or an object with one or
- * more of the following properties:
- * - **htmlElements** - `{Array}` - A list of elements to extend the current list of
- * HTML elements.
- * - **htmlVoidElements** - `{Array}` - A list of elements to extend the current list of
- * void HTML elements; i.e. elements that do not have an end tag.
- * - **svgElements** - `{Array}` - A list of elements to extend the current list of SVG
- * elements. The list of SVG elements is only taken into account if SVG is
- * {@link ngSanitize.$sanitizeProvider#enableSvg enabled} for `$sanitize`.
- *
- * Passing an array (`[...]`) is equivalent to passing `{htmlElements: [...]}`.
- *
- * @return {$sanitizeProvider} Returns self for chaining.
- */
- addValidElements: (elements: Array | Object) => any;
- /**
- * @ngdoc method
- * @name $sanitizeProvider#addValidAttrs
- * @kind function
- *
- * @description
- * Extends the built-in list of valid attributes, i.e. attributes that are considered safe and are
- * not stripped off during sanitization.
- *
- * **Note**:
- * The new attributes will not be treated as URI attributes, which means their values will not be
- * sanitized as URIs using `$compileProvider`'s
- * {@link ng.$compileProvider#aHrefSanitizationWhitelist aHrefSanitizationWhitelist} and
- * {@link ng.$compileProvider#imgSrcSanitizationWhitelist imgSrcSanitizationWhitelist}.
- *
- *
- * This method must be called during the {@link angular.Module#config config} phase. Once the
- * `$sanitize` service has been instantiated, this method has no effect.
- *
- *
- *
- * Keep in mind that extending the built-in list of attributes may expose your app to XSS or
- * other vulnerabilities. Be very mindful of the attributes you add.
- *
- *
- * @param {Array} attrs - A list of valid attributes.
- *
- * @returns {$sanitizeProvider} Returns self for chaining.
- */
- addValidAttrs: (attrs: Array) => any;
-}
-declare function sanitizeText(chars: any): string;
-declare var $sanitizeMinErr: any;
-declare var bind: any;
-declare var extend: any;
-declare var forEach: any;
-declare var isArray: any;
-declare var isDefined: any;
-declare var lowercase: any;
-declare var noop: any;
-declare var nodeContains: any;
-declare var htmlParser: any;
-declare var htmlSanitizeWriter: any;
diff --git a/dist/@types/vendor/assets/javascripts/zip/deflate.d.ts b/dist/@types/vendor/assets/javascripts/zip/deflate.d.ts
deleted file mode 100644
index e69de29bb..000000000
diff --git a/dist/@types/vendor/assets/javascripts/zip/inflate.d.ts b/dist/@types/vendor/assets/javascripts/zip/inflate.d.ts
deleted file mode 100644
index e69de29bb..000000000
diff --git a/dist/@types/vendor/assets/javascripts/zip/z-worker.d.ts b/dist/@types/vendor/assets/javascripts/zip/z-worker.d.ts
deleted file mode 100644
index e69de29bb..000000000
diff --git a/dist/@types/vendor/assets/javascripts/zip/zip.d.ts b/dist/@types/vendor/assets/javascripts/zip/zip.d.ts
deleted file mode 100644
index e69de29bb..000000000
From d49d2e996b47738252fdb8b44cd53b6ea882b9cb Mon Sep 17 00:00:00 2001
From: Baptiste Grob <60621355+baptiste-grob@users.noreply.github.com>
Date: Mon, 16 Nov 2020 17:00:01 +0100
Subject: [PATCH 7/7] fix: assign active tag when creating a new note
---
app/assets/javascripts/ui_models/app_state.ts | 14 ++++++++++++--
app/assets/javascripts/ui_models/editor.ts | 19 ++++++++++++++-----
.../javascripts/ui_models/editor_group.ts | 12 ++++++++----
3 files changed, 34 insertions(+), 11 deletions(-)
diff --git a/app/assets/javascripts/ui_models/app_state.ts b/app/assets/javascripts/ui_models/app_state.ts
index 4d93f71ee..c607c894d 100644
--- a/app/assets/javascripts/ui_models/app_state.ts
+++ b/app/assets/javascripts/ui_models/app_state.ts
@@ -152,10 +152,20 @@ export class AppState {
*/
async createEditor(title?: string) {
const activeEditor = this.getActiveEditor();
+ const activeTagUuid = this.selectedTag
+ ? this.selectedTag.isSmartTag()
+ ? undefined
+ : this.selectedTag.uuid
+ : undefined;
+
if (!activeEditor || this.multiEditorEnabled) {
- this.application.editorGroup.createEditor(undefined, title);
+ this.application.editorGroup.createEditor(
+ undefined,
+ title,
+ activeTagUuid
+ );
} else {
- await activeEditor.reset(title);
+ await activeEditor.reset(title, activeTagUuid);
}
}
diff --git a/app/assets/javascripts/ui_models/editor.ts b/app/assets/javascripts/ui_models/editor.ts
index 7c03fbdb6..0a5eed08e 100644
--- a/app/assets/javascripts/ui_models/editor.ts
+++ b/app/assets/javascripts/ui_models/editor.ts
@@ -1,4 +1,4 @@
-import { SNNote, ContentType, PayloadSource } from 'snjs';
+import { SNNote, ContentType, PayloadSource, UuidString, TagMutator } from 'snjs';
import { WebApplication } from './application';
export class Editor {
@@ -12,15 +12,16 @@ export class Editor {
constructor(
application: WebApplication,
- noteUuid?: string,
- noteTitle?: string
+ noteUuid: string | undefined,
+ noteTitle: string | undefined,
+ noteTag: UuidString | undefined
) {
this.application = application;
if (noteUuid) {
this.note = application.findItem(noteUuid) as SNNote;
this.streamItems();
} else {
- this.reset(noteTitle)
+ this.reset(noteTitle, noteTag)
.then(() => this.streamItems())
.catch(console.error);
}
@@ -65,7 +66,10 @@ export class Editor {
* Reverts the editor to a blank state, removing any existing note from view,
* and creating a placeholder note.
*/
- async reset(noteTitle = '') {
+ async reset(
+ noteTitle = '',
+ noteTag?: UuidString,
+ ) {
const note = await this.application.createTemplateItem(
ContentType.Note,
{
@@ -74,6 +78,11 @@ export class Editor {
references: []
}
) as SNNote;
+ if (noteTag) {
+ await this.application.changeItem(noteTag, (m) => {
+ m.addItemAsRelationship(note);
+ });
+ }
if (!this.isTemplateNote || this.note.title !== note.title) {
this.setNote(note as SNNote, true);
}
diff --git a/app/assets/javascripts/ui_models/editor_group.ts b/app/assets/javascripts/ui_models/editor_group.ts
index 5be00f8ec..6ded5a3e0 100644
--- a/app/assets/javascripts/ui_models/editor_group.ts
+++ b/app/assets/javascripts/ui_models/editor_group.ts
@@ -1,4 +1,4 @@
-import { removeFromArray } from 'snjs';
+import { removeFromArray, UuidString } from 'snjs';
import { Editor } from './editor';
import { WebApplication } from './application';
@@ -21,8 +21,12 @@ export class EditorGroup {
}
}
- createEditor(noteUuid?: string, noteTitle?: string) {
- const editor = new Editor(this.application, noteUuid, noteTitle);
+ createEditor(
+ noteUuid?: string,
+ noteTitle?: string,
+ noteTag?: UuidString
+ ) {
+ const editor = new Editor(this.application, noteUuid, noteTitle, noteTag);
this.editors.push(editor);
this.notifyObservers();
}
@@ -72,4 +76,4 @@ export class EditorGroup {
observer();
}
}
-}
\ No newline at end of file
+}