-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d7a43e4
commit 9ececdb
Showing
46 changed files
with
1,067 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"atom-workspace": { | ||
"alt-n": "wootom:togglePreview" | ||
"alt-n": "wootom:toggleNavigation", | ||
"alt-j": "wootom:togglePreview" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ViewRegistryAdder } from '../atom-abstractions/view-registry-adder'; | ||
import { WorkspaceItemManager } from '../atom-abstractions/workspace-item-manager'; | ||
import { HTMLView } from '../html-view/html-view'; | ||
import { HTMLViewModel } from '../html-view/html-view-model'; | ||
export declare class NavigationModel extends HTMLViewModel { | ||
/** | ||
* @param title The title of the HTML View pane item | ||
* @param view The view to use for the model | ||
* @param viewRegistryAdder Used to connect the model layer with the view | ||
* layer | ||
* @param workspaceItemOpener To be used to open a new pane with the view | ||
*/ | ||
constructor(title: string, view: Required<HTMLView>, viewRegistryAdder: ViewRegistryAdder, workspaceItemManager: WorkspaceItemManager); | ||
/** Activate the model; register it and its view with the ViewRegistry */ | ||
activate(): void; | ||
} | ||
export declare const navigationModel: NavigationModel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.navigationModel = exports.NavigationModel = void 0; | ||
const html_view_1 = require("../html-view/html-view"); | ||
const html_view_model_1 = require("../html-view/html-view-model"); | ||
class NavigationModel extends html_view_model_1.HTMLViewModel { | ||
/** | ||
* @param title The title of the HTML View pane item | ||
* @param view The view to use for the model | ||
* @param viewRegistryAdder Used to connect the model layer with the view | ||
* layer | ||
* @param workspaceItemOpener To be used to open a new pane with the view | ||
*/ | ||
constructor(title, view, viewRegistryAdder, workspaceItemManager) { | ||
super(title, view, viewRegistryAdder, workspaceItemManager); | ||
} | ||
/** Activate the model; register it and its view with the ViewRegistry */ | ||
activate() { | ||
this.viewRegistryAdder.addViewProvider(NavigationModel, () => this.view.render()); | ||
} | ||
} | ||
exports.NavigationModel = NavigationModel; | ||
exports.navigationModel = new NavigationModel('Wootom Navigation', new html_view_1.HTMLView(), atom.views, atom.workspace); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { WorkspaceObserver } from '../atom-abstractions/workspace-observer'; | ||
import { HTMLViewModel } from '../html-view/html-view-model'; | ||
import { Parser } from '../parser/parser'; | ||
import { RenderingManager } from '../rendering/rendering-manager'; | ||
export declare class NavigationSubscriber { | ||
private readonly htmlViewModel; | ||
private readonly parser; | ||
private readonly renderingManager; | ||
private readonly workspaceObserver; | ||
private contentCache; | ||
private editor; | ||
private editorSubscriptions; | ||
private workspaceSubscriptions; | ||
constructor(htmlViewModel: Required<HTMLViewModel>, parser: Required<Parser>, renderingManager: Required<RenderingManager>, workspaceObserver: WorkspaceObserver); | ||
activate(): void; | ||
deactivate(): void; | ||
toggle(): Promise<void>; | ||
private updateContent; | ||
private updateEditor; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NavigationSubscriber = void 0; | ||
const atom_1 = require("atom"); | ||
const navigation_1 = require("./navigation"); | ||
class NavigationSubscriber { | ||
constructor(htmlViewModel, parser, renderingManager, workspaceObserver) { | ||
this.htmlViewModel = htmlViewModel; | ||
this.parser = parser; | ||
this.renderingManager = renderingManager; | ||
this.workspaceObserver = workspaceObserver; | ||
this.editorSubscriptions = new atom_1.CompositeDisposable(); | ||
this.workspaceSubscriptions = new atom_1.CompositeDisposable(); | ||
} | ||
activate() { | ||
this.workspaceSubscriptions.add(this.workspaceObserver.onDidChangeActiveTextEditor(this.updateEditor.bind(this))); | ||
} | ||
deactivate() { | ||
this.contentCache = undefined; | ||
this.editor = undefined; | ||
this.editorSubscriptions.dispose(); | ||
this.workspaceSubscriptions.dispose(); | ||
} | ||
toggle() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this.htmlViewModel.isOpen) { | ||
console.log('Wootom: Closing navigation pane.'); | ||
this.htmlViewModel.close(); | ||
} | ||
else { | ||
console.log('Wootom: Opening navigation pane.'); | ||
yield this.htmlViewModel.open(); | ||
} | ||
}); | ||
} | ||
updateContent() { | ||
if (typeof this.editor === 'undefined' || !this.htmlViewModel.isOpen) { | ||
return; | ||
} | ||
const content = this.editor.getText(); | ||
if (typeof this.contentCache === 'undefined' || | ||
this.contentCache !== content) { | ||
console.log('Wootom: Rendering navigation.'); | ||
this.contentCache = content; | ||
const documentRoot = this.parser.parse(content); | ||
const navigation = new navigation_1.Navigation(this.editor, this.renderingManager, documentRoot); | ||
this.htmlViewModel.render(navigation.render()); | ||
document.dispatchEvent(new CustomEvent('wootom-preview-rendered')); | ||
} | ||
else { | ||
console.log('Wootom: Hit content cache.'); | ||
} | ||
} | ||
updateEditor(editor) { | ||
this.editorSubscriptions.dispose(); | ||
this.editor = editor; | ||
if (typeof editor === 'undefined') { | ||
console.log('Wootom: Unsubscribing from text editor.'); | ||
return; | ||
} | ||
console.log('Wootom: Subscribing to new editor.'); | ||
this.editorSubscriptions.add(editor.onDidSave(this.updateContent.bind(this)), editor.onDidStopChanging(this.updateContent.bind(this))); | ||
this.updateContent(); | ||
} | ||
} | ||
exports.NavigationSubscriber = NavigationSubscriber; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { TextEditor } from 'atom'; | ||
import { ASTNode } from '../ast/ast-node'; | ||
import { RenderingManager } from '../rendering/rendering-manager'; | ||
export declare class Navigation { | ||
private readonly editor; | ||
private readonly renderingManager; | ||
private readonly root; | ||
private documentParts; | ||
constructor(editor: TextEditor, renderingManager: Required<RenderingManager>, root: ASTNode); | ||
render(): Node; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Navigation = void 0; | ||
const table_of_contents_1 = require("./table-of-contents"); | ||
const table_of_labels_1 = require("./table-of-labels"); | ||
class Navigation { | ||
constructor(editor, renderingManager, root) { | ||
this.editor = editor; | ||
this.renderingManager = renderingManager; | ||
this.root = root; | ||
this.documentParts = root.children.filter(child => child.kind === 'DocumentPart'); | ||
} | ||
render() { | ||
const container = document.createElement('div'); | ||
container.classList.add('wootom-navigation'); | ||
const heading = document.createElement('h1'); | ||
heading.append('Navigation'); | ||
const toc = new table_of_contents_1.TableOfContents(this.editor, this.renderingManager, this.documentParts); | ||
const tol = new table_of_labels_1.TableOfLabels(this.editor, this.root); | ||
container.append(heading, toc.render(), tol.render()); | ||
return container; | ||
} | ||
} | ||
exports.Navigation = Navigation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { TextEditor } from 'atom'; | ||
import { DocumentPart } from '../ast/document-part'; | ||
import { RenderingManager } from '../rendering/rendering-manager'; | ||
export declare class TableOfContents { | ||
private readonly editor; | ||
private readonly renderingManager; | ||
private readonly documentParts; | ||
private list; | ||
private searchInput; | ||
private searchResults; | ||
constructor(editor: TextEditor, renderingManager: Required<RenderingManager>, documentParts: DocumentPart[]); | ||
render(): Node; | ||
private renderTreeNode; | ||
private renderHeading; | ||
private getLevel; | ||
private constructHeadingTree; | ||
private renderSearchResults; | ||
private search; | ||
} |
Oops, something went wrong.