Skip to content

⚠️ 📖 DRAFT: <text-editor>#115

Open
snuggs wants to merge 25 commits into
mainfrom
text-editor
Open

⚠️ 📖 DRAFT: <text-editor>#115
snuggs wants to merge 25 commits into
mainfrom
text-editor

Conversation

@snuggs

@snuggs snuggs commented Jul 21, 2017

Copy link
Copy Markdown
Member

@snuggs

snuggs commented Jul 23, 2017

Copy link
Copy Markdown
Member Author

@pachonk VERY interesting feature in the platform /cc @brandondees https://developer.mozilla.org/en/docs/Web/API/Document/execCommand

@snuggs

snuggs commented Jul 23, 2017

Copy link
Copy Markdown
Member Author

@pachonk are we interested in "medium style" editing?
image

@brandondees

Copy link
Copy Markdown
Collaborator

I don't love it, but then again I'm a vim user and I prefer markdown.... maybe it's progress, I don't know. The A11y treatment is key for stuff like this.

@brandondees

Copy link
Copy Markdown
Collaborator

that's very interesting to see there's a whole set of features for supporting this. how feasible is it to effectively polyfill those instead of creating yet another api?

@snuggs

snuggs commented Jul 23, 2017

Copy link
Copy Markdown
Member Author

@brandondees i mean do we care that much about Android browsers? Even Android users don't use the default browser for the most part. Usually use Chrome.

capture d ecran 2017-07-23 a 14 09 58

@grepsedawk

grepsedawk commented Jul 23, 2017 via email

Copy link
Copy Markdown
Collaborator

@snuggs

snuggs commented Jul 23, 2017

Copy link
Copy Markdown
Member Author

Exactly @pachonk. Great input

@brandondees

Copy link
Copy Markdown
Collaborator

d'oh, i was looking at MDN which says it's FF only. they really gotta figure out a better way to keep that info up to date...

so, no polyfill needed. let's do it.

@snuggs

snuggs commented Jul 23, 2017

Copy link
Copy Markdown
Member Author

@brandondees @pachonk @mrbernnz @janz93 @kurtcagle @dcchuck @halorium @tmornini comparison table for our <text-editor> WYSIWYG (Actually 400Bytes brotli compressed but that would be showing off :-) ):
capture d ecran 2017-07-23 a 19 10 57

@snuggs

snuggs commented Jul 23, 2017

Copy link
Copy Markdown
Member Author
<text-editor>
  <menu onclick=execute>
    <template name=actions>
      <button name={name} icon={icon} title={title}>{title}</button>
    </template>
  </menu>

  <article contenteditable>This is default text for article</article>
</text-editor>

<script defer>

Element `text-editor`

(class extends HTMLElement {

  execute (event, button = event.target, action = this.find (button.name)) {
    (HTMLButtonElement === button.constructor)
      && document.execCommand (action.command, false, action.value)
  }

  find (name) {
    for (var i = 0; i < this.actions.length; i++)
      if (name === this.actions [i].name)
          return this.actions [i]
  }

  get actions () {
    return [
      { icon: '¶', name: 'bold', title: 'Bold Text', command: 'bold' }
    , { icon: '¶', name: 'italic', title: 'Italicize Text', command: 'italic' }
    , { icon: '¶', name: 'underline', title: 'Underline Text', command: 'underline' }
    , { icon: '¶', name: 'left', title: 'Left Justify Text', command: 'justifyLeft' }
    , { icon: '¶', name: 'center', title: 'Center Justify Text', command: 'justifyCenter' }
    , { icon: '¶', name: 'right', title: 'Right Justify Text', command: 'justifyRight' }
    , { icon: '¶', name: 'strikethrough', title: 'Strikethrough Text', command: 'strikeThrough' }
    , { icon: '¶', name: 'paragraph', title: 'Convert Text to Paragraph', command: 'insertParagraph' }
    , { icon: '¶', name: 'ulist', title: 'Convert to Unordered List', command: 'insertUnorderedist' }
    , { icon: '¶', name: 'olist', title: 'Convert to Ordered List', command: 'insertOrderedist' }
    , { icon: '¶', name: 'line', title: 'Insert Horizontal Rule', command: 'insertHorizontalRule' }
    , { icon: '¶', name: 'link', title: 'Create URL Link', command: 'createLink' }
    , { icon: '¶', name: 'header', title: 'Create Header', command: 'formatBlock', value: '<h1>' }
    , { icon: '¶', name: 'subheader', title: 'Create Sub-Header', command: 'formatBlock', value: '<h2>' }
    ]
  }
})
</script>

@grepsedawk

Copy link
Copy Markdown
Collaborator

/bump
Hey, any [life] updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants