Skip to content

Commit

Permalink
1.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmeyers committed Oct 14, 2023
1 parent f257439 commit 0f69137
Show file tree
Hide file tree
Showing 12 changed files with 456 additions and 150 deletions.
94 changes: 49 additions & 45 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -1,52 +1,56 @@
import esbuild from "esbuild";
import process from "process";
import builtins from 'builtin-modules'
import esbuild from 'esbuild';
import process from 'process';
import builtins from 'builtin-modules';

const banner =
`/*
const banner = `/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
`;

const prod = (process.argv[2] === 'production');
const prod = process.argv[2] === 'production';

esbuild.build({
banner: {
js: banner,
},
entryPoints: ['src/main.ts'],
bundle: true,
external: [
'obsidian',
'electron',
'@codemirror/autocomplete',
'@codemirror/closebrackets',
'@codemirror/collab',
'@codemirror/commands',
'@codemirror/comment',
'@codemirror/fold',
'@codemirror/gutter',
'@codemirror/highlight',
'@codemirror/history',
'@codemirror/language',
'@codemirror/lint',
'@codemirror/matchbrackets',
'@codemirror/panel',
'@codemirror/rangeset',
'@codemirror/rectangular-selection',
'@codemirror/search',
'@codemirror/state',
'@codemirror/stream-parser',
'@codemirror/text',
'@codemirror/tooltip',
'@codemirror/view',
...builtins],
format: 'cjs',
watch: !prod,
target: 'es2016',
logLevel: "info",
sourcemap: prod ? false : 'inline',
treeShaking: true,
outfile: 'main.js',
}).catch(() => process.exit(1));
esbuild
.build({
banner: {
js: banner,
},
entryPoints: ['./src/main.ts'],
bundle: true,
external: [
'obsidian',
'electron',
'@codemirror/autocomplete',
'@codemirror/closebrackets',
'@codemirror/collab',
'@codemirror/commands',
'@codemirror/comment',
'@codemirror/fold',
'@codemirror/gutter',
'@codemirror/highlight',
'@codemirror/history',
'@codemirror/language',
'@codemirror/lint',
'@codemirror/matchbrackets',
'@codemirror/panel',
'@codemirror/rangeset',
'@codemirror/rectangular-selection',
'@codemirror/search',
'@codemirror/state',
'@codemirror/stream-parser',
'@codemirror/text',
'@codemirror/tooltip',
'@codemirror/view',
'node:*',
...builtins,
],
format: 'cjs',
watch: !prod,
target: 'es2016',
logLevel: 'info',
sourcemap: prod ? false : 'inline',
treeShaking: true,
outfile: 'main.js',
minify: prod,
})
.catch(() => process.exit(1));
16 changes: 8 additions & 8 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"id": "obsidian-list-callouts",
"name": "List Callouts",
"version": "1.1.4",
"minAppVersion": "1.1.1",
"description": "Create simple callouts in lists.",
"author": "mgmeyers",
"authorUrl": "https://github.com/mgmeyers/obsidian-list-callouts",
"isDesktopOnly": false
"id": "obsidian-list-callouts",
"name": "List Callouts",
"version": "1.1.5",
"minAppVersion": "1.1.1",
"description": "Create simple callouts in lists.",
"author": "mgmeyers",
"authorUrl": "https://github.com/mgmeyers/obsidian-list-callouts",
"isDesktopOnly": false
}
18 changes: 14 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
{
"name": "obsidian-sample-plugin",
"version": "1.0.1",
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
"name": "obsidian-list-callouts",
"version": "1.1.5",
"description": "Create simple callouts in lists.",
"main": "main.js",
"scripts": {
"dev": "node esbuild.config.mjs",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production"
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"check-types": "tsc --noemit",
"lint": "eslint ./src",
"lint:fix": "eslint ./src/**/* --fix",
"prettier": "prettier --write \"./src/**/*.{ts,tsx}\"",
"clean": "yarn prettier && yarn lint:fix",
"rlnotes": "git log $(git describe --tags --abbrev=0)..HEAD --oneline > release-notes.md && git add release-notes.md",
"bump": "node version-bump.mjs && git add package.json manifest.json versions.json && yarn rlnotes",
"release": "git commit -m $npm_package_version && git tag $npm_package_version && git push && git push --tags"
},
"keywords": [],
"author": "",
"license": "MIT",
"devDependencies": {
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0",
"@trivago/prettier-plugin-sort-imports": "4.2.0",
"@types/node": "^16.11.6",
"@typescript-eslint/eslint-plugin": "^5.2.0",
"@typescript-eslint/parser": "^5.2.0",
"builtin-modules": "^3.2.0",
"esbuild": "0.13.12",
"eslint": "^8.17.0",
"obsidian": "^1.1.1",
"prettier": "^3.0.3",
"tslib": "2.3.1",
"typescript": "4.4.4"
},
Expand Down
21 changes: 21 additions & 0 deletions prettier.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* eslint-disable no-undef */
module.exports = {
arrowParens: 'always',
bracketSpacing: true,
endOfLine: 'lf',
htmlWhitespaceSensitivity: 'css',
bracketSameLine: false,
jsxSingleQuote: false,
printWidth: 80,
proseWrap: 'preserve',
quoteProps: 'as-needed',
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'es5',
useTabs: false,
importOrder: ['^[./]'],
importOrderSeparation: true,
importOrderSortSpecifiers: true,
plugins: ["@trivago/prettier-plugin-sort-imports"]
};
4 changes: 4 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
f257439 Fixes #39
1d7111a Merge pull request #41 from acook/patch-1
d100754 Make background transparent to click events
6306b66 Change cursor to match other empty text areas
20 changes: 10 additions & 10 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { RangeSetBuilder, StateEffect, StateField } from '@codemirror/state';
import {
Decoration,
DecorationSet,
EditorView,
ViewPlugin,
ViewUpdate,
WidgetType,
} from "@codemirror/view";
import { RangeSetBuilder, StateEffect, StateField } from "@codemirror/state";
} from '@codemirror/view';
import { setIcon } from 'obsidian';

import { CalloutConfig } from "./settings";
import { setIcon } from "obsidian";
import { CalloutConfig } from './settings';

export const setConfig = StateEffect.define<CalloutConfig[]>();

export class CalloutBackground extends WidgetType {
toDOM() {
return createSpan({
cls: "lc-list-bg",
cls: 'lc-list-bg',
attr: {
"aria-hidden": "true",
'aria-hidden': 'true',
},
});
}
Expand All @@ -39,9 +39,9 @@ export class CalloutMarker extends WidgetType {
return createSpan(
{
text: this.char,
cls: "lc-list-marker",
cls: 'lc-list-marker',
attr: {
"aria-hidden": "true",
'aria-hidden': 'true',
},
},
(s) => {
Expand All @@ -56,7 +56,7 @@ export class CalloutMarker extends WidgetType {
export const calloutDecoration = (color: string) =>
Decoration.line({
attributes: {
class: "lc-list-callout",
class: 'lc-list-callout',
style: `--lc-callout-color: ${color}`,
},
});
Expand Down Expand Up @@ -95,7 +95,7 @@ export function buildCalloutDecos(view: EditorView) {
if (seen.has(line.from)) break;
seen.add(line.from);

const labelPos = line.from + match[1].length;
const labelPos = line.from + match[1].length;

// Set the line class and callout color
builder.add(line.from, line.from, calloutDecoration(callout.color));
Expand Down
45 changes: 23 additions & 22 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@
import { EditorView } from "@codemirror/view";
import { debounce, Events, MarkdownView, Plugin } from "obsidian";
import escapeStringRegexp from "escape-string-regexp";
import { EditorView } from '@codemirror/view';
import escapeStringRegexp from 'escape-string-regexp';
import { Events, MarkdownView, Plugin, debounce } from 'obsidian';

import { calloutExtension, calloutsConfigField, setConfig } from './extension';
import { buildPostProcessor } from './postProcessor';
import {
Callout,
CalloutConfig,
ListCalloutSettings,
ListCalloutsSettings,
} from "./settings";
import { calloutExtension, calloutsConfigField, setConfig } from "./extension";
import { buildPostProcessor } from "./postProcessor";
} from './settings';

const DEFAULT_SETTINGS: ListCalloutsSettings = [
{
color: "255, 214, 0",
char: "&",
color: '255, 214, 0',
char: '&',
},
{
color: "255, 145, 0",
char: "?",
color: '255, 145, 0',
char: '?',
},
{
color: "255, 23, 68",
char: "!",
color: '255, 23, 68',
char: '!',
},
{
color: "124, 77, 255",
char: "~",
color: '124, 77, 255',
char: '~',
},
{
color: "0, 184, 212",
char: "@",
color: '0, 184, 212',
char: '@',
},
{
color: "0, 200, 83",
char: "$",
color: '0, 200, 83',
char: '$',
},
{
color: "158, 158, 158",
char: "%",
color: '158, 158, 158',
char: '%',
},
];

Expand All @@ -64,15 +65,15 @@ export default class ListCalloutsPlugin extends Plugin {
calloutExtension,
]);

app.workspace.trigger("parse-style-settings");
app.workspace.trigger('parse-style-settings');
}

emitSettingsUpdate = debounce(() => this.dispatchUpdate(), 2000, true);

dispatchUpdate() {
const newConfig = this.buildEditorConfig();

app.workspace.getLeavesOfType("markdown").find((l) => {
app.workspace.getLeavesOfType('markdown').find((l) => {
const view = l.view as MarkdownView;
const cm = (view.editor as any).cm as EditorView;

Expand Down
Loading

0 comments on commit 0f69137

Please sign in to comment.