* Add utility functions for saving and restoring the caret location
Implement surroundNoSplitting
Clarify surroundNoSplitting comments
Start implementing surroundSplitting and triggerIfSimpleInput
Fix after rebase
Implement findBefore / findAfter in lib/surround
* to merge adjacent nodes into the surrounding nodes
Use new prettier settings with lib/{location,surround}
Fix imports that I missed to rename
Add some tests for find-adjacent
Split find-within from find-adjacent
Normalize nodes after insertion in surroundNoSplitting
Do not deep clone surroundNode
-> no intention of supporting deep nodes, as normalization would be impossible
Add some tests concerning nested surrounding nested nodes
Select surroundedRange after surrounding
Fix ascendWhileSingleInline
A flawed first surround/trigger implementation
Move trigger out of lib/surround
Implement Input Manager as a way to handle bold on empty selection
Switch bold button away from execCommand
Pass in Matcher instead of selector to find-adjacent and surroundNoSplitting
* Also adds a failing test for no-splitting
Refactor find-adjacent
* add failing test when findBefore's nodes have different amounts of
child nodes
Change type signature of find-adjacent methods to more single-concern
Add test for surrounding where adjacent block becomes three Text elements
Make nodes found within surrounded range extend the ranges endOffset
Add base parameter to surroundNoSplitting to stop ascending beyond container
Stop surrounding from bubbling beyond base in merge-match
Make all tests pass
Add some failing tests to point to future development
Add empty elements as constant
Implement a broken version of unsurround
Even split text if it creates zero-length texts
-> they are still valid, despite what Chromium says
Rename {start,end} to {start,end}Container
Add more unit tests with surround after a nested element
Set endOffset after split-off possibly zero length text nodes
Deal with empty elements when surrounding
Only include split off end text if zero length
Use range anchors instead off calcluating surroundedRange from offsets
* this approach allows for removal of base elements when unsurrounding
Comment out test which fail because of jsdom bugs
We'll be able to enable them again after Jest 28
Make the first unsurround tests pass
Add new failing test for unsurround text within tag
Fix unsurround
Test is deactivated until Jest 28
Rewrite input-manager and trigger callback after insertion
Avoid creating zero length text nodes by using insertBefore when appropriate
Implement matches vs keepMatches
Make shadow root and editable element available on component tree
Make WithState work with asynchronous updater functions
Add new Bold/Italic/UnderlineButton using our logic
Add failing test for unsurrounding
* Move surround/ to domlib
* Add jest dependency
* Make find-within return a sum type array rather than two arrays
* Use FoundMatch sum-type for find-above (and find-within)
* Fix issue where elements could be cleared twice
* if they are IN the range.endContainer
* Pass remaining test
* Add another failing test
* Fix empty text nodes being considered for surrounding
* Satisfy svelte check
* Make on more type correct
* Satisfy remaining tests
* Add missing copyright header
It's a tiny library that has not been updated in years, and it was
leading to a warning on startup:
DeprecationWarning: invalid escape sequence \W
return re.sub("\W+", "", string)
Merging note: the typing changes were fixed in a separate PR.
* Put rootDirs into subprojects
- typings do not work for any ts or svelte files
- if we set the 'rootDirs' in ts/tsconfig.json to '../bazel-bin/ts' and then inherit
them from e.g. editor, the root will be changed to '../../bazel-bin/ts',
however editor needs look in '../../bazel-bin/ts/editor' instead.
* Rename i18n and i18n_helpers to i18n-generated and i18n
- This way, we can restrict the awkwardness of importing files outside
the ts directory within lib
* Fix missing typing of i18n and backend_proto by adding back symlinks
* Split up i18n-generated into i18n-{translate,modules}
* Change i18n from singleton to functions
* Revert "Put rootDirs into subprojects"
This partially reverts commit e1d4292ce3979e7b7ee21bf3951b8a462d45c29c.
It seems like this might not be necessary after all.
However some other change made on this branch seems to have fixed
the .svelte.d.ts imports
* Introduce i18n-bundles to remove circular import
There was a circular import i18n.ts <-> i18n-translate.ts
* Create own directory for i18n
* Move lib/i18n/translate to lib/translate
* This restores tree shaking
* Update tsconfig libs and module
* es2018-2020 have wide support on all modern browsers including
* Switch bundles and langs inside i18n to variables again
* Add missing copyright header
* Rename translate.ts to ftl.ts
* Remove the symlinks again
I added them to fix to have completion for tr, however this would have
also have meant to abandon the tree shaking.
As we want to have tree shaking, it's also not necessary to have the
symlinks anymore
* Revert "Update tsconfig libs and module"
This reverts commit 0a96776a475e9901c1f9f3407c726d1d002fb9ef.
* move withCollapsedWhitespace back to i18n/utils
* Add back /ts as in rootDirs
The nice thing about the symlink approach is that it allowed tsc -b
to function without any changes to the tsconfig.json file, but it meant
there were extra links we had to maintain. So instead, we just add an
extra rootDirs entry, and add two commented-out lines that can be
uncommented when wanting to build with tsc directly.
ts_library() is deprecated and will presumably be dropped from a
future rules_nodejs, and it wasn't working with the jest tests
after updating, so we switch over to ts_project().
There are some downsides:
- It's a bit slower, as the worker mode doesn't appear to function
at the moment.
- Getting it working with a mix of source files and generated files
was quite tricky, especially as things behave differently on Windows,
and differently when editing with VS Code. Solved with a small patch
to the rules, and a wrapper script that copies everything into the
bin folder first. To keep VS Code working correctly as well, the built
files are symlinked into the source folder.
- TS libraries are not implicitly linked to node_modules, so they
can't be imported with an absolute name like "lib/proto" - we need
to use relative paths like "../lib/proto" instead. Adjusting "paths"
in tsconfig.json makes it work for TS compilation, but then it fails
at the esbuild stage. We could resolve it by wrapping the TS
libraries in a subsequent js_library() call, but that has the downside
of losing the transient dependencies, meaning they need to be listed
again. Alternatively we might be able to solve it in the future by
adjusting esbuild, but for now the paths have been made relative to
keep things simple.
Upsides:
- Along with updates to the Svelte tooling, Svelte typing has improved.
All exports made in a Svelte file are now visible to other files that
import them, and we no longer rebuild the Svelte files when TS files
are updated, as the Svelte files do no type checking themselves, and
are just a simple transpilation. Svelte-check now works on Windows again,
and there should be no errors when editing in VS Code after you've
built the project. The only downside seems to be that cmd+clicking
on a Svelte imports jumps to the .d.ts file instead of the original now;
presumably they'll fix that in a future plugin update.
- Each subfolder now has its own tsconfig.json, and tsc can be called
directly for testing purposes (but beware it will place build products
in the source tree): ts/node_modules/.bin/tsc -b ts
- We can drop the custom esbuild_toolchain, as it's included in the
latest rules_nodejs.
Other changes:
- "image_module_support" is moved into lib/, and imported with
<reference types=...>
- Images are now imported directly from their npm package; the
extra copy step has been removed.
Windows users may need to use "bazel clean" before building this,
due to old files lying around in the build folder.
Switching to lodash-es caused Jest to fail. The standard Jest workflow
would be to transpile things with Bazel, but we can do it faster by
bundling with esbuild.
the log in lib.test.ts has revealed numbers are being set as Long instead
of JS numbers, and the published workaround for it is not working :-(
- try out bootstrap modals - they're not perfect, but let's see how
they go for now. Won't be hard to switch to bridge commands if required.
- handle adding/renaming/removing
- add a class to manage the state
It looks like the templated_args change only masked the error last time;
Jest seems broken on Windows with both the patched .24 version, latest
stable, and the new beta version too, presumably because symlinks are
being handled differently on Windows somehow. It might be possible to
hack around the issue by patching the following file, but I'm not sure:
https://github.com/facebook/jest/blob/master/packages/jest-haste-map/src/crawlers/node.ts
Instead of generating a fluent.proto file with a giant enum, create
a .json file representing the translations that downstream consumers
can use for code generation.
This enables the generation of a separate method for each translation,
with a docstring that shows the actual text, and any required arguments
listed in the function signature.
The codebase is still using the old enum for now; updating it will need
to come in future commits, and the old enum will need to be kept
around, as add-ons are referencing it.
Other changes:
- move translation code into a separate crate
- store the translations on a per-file/module basis, which will allow
us to avoid sending 1000+ strings on each JS page load in the future
- drop the undocumented support for external .ftl files, that we weren't
using
- duplicate strings in translation files are now checked for at build
time
- fix i18n test failing when run outside Bazel
- drop slog dependency in i18n module
Committing for reference; will roll back afterwards.
This adds approximately 150k to the bundled .js file in release mode.
html-sanitizer might be useful to replace our custom paste filtering
code in the future, but for now I'm not sure it's worth the extra
page load time over doing the filtering in Rust.
Running and testing should be working on the three platforms, but
there's still a fair bit that needs to be done:
- Wheel building + testing in a venv still needs to be implemented.
- Python requirements still need to be compiled with piptool and pinned;
need to compile on all platforms then merge
- Cargo deps in cargo/ and rslib/ need to be cleaned up, and ideally
unified into one place
- Currently using rustls to work around openssl compilation issues
on Linux, but this will break corporate proxies with custom SSL
authorities; need to conditionally use openssl or use
https://github.com/seanmonstar/reqwest/pull/1058
- Makefiles and docs still need cleaning up
- It may make sense to reparent ts/* to the top level, as we don't
nest the other modules under a specific language.
- rspy and pylib must always be updated in lock-step, so merging
rspy into pylib as a private module would simplify things.
- Merging desktop-ftl and mobile-ftl into the core ftl would make
managing and updating translations easier.
- Obsolete scripts need removing.
- And probably more.