mirror of
https://github.com/vannamhh/progress-tracker.git
synced 2026-07-22 12:20:25 +00:00
Compare commits
No commits in common. "main" and "v1.0.0" have entirely different histories.
19 changed files with 1383 additions and 6150 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -20,8 +20,3 @@ data.json
|
|||
|
||||
# Exclude macOS Finder (System Explorer) View States
|
||||
.DS_Store
|
||||
|
||||
.cursor
|
||||
cursorkleosr
|
||||
.bmad
|
||||
.github
|
||||
675
LICENSE
675
LICENSE
|
|
@ -1,674 +1,5 @@
|
|||
gnu general public license
|
||||
version 3, 29 june 2007
|
||||
Copyright (C) 2020-2025 by Dynalist Inc.
|
||||
|
||||
copyright (c) 2007 free software foundation, inc. <https://fsf.org/>
|
||||
everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
|
||||
|
||||
preamble
|
||||
|
||||
the gnu general public license is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
the licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. by contrast,
|
||||
the gnu general public license is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. we, the free software foundation, use the
|
||||
gnu general public license for most of our software; it applies also to
|
||||
any other work released this way by its authors. you can apply it to
|
||||
your programs, too.
|
||||
|
||||
when we speak of free software, we are referring to freedom, not
|
||||
price. our general public licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
to protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
for example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. you must make sure that they, too, receive
|
||||
or can get the source code. and you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
developers that use the gnu gpl protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this license
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
for the developers' and authors' protection, the gpl clearly explains
|
||||
that there is no warranty for this free software. for both users' and
|
||||
authors' sake, the gpl requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. this is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. the systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. therefore, we
|
||||
have designed this version of the gpl to prohibit the practice for those
|
||||
products. if such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the gpl, as needed to protect the freedom of users.
|
||||
|
||||
finally, every program is threatened constantly by software patents.
|
||||
states should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. to prevent this, the gpl assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
the precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
terms and conditions
|
||||
|
||||
0. definitions.
|
||||
|
||||
"this license" refers to version 3 of the gnu general public license.
|
||||
|
||||
"copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"the program" refers to any copyrightable work licensed under this
|
||||
license. each licensee is addressed as "you". "licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
to "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. the resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
a "covered work" means either the unmodified program or a work based
|
||||
on the program.
|
||||
|
||||
to "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
to "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
an interactive user interface displays "appropriate legal notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this license, and how to view a copy of this license. if
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. source code.
|
||||
|
||||
the "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
a "standard interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
the "system libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a major component, but which is not part of that major
|
||||
component, and (b) serves only to enable use of the work with that
|
||||
major component, or to implement a standard interface for which an
|
||||
implementation is available to the public in source code form. a
|
||||
"major component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
the "corresponding source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. however, it does not include the work's
|
||||
system libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. for example, corresponding source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
the corresponding source need not include anything that users
|
||||
can regenerate automatically from other parts of the corresponding
|
||||
source.
|
||||
|
||||
the corresponding source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. basic permissions.
|
||||
|
||||
all rights granted under this license are granted for the term of
|
||||
copyright on the program, and are irrevocable provided the stated
|
||||
conditions are met. this license explicitly affirms your unlimited
|
||||
permission to run the unmodified program. the output from running a
|
||||
covered work is covered by this license only if the output, given its
|
||||
content, constitutes a covered work. this license acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
you may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. you may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this license in conveying all material for which you do
|
||||
not control copyright. those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. protecting users' legal rights from anti-circumvention law.
|
||||
|
||||
no covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the wipo copyright treaty adopted on 20 december 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
when you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this license with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. conveying verbatim copies.
|
||||
|
||||
you may convey verbatim copies of the program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this license and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this license along with the program.
|
||||
|
||||
you may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. conveying modified source versions.
|
||||
|
||||
you may convey a work based on the program, or the modifications to
|
||||
produce it from the program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) the work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) the work must carry prominent notices stating that it is
|
||||
released under this license and any conditions added under section
|
||||
7. this requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) you must license the entire work, as a whole, under this
|
||||
license to anyone who comes into possession of a copy. this
|
||||
license will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. this license gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) if the work has interactive user interfaces, each must display
|
||||
appropriate legal notices; however, if the program has interactive
|
||||
interfaces that do not display appropriate legal notices, your
|
||||
work need not make them do so.
|
||||
|
||||
a compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. inclusion of a covered work
|
||||
in an aggregate does not cause this license to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. conveying non-source forms.
|
||||
|
||||
you may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable corresponding source under the terms of this license,
|
||||
in one of these ways:
|
||||
|
||||
a) convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
corresponding source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the corresponding source for all the software in the
|
||||
product that is covered by this license, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
corresponding source from a network server at no charge.
|
||||
|
||||
c) convey individual copies of the object code with a copy of the
|
||||
written offer to provide the corresponding source. this
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
corresponding source in the same way through the same place at no
|
||||
further charge. you need not require recipients to copy the
|
||||
corresponding source along with the object code. if the place to
|
||||
copy the object code is a network server, the corresponding source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
corresponding source. regardless of what server hosts the
|
||||
corresponding source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and corresponding
|
||||
source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
a separable portion of the object code, whose source code is excluded
|
||||
from the corresponding source as a system library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
a "user product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. in determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. for a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. a product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"installation information" for a user product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that user product from
|
||||
a modified version of its corresponding source. the information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
if you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a user product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
user product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
corresponding source conveyed under this section must be accompanied
|
||||
by the installation information. but this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the user product (for example, the work has
|
||||
been installed in rom).
|
||||
|
||||
the requirement to provide installation information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the user product in which it has been modified or installed. access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
corresponding source conveyed, and installation information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. additional terms.
|
||||
|
||||
"additional permissions" are terms that supplement the terms of this
|
||||
license by making exceptions from one or more of its conditions.
|
||||
additional permissions that are applicable to the entire program shall
|
||||
be treated as though they were included in this license, to the extent
|
||||
that they are valid under applicable law. if additional permissions
|
||||
apply only to part of the program, that part may be used separately
|
||||
under those permissions, but the entire program remains governed by
|
||||
this license without regard to the additional permissions.
|
||||
|
||||
when you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) you may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
notwithstanding any other provision of this license, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this license with terms:
|
||||
|
||||
a) disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this license; or
|
||||
|
||||
b) requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the appropriate legal
|
||||
notices displayed by works containing it; or
|
||||
|
||||
c) prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
all other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. if the program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this license along with a term that is a further
|
||||
restriction, you may remove that term. if a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
license, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
if you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. termination.
|
||||
|
||||
you may not propagate or modify a covered work except as expressly
|
||||
provided under this license. any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this license (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
however, if you cease all violation of this license, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this license (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this license. if your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. acceptance not required for having copies.
|
||||
|
||||
you are not required to accept this license in order to receive or
|
||||
run a copy of the program. ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. however,
|
||||
nothing other than this license grants you permission to propagate or
|
||||
modify any covered work. these actions infringe copyright if you do
|
||||
not accept this license. therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this license to do so.
|
||||
|
||||
10. automatic licensing of downstream recipients.
|
||||
|
||||
each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this license. you are not responsible
|
||||
for enforcing compliance by third parties with this license.
|
||||
|
||||
an "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. if propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
corresponding source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
you may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this license. for example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this license, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the program or any portion of it.
|
||||
|
||||
11. patents.
|
||||
|
||||
a "contributor" is a copyright holder who authorizes use under this
|
||||
license of the program or a work on which the program is based. the
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
a contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this license, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. for
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this license.
|
||||
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
in the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). to "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
if you convey a covered work, knowingly relying on a patent license,
|
||||
and the corresponding source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this license, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the corresponding source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this license, to extend the patent
|
||||
license to downstream recipients. "knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
if, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
a patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this license. you may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 march 2007.
|
||||
|
||||
nothing in this license shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. no surrender of others' freedom.
|
||||
|
||||
if conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this license, they do not
|
||||
excuse you from the conditions of this license. if you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
license and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. for example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the program, the only way you could satisfy both those terms and this
|
||||
license would be to refrain entirely from conveying the program.
|
||||
|
||||
13. use with the gnu affero general public license.
|
||||
|
||||
notwithstanding any other provision of this license, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the gnu affero general public license into a single
|
||||
combined work, and to convey the resulting work. the terms of this
|
||||
license will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the gnu affero general public license,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. revised versions of this license.
|
||||
|
||||
the free software foundation may publish revised and/or new versions of
|
||||
the gnu general public license from time to time. such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
each version is given a distinguishing version number. if the
|
||||
program specifies that a certain numbered version of the gnu general
|
||||
public license "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the free software
|
||||
foundation. if the program does not specify a version number of the
|
||||
gnu general public license, you may choose any version ever published
|
||||
by the free software foundation.
|
||||
|
||||
if the program specifies that a proxy can decide which future
|
||||
versions of the gnu general public license can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the program.
|
||||
|
||||
later license versions may give you additional or different
|
||||
permissions. however, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. disclaimer of warranty.
|
||||
|
||||
there is no warranty for the program, to the extent permitted by
|
||||
applicable law. except when otherwise stated in writing the copyright
|
||||
holders and/or other parties provide the program "as is" without warranty
|
||||
of any kind, either expressed or implied, including, but not limited to,
|
||||
the implied warranties of merchantability and fitness for a particular
|
||||
purpose. the entire risk as to the quality and performance of the program
|
||||
is with you. should the program prove defective, you assume the cost of
|
||||
all necessary servicing, repair or correction.
|
||||
|
||||
16. limitation of liability.
|
||||
|
||||
in no event unless required by applicable law or agreed to in writing
|
||||
will any copyright holder, or any other party who modifies and/or conveys
|
||||
the program as permitted above, be liable to you for damages, including any
|
||||
general, special, incidental or consequential damages arising out of the
|
||||
use or inability to use the program (including but not limited to loss of
|
||||
data or data being rendered inaccurate or losses sustained by you or third
|
||||
parties or a failure of the program to operate with any other programs),
|
||||
even if such holder or other party has been advised of the possibility of
|
||||
such damages.
|
||||
|
||||
17. interpretation of sections 15 and 16.
|
||||
|
||||
if the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the program in return for a fee.
|
||||
|
||||
end of terms and conditions
|
||||
|
||||
how to apply these terms to your new programs
|
||||
|
||||
if you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
to do so, attach the following notices to the program. it is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
copyright (c) <year> <name of author>
|
||||
|
||||
this program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the gnu general public license as published by
|
||||
the free software foundation, either version 3 of the license, or
|
||||
(at your option) any later version.
|
||||
|
||||
this program is distributed in the hope that it will be useful,
|
||||
but without any warranty; without even the implied warranty of
|
||||
merchantability or fitness for a particular purpose. see the
|
||||
gnu general public license for more details.
|
||||
|
||||
you should have received a copy of the gnu general public license
|
||||
along with this program. if not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
if the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> copyright (c) <year> <name of author>
|
||||
this program comes with absolutely no warranty; for details type `show w'.
|
||||
this is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
the hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the general public license. of course, your program's commands
|
||||
might be different; for a gui interface, you would use an "about box".
|
||||
|
||||
you should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
for more information on this, and how to apply and follow the gnu gpl, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
the gnu general public license does not permit incorporating your program
|
||||
into proprietary programs. if your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. if this is what you want to do, use the gnu lesser general
|
||||
public license instead of this license. but first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
175
README.md
175
README.md
|
|
@ -1,156 +1,65 @@
|
|||
# Progress Tracker Plugin for Obsidian
|
||||
|
||||
A plugin for Obsidian that helps you track progress of your tasks in real-time. It provides a visual progress bar and integrates with Kanban boards to help you manage your tasks more effectively.
|
||||
|
||||
## What's new in the latest update
|
||||
|
||||
- **Sidebar duplication bug fixed:** Only one progress tracker view is created, even after reloads.
|
||||
- **Sidebar position:** Progress tracker now appears in the right sidebar by default.
|
||||
- **Custom checkbox states:** Improved support and protection for custom states in Kanban boards.
|
||||
- **View initialization:** Progress bar view now reliably loads and updates when opened.
|
||||
A plugin for Obsidian (https://obsidian.md) that helps you track progress and manage tasks in your notes.
|
||||
|
||||
## Features
|
||||
|
||||
- Real-time progress tracking of tasks in your notes
|
||||
- Visual progress bar showing completion percentage
|
||||
- Automatic status updates based on task completion
|
||||
- Kanban board integration for task management
|
||||
- **Custom checkbox states for Kanban columns** (NEW!)
|
||||
- Customizable colors and thresholds
|
||||
- Debug mode for troubleshooting
|
||||
- Track progress of tasks and projects
|
||||
- Add progress bars to your notes
|
||||
- Monitor completion status
|
||||
- Generate progress reports
|
||||
- Customize tracking settings
|
||||
|
||||
## Installation
|
||||
|
||||
1. Open Obsidian Settings
|
||||
2. Go to Community Plugins and disable Safe Mode
|
||||
3. Click Browse and search for "Progress Tracker"
|
||||
4. Install the plugin
|
||||
5. Enable the plugin in your Community Plugins list
|
||||
3. Install and enable the Dataview plugin (required dependency)
|
||||
4. Click Browse and search for "Progress Tracker"
|
||||
5. Install the plugin
|
||||
6. Enable the plugin in your settings
|
||||
|
||||
## Dependencies
|
||||
|
||||
This plugin requires the [Dataview plugin](https://github.com/blacksmithgu/obsidian-dataview) to be installed and enabled. Dataview is used for:
|
||||
- Querying and tracking progress data
|
||||
- Generating progress reports
|
||||
- Analyzing task completion statistics
|
||||
|
||||
Please make sure to install Dataview before using Progress Tracker.
|
||||
|
||||
## Usage
|
||||
|
||||
### Basic Usage
|
||||
### Basic Progress Tracking
|
||||
- Add progress indicators to any note
|
||||
- Update progress status with simple commands
|
||||
- View completion percentages
|
||||
|
||||
1. Create tasks in your notes using Markdown checkboxes:
|
||||
```markdown
|
||||
- [ ] Task 1
|
||||
- [x] Completed task
|
||||
- [ ] Task 3
|
||||
```
|
||||
|
||||
2. The progress bar will automatically update as you check/uncheck tasks.
|
||||
|
||||
### Kanban Integration
|
||||
|
||||
The plugin can automatically move cards in your Kanban boards based on task completion:
|
||||
|
||||
1. Set up a Kanban board in Obsidian
|
||||
2. Configure the target Kanban board in plugin settings
|
||||
3. As you complete tasks, cards will move to appropriate columns
|
||||
|
||||
### Custom Checkbox States (NEW!)
|
||||
|
||||
You can now configure custom checkbox states for different Kanban columns:
|
||||
|
||||
1. Enable "Custom Checkbox States" in plugin settings
|
||||
2. Configure mappings between column names and checkbox states:
|
||||
- `Todo` → `[ ]` (unchecked)
|
||||
- `In Progress` → `[/]` (in progress)
|
||||
- `Complete` → `[x]` (completed)
|
||||
- `Done` → `[x]` (completed)
|
||||
- Or any custom states like `[>]`, `[-]`, etc.
|
||||
|
||||
3. When cards are moved between columns, their checkbox states will automatically update
|
||||
|
||||
#### Supported Checkbox States
|
||||
|
||||
- `[ ]` - Todo/Unchecked
|
||||
- `[x]` - Completed
|
||||
- `[/]` - In Progress
|
||||
- `[>]` - Forwarded/Deferred
|
||||
- `[-]` - Cancelled
|
||||
- `[!]` - Important
|
||||
|
||||
#### Kanban Normalization Protection (NEW!)
|
||||
|
||||
The plugin now includes intelligent protection against unwanted checkbox state normalization by the Kanban plugin:
|
||||
|
||||
- **Real-Time Detection**: Instantly detects when the Kanban plugin tries to convert custom states to standard states
|
||||
- **Immediate Reversion**: Automatically reverts unwanted normalizations in real-time
|
||||
- **Smart Pattern Analysis**: Distinguishes between legitimate user changes and unwanted plugin normalizations
|
||||
- **Selective Protection**: Only protects states that match your column mappings while preserving legitimate changes
|
||||
- **Multi-Layer Defense**: Combines immediate detection, movement analysis, and content comparison for comprehensive protection
|
||||
- **Non-Invasive**: Works seamlessly without interfering with normal Kanban operations
|
||||
- **Debug Support**: Comprehensive logging and testing commands for troubleshooting
|
||||
|
||||
**How it works:**
|
||||
1. **Immediate Detection**: Monitors editor changes in real-time to catch normalization as it happens
|
||||
2. **Pattern Recognition**: Analyzes content changes to identify unwanted custom state → [x] conversions
|
||||
3. **Smart Reversion**: Automatically restores correct checkbox states based on column mappings
|
||||
4. **Movement Protection**: Prevents card movements from triggering unwanted normalization cascades
|
||||
|
||||
This ensures your custom checkbox states (like `[/]`, `[~]`, etc.) remain intact when working with Kanban boards, even when the Kanban plugin tries to normalize them.
|
||||
|
||||
### Enhanced Custom State Support
|
||||
|
||||
The plugin now properly recognizes and counts all custom checkbox states with advanced conflict prevention and precision targeting. When custom checkbox states are enabled:
|
||||
|
||||
- **Progress Calculation**: Custom states (like `[/]`, `[-]`, `[~]`) are counted as "tasks in progress" and included in the total task count
|
||||
- **Smart Auto-Sync**: Auto-sync only updates cards that don't already have the correct checkbox state for their column
|
||||
- **Conflict Prevention**: Advanced timing detection prevents race conditions between auto-sync and manual card movements
|
||||
- **Precision Targeting**: Only cards that actually moved between columns are updated, eliminating false positives
|
||||
- **Content Normalization**: Card movements are detected by normalized content comparison, not checkbox states or fuzzy matching
|
||||
- **Preserved States**: Cards with existing correct states are left unchanged to prevent unnecessary modifications
|
||||
- **Enhanced Detection**: All task-related changes are properly detected regardless of checkbox state
|
||||
|
||||
**Note:** When updating checkbox states, only the main card checkbox is modified. Sub-items and nested checkboxes within cards are preserved to maintain data integrity. The plugin uses sophisticated position-based replacement and precision targeting to ensure only cards that actually moved are updated, completely preventing accidental modifications to other cards.
|
||||
### Progress Reports
|
||||
- Generate summary reports
|
||||
- Track progress over time
|
||||
- Export progress data
|
||||
|
||||
### Settings
|
||||
|
||||
#### Progress Bar Colors
|
||||
- Choose between default theme colors or custom color schemes
|
||||
- Set custom colors for different progress levels
|
||||
- Configure progress thresholds
|
||||
|
||||
#### Performance
|
||||
- Adjust update delays for different actions
|
||||
- Configure animation settings
|
||||
- Set maximum height for the progress bar container
|
||||
|
||||
#### Metadata Auto-Update
|
||||
- Automatically update file metadata on task completion
|
||||
- Configure status labels for different progress states
|
||||
- Set up finished date tracking
|
||||
|
||||
#### Kanban Integration
|
||||
- Enable/disable automatic Kanban board updates
|
||||
- Configure target Kanban board
|
||||
- Set up column mapping for task states
|
||||
|
||||
#### Custom Checkbox States
|
||||
- Enable custom checkbox state management
|
||||
- Configure column-to-checkbox mappings
|
||||
- Add/remove column mappings as needed
|
||||
- Reset to default mappings
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If you encounter issues:
|
||||
|
||||
1. Enable Debug Mode in settings to see detailed logs
|
||||
2. Check if Dataview plugin is installed and enabled
|
||||
3. Verify your Kanban board configuration
|
||||
4. Clear the completed files cache if needed
|
||||
5. Check custom checkbox state mappings if using that feature
|
||||
- Customize progress bar appearance
|
||||
- Configure tracking preferences
|
||||
- Set up notification options
|
||||
|
||||
## Support
|
||||
|
||||
If you find this plugin helpful, you can:
|
||||
If you encounter any issues or have suggestions for improvements, please:
|
||||
- Open an issue on GitHub
|
||||
- Join our community discussions
|
||||
|
||||
- Star the repository
|
||||
- Report issues on GitHub
|
||||
- Submit feature requests
|
||||
- Contribute to the code
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome! Please feel free to submit a Pull Request.
|
||||
|
||||
1. Fork the repository
|
||||
2. Create your feature branch
|
||||
3. Commit your changes
|
||||
4. Push to the branch
|
||||
5. Create a Pull Request
|
||||
|
||||
## License
|
||||
|
||||
|
|
|
|||
BIN
Screenshot.jpg
BIN
Screenshot.jpg
Binary file not shown.
|
Before Width: | Height: | Size: 46 KiB |
|
|
@ -1,10 +1,11 @@
|
|||
{
|
||||
"id": "progress-tracker",
|
||||
"name": "ProgressTracker",
|
||||
"version": "1.5.4",
|
||||
"minAppVersion": "1.1.0",
|
||||
"description": "Track task completion with a visual progress bar in your sidebar, auto update column Kanban",
|
||||
"version": "1.0.0",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "Track task completion with a visual progress bar in your sidebar",
|
||||
"author": "VN",
|
||||
"authorUrl": "https://github.com/vannamhh/",
|
||||
"authorUrl": "https://wpmasterynow.com",
|
||||
"fundingUrl": "https://wpmasterynow.com",
|
||||
"isDesktopOnly": false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
11
package.json
11
package.json
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "progress-tracker",
|
||||
"version": "1.5.4",
|
||||
"version": "1.0.0",
|
||||
"description": "Track task completion with a visual progress bar in your sidebar",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
@ -8,12 +8,7 @@
|
|||
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
|
||||
"version": "node version-bump.mjs && git add manifest.json versions.json"
|
||||
},
|
||||
"keywords": [
|
||||
"obsidian",
|
||||
"dataview",
|
||||
"progress",
|
||||
"task"
|
||||
],
|
||||
"keywords": ["obsidian", "dataview", "progress", "task"],
|
||||
"author": "VN",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
|
|
@ -26,4 +21,4 @@
|
|||
"tslib": "2.4.0",
|
||||
"typescript": "4.7.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,109 +0,0 @@
|
|||
import { KanbanColumnCheckboxMapping } from "./types";
|
||||
|
||||
/**
|
||||
* Main settings interface for the Task Progress Bar plugin
|
||||
* Contains all configurable options for the plugin behavior
|
||||
*/
|
||||
export interface TaskProgressBarSettings {
|
||||
// Debug settings
|
||||
showDebugInfo: boolean;
|
||||
|
||||
// Progress bar color settings
|
||||
progressColorScheme: "default" | "red-orange-green" | "custom";
|
||||
lowProgressColor: string;
|
||||
mediumProgressColor: string;
|
||||
highProgressColor: string;
|
||||
completeProgressColor: string;
|
||||
lowProgressThreshold: number;
|
||||
mediumProgressThreshold: number;
|
||||
highProgressThreshold: number;
|
||||
|
||||
// Animation settings
|
||||
showUpdateAnimation: boolean;
|
||||
updateAnimationDelay: number;
|
||||
|
||||
// Performance settings
|
||||
editorChangeDelay: number;
|
||||
keyboardInputDelay: number;
|
||||
checkboxClickDelay: number;
|
||||
|
||||
// Interface settings
|
||||
maxTabsHeight: string;
|
||||
|
||||
// Metadata auto-update settings
|
||||
autoUpdateMetadata: boolean;
|
||||
autoChangeStatus: boolean;
|
||||
autoUpdateFinishedDate: boolean;
|
||||
|
||||
// Kanban integration settings
|
||||
autoUpdateKanban: boolean;
|
||||
kanbanCompletedColumn: string; // Deprecated but kept for backward compatibility
|
||||
statusTodo: string;
|
||||
statusInProgress: string;
|
||||
statusCompleted: string;
|
||||
kanbanAutoDetect: boolean;
|
||||
kanbanSpecificFiles: string[];
|
||||
kanbanExcludeFiles: string[];
|
||||
kanbanSyncWithStatus: boolean;
|
||||
|
||||
// Auto-add to Kanban settings
|
||||
autoAddToKanban: boolean;
|
||||
autoAddKanbanBoard: string;
|
||||
autoAddKanbanColumn: string;
|
||||
|
||||
// Custom checkbox states settings
|
||||
enableCustomCheckboxStates: boolean;
|
||||
kanbanColumnCheckboxMappings: KanbanColumnCheckboxMapping[];
|
||||
|
||||
// Kanban sync settings
|
||||
enableKanbanToFileSync: boolean;
|
||||
enableKanbanAutoSync: boolean;
|
||||
enableKanbanNormalizationProtection: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default settings values for the plugin
|
||||
* Used when no saved settings exist or for resetting to defaults
|
||||
*/
|
||||
export const DEFAULT_SETTINGS: TaskProgressBarSettings = {
|
||||
showDebugInfo: false,
|
||||
progressColorScheme: "default",
|
||||
lowProgressColor: "#e06c75", // Red
|
||||
mediumProgressColor: "#e5c07b", // Orange/Yellow
|
||||
highProgressColor: "#61afef", // Blue
|
||||
completeProgressColor: "#98c379", // Green
|
||||
lowProgressThreshold: 33,
|
||||
mediumProgressThreshold: 66,
|
||||
highProgressThreshold: 99,
|
||||
showUpdateAnimation: true,
|
||||
updateAnimationDelay: 150,
|
||||
editorChangeDelay: 200,
|
||||
keyboardInputDelay: 50,
|
||||
checkboxClickDelay: 100,
|
||||
maxTabsHeight: "auto",
|
||||
autoUpdateMetadata: true,
|
||||
autoChangeStatus: true,
|
||||
autoUpdateFinishedDate: true,
|
||||
autoUpdateKanban: true,
|
||||
kanbanCompletedColumn: "Complete", // Deprecated
|
||||
statusTodo: "Todo",
|
||||
statusInProgress: "In Progress",
|
||||
statusCompleted: "Completed",
|
||||
kanbanAutoDetect: true,
|
||||
kanbanSpecificFiles: [],
|
||||
kanbanExcludeFiles: [],
|
||||
kanbanSyncWithStatus: true,
|
||||
autoAddToKanban: false,
|
||||
autoAddKanbanBoard: "",
|
||||
autoAddKanbanColumn: "Todo",
|
||||
enableCustomCheckboxStates: false,
|
||||
kanbanColumnCheckboxMappings: [
|
||||
{ columnName: "Todo", checkboxState: "[ ]" },
|
||||
{ columnName: "In Progress", checkboxState: "[/]" },
|
||||
{ columnName: "Complete", checkboxState: "[x]" },
|
||||
{ columnName: "Done", checkboxState: "[x]" },
|
||||
],
|
||||
enableKanbanToFileSync: false,
|
||||
enableKanbanAutoSync: false,
|
||||
enableKanbanNormalizationProtection: true,
|
||||
};
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
import { App } from "obsidian";
|
||||
|
||||
/**
|
||||
* Type-safe interface for Dataview API
|
||||
* Provides methods for executing JavaScript in Dataview context and accessing page data
|
||||
*/
|
||||
export interface DataviewApi {
|
||||
executeJs(
|
||||
code: string,
|
||||
container: HTMLElement,
|
||||
sourcePath?: string
|
||||
): Promise<any>;
|
||||
page(path: string): any;
|
||||
pages(source: string): any[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Type-safe interface for accessing Obsidian plugins
|
||||
* Extended App interface to safely access internal plugin APIs
|
||||
*/
|
||||
export interface ObsidianApp extends App {
|
||||
plugins?: {
|
||||
plugins?: {
|
||||
dataview?: {
|
||||
api?: DataviewApi;
|
||||
};
|
||||
};
|
||||
enabledPlugins?: Set<string>;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Extended window interface for Dataview API access
|
||||
* Dataview may expose its API on the global window object
|
||||
*/
|
||||
declare global {
|
||||
interface Window {
|
||||
DataviewAPI?: DataviewApi;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for mapping Kanban column names to checkbox states
|
||||
* Allows custom checkbox states for different workflow stages
|
||||
*/
|
||||
export interface KanbanColumnCheckboxMapping {
|
||||
columnName: string;
|
||||
checkboxState: string; // e.g., "[ ]", "[/]", "[x]", "[>]", etc.
|
||||
}
|
||||
|
||||
/**
|
||||
* Structure for storing Kanban column data with items
|
||||
*/
|
||||
export interface KanbanColumn {
|
||||
items: Array<{ text: string }>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Type for parsed Kanban board structure
|
||||
*/
|
||||
export type KanbanBoard = Record<string, KanbanColumn>;
|
||||
|
||||
/**
|
||||
* Interface for card movement tracking
|
||||
*/
|
||||
export interface CardMovement {
|
||||
card: string;
|
||||
oldColumn: string;
|
||||
newColumn: string;
|
||||
cardIndex: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for normalization detection detector state
|
||||
*/
|
||||
export interface NormalizationDetectorState {
|
||||
preChangeCheckpoints: Map<number, string>;
|
||||
lastKanbanUIInteraction: number;
|
||||
pendingNormalizationCheck: number | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for checkbox normalization patterns analysis result
|
||||
*/
|
||||
export interface CheckboxNormalizationAnalysis {
|
||||
hasNormalization: boolean;
|
||||
normalizedStates: Array<{ line: number; from: string; to: string }>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for extracted Obsidian-style links
|
||||
*/
|
||||
export interface ObsidianLink {
|
||||
path: string;
|
||||
alias?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for extracted Markdown-style links
|
||||
*/
|
||||
export interface MarkdownLink {
|
||||
text: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for card content extraction result
|
||||
*/
|
||||
export interface CardContent {
|
||||
content: string;
|
||||
lineCount: number;
|
||||
}
|
||||
503
src/main.ts
503
src/main.ts
|
|
@ -1,503 +0,0 @@
|
|||
/**
|
||||
* Progress Tracker Plugin for Obsidian
|
||||
*
|
||||
* A plugin that tracks task progress in markdown files and integrates with Kanban boards.
|
||||
* Supports custom checkbox states and automatic status updates.
|
||||
*/
|
||||
|
||||
import {
|
||||
App,
|
||||
Plugin,
|
||||
WorkspaceLeaf,
|
||||
TFile,
|
||||
MarkdownView,
|
||||
debounce,
|
||||
} from "obsidian";
|
||||
|
||||
// Import interfaces and types
|
||||
import { TaskProgressBarSettings, DEFAULT_SETTINGS } from "./interfaces/settings";
|
||||
import { DataviewApi } from "./interfaces/types";
|
||||
|
||||
// Import utilities
|
||||
import { DebugLogger } from "./utils/logger";
|
||||
|
||||
// Import services
|
||||
import { DataviewService } from "./services/DataviewService";
|
||||
import { FileService } from "./services/FileService";
|
||||
import { KanbanService } from "./services/KanbanService";
|
||||
|
||||
// Import views
|
||||
import { TaskProgressBarView } from "./views/ProgressBarView";
|
||||
import { TaskProgressBarSettingTab } from "./views/SettingsTab";
|
||||
|
||||
/**
|
||||
* Main plugin class for Progress Tracker
|
||||
*/
|
||||
export default class TaskProgressBarPlugin extends Plugin {
|
||||
settings: TaskProgressBarSettings;
|
||||
dvAPI: DataviewApi | null = null;
|
||||
sidebarView: TaskProgressBarView | null = null;
|
||||
|
||||
// Services
|
||||
private dataviewService: DataviewService;
|
||||
private fileService: FileService;
|
||||
private kanbanService: KanbanService;
|
||||
|
||||
// Internal state
|
||||
private lastActiveFile: TFile | null = null;
|
||||
private lastFileContent: string = "";
|
||||
private logger: DebugLogger;
|
||||
|
||||
async onload() {
|
||||
await this.loadSettings();
|
||||
|
||||
// Initialize debug logger
|
||||
this.logger = new DebugLogger(() => this.settings.showDebugInfo);
|
||||
|
||||
// Initialize services
|
||||
this.dataviewService = new DataviewService(this.app, this.logger);
|
||||
this.fileService = new FileService(this.app, this.logger);
|
||||
this.kanbanService = new KanbanService(
|
||||
this.app,
|
||||
this.settings,
|
||||
this.logger,
|
||||
this.fileService
|
||||
);
|
||||
|
||||
// Apply the max-height CSS style as soon as the plugin loads
|
||||
this.applyMaxTabsHeightStyle();
|
||||
|
||||
// Register view type for the sidebar
|
||||
this.registerView(
|
||||
"progress-tracker",
|
||||
(leaf) => {
|
||||
this.sidebarView = new TaskProgressBarView(
|
||||
leaf,
|
||||
this.app,
|
||||
this.settings,
|
||||
this.logger,
|
||||
this.dvAPI
|
||||
);
|
||||
|
||||
// Inject KanbanService for Kanban integration
|
||||
this.sidebarView.setKanbanService(this.kanbanService);
|
||||
|
||||
return this.sidebarView;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// Add icon to the left sidebar
|
||||
this.addRibbonIcon("bar-chart-horizontal", "Progress Tracker", () => {
|
||||
this.activateView();
|
||||
});
|
||||
|
||||
// Add settings tab
|
||||
this.addSettingTab(new TaskProgressBarSettingTab(this.app, this));
|
||||
|
||||
// Check Dataview API and set up interval to check again if not found
|
||||
this.checkDataviewAPI();
|
||||
|
||||
// Register event handlers
|
||||
this.registerEventHandlers();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all event handlers for the plugin
|
||||
*/
|
||||
private registerEventHandlers(): void {
|
||||
// Register event to update progress bar when file changes
|
||||
this.registerEvent(
|
||||
this.app.workspace.on("file-open", (file) => {
|
||||
if (file) {
|
||||
this.lastActiveFile = file;
|
||||
|
||||
// Handle auto-sync for Kanban boards
|
||||
if (
|
||||
this.settings.enableKanbanAutoSync &&
|
||||
this.settings.enableCustomCheckboxStates &&
|
||||
this.kanbanService.isKanbanBoard(file) &&
|
||||
!this.kanbanService.hasBeenAutoSynced(file.path) &&
|
||||
!this.kanbanService.getIsUpdatingFromKanban()
|
||||
) {
|
||||
this.logger.log(`Auto-syncing Kanban board on open: ${file.path}`);
|
||||
|
||||
setTimeout(async () => {
|
||||
if (
|
||||
!this.kanbanService.getIsUpdatingFromKanban() &&
|
||||
!this.kanbanService.getLastKanbanContent(file.path)
|
||||
) {
|
||||
await this.kanbanService.autoSyncKanbanCheckboxStates(file);
|
||||
} else {
|
||||
this.logger.log(
|
||||
`Skipping auto-sync - update in progress or file already tracked`
|
||||
);
|
||||
}
|
||||
}, 800);
|
||||
}
|
||||
|
||||
// Original progress bar update logic
|
||||
setTimeout(async () => {
|
||||
await this.updateLastFileContent(file);
|
||||
if (this.sidebarView) {
|
||||
this.sidebarView.updateProgressBar(file);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
// Register event to listen for file modifications (for Kanban UI changes)
|
||||
this.registerEvent(
|
||||
this.app.vault.on("modify", async (file) => {
|
||||
if (
|
||||
file instanceof TFile &&
|
||||
this.settings.enableKanbanToFileSync &&
|
||||
this.settings.enableCustomCheckboxStates &&
|
||||
this.kanbanService.isKanbanBoard(file)
|
||||
) {
|
||||
this.logger.log(`File modified event for Kanban board: ${file.path}`);
|
||||
|
||||
if (this.kanbanService.getIsUpdatingFromKanban()) {
|
||||
this.logger.log("Skipping file modify - currently updating from plugin");
|
||||
return;
|
||||
}
|
||||
|
||||
setTimeout(async () => {
|
||||
try {
|
||||
const newContent = await this.app.vault.read(file);
|
||||
await this.kanbanService.handleKanbanBoardChange(file, newContent);
|
||||
} catch (error) {
|
||||
this.logger.error("Error handling file modify for Kanban board:", error as Error);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
// Register event to update progress bar when editor changes
|
||||
this.registerEvent(
|
||||
this.app.workspace.on(
|
||||
"editor-change",
|
||||
debounce(async (editor, view) => {
|
||||
if (view instanceof MarkdownView && this.sidebarView) {
|
||||
if (this.kanbanService.getIsUpdatingFromKanban()) {
|
||||
this.logger.log("Skipping editor-change - currently updating from Kanban");
|
||||
return;
|
||||
}
|
||||
|
||||
const content = editor.getValue();
|
||||
const currentFile = view.file;
|
||||
|
||||
// Check if this is a Kanban board file and handle card checkbox sync
|
||||
if (
|
||||
this.settings.enableKanbanToFileSync &&
|
||||
this.settings.enableCustomCheckboxStates &&
|
||||
currentFile &&
|
||||
this.kanbanService.isKanbanBoard(currentFile)
|
||||
) {
|
||||
this.logger.log(`Detected Kanban board change: ${currentFile.path}`);
|
||||
|
||||
// Enhanced immediate Kanban normalization protection
|
||||
if (this.settings.enableKanbanNormalizationProtection) {
|
||||
const hasImmediateNormalization =
|
||||
this.kanbanService.detectImmediateKanbanNormalization(
|
||||
this.lastFileContent,
|
||||
content
|
||||
);
|
||||
this.logger.log(`Immediate normalization check: ${hasImmediateNormalization}`);
|
||||
|
||||
if (hasImmediateNormalization) {
|
||||
this.logger.log("Detected immediate Kanban normalization - reverting unwanted changes");
|
||||
const revertedContent = this.kanbanService.revertKanbanNormalization(
|
||||
this.lastFileContent,
|
||||
content,
|
||||
currentFile
|
||||
);
|
||||
|
||||
if (revertedContent !== content) {
|
||||
this.kanbanService.setIsUpdatingFromKanban(true);
|
||||
|
||||
setTimeout(async () => {
|
||||
const syncedContent =
|
||||
await this.kanbanService.syncAllCheckboxStatesToMappings(
|
||||
currentFile,
|
||||
revertedContent
|
||||
);
|
||||
await this.app.vault.modify(currentFile, syncedContent);
|
||||
this.lastFileContent = syncedContent;
|
||||
await this.kanbanService.forceRefreshKanbanUI(currentFile);
|
||||
|
||||
setTimeout(() => {
|
||||
this.kanbanService.setIsUpdatingFromKanban(false);
|
||||
}, 100);
|
||||
}, 50);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(async () => {
|
||||
const latestContent = await this.app.vault.read(currentFile);
|
||||
await this.kanbanService.handleKanbanBoardChange(currentFile, latestContent);
|
||||
}, 200);
|
||||
}
|
||||
|
||||
// Original logic for regular file changes
|
||||
if (
|
||||
content.includes("- [") ||
|
||||
this.lastFileContent.includes("- [") ||
|
||||
/- \[[^\]]*\]/.test(content) ||
|
||||
/- \[[^\]]*\]/.test(this.lastFileContent)
|
||||
) {
|
||||
const hasContentChanged = this.hasTaskContentChanged(
|
||||
this.lastFileContent,
|
||||
content
|
||||
);
|
||||
|
||||
if (hasContentChanged) {
|
||||
this.lastFileContent = content;
|
||||
|
||||
if (currentFile) {
|
||||
this.sidebarView.updateProgressBar(currentFile, content);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, this.settings.editorChangeDelay)
|
||||
)
|
||||
);
|
||||
|
||||
// Listen for keydown events to detect when user enters new tasks or checks/unchecks tasks
|
||||
this.registerDomEvent(document, "keydown", (evt: KeyboardEvent) => {
|
||||
// Check if we're in the editor
|
||||
const activeView = this.app.workspace.getActiveViewOfType(MarkdownView);
|
||||
if (activeView && activeView.getMode() === "source") {
|
||||
// Update immediately when pressing keys related to tasks
|
||||
if (
|
||||
["Enter", "Space", "]", "x", "X", "Backspace", "Delete"].includes(evt.key)
|
||||
) {
|
||||
// Update immediately
|
||||
setTimeout(() => {
|
||||
const content = activeView.editor.getValue();
|
||||
|
||||
// Check if content contains tasks and if they have changed (enhanced for custom states)
|
||||
if (
|
||||
(content.includes("- [") || /- \[[^\]]*\]/.test(content)) &&
|
||||
this.hasTaskContentChanged(this.lastFileContent, content)
|
||||
) {
|
||||
this.lastActiveFile = activeView.file;
|
||||
|
||||
// Update progress bar immediately
|
||||
if (this.sidebarView) {
|
||||
this.sidebarView.updateProgressBar(activeView.file, content);
|
||||
}
|
||||
|
||||
// Then update last file content
|
||||
this.lastFileContent = content;
|
||||
}
|
||||
}, this.settings.keyboardInputDelay);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Listen for click events in the editor to detect when tasks are checked/unchecked
|
||||
this.registerDomEvent(document, "click", (evt: MouseEvent) => {
|
||||
const target = evt.target as HTMLElement;
|
||||
|
||||
// Check if click is on a task checkbox
|
||||
if (
|
||||
target &&
|
||||
target.tagName === "INPUT" &&
|
||||
target.classList.contains("task-list-item-checkbox")
|
||||
) {
|
||||
// Wait a bit for Obsidian to update the task state in the file
|
||||
setTimeout(async () => {
|
||||
const activeFile = this.app.workspace.getActiveFile();
|
||||
if (activeFile && this.sidebarView) {
|
||||
// Read current file content
|
||||
const content = await this.app.vault.read(activeFile);
|
||||
|
||||
// Only update if tasks have changed
|
||||
if (this.hasTaskContentChanged(this.lastFileContent, content)) {
|
||||
// Update progress bar immediately
|
||||
this.lastActiveFile = activeFile;
|
||||
this.sidebarView.updateProgressBar(activeFile, content);
|
||||
|
||||
// Then update last file content
|
||||
this.lastFileContent = content;
|
||||
}
|
||||
}
|
||||
}, this.settings.checkboxClickDelay);
|
||||
}
|
||||
});
|
||||
|
||||
// Activate view when plugin loads - wait a bit for Obsidian to fully start
|
||||
setTimeout(() => {
|
||||
this.activateView();
|
||||
|
||||
// We'll use a single delayed update instead of multiple updates
|
||||
setTimeout(async () => {
|
||||
const currentFile = this.app.workspace.getActiveFile();
|
||||
if (currentFile && this.sidebarView) {
|
||||
this.logger.log("Initial file load after plugin start:", currentFile.path);
|
||||
|
||||
await this.updateLastFileContent(currentFile);
|
||||
// Use a flag to indicate this is the initial load
|
||||
this.sidebarView.updateProgressBar(currentFile, undefined, true);
|
||||
}
|
||||
}, 1500);
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if task content has changed between two versions
|
||||
*/
|
||||
private hasTaskContentChanged(oldContent: string, newContent: string): boolean {
|
||||
// Quick length check first
|
||||
if (oldContent.length !== newContent.length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Extract task lines for comparison
|
||||
const oldTaskLines = oldContent
|
||||
.split("\n")
|
||||
.filter((line) => /- \[[^\]]*\]/.test(line));
|
||||
const newTaskLines = newContent
|
||||
.split("\n")
|
||||
.filter((line) => /- \[[^\]]*\]/.test(line));
|
||||
|
||||
// Check if number of tasks changed
|
||||
if (oldTaskLines.length !== newTaskLines.length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if any task content changed
|
||||
for (let i = 0; i < oldTaskLines.length; i++) {
|
||||
if (oldTaskLines[i] !== newTaskLines[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the cached file content
|
||||
*/
|
||||
private async updateLastFileContent(file: TFile): Promise<void> {
|
||||
try {
|
||||
this.lastFileContent = await this.app.vault.read(file);
|
||||
} catch (error) {
|
||||
this.logger.error("Error reading file content:", error as Error);
|
||||
}
|
||||
}
|
||||
|
||||
async onunload() {
|
||||
// Cleanup services
|
||||
this.dataviewService.cleanup();
|
||||
this.fileService.cleanup();
|
||||
this.kanbanService.cleanup();
|
||||
}
|
||||
|
||||
async loadSettings() {
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
||||
}
|
||||
|
||||
async saveSettings() {
|
||||
await this.saveData(this.settings);
|
||||
|
||||
// Update services with new settings
|
||||
if (this.kanbanService) {
|
||||
this.kanbanService.updateSettings(this.settings);
|
||||
}
|
||||
if (this.sidebarView) {
|
||||
this.sidebarView.updateSettings(this.settings);
|
||||
}
|
||||
|
||||
// Apply max tabs height style
|
||||
this.applyMaxTabsHeightStyle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply max-height style to workspace tabs
|
||||
*/
|
||||
private applyMaxTabsHeightStyle(): void {
|
||||
const styleId = "progress-tracker-max-tabs-height";
|
||||
let styleEl = document.getElementById(styleId);
|
||||
|
||||
if (!styleEl) {
|
||||
styleEl = document.createElement("style");
|
||||
styleEl.id = styleId;
|
||||
document.head.appendChild(styleEl);
|
||||
}
|
||||
|
||||
const maxHeight = this.settings.maxTabsHeight || "auto";
|
||||
styleEl.textContent = `
|
||||
.workspace-tabs:has(.workspace-tab-container .progress-tracker-leaf) {
|
||||
max-height: ${maxHeight};
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check and initialize Dataview API
|
||||
*/
|
||||
checkDataviewAPI(): void {
|
||||
this.dvAPI = this.dataviewService.getDataviewAPI();
|
||||
|
||||
if (this.dvAPI) {
|
||||
this.logger.log("Dataview API found and cached");
|
||||
|
||||
// Update the sidebar view with the new API
|
||||
if (this.sidebarView) {
|
||||
this.sidebarView.updateDataviewAPI(this.dvAPI);
|
||||
}
|
||||
} else {
|
||||
this.logger.log("Dataview API not found, starting periodic check");
|
||||
this.dataviewService.startPeriodicCheck((api) => {
|
||||
this.dvAPI = api;
|
||||
if (this.sidebarView) {
|
||||
this.sidebarView.updateDataviewAPI(this.dvAPI);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate the sidebar view
|
||||
*/
|
||||
async activateView(): Promise<void> {
|
||||
const { workspace } = this.app;
|
||||
|
||||
// Wait for workspace to be ready
|
||||
if (!workspace.layoutReady) {
|
||||
workspace.onLayoutReady(() => this.activateView());
|
||||
return;
|
||||
}
|
||||
|
||||
let leaf: WorkspaceLeaf | null = null;
|
||||
const leaves = workspace.getLeavesOfType("progress-tracker");
|
||||
|
||||
if (leaves.length > 0) {
|
||||
leaf = leaves[0];
|
||||
} else {
|
||||
// Try to get right leaf, with fallback
|
||||
const rightLeaf = workspace.getRightLeaf(false);
|
||||
if (rightLeaf) {
|
||||
leaf = rightLeaf;
|
||||
await leaf.setViewState({ type: "progress-tracker", active: true });
|
||||
} else {
|
||||
// Fallback: create a new split in the right sidebar
|
||||
leaf = workspace.getLeaf('split', 'vertical');
|
||||
if (leaf) {
|
||||
await leaf.setViewState({ type: "progress-tracker", active: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (leaf) {
|
||||
workspace.revealLeaf(leaf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,126 +0,0 @@
|
|||
import { App } from "obsidian";
|
||||
import { DataviewApi, ObsidianApp } from "../interfaces/types";
|
||||
import { DebugLogger } from "../utils/logger";
|
||||
|
||||
/**
|
||||
* Service for managing Dataview API integration
|
||||
* Provides methods for safely accessing and checking Dataview availability
|
||||
*/
|
||||
export class DataviewService {
|
||||
private app: App;
|
||||
private logger: DebugLogger;
|
||||
private dvAPI: DataviewApi | null = null;
|
||||
private checkInterval: number | null = null;
|
||||
|
||||
constructor(app: App, logger: DebugLogger) {
|
||||
this.app = app;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely get Dataview API with proper type checking
|
||||
* @returns DataviewApi instance or null if not available
|
||||
*/
|
||||
getDataviewAPI(): DataviewApi | null {
|
||||
try {
|
||||
// Method 1: Through window object (most reliable)
|
||||
if (typeof window !== "undefined" && window.DataviewAPI) {
|
||||
return window.DataviewAPI;
|
||||
}
|
||||
|
||||
// Method 2: Through app.plugins with type safety
|
||||
const obsidianApp = this.app as ObsidianApp;
|
||||
const dataviewPlugin = obsidianApp.plugins?.plugins?.dataview;
|
||||
if (dataviewPlugin?.api) {
|
||||
return dataviewPlugin.api;
|
||||
}
|
||||
|
||||
// Method 3: Check if plugin is enabled
|
||||
const enabledPlugins = obsidianApp.plugins?.enabledPlugins;
|
||||
if (enabledPlugins?.has("dataview")) {
|
||||
// Plugin is enabled but API not ready yet
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (error) {
|
||||
console.error("Error accessing Dataview API:", error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for Dataview API availability and cache the result
|
||||
* @returns DataviewApi instance or null
|
||||
*/
|
||||
checkAndCacheAPI(): DataviewApi | null {
|
||||
this.dvAPI = this.getDataviewAPI();
|
||||
return this.dvAPI;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cached Dataview API
|
||||
* @returns Cached DataviewApi instance or null
|
||||
*/
|
||||
getCachedAPI(): DataviewApi | null {
|
||||
return this.dvAPI;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start periodic checking for Dataview API availability
|
||||
* @param onFound - Callback when Dataview API is found, receives the API instance
|
||||
* @param intervalMs - Check interval in milliseconds (default 2000)
|
||||
*/
|
||||
startPeriodicCheck(onFound?: (api: DataviewApi) => void, intervalMs: number = 2000): void {
|
||||
// Check immediately first
|
||||
this.dvAPI = this.getDataviewAPI();
|
||||
|
||||
// If found immediately, call callback
|
||||
if (this.dvAPI) {
|
||||
if (onFound) {
|
||||
onFound(this.dvAPI);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// If not found, set up interval to check again
|
||||
this.checkInterval = window.setInterval(() => {
|
||||
this.dvAPI = this.getDataviewAPI();
|
||||
if (this.dvAPI) {
|
||||
// If found, clear interval
|
||||
this.stopPeriodicCheck();
|
||||
|
||||
// Call callback if provided
|
||||
if (onFound) {
|
||||
onFound(this.dvAPI);
|
||||
}
|
||||
}
|
||||
}, intervalMs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop periodic checking for Dataview API
|
||||
*/
|
||||
stopPeriodicCheck(): void {
|
||||
if (this.checkInterval) {
|
||||
clearInterval(this.checkInterval);
|
||||
this.checkInterval = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if Dataview API is available
|
||||
* @returns true if Dataview API is available
|
||||
*/
|
||||
isAvailable(): boolean {
|
||||
return this.dvAPI !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup resources
|
||||
*/
|
||||
cleanup(): void {
|
||||
this.stopPeriodicCheck();
|
||||
this.dvAPI = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,188 +0,0 @@
|
|||
import { App, TFile, Notice } from "obsidian";
|
||||
import { DebugLogger } from "../utils/logger";
|
||||
import { validateContent } from "../utils/helpers";
|
||||
|
||||
/**
|
||||
* Service for safe file operations with validation and rate limiting
|
||||
*/
|
||||
export class FileService {
|
||||
private app: App;
|
||||
private logger: DebugLogger;
|
||||
private fileOperationLimiter: Map<string, number> = new Map();
|
||||
private readonly FILE_OPERATION_DELAY = 100; // Minimum ms between operations per file
|
||||
|
||||
constructor(app: App, logger: DebugLogger) {
|
||||
this.app = app;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate file before performing operations
|
||||
* @param file - File to validate
|
||||
* @returns true if file is safe to operate on
|
||||
*/
|
||||
isValidFile(file: TFile | null): boolean {
|
||||
if (!file) return false;
|
||||
|
||||
// Check if file path is safe (no path traversal)
|
||||
if (file.path.includes("..") || file.path.includes("//")) {
|
||||
this.logger.error(`Unsafe file path detected: ${file.path}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if file is markdown
|
||||
if (!file.path.endsWith(".md")) {
|
||||
this.logger.warn(`Non-markdown file: ${file.path}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check file size (prevent processing extremely large files)
|
||||
if (file.stat.size > 10 * 1024 * 1024) {
|
||||
// 10MB limit
|
||||
this.logger.error(
|
||||
`File too large: ${file.path} (${file.stat.size} bytes)`
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate content before processing
|
||||
* @param content - Content to validate
|
||||
* @returns true if content is safe to process
|
||||
*/
|
||||
isValidContent(content: string): boolean {
|
||||
const result = validateContent(content);
|
||||
if (!result.isValid) {
|
||||
this.logger.error(result.error || "Invalid content");
|
||||
}
|
||||
return result.isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if file operation is rate limited
|
||||
* @param filePath - Path of file to check
|
||||
* @returns true if operation should be allowed
|
||||
*/
|
||||
checkRateLimit(filePath: string): boolean {
|
||||
const now = Date.now();
|
||||
const lastOperation = this.fileOperationLimiter.get(filePath);
|
||||
|
||||
if (lastOperation && now - lastOperation < this.FILE_OPERATION_DELAY) {
|
||||
this.logger.warn(`Rate limited file operation: ${filePath}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
this.fileOperationLimiter.set(filePath, now);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe async operation wrapper with error handling
|
||||
* @param operation - Async operation to execute
|
||||
* @param context - Context description for error handling
|
||||
* @param fallbackValue - Value to return on error
|
||||
*/
|
||||
async safeAsyncOperation<T>(
|
||||
operation: () => Promise<T>,
|
||||
context: string,
|
||||
fallbackValue: T
|
||||
): Promise<T> {
|
||||
try {
|
||||
return await operation();
|
||||
} catch (error) {
|
||||
this.logger.error(
|
||||
`${context}: ${
|
||||
error instanceof Error ? error.message : String(error)
|
||||
}`,
|
||||
error instanceof Error ? error : undefined
|
||||
);
|
||||
return fallbackValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read file content safely with validation
|
||||
* @param file - File to read
|
||||
* @returns File content or null on error
|
||||
*/
|
||||
async readFileSafe(file: TFile): Promise<string | null> {
|
||||
if (!this.isValidFile(file)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.safeAsyncOperation(
|
||||
async () => {
|
||||
const content = await this.app.vault.read(file);
|
||||
if (!this.isValidContent(content)) {
|
||||
return null;
|
||||
}
|
||||
return content;
|
||||
},
|
||||
`Reading file ${file.path}`,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify file content safely with validation and rate limiting
|
||||
* @param file - File to modify
|
||||
* @param content - New content
|
||||
* @returns true if modification was successful
|
||||
*/
|
||||
async modifyFileSafe(file: TFile, content: string): Promise<boolean> {
|
||||
if (!this.isValidFile(file)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.isValidContent(content)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.checkRateLimit(file.path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.safeAsyncOperation(
|
||||
async () => {
|
||||
await this.app.vault.modify(file, content);
|
||||
return true;
|
||||
},
|
||||
`Modifying file ${file.path}`,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Standardized error handler for plugin operations
|
||||
* @param error - Error object or message
|
||||
* @param context - Context where error occurred
|
||||
* @param showNotice - Whether to show user notification
|
||||
*/
|
||||
handleError(
|
||||
error: Error | string,
|
||||
context: string,
|
||||
showNotice: boolean = false
|
||||
): void {
|
||||
const errorMessage = error instanceof Error ? error.message : error;
|
||||
const fullMessage = `${context}: ${errorMessage}`;
|
||||
|
||||
this.logger.error(
|
||||
fullMessage,
|
||||
error instanceof Error ? error : undefined
|
||||
);
|
||||
|
||||
if (showNotice) {
|
||||
new Notice(`Progress Tracker Error: ${errorMessage}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup resources
|
||||
*/
|
||||
cleanup(): void {
|
||||
this.fileOperationLimiter.clear();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,357 +0,0 @@
|
|||
/**
|
||||
* Remove code blocks from content to avoid counting tasks inside them
|
||||
* @param content - Content with potential code blocks
|
||||
* @returns Content without code blocks
|
||||
*/
|
||||
export function removeCodeBlocks(content: string): string {
|
||||
// Remove fenced code blocks (```)
|
||||
let result = content.replace(/```[\s\S]*?```/g, '');
|
||||
|
||||
// Remove inline code blocks (`)
|
||||
result = result.replace(/`[^`\n]+`/g, '');
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Task Counting
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* Interface for task count results
|
||||
*/
|
||||
export interface TaskCounts {
|
||||
incomplete: number;
|
||||
completed: number;
|
||||
customStates: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count all tasks in content with support for custom checkbox states
|
||||
* @param content - Content to parse
|
||||
* @param enableCustomCheckboxStates - Whether to use enhanced counting for custom states
|
||||
* @returns TaskCounts object with breakdown of task states
|
||||
*/
|
||||
export function countAllTasks(content: string, enableCustomCheckboxStates: boolean): TaskCounts {
|
||||
const contentWithoutCodeBlocks = removeCodeBlocks(content);
|
||||
|
||||
let incomplete = 0;
|
||||
let completed = 0;
|
||||
let customStates = 0;
|
||||
|
||||
if (enableCustomCheckboxStates) {
|
||||
// Enhanced counting for custom checkbox states
|
||||
const taskCounts = countTasksByCheckboxState(content);
|
||||
incomplete = taskCounts[" "] || 0;
|
||||
completed = taskCounts["x"] || 0;
|
||||
|
||||
// Count all custom states
|
||||
for (const [state, count] of Object.entries(taskCounts)) {
|
||||
if (state !== " " && state !== "x" && state.trim() !== "") {
|
||||
customStates += count;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Legacy counting - only [ ] and [x]
|
||||
incomplete = (contentWithoutCodeBlocks.match(/- \[ \]/g) || []).length;
|
||||
completed = (contentWithoutCodeBlocks.match(/- \[x\]/gi) || []).length;
|
||||
}
|
||||
|
||||
let total = incomplete + completed + customStates;
|
||||
|
||||
// Try relaxed regex if no tasks found
|
||||
if (total === 0) {
|
||||
incomplete = (contentWithoutCodeBlocks.match(/[-*] \[ \]/g) || []).length;
|
||||
completed = (contentWithoutCodeBlocks.match(/[-*] \[x\]/gi) || []).length;
|
||||
total = incomplete + completed;
|
||||
}
|
||||
|
||||
return { incomplete, completed, customStates, total };
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// UI Constants
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* CSS class names used throughout the plugin UI
|
||||
*/
|
||||
export const UI_CLASSES = {
|
||||
// Container classes
|
||||
PROGRESS_CONTAINER: "task-progress-container",
|
||||
PROGRESS_LAYOUT: "progress-layout",
|
||||
PROGRESS_BAR_CONTAINER: "pt-progress-bar-container",
|
||||
PROGRESS_ELEMENT: "progress-element",
|
||||
PROGRESS_VALUE: "progress-value",
|
||||
PROGRESS_STATS: "progress-stats-compact",
|
||||
PROGRESS_PERCENTAGE: "progress-percentage-small",
|
||||
|
||||
// Message classes
|
||||
NO_TASKS_MESSAGE: "no-tasks-message",
|
||||
LOADING_INDICATOR: "loading-indicator",
|
||||
DATAVIEW_WARNING: "dataview-warning-compact",
|
||||
DATAVIEW_WARNING_TEXT: "dataview-warning-text",
|
||||
DEBUG_INFO: "debug-info",
|
||||
|
||||
// Leaf classes
|
||||
PROGRESS_TRACKER_LEAF: "progress-tracker-leaf",
|
||||
} as const;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Safely escape regex special characters in a string
|
||||
* Used by multiple methods that need to create regex patterns
|
||||
* @param string - String to escape
|
||||
* @returns Escaped string safe for use in regex
|
||||
*/
|
||||
export function escapeRegExp(string: string): string {
|
||||
if (!string) return "";
|
||||
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate CSS value to prevent XSS injection
|
||||
* @param value - CSS value to validate
|
||||
* @returns true if value is safe to use
|
||||
*/
|
||||
export function isValidCSSValue(value: string): boolean {
|
||||
if (!value || typeof value !== "string") return false;
|
||||
|
||||
// Allow specific safe values
|
||||
if (value === "auto" || value === "none") return true;
|
||||
|
||||
// Allow valid CSS length values (px, em, rem, vh, %)
|
||||
const validCSSPattern = /^(\d+(\.\d+)?)(px|em|rem|vh|%)$/;
|
||||
return validCSSPattern.test(value.trim());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if content is safe to process
|
||||
* @param content - Content to validate
|
||||
* @param maxSize - Maximum allowed content size in bytes (default 5MB)
|
||||
* @returns Object with isValid flag and optional error message
|
||||
*/
|
||||
export function validateContent(
|
||||
content: string,
|
||||
maxSize: number = 5 * 1024 * 1024
|
||||
): { isValid: boolean; error?: string } {
|
||||
if (typeof content !== "string") {
|
||||
return { isValid: false, error: "Content is not a string" };
|
||||
}
|
||||
|
||||
// Check content size
|
||||
if (content.length > maxSize) {
|
||||
return {
|
||||
isValid: false,
|
||||
error: `Content too large: ${content.length} characters`,
|
||||
};
|
||||
}
|
||||
|
||||
// Check for suspicious patterns that might indicate injection
|
||||
const suspiciousPatterns = [
|
||||
/<script[^>]*>/i,
|
||||
/javascript:/i,
|
||||
/data:text\/html/i,
|
||||
/vbscript:/i,
|
||||
];
|
||||
|
||||
for (const pattern of suspiciousPatterns) {
|
||||
if (pattern.test(content)) {
|
||||
return {
|
||||
isValid: false,
|
||||
error: "Suspicious content pattern detected",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return { isValid: true };
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if content has tasks using extended pattern
|
||||
* Supports custom checkbox states like [/], [-], [~], etc.
|
||||
* @param content - Content to check
|
||||
* @returns true if content contains tasks
|
||||
*/
|
||||
export function hasTasksInContent(content: string): boolean {
|
||||
// Remove code blocks before checking for tasks
|
||||
const contentWithoutCodeBlocks = removeCodeBlocks(content);
|
||||
const extendedTaskRegex = /- \[[^\]]*\]/i;
|
||||
return extendedTaskRegex.test(contentWithoutCodeBlocks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Count tasks with different checkbox states
|
||||
* @param content - Content to parse
|
||||
* @returns Object with checkbox state as key and count as value
|
||||
*/
|
||||
export function countTasksByCheckboxState(content: string): {
|
||||
[state: string]: number;
|
||||
} {
|
||||
const taskCounts: { [state: string]: number } = {};
|
||||
|
||||
// Remove code blocks before counting tasks
|
||||
const contentWithoutCodeBlocks = removeCodeBlocks(content);
|
||||
const lines = contentWithoutCodeBlocks.split("\n");
|
||||
|
||||
for (const line of lines) {
|
||||
const match = line.trim().match(/^- \[([^\]]*)\]/);
|
||||
if (match) {
|
||||
const state = match[1];
|
||||
taskCounts[state] = (taskCounts[state] || 0) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return taskCounts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if content changes are related to tasks
|
||||
* Supports custom checkbox states like [/], [-], [~], etc.
|
||||
* @param oldContent - Previous file content
|
||||
* @param newContent - Current file content
|
||||
* @returns true if task-related changes detected
|
||||
*/
|
||||
export function hasTaskContentChanged(
|
||||
oldContent: string,
|
||||
newContent: string
|
||||
): boolean {
|
||||
// Remove code blocks before comparing
|
||||
const oldContentWithoutCodeBlocks = removeCodeBlocks(oldContent);
|
||||
const newContentWithoutCodeBlocks = removeCodeBlocks(newContent);
|
||||
|
||||
// Split content into lines
|
||||
const oldLines = oldContentWithoutCodeBlocks.split("\n");
|
||||
const newLines = newContentWithoutCodeBlocks.split("\n");
|
||||
|
||||
// Find task lines in both contents - support all checkbox states
|
||||
const oldTasks = oldLines.filter((line) =>
|
||||
line.trim().match(/^[-*] \[[^\]]*\]/i)
|
||||
);
|
||||
const newTasks = newLines.filter((line) =>
|
||||
line.trim().match(/^[-*] \[[^\]]*\]/i)
|
||||
);
|
||||
|
||||
// Compare task count
|
||||
if (oldTasks.length !== newTasks.length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Compare each task
|
||||
for (let i = 0; i < oldTasks.length; i++) {
|
||||
if (oldTasks[i] !== newTasks[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize card content for comparison by removing checkbox states and extra whitespace
|
||||
* This allows us to detect card movements regardless of checkbox state changes
|
||||
* @param cardContent - Card content to normalize
|
||||
* @returns Normalized card content
|
||||
*/
|
||||
export function normalizeCardContentForComparison(cardContent: string): string {
|
||||
return cardContent
|
||||
.replace(/^(\s*- )\[[^\]]*\](.*)$/gm, "$1$2") // Remove checkbox states
|
||||
.trim(); // Remove extra whitespace
|
||||
}
|
||||
|
||||
/**
|
||||
* Update checkbox state in a single card text
|
||||
* Only updates the main card checkbox, preserving sub-items and nested checkboxes
|
||||
* @param cardText - Card text to update
|
||||
* @param targetCheckboxState - Target checkbox state (e.g., "[x]", "[ ]", "[/]")
|
||||
* @returns Updated card text
|
||||
*/
|
||||
export function updateCheckboxStateInCardText(
|
||||
cardText: string,
|
||||
targetCheckboxState: string
|
||||
): string {
|
||||
// Split content into lines to process only the first line (main card)
|
||||
const lines = cardText.split("\n");
|
||||
if (lines.length === 0) return cardText;
|
||||
|
||||
// Pattern to match various checkbox states: - [ ], - [x], - [/], - [>], etc.
|
||||
// Remove global flag to only match once per line
|
||||
const checkboxPattern = /^(\s*[-*] )\[[^\]]*\](.*)$/;
|
||||
|
||||
// Only update the first line if it matches the pattern (main card line)
|
||||
if (checkboxPattern.test(lines[0])) {
|
||||
lines[0] = lines[0].replace(
|
||||
checkboxPattern,
|
||||
(match, prefix, suffix) => {
|
||||
return `${prefix}${targetCheckboxState}${suffix}`;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Join lines back together, preserving sub-items unchanged
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract Obsidian-style links from content
|
||||
* @param content - Content to extract links from
|
||||
* @returns Array of objects with path and optional alias
|
||||
*/
|
||||
export function extractObsidianLinks(
|
||||
content: string
|
||||
): Array<{ path: string; alias?: string }> {
|
||||
const links: Array<{ path: string; alias?: string }> = [];
|
||||
const linkPattern = /\[\[(.*?)\]\]/g;
|
||||
let match;
|
||||
|
||||
while ((match = linkPattern.exec(content)) !== null) {
|
||||
const [_, linkContent] = match;
|
||||
const [path, alias] = linkContent.split("|").map((s) => s.trim());
|
||||
links.push({ path, alias });
|
||||
}
|
||||
|
||||
return links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract Markdown-style links from content
|
||||
* @param content - Content to extract links from
|
||||
* @returns Array of objects with text and url
|
||||
*/
|
||||
export function extractMarkdownLinks(
|
||||
content: string
|
||||
): Array<{ text: string; url: string }> {
|
||||
const links: Array<{ text: string; url: string }> = [];
|
||||
const linkPattern = /\[(.*?)\]\((.*?)\)/g;
|
||||
let match;
|
||||
|
||||
while ((match = linkPattern.exec(content)) !== null) {
|
||||
const [_, text, url] = match;
|
||||
links.push({ text: text.trim(), url: url.trim() });
|
||||
}
|
||||
|
||||
return links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the main link content from a card
|
||||
* @param cardText - Card text to extract link from
|
||||
* @returns Link path or null if not found
|
||||
*/
|
||||
export function extractMainLinkFromCard(cardText: string): string | null {
|
||||
// Look for [[link]] pattern
|
||||
const obsidianMatch = cardText.match(/\[\[([^\]]+)\]\]/);
|
||||
if (obsidianMatch) {
|
||||
return obsidianMatch[1];
|
||||
}
|
||||
|
||||
// Look for [text](url) pattern
|
||||
const markdownMatch = cardText.match(/\[([^\]]+)\]\(([^)]+)\)/);
|
||||
if (markdownMatch) {
|
||||
return markdownMatch[2]; // Return the URL part
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
/**
|
||||
* Debug logger utility that only logs when debug mode is enabled
|
||||
* Prevents console spam in production builds
|
||||
*/
|
||||
export class DebugLogger {
|
||||
private isDebugEnabled: () => boolean;
|
||||
|
||||
constructor(isDebugEnabled: () => boolean) {
|
||||
this.isDebugEnabled = isDebugEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a message with optional arguments
|
||||
* @param message - Message to log
|
||||
* @param args - Additional arguments to log
|
||||
*/
|
||||
log(message: string, ...args: any[]): void {
|
||||
if (this.isDebugEnabled()) {
|
||||
console.log(`[Progress Tracker] ${message}`, ...args);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an error message with optional error object
|
||||
* @param message - Error message
|
||||
* @param error - Optional error object
|
||||
*/
|
||||
error(message: string, error?: Error): void {
|
||||
if (this.isDebugEnabled()) {
|
||||
console.error(`[Progress Tracker ERROR] ${message}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a warning message with optional arguments
|
||||
* @param message - Warning message
|
||||
* @param args - Additional arguments to log
|
||||
*/
|
||||
warn(message: string, ...args: any[]): void {
|
||||
if (this.isDebugEnabled()) {
|
||||
console.warn(`[Progress Tracker WARNING] ${message}`, ...args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
import { App, SuggestModal, TFile } from "obsidian";
|
||||
|
||||
/**
|
||||
* Helper class for file picking in settings
|
||||
*/
|
||||
export class FileSuggestModal extends SuggestModal<TFile> {
|
||||
onChooseItem: (file: TFile) => void;
|
||||
|
||||
constructor(app: App) {
|
||||
super(app);
|
||||
this.onChooseItem = () => {}; // Default empty implementation
|
||||
}
|
||||
|
||||
getSuggestions(query: string): TFile[] {
|
||||
const files = this.app.vault.getMarkdownFiles();
|
||||
// Filter to only show potential Kanban board files
|
||||
const kanbanFiles = files.filter((file) => {
|
||||
// Show all Markdown files when no query
|
||||
if (!query) return true;
|
||||
// Otherwise filter by name/path containing the query
|
||||
return file.path.toLowerCase().includes(query.toLowerCase());
|
||||
});
|
||||
return kanbanFiles;
|
||||
}
|
||||
|
||||
renderSuggestion(file: TFile, el: HTMLElement) {
|
||||
el.createEl("div", { text: file.path });
|
||||
}
|
||||
|
||||
// Implement the required abstract method
|
||||
onChooseSuggestion(file: TFile, evt: MouseEvent | KeyboardEvent) {
|
||||
if (this.onChooseItem) {
|
||||
this.onChooseItem(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,566 +0,0 @@
|
|||
import {
|
||||
App,
|
||||
WorkspaceLeaf,
|
||||
TFile,
|
||||
ItemView,
|
||||
Notice,
|
||||
} from "obsidian";
|
||||
import { TaskProgressBarSettings } from "../interfaces/settings";
|
||||
import { DataviewApi } from "../interfaces/types";
|
||||
import { DebugLogger } from "../utils/logger";
|
||||
import {
|
||||
hasTasksInContent,
|
||||
countAllTasks,
|
||||
UI_CLASSES,
|
||||
type TaskCounts
|
||||
} from "../utils/helpers";
|
||||
import { KanbanService } from "../services/KanbanService";
|
||||
|
||||
// ============================================================================
|
||||
// Types
|
||||
// ============================================================================
|
||||
|
||||
interface ProgressData {
|
||||
percentage: number;
|
||||
completedCount: number;
|
||||
totalTasks: number;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Progress Bar View
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* Progress bar view that displays task completion status in the sidebar
|
||||
* Refactored to use centralized helpers and KanbanService
|
||||
*/
|
||||
export class TaskProgressBarView extends ItemView {
|
||||
private settings: TaskProgressBarSettings;
|
||||
private logger: DebugLogger;
|
||||
private dvAPI: DataviewApi | null = null;
|
||||
private kanbanService: KanbanService | null = null;
|
||||
|
||||
currentFile: TFile | null = null;
|
||||
isVisible: boolean = false;
|
||||
lastUpdateTime: number = 0;
|
||||
initialLoadComplete: boolean = false;
|
||||
completedFilesMap: Map<string, boolean> = new Map();
|
||||
|
||||
constructor(
|
||||
leaf: WorkspaceLeaf,
|
||||
_app: App,
|
||||
settings: TaskProgressBarSettings,
|
||||
logger: DebugLogger,
|
||||
dvAPI: DataviewApi | null
|
||||
) {
|
||||
super(leaf);
|
||||
this.settings = settings;
|
||||
this.logger = logger;
|
||||
this.dvAPI = dvAPI;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Public API Methods
|
||||
// ============================================================================
|
||||
|
||||
updateSettings(settings: TaskProgressBarSettings): void {
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
updateDataviewAPI(dvAPI: DataviewApi | null): void {
|
||||
this.dvAPI = dvAPI;
|
||||
}
|
||||
|
||||
setKanbanService(kanbanService: KanbanService): void {
|
||||
this.kanbanService = kanbanService;
|
||||
}
|
||||
|
||||
setIsKanbanBoardFn(fn: (file: TFile) => boolean): void {
|
||||
// Keep for backwards compatibility - now uses KanbanService
|
||||
}
|
||||
|
||||
clearCompletedFilesCache(): void {
|
||||
this.completedFilesMap.clear();
|
||||
this.logger.log("Cleared completed files cache");
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// ItemView Overrides
|
||||
// ============================================================================
|
||||
|
||||
getViewType(): string {
|
||||
return "progress-tracker";
|
||||
}
|
||||
|
||||
getDisplayText(): string {
|
||||
return "Task progress bar";
|
||||
}
|
||||
|
||||
getIcon(): string {
|
||||
return "bar-chart-horizontal";
|
||||
}
|
||||
|
||||
async onOpen(): Promise<void> {
|
||||
this.isVisible = true;
|
||||
this.initialLoadComplete = false;
|
||||
|
||||
this.addLeafClasses();
|
||||
this.initializeContainer();
|
||||
|
||||
// Trigger initial update after a short delay
|
||||
setTimeout(async () => {
|
||||
const currentFile = this.app.workspace.getActiveFile();
|
||||
if (currentFile) {
|
||||
await this.updateProgressBar(currentFile, undefined, true);
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
|
||||
async onClose(): Promise<void> {
|
||||
this.isVisible = false;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Main Progress Bar Methods
|
||||
// ============================================================================
|
||||
|
||||
async updateProgressBar(
|
||||
file: TFile | null,
|
||||
content?: string,
|
||||
isInitialLoad: boolean = false
|
||||
): Promise<void> {
|
||||
if (!file) return;
|
||||
|
||||
// Throttle updates
|
||||
const now = Date.now();
|
||||
if (!isInitialLoad && now - this.lastUpdateTime < 100) return;
|
||||
this.lastUpdateTime = now;
|
||||
|
||||
this.currentFile = file;
|
||||
|
||||
const container = this.getProgressContainer();
|
||||
if (!container) return;
|
||||
|
||||
// Clear on initial load
|
||||
if (isInitialLoad || !this.initialLoadComplete) {
|
||||
container.empty();
|
||||
this.initialLoadComplete = true;
|
||||
}
|
||||
|
||||
// Add animation class if enabled
|
||||
if (this.settings.showUpdateAnimation) {
|
||||
container.classList.add("updating");
|
||||
}
|
||||
|
||||
try {
|
||||
const fileContent = content || await this.app.vault.read(file);
|
||||
|
||||
if (!hasTasksInContent(fileContent)) {
|
||||
this.showNoTasksMessage(container);
|
||||
this.logger.log("No tasks found in file:", file.path);
|
||||
} else {
|
||||
await this.createProgressBarFromContent(container, fileContent, file);
|
||||
}
|
||||
} catch (error) {
|
||||
this.showErrorMessage(container, error as Error);
|
||||
} finally {
|
||||
if (this.settings.showUpdateAnimation) {
|
||||
setTimeout(() => {
|
||||
container.classList.remove("updating");
|
||||
}, this.settings.updateAnimationDelay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Progress Bar Creation
|
||||
// ============================================================================
|
||||
|
||||
private async createProgressBarFromContent(
|
||||
container: HTMLElement,
|
||||
content: string,
|
||||
file: TFile
|
||||
): Promise<void> {
|
||||
this.logger.log(`Creating progress bar for file: ${file.path}`);
|
||||
|
||||
// Check Dataview API
|
||||
if (!this.dvAPI) {
|
||||
this.showDataviewWarning(container);
|
||||
return;
|
||||
}
|
||||
|
||||
// Count tasks using centralized helper
|
||||
const taskCounts = countAllTasks(content, this.settings.enableCustomCheckboxStates);
|
||||
|
||||
this.logger.log(
|
||||
`Task counts - incomplete: ${taskCounts.incomplete}, completed: ${taskCounts.completed}, ` +
|
||||
`custom states: ${taskCounts.customStates}, total: ${taskCounts.total}`
|
||||
);
|
||||
|
||||
if (taskCounts.total === 0) {
|
||||
this.showNoTasksMessage(container);
|
||||
return;
|
||||
}
|
||||
|
||||
const progressData: ProgressData = {
|
||||
completedCount: taskCounts.completed,
|
||||
totalTasks: taskCounts.total,
|
||||
percentage: Math.round((taskCounts.completed / taskCounts.total) * 100),
|
||||
};
|
||||
|
||||
// Update UI first for responsiveness
|
||||
this.updateProgressBarUI(container, progressData);
|
||||
|
||||
// Process async updates
|
||||
this.processAsyncUpdates(file, progressData);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// UI Update Methods
|
||||
// ============================================================================
|
||||
|
||||
private updateProgressBarUI(container: HTMLElement, data: ProgressData): void {
|
||||
const { percentage, completedCount, totalTasks } = data;
|
||||
|
||||
// Get or create UI elements
|
||||
let progressLayout = container.querySelector(`.${UI_CLASSES.PROGRESS_LAYOUT}`) as HTMLElement;
|
||||
let statsContainer = container.querySelector(`.${UI_CLASSES.PROGRESS_STATS}`) as HTMLElement;
|
||||
|
||||
if (!progressLayout || !statsContainer) {
|
||||
container.empty();
|
||||
this.createProgressBarStructure(container);
|
||||
progressLayout = container.querySelector(`.${UI_CLASSES.PROGRESS_LAYOUT}`) as HTMLElement;
|
||||
statsContainer = container.querySelector(`.${UI_CLASSES.PROGRESS_STATS}`) as HTMLElement;
|
||||
}
|
||||
|
||||
// Update percentage text
|
||||
const percentageElement = progressLayout?.querySelector(`.${UI_CLASSES.PROGRESS_PERCENTAGE}`) as HTMLElement;
|
||||
if (percentageElement) {
|
||||
percentageElement.setText(`${percentage}%`);
|
||||
}
|
||||
|
||||
// Update progress bar
|
||||
const progressValue = container.querySelector(`.${UI_CLASSES.PROGRESS_VALUE}`) as HTMLElement;
|
||||
if (progressValue) {
|
||||
if (!progressValue.hasAttribute("data-has-transition")) {
|
||||
progressValue.style.transition = "width 0.3s ease-in-out, background-color 0.3s ease";
|
||||
progressValue.setAttribute("data-has-transition", "true");
|
||||
}
|
||||
progressValue.style.width = `${percentage}%`;
|
||||
this.applyProgressColor(progressValue, percentage);
|
||||
}
|
||||
|
||||
// Update progress element data attribute
|
||||
const progressElement = container.querySelector(`.${UI_CLASSES.PROGRESS_ELEMENT}`) as HTMLElement;
|
||||
if (progressElement) {
|
||||
progressElement.setAttribute("data-percentage", percentage.toString());
|
||||
}
|
||||
|
||||
// Update stats
|
||||
if (statsContainer) {
|
||||
statsContainer.empty();
|
||||
statsContainer.createSpan({ text: `${completedCount}/${totalTasks} tasks` });
|
||||
}
|
||||
|
||||
// Update debug info
|
||||
this.updateDebugInfo(container, data);
|
||||
}
|
||||
|
||||
private createProgressBarStructure(container: HTMLElement): void {
|
||||
const progressLayout = container.createDiv({ cls: UI_CLASSES.PROGRESS_LAYOUT });
|
||||
|
||||
// Percentage text
|
||||
progressLayout.createEl("div", { cls: UI_CLASSES.PROGRESS_PERCENTAGE });
|
||||
|
||||
// Progress bar
|
||||
const progressBarContainer = progressLayout.createDiv({ cls: UI_CLASSES.PROGRESS_BAR_CONTAINER });
|
||||
const progressElement = progressBarContainer.createDiv({ cls: UI_CLASSES.PROGRESS_ELEMENT });
|
||||
progressElement.createDiv({ cls: UI_CLASSES.PROGRESS_VALUE });
|
||||
|
||||
// Stats container
|
||||
container.createDiv({ cls: UI_CLASSES.PROGRESS_STATS });
|
||||
}
|
||||
|
||||
private applyProgressColor(progressElement: HTMLElement, percentage: number): void {
|
||||
if (this.settings.progressColorScheme === "default") {
|
||||
progressElement.style.backgroundColor = "";
|
||||
return;
|
||||
}
|
||||
|
||||
let newColor = "";
|
||||
if (percentage === 100) {
|
||||
newColor = this.settings.completeProgressColor;
|
||||
} else if (percentage >= this.settings.mediumProgressThreshold) {
|
||||
newColor = this.settings.highProgressColor;
|
||||
} else if (percentage >= this.settings.lowProgressThreshold) {
|
||||
newColor = this.settings.mediumProgressColor;
|
||||
} else {
|
||||
newColor = this.settings.lowProgressColor;
|
||||
}
|
||||
|
||||
if (progressElement.style.backgroundColor !== newColor) {
|
||||
progressElement.style.backgroundColor = newColor;
|
||||
}
|
||||
}
|
||||
|
||||
private updateDebugInfo(container: HTMLElement, data: ProgressData): void {
|
||||
if (!this.settings.showDebugInfo) {
|
||||
const debugInfo = container.querySelector(`.${UI_CLASSES.DEBUG_INFO}`);
|
||||
if (debugInfo) debugInfo.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
let debugInfo = container.querySelector(`.${UI_CLASSES.DEBUG_INFO}`) as HTMLElement;
|
||||
if (!debugInfo) {
|
||||
debugInfo = container.createDiv({ cls: UI_CLASSES.DEBUG_INFO });
|
||||
} else {
|
||||
debugInfo.empty();
|
||||
}
|
||||
|
||||
const { percentage, completedCount, totalTasks } = data;
|
||||
debugInfo.createEl("p", { text: `Debug info:` });
|
||||
debugInfo.createEl("p", { text: `File: ${this.currentFile?.path}` });
|
||||
debugInfo.createEl("p", { text: `Incomplete tasks: ${totalTasks - completedCount}` });
|
||||
debugInfo.createEl("p", { text: `Completed tasks: ${completedCount}` });
|
||||
debugInfo.createEl("p", { text: `Total tasks: ${totalTasks}` });
|
||||
debugInfo.createEl("p", { text: `Percentage: ${percentage}%` });
|
||||
debugInfo.createEl("p", { text: `Update time: ${new Date().toISOString()}` });
|
||||
debugInfo.createEl("p", { text: `Color scheme: ${this.settings.progressColorScheme}` });
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Message Display Methods
|
||||
// ============================================================================
|
||||
|
||||
private showNoTasksMessage(container: HTMLElement): void {
|
||||
if (!container.querySelector(`.${UI_CLASSES.NO_TASKS_MESSAGE}`)) {
|
||||
container.empty();
|
||||
container.createEl("p", {
|
||||
text: "No tasks found in this file",
|
||||
cls: UI_CLASSES.NO_TASKS_MESSAGE,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private showDataviewWarning(container: HTMLElement): void {
|
||||
if (!container.querySelector(`.${UI_CLASSES.DATAVIEW_WARNING}`)) {
|
||||
container.empty();
|
||||
const warning = container.createDiv({ cls: UI_CLASSES.DATAVIEW_WARNING });
|
||||
warning.createEl("span", {
|
||||
text: "Dataview not available",
|
||||
cls: UI_CLASSES.DATAVIEW_WARNING_TEXT,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private showErrorMessage(container: HTMLElement, error: Error): void {
|
||||
this.logger.error("Error updating progress bar:", error);
|
||||
container.empty();
|
||||
container.createEl("p", {
|
||||
text: `Error updating progress bar: ${error.message}`,
|
||||
});
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Async Processing Methods
|
||||
// ============================================================================
|
||||
|
||||
private processAsyncUpdates(file: TFile, data: ProgressData): void {
|
||||
setTimeout(async () => {
|
||||
try {
|
||||
const { percentage, completedCount, totalTasks } = data;
|
||||
|
||||
// Calculate target status FIRST
|
||||
let targetStatus = this.settings.statusInProgress;
|
||||
if (percentage === 0) {
|
||||
targetStatus = this.settings.statusTodo;
|
||||
} else if (percentage === 100) {
|
||||
targetStatus = this.settings.statusCompleted;
|
||||
}
|
||||
|
||||
// Update status based on progress
|
||||
let statusChanged = false;
|
||||
if (this.settings.autoChangeStatus) {
|
||||
statusChanged = await this.updateStatusBasedOnProgress(file, percentage);
|
||||
|
||||
// Wait for metadata cache to update after frontmatter change
|
||||
if (statusChanged) {
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
}
|
||||
}
|
||||
|
||||
// Update Kanban boards - PASS the calculated status directly
|
||||
// instead of reading from YAML to avoid race condition
|
||||
if (this.settings.autoUpdateKanban && this.kanbanService) {
|
||||
if (statusChanged || !this.completedFilesMap.has(file.path)) {
|
||||
await this.updateKanbanBoards(file, completedCount, totalTasks, targetStatus);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle 100% completion
|
||||
if (percentage === 100 && this.settings.autoUpdateMetadata) {
|
||||
if (!this.completedFilesMap.has(file.path)) {
|
||||
await this.updateFileMetadata(file);
|
||||
this.completedFilesMap.set(file.path, true);
|
||||
}
|
||||
} else if (percentage < 100) {
|
||||
this.completedFilesMap.delete(file.path);
|
||||
}
|
||||
|
||||
// Auto-add to Kanban board
|
||||
if (
|
||||
this.settings.autoAddToKanban &&
|
||||
this.settings.autoAddKanbanBoard &&
|
||||
totalTasks > 0 &&
|
||||
!this.completedFilesMap.has(file.path) &&
|
||||
this.kanbanService
|
||||
) {
|
||||
await this.kanbanService.addFileToKanbanBoard(file);
|
||||
}
|
||||
} catch (error) {
|
||||
this.logger.error("Error in async updates:", error as Error);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Status & Metadata Methods
|
||||
// ============================================================================
|
||||
|
||||
async updateStatusBasedOnProgress(file: TFile, progressPercentage: number): Promise<boolean> {
|
||||
if (!file || !this.settings.autoChangeStatus) return false;
|
||||
|
||||
try {
|
||||
let needsUpdate = false;
|
||||
|
||||
// Determine target status
|
||||
let targetStatus = this.settings.statusInProgress;
|
||||
if (progressPercentage === 0) {
|
||||
targetStatus = this.settings.statusTodo;
|
||||
} else if (progressPercentage === 100) {
|
||||
targetStatus = this.settings.statusCompleted;
|
||||
}
|
||||
|
||||
await this.app.fileManager.processFrontMatter(file, (frontmatter) => {
|
||||
if (frontmatter["status"] !== targetStatus) {
|
||||
frontmatter["status"] = targetStatus;
|
||||
needsUpdate = true;
|
||||
}
|
||||
|
||||
if (progressPercentage < 100 && this.settings.autoUpdateFinishedDate && frontmatter["finished"]) {
|
||||
delete frontmatter["finished"];
|
||||
needsUpdate = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (needsUpdate) {
|
||||
this.logger.log(`Updated status to "${targetStatus}" for file: ${file.path}`);
|
||||
}
|
||||
|
||||
return needsUpdate;
|
||||
} catch (error) {
|
||||
this.logger.error("Error updating status:", error as Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async updateFileMetadata(file: TFile): Promise<void> {
|
||||
try {
|
||||
await this.app.fileManager.processFrontMatter(file, (frontmatter) => {
|
||||
const today = new Date().toISOString().split("T")[0];
|
||||
|
||||
if (this.settings.autoChangeStatus && frontmatter["status"] !== this.settings.statusCompleted) {
|
||||
frontmatter["status"] = this.settings.statusCompleted;
|
||||
this.logger.log(`Updating status to ${this.settings.statusCompleted} in file: ${file.path}`);
|
||||
}
|
||||
|
||||
if (this.settings.autoUpdateFinishedDate && frontmatter["finished"] !== today) {
|
||||
frontmatter["finished"] = today;
|
||||
this.logger.log(`Updating finished date to ${today} in file: ${file.path}`);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
this.logger.error("Error updating file metadata:", error as Error);
|
||||
new Notice(`Error updating metadata for ${file.basename}: ${(error as Error).message}`);
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Kanban Integration Methods
|
||||
// ============================================================================
|
||||
|
||||
async updateKanbanBoards(
|
||||
file: TFile,
|
||||
completedTasks: number,
|
||||
totalTasks: number,
|
||||
targetStatus?: string
|
||||
): Promise<void> {
|
||||
if (!this.settings.autoUpdateKanban || totalTasks === 0 || !this.kanbanService) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Use passed targetStatus if available, otherwise calculate or read from YAML
|
||||
let finalStatus: string;
|
||||
if (targetStatus) {
|
||||
// Use the status passed from processAsyncUpdates (already calculated)
|
||||
finalStatus = targetStatus;
|
||||
this.logger.log(`Using passed target status for ${file.path}: ${finalStatus}`);
|
||||
} else {
|
||||
// Fallback: Calculate status from progress
|
||||
const currentStatus = this.kanbanService.calculateStatusFromProgress(completedTasks, totalTasks);
|
||||
|
||||
// Get status from YAML if available
|
||||
const statusFromYaml = await this.kanbanService.getStatusFromYaml(file);
|
||||
finalStatus = statusFromYaml || currentStatus;
|
||||
}
|
||||
|
||||
this.logger.log(`Updating Kanban boards for ${file.path} with status: ${finalStatus}`);
|
||||
|
||||
// Process Kanban boards using the service
|
||||
const updatedBoardCount = await this.kanbanService.processKanbanBoardsForFile(file, finalStatus);
|
||||
|
||||
if (updatedBoardCount > 0) {
|
||||
new Notice(
|
||||
`Updated ${updatedBoardCount} Kanban board${updatedBoardCount > 1 ? "s" : ""} ` +
|
||||
`to move ${file.basename} to ${finalStatus} column`
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
this.logger.error("Error updating Kanban boards:", error as Error);
|
||||
new Notice(`Error updating Kanban boards: ${(error as Error).message}`);
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Helper Methods
|
||||
// ============================================================================
|
||||
|
||||
private addLeafClasses(): void {
|
||||
const leaf = this.leaf as any;
|
||||
if (leaf?.containerEl) {
|
||||
leaf.containerEl.addClass(UI_CLASSES.PROGRESS_TRACKER_LEAF);
|
||||
}
|
||||
|
||||
const parentLeaf = this.containerEl.closest(".workspace-leaf");
|
||||
if (parentLeaf) {
|
||||
parentLeaf.addClass(UI_CLASSES.PROGRESS_TRACKER_LEAF);
|
||||
}
|
||||
}
|
||||
|
||||
private initializeContainer(): void {
|
||||
const container = this.containerEl.children[1];
|
||||
container.empty();
|
||||
|
||||
const progressContainer = container.createDiv({ cls: UI_CLASSES.PROGRESS_CONTAINER });
|
||||
progressContainer.createEl("p", {
|
||||
text: "Loading task progress...",
|
||||
cls: UI_CLASSES.LOADING_INDICATOR,
|
||||
});
|
||||
}
|
||||
|
||||
private getProgressContainer(): HTMLElement | null {
|
||||
const container = this.containerEl.children[1];
|
||||
return container.querySelector(`.${UI_CLASSES.PROGRESS_CONTAINER}`) as HTMLElement;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,997 +0,0 @@
|
|||
import {
|
||||
App,
|
||||
PluginSettingTab,
|
||||
Setting,
|
||||
TFile,
|
||||
Notice,
|
||||
Plugin,
|
||||
} from "obsidian";
|
||||
import { TaskProgressBarSettings, DEFAULT_SETTINGS } from "../interfaces/settings";
|
||||
import { DataviewApi } from "../interfaces/types";
|
||||
import { FileSuggestModal } from "./FileModal";
|
||||
import { TaskProgressBarView } from "./ProgressBarView";
|
||||
|
||||
/**
|
||||
* Interface for the plugin to interact with the settings tab
|
||||
*/
|
||||
export interface SettingsTabPlugin extends Plugin {
|
||||
settings: TaskProgressBarSettings;
|
||||
dvAPI: DataviewApi | null;
|
||||
sidebarView: TaskProgressBarView | null;
|
||||
checkDataviewAPI(): void;
|
||||
saveSettings(): Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings tab for the Task Progress Bar plugin
|
||||
*/
|
||||
export class TaskProgressBarSettingTab extends PluginSettingTab {
|
||||
plugin: SettingsTabPlugin;
|
||||
|
||||
constructor(app: App, plugin: SettingsTabPlugin) {
|
||||
super(app, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
display(): void {
|
||||
const { containerEl } = this;
|
||||
|
||||
containerEl.empty();
|
||||
|
||||
// Add Dataview status information
|
||||
const dataviewStatus = containerEl.createDiv({
|
||||
cls: "dataview-status",
|
||||
});
|
||||
if (this.plugin.dvAPI) {
|
||||
dataviewStatus.createEl("p", {
|
||||
text: "✅ Dataview API is available",
|
||||
cls: "dataview-available",
|
||||
});
|
||||
} else {
|
||||
dataviewStatus.createEl("p", {
|
||||
text: "❌ Dataview API is not available",
|
||||
cls: "dataview-unavailable",
|
||||
});
|
||||
|
||||
// Add button to check for Dataview again
|
||||
const checkButton = dataviewStatus.createEl("button", {
|
||||
text: "Check for Dataview",
|
||||
cls: "mod-cta",
|
||||
});
|
||||
checkButton.addEventListener("click", () => {
|
||||
this.plugin.checkDataviewAPI();
|
||||
if (this.plugin.dvAPI) {
|
||||
new Notice("Dataview API found!");
|
||||
this.display(); // Refresh settings tab
|
||||
} else {
|
||||
new Notice(
|
||||
"Dataview API not found. Make sure Dataview plugin is installed and enabled."
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Show debug info")
|
||||
.setDesc(
|
||||
"Show debug information in the sidebar to help troubleshoot task counting issues"
|
||||
)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.showDebugInfo)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.showDebugInfo = value;
|
||||
await this.plugin.saveSettings();
|
||||
|
||||
// Update sidebar if open - use public method
|
||||
const currentFile = this.app.workspace.getActiveFile();
|
||||
if (currentFile) {
|
||||
// Use public method to update UI
|
||||
this.plugin.checkDataviewAPI();
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
// Animation settings section
|
||||
new Setting(containerEl).setName("Animation").setHeading();
|
||||
|
||||
// Add new setting for animation
|
||||
new Setting(containerEl)
|
||||
.setName("Show update animation")
|
||||
.setDesc("Show a brief animation when updating the progress bar")
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.showUpdateAnimation)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.showUpdateAnimation = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
// Performance settings section
|
||||
new Setting(containerEl).setName("Performance").setHeading();
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Editor change delay")
|
||||
.setDesc(
|
||||
"Delay before updating after editor content changes (lower = more responsive, higher = better performance)"
|
||||
)
|
||||
.addSlider((slider) =>
|
||||
slider
|
||||
.setLimits(100, 1000, 50)
|
||||
.setValue(this.plugin.settings.editorChangeDelay)
|
||||
.setDynamicTooltip()
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.editorChangeDelay = value;
|
||||
await this.plugin.saveSettings();
|
||||
new Notice(
|
||||
"Editor change delay updated. Restart plugin to apply changes."
|
||||
);
|
||||
})
|
||||
)
|
||||
.addExtraButton((button) =>
|
||||
button
|
||||
.setIcon("reset")
|
||||
.setTooltip("Reset to default (500ms)")
|
||||
.onClick(async () => {
|
||||
this.plugin.settings.editorChangeDelay = 500;
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
new Notice(
|
||||
"Editor change delay reset. Restart plugin to apply changes."
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Keyboard input delay")
|
||||
.setDesc(
|
||||
"Delay after keyboard input before updating progress (in milliseconds)"
|
||||
)
|
||||
.addSlider((slider) =>
|
||||
slider
|
||||
.setLimits(100, 1000, 50)
|
||||
.setValue(this.plugin.settings.keyboardInputDelay)
|
||||
.setDynamicTooltip()
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.keyboardInputDelay = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
)
|
||||
.addExtraButton((button) =>
|
||||
button
|
||||
.setIcon("reset")
|
||||
.setTooltip("Reset to default (100ms)")
|
||||
.onClick(async () => {
|
||||
this.plugin.settings.keyboardInputDelay = 100;
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Checkbox click delay")
|
||||
.setDesc(
|
||||
"Delay after checkbox click before updating progress (in milliseconds)"
|
||||
)
|
||||
.addSlider((slider) =>
|
||||
slider
|
||||
.setLimits(100, 1000, 50)
|
||||
.setValue(this.plugin.settings.checkboxClickDelay)
|
||||
.setDynamicTooltip()
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.checkboxClickDelay = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
)
|
||||
.addExtraButton((button) =>
|
||||
button
|
||||
.setIcon("reset")
|
||||
.setTooltip("Reset to default (200ms)")
|
||||
.onClick(async () => {
|
||||
this.plugin.settings.checkboxClickDelay = 200;
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
})
|
||||
);
|
||||
|
||||
// Add color scheme settings
|
||||
new Setting(containerEl).setName("Progress bar colors").setHeading();
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Color scheme")
|
||||
.setDesc("Choose a color scheme for the progress bar")
|
||||
.addDropdown((dropdown) =>
|
||||
dropdown
|
||||
.addOption("default", "Default (Theme Colors)")
|
||||
.addOption("red-orange-green", "Red-Orange-Blue-Green")
|
||||
.addOption("custom", "Custom Colors")
|
||||
.setValue(this.plugin.settings.progressColorScheme)
|
||||
.onChange(
|
||||
async (
|
||||
value: "default" | "red-orange-green" | "custom"
|
||||
) => {
|
||||
this.plugin.settings.progressColorScheme = value;
|
||||
|
||||
// Set preset colors if red-orange-green is selected
|
||||
if (value === "red-orange-green") {
|
||||
this.plugin.settings.lowProgressColor =
|
||||
"#e06c75";
|
||||
this.plugin.settings.mediumProgressColor =
|
||||
"#e5c07b";
|
||||
this.plugin.settings.highProgressColor =
|
||||
"#61afef";
|
||||
this.plugin.settings.completeProgressColor =
|
||||
"#98c379";
|
||||
|
||||
this.plugin.settings.lowProgressThreshold = 30;
|
||||
this.plugin.settings.mediumProgressThreshold = 60;
|
||||
this.plugin.settings.highProgressThreshold = 99;
|
||||
|
||||
new Notice(
|
||||
"Applied Red-Orange-Blue-Green color scheme"
|
||||
);
|
||||
}
|
||||
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
|
||||
// Update the view if open
|
||||
const currentFile =
|
||||
this.app.workspace.getActiveFile();
|
||||
if (currentFile && this.plugin.sidebarView) {
|
||||
this.plugin.sidebarView.updateProgressBar(
|
||||
currentFile
|
||||
);
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
// Only show custom color settings if custom is selected
|
||||
if (this.plugin.settings.progressColorScheme === "custom") {
|
||||
this.displayCustomColorSettings(containerEl);
|
||||
}
|
||||
|
||||
// Interface settings section
|
||||
new Setting(containerEl).setName("Interface").setHeading();
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Max tabs height")
|
||||
.setDesc(
|
||||
"Maximum height for workspace tabs (e.g., 110px, 200px, auto)"
|
||||
)
|
||||
.addText((text) => {
|
||||
text.setValue(this.plugin.settings.maxTabsHeight);
|
||||
|
||||
text.inputEl.addEventListener("blur", async () => {
|
||||
const value = text.inputEl.value;
|
||||
const isValid =
|
||||
value === "auto" ||
|
||||
value === "none" ||
|
||||
/^\d+(\.\d+)?(px|em|rem|vh|%)$/.test(value);
|
||||
|
||||
if (isValid) {
|
||||
if (this.plugin.settings.maxTabsHeight !== value) {
|
||||
this.plugin.settings.maxTabsHeight = value;
|
||||
await this.plugin.saveSettings();
|
||||
new Notice(`Max tabs height updated to ${value}`);
|
||||
}
|
||||
} else {
|
||||
new Notice(
|
||||
"Please enter 'auto', 'none' or a valid CSS length value (e.g., 110px)"
|
||||
);
|
||||
text.setValue(this.plugin.settings.maxTabsHeight);
|
||||
}
|
||||
});
|
||||
|
||||
text.inputEl.addEventListener("keydown", async (event) => {
|
||||
if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
text.inputEl.blur();
|
||||
}
|
||||
});
|
||||
|
||||
text.inputEl.style.width = "120px";
|
||||
text.inputEl.placeholder = "auto";
|
||||
|
||||
return text;
|
||||
})
|
||||
.addExtraButton((button) =>
|
||||
button
|
||||
.setIcon("reset")
|
||||
.setTooltip("Reset to default (auto)")
|
||||
.onClick(async () => {
|
||||
this.plugin.settings.maxTabsHeight = "auto";
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
new Notice("Max tabs height reset to 'auto'");
|
||||
})
|
||||
);
|
||||
|
||||
// Add Metadata Auto-Update Settings
|
||||
new Setting(containerEl).setName("Metadata auto-update").setHeading();
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Auto-update metadata")
|
||||
.setDesc(
|
||||
"Automatically update metadata when all tasks are completed"
|
||||
)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.autoUpdateMetadata)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.autoUpdateMetadata = value;
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
})
|
||||
);
|
||||
|
||||
// Only show these settings if auto-update is enabled
|
||||
if (this.plugin.settings.autoUpdateMetadata) {
|
||||
this.displayMetadataSettings(containerEl);
|
||||
}
|
||||
|
||||
// Add new section for auto-add to Kanban
|
||||
new Setting(containerEl)
|
||||
.setName("Auto-add files to Kanban board")
|
||||
.setDesc(
|
||||
"Automatically add files with tasks to a specified Kanban board if they're not already there"
|
||||
)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.autoAddToKanban)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.autoAddToKanban = value;
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
})
|
||||
);
|
||||
|
||||
if (this.plugin.settings.autoAddToKanban) {
|
||||
this.displayAutoAddKanbanSettings(containerEl);
|
||||
}
|
||||
|
||||
// Add new section for custom checkbox states
|
||||
new Setting(containerEl)
|
||||
.setName("Custom Checkbox States")
|
||||
.setDesc(
|
||||
"Configure custom checkbox states for different Kanban columns"
|
||||
)
|
||||
.setHeading();
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Enable custom checkbox states")
|
||||
.setDesc(
|
||||
"When enabled, cards will automatically update their checkbox states when moved between Kanban columns"
|
||||
)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.enableCustomCheckboxStates)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.enableCustomCheckboxStates = value;
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
})
|
||||
);
|
||||
|
||||
if (this.plugin.settings.enableCustomCheckboxStates) {
|
||||
this.displayCustomCheckboxSettings(containerEl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display custom color settings
|
||||
*/
|
||||
private displayCustomColorSettings(containerEl: HTMLElement): void {
|
||||
new Setting(containerEl)
|
||||
.setName("Low progress color")
|
||||
.setDesc(
|
||||
`Color for progress below ${this.plugin.settings.lowProgressThreshold}%`
|
||||
)
|
||||
.addText((text) =>
|
||||
text
|
||||
.setValue(this.plugin.settings.lowProgressColor)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.lowProgressColor = value;
|
||||
await this.plugin.saveSettings();
|
||||
this.updateProgressBarView();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Medium progress color")
|
||||
.setDesc(
|
||||
`Color for progress between ${this.plugin.settings.lowProgressThreshold}% and ${this.plugin.settings.mediumProgressThreshold}%`
|
||||
)
|
||||
.addText((text) =>
|
||||
text
|
||||
.setValue(this.plugin.settings.mediumProgressColor)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.mediumProgressColor = value;
|
||||
await this.plugin.saveSettings();
|
||||
this.updateProgressBarView();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("High progress color")
|
||||
.setDesc(
|
||||
`Color for progress between ${this.plugin.settings.mediumProgressThreshold}% and ${this.plugin.settings.highProgressThreshold}%`
|
||||
)
|
||||
.addText((text) =>
|
||||
text
|
||||
.setValue(this.plugin.settings.highProgressColor)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.highProgressColor = value;
|
||||
await this.plugin.saveSettings();
|
||||
this.updateProgressBarView();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Complete progress color")
|
||||
.setDesc("Color for 100% progress")
|
||||
.addText((text) =>
|
||||
text
|
||||
.setValue(this.plugin.settings.completeProgressColor)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.completeProgressColor = value;
|
||||
await this.plugin.saveSettings();
|
||||
this.updateProgressBarView();
|
||||
})
|
||||
);
|
||||
|
||||
// Add threshold settings
|
||||
new Setting(containerEl)
|
||||
.setName("Low progress threshold")
|
||||
.setDesc("Percentage below which progress is considered low")
|
||||
.addSlider((slider) =>
|
||||
slider
|
||||
.setLimits(1, 99, 1)
|
||||
.setValue(this.plugin.settings.lowProgressThreshold)
|
||||
.setDynamicTooltip()
|
||||
.onChange(async (value) => {
|
||||
if (value >= this.plugin.settings.mediumProgressThreshold) {
|
||||
value = this.plugin.settings.mediumProgressThreshold - 1;
|
||||
}
|
||||
this.plugin.settings.lowProgressThreshold = value;
|
||||
await this.plugin.saveSettings();
|
||||
this.updateProgressBarView();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Medium progress threshold")
|
||||
.setDesc("Percentage below which progress is considered medium")
|
||||
.addSlider((slider) =>
|
||||
slider
|
||||
.setLimits(1, 99, 1)
|
||||
.setValue(this.plugin.settings.mediumProgressThreshold)
|
||||
.setDynamicTooltip()
|
||||
.onChange(async (value) => {
|
||||
if (value <= this.plugin.settings.lowProgressThreshold) {
|
||||
value = this.plugin.settings.lowProgressThreshold + 1;
|
||||
}
|
||||
if (value >= this.plugin.settings.highProgressThreshold) {
|
||||
value = this.plugin.settings.highProgressThreshold - 1;
|
||||
}
|
||||
this.plugin.settings.mediumProgressThreshold = value;
|
||||
await this.plugin.saveSettings();
|
||||
this.updateProgressBarView();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("High progress threshold")
|
||||
.setDesc(
|
||||
"Percentage below which progress is considered high (but not complete)"
|
||||
)
|
||||
.addSlider((slider) =>
|
||||
slider
|
||||
.setLimits(1, 99, 1)
|
||||
.setValue(this.plugin.settings.highProgressThreshold)
|
||||
.setDynamicTooltip()
|
||||
.onChange(async (value) => {
|
||||
if (value <= this.plugin.settings.mediumProgressThreshold) {
|
||||
value = this.plugin.settings.mediumProgressThreshold + 1;
|
||||
}
|
||||
this.plugin.settings.highProgressThreshold = value;
|
||||
await this.plugin.saveSettings();
|
||||
this.updateProgressBarView();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display metadata settings
|
||||
*/
|
||||
private displayMetadataSettings(containerEl: HTMLElement): void {
|
||||
new Setting(containerEl)
|
||||
.setName("Change status")
|
||||
.setDesc(
|
||||
"Change 'status: In Progress' to 'status: Completed' when tasks reach 100%"
|
||||
)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.autoChangeStatus)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.autoChangeStatus = value;
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Update finished date")
|
||||
.setDesc(
|
||||
"Set 'finished: ' to today's date when tasks reach 100%"
|
||||
)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.autoUpdateFinishedDate)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.autoUpdateFinishedDate = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
// Show status label settings if status changing is enabled
|
||||
if (this.plugin.settings.autoChangeStatus) {
|
||||
this.displayStatusLabelSettings(containerEl);
|
||||
}
|
||||
|
||||
// Add Kanban integration settings
|
||||
new Setting(containerEl).setName("Kanban integration").setHeading();
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Update Kanban boards")
|
||||
.setDesc(
|
||||
"Automatically move cards in Kanban boards based on task status"
|
||||
)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.autoUpdateKanban)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.autoUpdateKanban = value;
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
})
|
||||
);
|
||||
|
||||
if (this.plugin.settings.autoUpdateKanban) {
|
||||
this.displayKanbanIntegrationSettings(containerEl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display status label settings
|
||||
*/
|
||||
private displayStatusLabelSettings(containerEl: HTMLElement): void {
|
||||
new Setting(containerEl)
|
||||
.setName("Todo status label")
|
||||
.setDesc("Status label for files with 0% progress")
|
||||
.addText((text) =>
|
||||
text
|
||||
.setPlaceholder("Todo")
|
||||
.setValue(this.plugin.settings.statusTodo)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.statusTodo = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
)
|
||||
.addExtraButton((button) =>
|
||||
button
|
||||
.setIcon("reset")
|
||||
.setTooltip("Reset to default")
|
||||
.onClick(async () => {
|
||||
this.plugin.settings.statusTodo = "Todo";
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("In progress status label")
|
||||
.setDesc("Status label for files with 1-99% progress")
|
||||
.addText((text) =>
|
||||
text
|
||||
.setPlaceholder("In Progress")
|
||||
.setValue(this.plugin.settings.statusInProgress)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.statusInProgress = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
)
|
||||
.addExtraButton((button) =>
|
||||
button
|
||||
.setIcon("reset")
|
||||
.setTooltip("Reset to default")
|
||||
.onClick(async () => {
|
||||
this.plugin.settings.statusInProgress = "In Progress";
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Completed status label")
|
||||
.setDesc("Status label for files with 100% progress")
|
||||
.addText((text) =>
|
||||
text
|
||||
.setPlaceholder("Completed")
|
||||
.setValue(this.plugin.settings.statusCompleted)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.statusCompleted = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
)
|
||||
.addExtraButton((button) =>
|
||||
button
|
||||
.setIcon("reset")
|
||||
.setTooltip("Reset to default")
|
||||
.onClick(async () => {
|
||||
this.plugin.settings.statusCompleted = "Completed";
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Kanban integration settings
|
||||
*/
|
||||
private displayKanbanIntegrationSettings(containerEl: HTMLElement): void {
|
||||
new Setting(containerEl)
|
||||
.setName("Sync Kanban columns with status")
|
||||
.setDesc(
|
||||
"Match Kanban column names to status values (Todo, In Progress, Completed)"
|
||||
)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.kanbanSyncWithStatus)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.kanbanSyncWithStatus = value;
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
})
|
||||
);
|
||||
|
||||
// Only show this if sync with status is disabled (legacy mode)
|
||||
if (!this.plugin.settings.kanbanSyncWithStatus) {
|
||||
new Setting(containerEl)
|
||||
.setName("Completed column name")
|
||||
.setDesc(
|
||||
"The name of the column where completed items should be moved to (e.g., 'Complete', 'Done', 'Finished')"
|
||||
)
|
||||
.addText((text) =>
|
||||
text
|
||||
.setPlaceholder("Complete")
|
||||
.setValue(this.plugin.settings.kanbanCompletedColumn)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.kanbanCompletedColumn = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
)
|
||||
.addExtraButton((button) =>
|
||||
button
|
||||
.setIcon("reset")
|
||||
.setTooltip("Reset to default (Complete)")
|
||||
.onClick(async () => {
|
||||
this.plugin.settings.kanbanCompletedColumn =
|
||||
"Complete";
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// Add Auto-detect settings
|
||||
new Setting(containerEl)
|
||||
.setName("Auto-detect Kanban boards")
|
||||
.setDesc(
|
||||
"Automatically detect files that appear to be Kanban boards"
|
||||
)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.kanbanAutoDetect)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.kanbanAutoDetect = value;
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
})
|
||||
);
|
||||
|
||||
// Note about column naming
|
||||
const infoDiv = containerEl.createDiv({
|
||||
cls: "kanban-info",
|
||||
attr: {
|
||||
style: "background: var(--background-secondary-alt); padding: 10px; border-radius: 5px; margin-top: 10px;",
|
||||
},
|
||||
});
|
||||
|
||||
infoDiv.createEl("p", {
|
||||
text: "ℹ️ Column naming tip:",
|
||||
attr: {
|
||||
style: "font-weight: bold; margin: 0 0 5px 0;",
|
||||
},
|
||||
});
|
||||
|
||||
infoDiv.createEl("p", {
|
||||
text: `To get the best results, name your Kanban columns to match the status values: "${this.plugin.settings.statusTodo}", "${this.plugin.settings.statusInProgress}", and "${this.plugin.settings.statusCompleted}".`,
|
||||
attr: {
|
||||
style: "margin: 0;",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Display auto-add to Kanban settings
|
||||
*/
|
||||
private displayAutoAddKanbanSettings(containerEl: HTMLElement): void {
|
||||
new Setting(containerEl)
|
||||
.setName("Target Kanban board")
|
||||
.setDesc(
|
||||
"The path to the Kanban board where files should be added"
|
||||
)
|
||||
.addText((text) =>
|
||||
text
|
||||
.setPlaceholder("path/to/kanban.md")
|
||||
.setValue(this.plugin.settings.autoAddKanbanBoard)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.autoAddKanbanBoard = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
// Add file picker button
|
||||
containerEl.createEl("div", {
|
||||
text: "Select Kanban board file:",
|
||||
attr: { style: "margin-left: 36px; margin-bottom: 8px;" },
|
||||
});
|
||||
|
||||
const filePickerContainer = containerEl.createEl("div", {
|
||||
attr: { style: "margin-left: 36px; margin-bottom: 12px;" },
|
||||
});
|
||||
|
||||
const filePickerButton = filePickerContainer.createEl("button", {
|
||||
text: "Browse...",
|
||||
cls: "mod-cta",
|
||||
});
|
||||
|
||||
filePickerButton.addEventListener("click", async () => {
|
||||
try {
|
||||
const modal = new FileSuggestModal(this.app);
|
||||
modal.onChooseItem = (file: TFile) => {
|
||||
if (file) {
|
||||
this.plugin.settings.autoAddKanbanBoard = file.path;
|
||||
this.plugin.saveSettings().then(() => {
|
||||
this.display();
|
||||
});
|
||||
}
|
||||
};
|
||||
modal.open();
|
||||
} catch (error) {
|
||||
new Notice(
|
||||
"Error opening file picker. Please enter the path manually."
|
||||
);
|
||||
console.error("File picker error:", error);
|
||||
}
|
||||
});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Target column")
|
||||
.setDesc(
|
||||
"The column where new files should be added (e.g., 'Todo', 'Backlog')"
|
||||
)
|
||||
.addText((text) =>
|
||||
text
|
||||
.setPlaceholder("Todo")
|
||||
.setValue(this.plugin.settings.autoAddKanbanColumn)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.autoAddKanbanColumn = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
)
|
||||
.addExtraButton((button) =>
|
||||
button
|
||||
.setIcon("reset")
|
||||
.setTooltip("Reset to default (Todo)")
|
||||
.onClick(async () => {
|
||||
this.plugin.settings.autoAddKanbanColumn = "Todo";
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display custom checkbox settings
|
||||
*/
|
||||
private displayCustomCheckboxSettings(containerEl: HTMLElement): void {
|
||||
// Add new setting for Kanban card checkbox sync
|
||||
new Setting(containerEl)
|
||||
.setName("Enable Kanban card checkbox sync")
|
||||
.setDesc(
|
||||
"When enabled, dragging cards between Kanban columns will automatically update checkbox states of the cards in the Kanban board"
|
||||
)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.enableKanbanToFileSync)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.enableKanbanToFileSync = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
// Add new setting for auto-sync on Kanban open
|
||||
new Setting(containerEl)
|
||||
.setName("Auto-sync checkbox states on Kanban open")
|
||||
.setDesc(
|
||||
"When enabled, automatically sync all card checkbox states to match their columns when opening a Kanban board (runs once per session for performance)"
|
||||
)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.enableKanbanAutoSync)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.enableKanbanAutoSync = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
// NEW: Add setting for Kanban normalization protection
|
||||
new Setting(containerEl)
|
||||
.setName(
|
||||
"Protect custom checkbox states from Kanban normalization"
|
||||
)
|
||||
.setDesc(
|
||||
"When enabled, prevents the Kanban plugin from automatically converting custom checkbox states (like [/], [~]) to standard states ([x]). This preserves your custom state mappings."
|
||||
)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(
|
||||
this.plugin.settings.enableKanbanNormalizationProtection
|
||||
)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.enableKanbanNormalizationProtection =
|
||||
value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
// Add explanation
|
||||
const infoDiv = containerEl.createDiv({
|
||||
cls: "custom-checkbox-info",
|
||||
attr: {
|
||||
style: "background: var(--background-secondary-alt); padding: 10px; border-radius: 5px; margin: 10px 0;",
|
||||
},
|
||||
});
|
||||
|
||||
infoDiv.createEl("p", {
|
||||
text: "ℹ️ Custom Checkbox States Configuration:",
|
||||
attr: {
|
||||
style: "font-weight: bold; margin: 0 0 5px 0;",
|
||||
},
|
||||
});
|
||||
|
||||
infoDiv.createEl("p", {
|
||||
text: "Define which checkbox state should be used for each Kanban column. Common states include: [ ] (todo), [/] (in progress), [x] (completed), [>] (forwarded), [-] (cancelled).",
|
||||
attr: {
|
||||
style: "margin: 0 0 5px 0;",
|
||||
},
|
||||
});
|
||||
|
||||
// Display current mappings
|
||||
this.plugin.settings.kanbanColumnCheckboxMappings.forEach(
|
||||
(mapping, index) => {
|
||||
const mappingContainer = containerEl.createDiv({
|
||||
cls: "checkbox-mapping-container",
|
||||
attr: {
|
||||
style: "display: flex; gap: 10px; align-items: center; margin: 10px 0; padding: 10px; border: 1px solid var(--background-modifier-border); border-radius: 5px;",
|
||||
},
|
||||
});
|
||||
|
||||
// Column name input
|
||||
const columnInput = mappingContainer.createEl("input", {
|
||||
type: "text",
|
||||
value: mapping.columnName,
|
||||
attr: {
|
||||
placeholder: "Column Name",
|
||||
style: "flex: 1; padding: 5px;",
|
||||
},
|
||||
});
|
||||
|
||||
// Checkbox state input
|
||||
const checkboxInput = mappingContainer.createEl("input", {
|
||||
type: "text",
|
||||
value: mapping.checkboxState,
|
||||
attr: {
|
||||
placeholder: "[ ]",
|
||||
style: "width: 60px; padding: 5px; text-align: center;",
|
||||
},
|
||||
});
|
||||
|
||||
// Delete button
|
||||
const deleteButton = mappingContainer.createEl("button", {
|
||||
text: "Remove",
|
||||
cls: "mod-warning",
|
||||
attr: {
|
||||
style: "padding: 5px 10px;",
|
||||
},
|
||||
});
|
||||
|
||||
// Event listeners
|
||||
columnInput.addEventListener("change", async () => {
|
||||
this.plugin.settings.kanbanColumnCheckboxMappings[
|
||||
index
|
||||
].columnName = columnInput.value;
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
|
||||
checkboxInput.addEventListener("change", async () => {
|
||||
this.plugin.settings.kanbanColumnCheckboxMappings[
|
||||
index
|
||||
].checkboxState = checkboxInput.value;
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
|
||||
deleteButton.addEventListener("click", async () => {
|
||||
this.plugin.settings.kanbanColumnCheckboxMappings.splice(
|
||||
index,
|
||||
1
|
||||
);
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// Add new mapping button
|
||||
const addMappingButton = containerEl.createEl("button", {
|
||||
text: "Add Column Mapping",
|
||||
cls: "mod-cta",
|
||||
attr: {
|
||||
style: "margin: 10px 0;",
|
||||
},
|
||||
});
|
||||
|
||||
addMappingButton.addEventListener("click", async () => {
|
||||
this.plugin.settings.kanbanColumnCheckboxMappings.push({
|
||||
columnName: "",
|
||||
checkboxState: "[ ]",
|
||||
});
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
});
|
||||
|
||||
// Reset to defaults button
|
||||
const resetButton = containerEl.createEl("button", {
|
||||
text: "Reset to Defaults",
|
||||
cls: "mod-warning",
|
||||
attr: {
|
||||
style: "margin: 10px 0;",
|
||||
},
|
||||
});
|
||||
|
||||
resetButton.addEventListener("click", async () => {
|
||||
this.plugin.settings.kanbanColumnCheckboxMappings = [
|
||||
{ columnName: "Todo", checkboxState: "[ ]" },
|
||||
{ columnName: "In Progress", checkboxState: "[/]" },
|
||||
{ columnName: "Complete", checkboxState: "[x]" },
|
||||
{ columnName: "Done", checkboxState: "[x]" },
|
||||
];
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to update the progress bar view
|
||||
*/
|
||||
private updateProgressBarView(): void {
|
||||
const currentFile = this.app.workspace.getActiveFile();
|
||||
if (currentFile && this.plugin.sidebarView) {
|
||||
this.plugin.sidebarView.updateProgressBar(currentFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
19
styles.css
19
styles.css
|
|
@ -16,8 +16,7 @@ If your plugin does not need CSS, delete this file.
|
|||
max-height: 110px !important;
|
||||
} */
|
||||
|
||||
/* 1. Reset biến toàn cục quy định chiều cao tối thiểu */
|
||||
|
||||
|
||||
.task-progress-container {
|
||||
padding: 10px;
|
||||
margin-bottom: 10px;
|
||||
|
|
@ -301,11 +300,6 @@ If your plugin does not need CSS, delete this file.
|
|||
|
||||
.workspace-leaf-content[data-type="progress-tracker"] .view-content {
|
||||
overflow: hidden;
|
||||
padding-right: 12px;
|
||||
}
|
||||
|
||||
.workspace-leaf.progress-tracker-leaf, .workspace-leaf:has(.workspace-leaf-content[data-type="progress-tracker"]) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Thông báo Dataview nhỏ gọn */
|
||||
|
|
@ -323,6 +317,7 @@ If your plugin does not need CSS, delete this file.
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* Điều chỉnh chiều cao tối thiểu của sidebar */
|
||||
.workspace-leaf-content[data-type="progress-tracker"] {
|
||||
--sidebar-min-height: 67px !important;
|
||||
|
|
@ -353,13 +348,3 @@ If your plugin does not need CSS, delete this file.
|
|||
.workspace-leaf-content[data-type="progress-tracker"] .view-content {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.workspace-leaf.progress-tracker-leaf, .workspace-leaf:has(.workspace-leaf-content[data-type="progress-tracker"]) {
|
||||
min-width: 100%;
|
||||
}
|
||||
|
||||
/* Ensure content fits within constrained height */
|
||||
.progress-tracker-leaf .task-progress-container {
|
||||
padding: 8px;
|
||||
margin: 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue