mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-29 10:00:08 +00:00
407 lines
14 KiB
HTML
Executable File
407 lines
14 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<link rel="stylesheet" href="css/default.css">
|
|
|
|
<link rel="stylesheet" href="editor.css"/>
|
|
|
|
<style>
|
|
|
|
.add-row {
|
|
height: 1.2em !important;
|
|
}
|
|
|
|
</style>
|
|
|
|
<script src="lib/highlight.min.js"></script>
|
|
|
|
<script src="generic.js"></script>
|
|
<script src="editor.js"></script>
|
|
<script>
|
|
|
|
var editor
|
|
|
|
var setup = function(){
|
|
window.editor = {
|
|
__proto__: Outline,
|
|
}.setup(
|
|
document.querySelector('.editor')) }
|
|
|
|
</script>
|
|
</head>
|
|
<body onload="setup()">
|
|
<div class="editor" autofocus>
|
|
<!-- header -->
|
|
<div class="header"></div>
|
|
<!-- code -->
|
|
<textarea class="code">
|
|
- # Outline editor prototype
|
|
- An outline-based markdown editor experiment
|
|
- ### Infuences::
|
|
- Logseq
|
|
- Conboy (Nokia N900's Tomboy clone)
|
|
- Bonsai (on PalmOS)
|
|
- Google Keep
|
|
-
|
|
- // Seems that I unintentionally implemented quite a chunk of the markdown spec ;)
|
|
-
|
|
- ## Bugs:
|
|
focused:: true
|
|
- BUG: mobile browsers behave quite chaotically ignoring parts of the styling...
|
|
- FF:
|
|
- zooming on edited field
|
|
- normal textarea is not sized correctly
|
|
- General:
|
|
- side margins are a bit too large (account for toolbat to the right)
|
|
-
|
|
- ## ToDo:
|
|
- editor as a custom element / web component
|
|
- DONE data interface:
|
|
collapsed:: true
|
|
- the "natural" way to pass data is to use the same mechanism as `<textarea>` the problem is that we can't extend `HTMLTextAreaElement` as it can not have shadow dom (reject?)
|
|
- adding an explicit textarea element is an odd requirement (reject?)
|
|
- seems that the least bad way to go is to use the `value` attribute
|
|
- DONE API: directly mixin Outline?
|
|
- events
|
|
- test nesting...
|
|
-
|
|
- selection / multiple node selection (via shift+motion)
|
|
- copy/paste nodes/trees
|
|
- numbered lists: add counters to a depth of 6-7...
|
|
- _or find a way to make them repeat..._
|
|
- FEATURE: read-only mode
|
|
- auto-shift done blocks to the end of siblings... (option?)
|
|
- ...or should this be `sort:: done` -- i.e. sort children by done status??
|
|
- codeblock as a block
|
|
_...if only whitespace before/after clear it and style whole block..._
|
|
_...might be a good idea to do this with codeblock at start/end of block..._
|
|
- Code blocks and bullets:
|
|
- ```
|
|
code
|
|
```
|
|
- _bullet should be either in the middle of the block or at the first line of code (preferred)..._
|
|
- export html
|
|
- embed css
|
|
- cleanup html
|
|
- generate ideomatic html (???)
|
|
- style attrs (see: [attrs](#attributes))
|
|
- FEATURE: `collapse-children:: true` block option -- when loading collapse all immediate children
|
|
- FF: figure out a way to draw expand/collapse bullets without the use of CSS' `:has(..)`
|
|
- table inline editing a-la code editing -- click cell and edit directly...
|
|
- a way to make a block monospace (???)
|
|
- Nerd fonts (option???)
|
|
- smooth scrolling
|
|
- _...this is more complicated than adding `behavior: "smooth"` to `.scrollIntoView(..)` as scrolling animation will get interrupted by next user input..._
|
|
- need to cancel animation if things are moving too fast...
|
|
- make this generic (???)
|
|
- FEATURE? block templates...
|
|
collapsed:: true
|
|
- something like: `TPL: [_] <editable/> -- <editable/>`
|
|
- `TPL:` -- template marker
|
|
- `<editable/>` -- field marker
|
|
- each child node will copy the template and allow editing of only fields
|
|
- not clear how to handle template changes...
|
|
- JSON API
|
|
- cli
|
|
- Q: do we use \\t for indent? (option???)
|
|
- Q: persistent empty first/last node (a button to create a new node)?
|
|
- Q: should list bullets be on the same level as nodes or offset??
|
|
collapsed:: true
|
|
- A) justified to bullet:
|
|
* list item
|
|
* list item
|
|
block text
|
|
- B) justified to text _(current)_:
|
|
* list item
|
|
* list item
|
|
block text
|
|
- NOTE: this is only a problem if making list-items manually -- disable???
|
|
- empty item height is a bit off...
|
|
- search?
|
|
- _...not sure if search should be internal or external yet..._
|
|
- DONE make `---` block not show list bullets...
|
|
- DONE: undo: checkboxes and DONE??
|
|
collapsed:: true
|
|
_...this should be triggered by text change -- move current implementation to .__editedcode__()??..._
|
|
- DONE undo
|
|
- DONE crop: make path clickable
|
|
- DONE Q: crop: should we control crop via "crop-in"/"crop-out" instead of crop/uncrop??
|
|
- _crop-in/crop-out seems more natural..._
|
|
- DONE crop: show crop path (and depth)
|
|
- DONE over-travel pause -- when going fast over start/end stop...
|
|
- DONE focus:
|
|
collapsed:: true
|
|
- DONE `<editor>.autofocus`
|
|
- DONE `focused:: true` attr (`.text(..)`/`.json(..)`/`.load(..)`)
|
|
- DONE focusing editor -> focus focused block
|
|
- DONE identify a block:
|
|
collapsed:: true
|
|
- DONE index (flat)
|
|
- DONE path (index)
|
|
- DONE id
|
|
- _the id attr is done, but we still need to get the node via id_
|
|
- DONE pgup/pgdown/home/end buttons
|
|
- DONE FEATURE: "crop" -- view block tree separately...
|
|
- DONE unify attr parsing
|
|
collapsed:: true
|
|
- _now duplicated in `.parse(..)` and `.__code2html__(..)`_
|
|
- might be a good idea to add a special text parse stage and use in on both branches...
|
|
- DONE attrs in editor are not parsed correctly (see: [attrs](#attributes))
|
|
- DONE multiple attrs are not handled correctly (see: [attrs](#attributes))
|
|
- DONE call `.sync()` on all changes...
|
|
- DONE show list bullet if node is empty but edited...
|
|
collapsed:: true
|
|
- _...not sure which is best, so both options are available, see: `editor.css`_
|
|
- DONE Q: can we get the caret line in a textarea???
|
|
collapsed:: true
|
|
- _...this will fix a lot of issues with moving between blocks in edit mode..._
|
|
- DONE Q: can we place the cursor on item click where it was clicked before before the code expanded?
|
|
collapsed:: true
|
|
- for example
|
|
- #### Click in this line and see where the cursor goes
|
|
- _not sure how..._
|
|
- DONE click to select/edit node must retain click position in text...
|
|
- DONE checkbox navigation via `alt-<arrow>`
|
|
collapsed:: true
|
|
- _might be a good idea to include also TODO/DONE navigation -- not yet sure how to mark undone blocks (i.e. the ones marked with TODO in Logseg)..._
|
|
- toggle with `space`
|
|
- navigation auto-selects first checkbox
|
|
- DONE editor: backsapce/del at start/end of a block should join it with prev/next
|
|
- DONE editor: pressing enter in text edit mode should split text into two blocks
|
|
- DONE editor: shifting nodes up/down
|
|
- DONE Q: can we edit code in a code block directly? (a-la Logseq)
|
|
- DONE "percentage complete" in parent blocks with todo's nested
|
|
- DONE `.editor .outline:empty` view and behavior...
|
|
- DONE editor: semi-live update styles
|
|
- DONE do a better expand/collapse icons
|
|
- DONE loading from DOM -- fill textarea
|
|
- DONE focus management
|
|
- DONE mouse/touch controls
|
|
- DONE navigation
|
|
- DONE expand/collapse subtree
|
|
- DONE shift subtree up/down
|
|
- DONE create node
|
|
- DONE edit node
|
|
- DONE serialize/deserialize
|
|
- DONE add optional text styling to nodes
|
|
-
|
|
- ## Refactoring:
|
|
- Q: Implementation: JSON-based, DOM-based (current) or both?
|
|
- implement JSON-based
|
|
- compare and decide...
|
|
- Plugin architecture
|
|
- DONE basic structure
|
|
- plugin handler sequencing (see: `<editor>.setup(..)`)
|
|
- DONE plugin handler canceling (see: `<editor>.runPlugins(..)`)
|
|
- DONE Item parser (`.__code2html__(..)`)
|
|
collapsed:: true
|
|
- DONE split out
|
|
- DONE define a way to extend/stack parsers
|
|
- DONE Format parser/generator
|
|
collapsed:: true
|
|
- DONE split out
|
|
- DONE define api (see: `<editor>.__code2text__(..) / <editor>.__text2code__(..)`)
|
|
- CSS
|
|
- separate out settings
|
|
- separate out theming
|
|
- Actions -- move user actions (code in `.keyboard`) into methods
|
|
- Move to `keyboard.js`
|
|
- Q: do we need a concatenative API??
|
|
- `<block>.get() -> <block>`
|
|
- Docs
|
|
-
|
|
- ## Docs
|
|
- ### Controls
|
|
- ASAP: these need updating...
|
|
- | Key | Action |
|
|
| up | focus node above |
|
|
| down | focus node below |
|
|
| left | focus parent node |
|
|
| right | focus first child node |
|
|
| tab | indent node |
|
|
| s-tab | deindent node |
|
|
| s-pgup | shift node up |
|
|
| s-pgdown | shift node down |
|
|
| s-left | collapse node |
|
|
| s-right | expand node |
|
|
| c-left | prev checkbox |
|
|
| c-right | next checkbox |
|
|
| space | toggle current checkbox |
|
|
| a-x | toggle current element DONE |
|
|
| c-z | normal: undo |
|
|
| c-s-z | normal: redo |
|
|
| c | normal: crop current node |
|
|
| enter | normal: edit node |
|
|
| | edit: create node below |
|
|
| esc | crop: exit crop |
|
|
| | edit: exit edit mode |
|
|
- ### Formatting
|
|
- The formatting mostly adheres to the markdown spec with a few minor differences
|
|
-
|
|
- Styles:
|
|
- # Heading 1
|
|
- ## Heading 2
|
|
- ### Heading 3
|
|
- #### Heading 4
|
|
- ##### Heading 5
|
|
- ###### Heading 6
|
|
- Text
|
|
- Lists::
|
|
- bullet:
|
|
- a:
|
|
collapsed:: true
|
|
- bullets:
|
|
- in:
|
|
- very:
|
|
- deep:
|
|
- list:
|
|
- of:
|
|
- items:
|
|
- b
|
|
- c
|
|
- numbered#
|
|
- a
|
|
- b#
|
|
- x#
|
|
collapsed:: true
|
|
- bullets#
|
|
- in#
|
|
- very#
|
|
- deep#
|
|
- list#
|
|
- of#
|
|
- items#
|
|
- y
|
|
- z
|
|
- c
|
|
- > quote
|
|
- Notes
|
|
- NOTE: a note text
|
|
- NOTE:
|
|
- a root note can also be empty
|
|
- click on the outer border to edit root
|
|
- // C-style comment
|
|
- ; ASM-style comment
|
|
- XXX Highlight
|
|
- DONE Done (toggled via: `ctrl-d`)
|
|
- Basic inline *bold*, _italic_ and ~striked~
|
|
- Marking ==text==
|
|
- Code:
|
|
- Inline quoting `html <b>code</b>`
|
|
- code blocks
|
|
```javascript
|
|
var text = 'Hello, world!'
|
|
|
|
console.log(text)
|
|
```
|
|
- Line
|
|
- ---
|
|
- Markers: ASAP, BUG, FIX, HACK, STUB, WARNING, and CAUTION
|
|
- Basic task management
|
|
- [%] Completion status
|
|
- Inline [X] checkboxes [_]
|
|
- To do items/blocks
|
|
- [_] undone item
|
|
_(clicking the checkbox updates the item)_
|
|
- [X] done item
|
|
- [_] we can also add inline [x] checkboxes and states: [%]
|
|
- navigating checkboxes in view mode can be done via `ctrl-left` / `ctrl-right` and toggling is done via `space`
|
|
- links
|
|
- [link](about:blank)
|
|
- [local links](#attributes)
|
|
- https://example.com
|
|
- ./path/to/file /path/to -- _not supported yet_
|
|
- Tables
|
|
- | a | b | c |
|
|
| 1 | 2 | 3 |
|
|
| 11 | 22 | 33 |
|
|
- Symbols -- _should these be ligatures?_
|
|
- (i), (c), /!\, ...
|
|
- -- and ---
|
|
- Attributes:
|
|
id:: attributes
|
|
- collapsed
|
|
collapsed:: true
|
|
- a
|
|
- b
|
|
- c
|
|
- id
|
|
id:: node-with-id
|
|
- combined
|
|
id:: combined-several-ids
|
|
collapsed:: true
|
|
- a
|
|
- b
|
|
- c
|
|
-
|
|
- ---
|
|
- ### Playground for testing
|
|
- A
|
|
collapsed:: true
|
|
- a
|
|
- b
|
|
- c
|
|
- B
|
|
- d
|
|
- e
|
|
- C
|
|
- This is a line of text
|
|
- This is a set
|
|
text lines
|
|
- Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text Lots of text
|
|
- </textarea>
|
|
<!-- outline -->
|
|
<div class="outline" tabindex="0"></div>
|
|
<!-- toolbar (optional) -->
|
|
<!--div class="toolbar">
|
|
<button onclick="editor.deindent().focus()"><</button>
|
|
<button onclick="editor.indent().focus()">></button>
|
|
<button onclick="editor.Block('before').focus()" class="add-row">+</button>
|
|
<hr>
|
|
<button onclick="editor.Block('after').focus()" class="add-row">+</button>
|
|
<button onclick="editor.toggleCollapse()?.focus()">˅˄</button>
|
|
<button onclick="editor.remove()">×</button>
|
|
</div-->
|
|
</div>
|
|
|
|
<hr>
|
|
|
|
<button onclick="editor.dom.classList.toggle('show-click-zones')">show/hide click zones</button>
|
|
<button onclick="editor.dom.classList.toggle('block-offsets')">show/hide block offsets</button>
|
|
|
|
|
|
|
|
|
|
<hr>
|
|
|
|
<h1>Outline editor as web component</h1>
|
|
|
|
<outline-editor value="
|
|
- ## code as part of an attribute
|
|
- as long as "quotes" are sanitized in the html, this is the safest">
|
|
</outline-editor>
|
|
|
|
<hr>
|
|
|
|
<outline-editor>
|
|
<textarea>- ## code enclosed in `<textarea>` element
|
|
- code is treated as-is
|
|
- the only exception is the closing textarea tag</textarea>
|
|
</outline-editor>
|
|
|
|
<hr>
|
|
|
|
<outline-editor>
|
|
- ## raw outline editor element
|
|
- the children are not protected
|
|
- any html <elements> are going to be parsed by the browser
|
|
</outline-editor>
|
|
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|
|
<!-- vim:set ts=4 sw=4 : -->
|