From 856da22b0ba8b9fb62b6a48ab93efb36203e13c0 Mon Sep 17 00:00:00 2001 From: tkat0 Date: Sun, 18 Sep 2022 08:18:20 +0900 Subject: [PATCH] refactor: extract domain --- packages/outliner/src/adapter/ObsidianAdapterImpl.ts | 4 ++-- packages/outliner/src/domain/model.ts | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/outliner/src/adapter/ObsidianAdapterImpl.ts b/packages/outliner/src/adapter/ObsidianAdapterImpl.ts index 528f785..bd30b43 100644 --- a/packages/outliner/src/adapter/ObsidianAdapterImpl.ts +++ b/packages/outliner/src/adapter/ObsidianAdapterImpl.ts @@ -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) {} @@ -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; } } diff --git a/packages/outliner/src/domain/model.ts b/packages/outliner/src/domain/model.ts index f48e476..27e008c 100644 --- a/packages/outliner/src/domain/model.ts +++ b/packages/outliner/src/domain/model.ts @@ -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. "