Skip to content

Commit

Permalink
refactor: extract domain
Browse files Browse the repository at this point in the history
  • Loading branch information
tkat0 committed Sep 17, 2022
1 parent f5977e4 commit 856da22
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/outliner/src/adapter/ObsidianAdapterImpl.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { App, Editor, EditorChange, VaultConfig } from 'obsidian';
import type { ObsidianAdapter, ReadCurrentLineOutput } from 'src/domain/adapter/ObsidianAdapter';
import { IndentDirection, LineNo, LineRange, ListItem } from 'src/domain/model';
import { EXCLUDE_LIST_SECTIONS, IndentDirection, LineNo, LineRange, ListItem } from 'src/domain/model';

export class ObsidianAdapterImpl implements ObsidianAdapter {
constructor(private app: App, private editor: Editor, private config: VaultConfig) {}
Expand All @@ -14,7 +14,7 @@ export class ObsidianAdapterImpl implements ObsidianAdapter {
for (const section of sections) {
const { position, type } = section;
if (position.start.line <= line && line <= position.end.line) {
if (['code', 'table', 'heading'].includes(type)) {
if (EXCLUDE_LIST_SECTIONS.includes(type)) {
return false;
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/outliner/src/domain/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export interface LineRange {
end: LineNo;
}

/** The markdown sections where list items should not be placed */
export const EXCLUDE_LIST_SECTIONS = ['code', 'table', 'heading'];

/**
* matches line as follows.
* " - ", " * ", " 1. "
Expand Down

0 comments on commit 856da22

Please sign in to comment.