Commit Graph

134 Commits

Author SHA1 Message Date
Weston Ruter
2869e3a186 Administration: Remove deprecated unload event handlers and use pagehide (and pageshow) when appropriate.
Use `pagehide` event instead of `unload` in the following cases:

* For classic editor to release the post lock.
* In Text widget to rebuild editor after dragging widget to new location in classic widgets interface.
* To clear out the `window.name` when navigating away from a post preview.
* To suspend heartbeat, while also using `pageshow` event to resume as if it had been a focused tab in case page restored from bfcache. 

Also:

* Remove obsolete mobile cleanup code in `js/_enqueues/lib/gallery.js` (introduced in [9894]). Do same for `src/js/_enqueues/wp/media/models.js` (introduced in [22872]). See #22552.
* Remove obsolete Firefox-specific workaround in `js/_enqueues/wp/mce-view.js` from [39282]. See #38511.

Fixes #55491.
Props spenserhale, westonruter, adamsilverstein, azaozz, shawfactor, peterwilsoncc, swissspidy.
Built from https://develop.svn.wordpress.org/trunk@56809


git-svn-id: http://core.svn.wordpress.org/trunk@56321 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-10-09 21:31:27 +00:00
whyisjake
3dd9628aae Build/Test Tools: Enable JSDocs to be linted with ESLint.
As part of the [Javascript Inline Docs Initiative](https://make.wordpress.org/core/handbook/docs/inline/js/) this add some tooling to lint Javascript docblocks. Two new commands:

* `npm run lint:jsdoc`
* `npm run lint:jsdoc:fix`

The latter will run the linter and try to fix an possible issues automatically.

Fixes #43828.
Props netweb, atimmer, kamataryo, whyisjake.


Built from https://develop.svn.wordpress.org/trunk@48650


git-svn-id: http://core.svn.wordpress.org/trunk@48412 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-27 23:35:02 +00:00
Sergey Biryukov
001ffe81fb Docs: Improve inline comments per the documentation standards.
Includes minor code layout fixes for better readability.

See #48303.
Built from https://develop.svn.wordpress.org/trunk@47122


git-svn-id: http://core.svn.wordpress.org/trunk@46922 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-29 00:45:18 +00:00
Andrew Ozz
ee8813606d TinyMCE: fix adding of too many undo levels for wpviews. The HTML changes several times when a wpview is added. We only want one undo level. Also fixes cases when the cursor is next to an embeddable URL in the Text tab and the user switches to the Visual tab.
See #45307.
Built from https://develop.svn.wordpress.org/trunk@45631


git-svn-id: http://core.svn.wordpress.org/trunk@45442 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-12 03:25:55 +00:00
atimmer
bde558be2f Docs: Add file doc @output annotations.
These annotations make it clear to the reader of a JavaScript source
where the build process outputs to. These annotations can later be
integrated in a webpack configuration. This way there is one source of
truth.

The `build` folder is omitted from the paths, because a single JS file
shouldn't not be responsible of knowing where outputs in general will
end up at. A file only knows its output location relative to the
project.

Props adamsilverstein, herregroen, omarreiss, pento.
Fixes #44361.

Built from https://develop.svn.wordpress.org/trunk@43347


git-svn-id: http://core.svn.wordpress.org/trunk@43175 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-06-28 02:30:15 +00:00
Weston Ruter
fe2fda8cc2 Editor: Fix determining TinyMCE editor width when in inline mode instead of iframe mode.
See #40854.
Amends [41985].
Props aduth.
Fixes #42416 for trunk.

Built from https://develop.svn.wordpress.org/trunk@42390


git-svn-id: http://core.svn.wordpress.org/trunk@42219 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-12-13 05:17:48 +00:00
Weston Ruter
9093718b15 Editor: Specify maxwidth in parse-embed requests based on width of editor iframe so that TinyMCE view embeds fit, particularly in Text widgets.
See #40854, #34115.

Built from https://develop.svn.wordpress.org/trunk@41985


git-svn-id: http://core.svn.wordpress.org/trunk@41819 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-24 04:07:50 +00:00
Dominik Schilling
83853f9fd2 TinyMCE: Improve the previews for shortcodes.
Built from https://develop.svn.wordpress.org/trunk@41395


git-svn-id: http://core.svn.wordpress.org/trunk@41228 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-19 08:19:45 +00:00
Adam Silverstein
8a23b80b56 Docs: JSDoc improvements for namespaces.
Improve JS parsing of our inline JSDocs by introducing `@namespace`, `@lends` and `@memberOf`. Helps set the way for showing our JavaScript documentation on developer.wordpress.org, see https://meta.trac.wordpress.org/ticket/3063.

* Define all used namespaces using @namespace.
* Correctly specify in which namespace each class is using @memberOf.
* Define each usage of the extend function as a prototype assignment using @lends.
* Some comment blocks were moved to correct the parsing of certain definitions. 

Props herregroen, atimmer, netweb, SergeyBiryukov.  
Fixes #41682.

Built from https://develop.svn.wordpress.org/trunk@41351


git-svn-id: http://core.svn.wordpress.org/trunk@41184 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-08 18:42:49 +00:00
Andrew Ozz
c0399b4fde TinyMCE: Fix cursor position after updating a wpview node. Fix hiding the inline toolbar on editor blur.
Props iseulde, azaozz.
Fixes #40480 for trunk.
Built from https://develop.svn.wordpress.org/trunk@40481


git-svn-id: http://core.svn.wordpress.org/trunk@40357 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-04-19 22:10:42 +00:00
Andrew Ozz
69c29935d5 TinyMCE: improve the previews for embedded WordPress posts:
- Add option to force a sandbox iframe in wpview.
- Use it to show the embedded post preview.
- Remove the deprecated `wpembed` plugin.js

Fixes #39513.
Built from https://develop.svn.wordpress.org/trunk@40019


git-svn-id: http://core.svn.wordpress.org/trunk@39956 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-01-27 04:25:44 +00:00
Andrew Ozz
45f3ee380c TinyMCE: when inserting a wpview, place the caret after is so the user can continue typing without interruption.
Props iseulde.
Fixes #39337.
Built from https://develop.svn.wordpress.org/trunk@39903


git-svn-id: http://core.svn.wordpress.org/trunk@39840 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-01-15 02:41:40 +00:00
Ella Iseulde Van Dorpe
79b3576650 TinyMCE views: fix Firefox issues.
* Set focus before rendering to prevent reload in Firefox.
* Rerender views if they are unloaded.
* Remove timeout added in [29513].
* Fix argument in wp.mce.views.render.
* Empty views on hide. Missed in #36434.

Props gitlost, azaozz, iseulde.
Fixes #38511.


Built from https://develop.svn.wordpress.org/trunk@39282


git-svn-id: http://core.svn.wordpress.org/trunk@39222 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-17 20:32:32 +00:00
Drew Jaynes
5f4497f0af Docs: Fix multiple trivial typos throughout a variety of core files.
Props ottok.
Fixes #38489.

Built from https://develop.svn.wordpress.org/trunk@39051


git-svn-id: http://core.svn.wordpress.org/trunk@38993 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-31 06:28:32 +00:00
Andrew Ozz
af8eaef148 TinyMCE: add support for custom dashicon for wp.mce.View.setLoader().
Props procodewp.
Fixes #37900.
Built from https://develop.svn.wordpress.org/trunk@38774


git-svn-id: http://core.svn.wordpress.org/trunk@38717 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-11 00:56:29 +00:00
Andrew Ozz
101545cbb5 TinyMCE, wpView:
- Add the `wpview-wrap` class and pass third param to the getNodes() callback for back-compat.
- Attach the mutation observer that resizes a view iframe inside the iframe to minimize memory use/leaks.
- Remove the `wp-mce-view-unbind` event. It has never been particularly reliable and now it doesn't fire when the user deletes a view by typing or pasting over it.
- Restore changing of a view iframe body classes when the editor body classes change.

Props iseulde, azaozz.
Fixes #36434.
Built from https://develop.svn.wordpress.org/trunk@38158


git-svn-id: http://core.svn.wordpress.org/trunk@38099 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-26 23:13:28 +00:00
Andrew Ozz
59c1e02c84 TinyMCE, wpView: bail early when the iframe node is not attached to the DOM. We can't load any HTML in it as here is no iframe.contentWindow in these cases.
See #36434.
Built from https://develop.svn.wordpress.org/trunk@38157


git-svn-id: http://core.svn.wordpress.org/trunk@38098 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-26 22:06:28 +00:00
Ella Iseulde Van Dorpe
6e72bc4ec5 TinyMCE: use new non-editable implementation
Use TinyMCE's implementation of `contenteditable="false"` for views.

First pass.

See #36434.


Built from https://develop.svn.wordpress.org/trunk@37446


git-svn-id: http://core.svn.wordpress.org/trunk@37414 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-17 18:49:30 +00:00
Andrew Ozz
4cdddd401a TinyMCE:
- Sanitize and render HTML in captions when showing a gallery preview (wpView).
- Encode/escape HTML entered in the text field in the wpLink dialog.

Props iseulde, kraftbj, jnylen0, shawarkhan.
Fixes #32616.
Built from https://develop.svn.wordpress.org/trunk@35341


git-svn-id: http://core.svn.wordpress.org/trunk@35307 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-21 20:38:26 +00:00
Ella Iseulde Van Dorpe
ef01315cac TinyMCE: make sure markers are removed after first init
This is only relevant to non embeddable URLs.
After first init, markers were set but not removed,
causing an edited URL to revert when switching to text mode
or any paragraph after the URL to just contain that URL.

Fixes #33954.

Built from https://develop.svn.wordpress.org/trunk@35216


git-svn-id: http://core.svn.wordpress.org/trunk@35182 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-16 05:43:26 +00:00
Ella Iseulde Van Dorpe
926006ea56 TinyMCE: views: correct cursor position after paste
Fixes #33174.

Built from https://develop.svn.wordpress.org/trunk@33484


git-svn-id: http://core.svn.wordpress.org/trunk@33451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-29 13:49:24 +00:00
Ella Iseulde Van Dorpe
63dc60ee7b JSHint for [33426]
Oops. :|

See #33096.

Built from https://develop.svn.wordpress.org/trunk@33428


git-svn-id: http://core.svn.wordpress.org/trunk@33395 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-26 18:18:24 +00:00
Ella Iseulde Van Dorpe
d44c684599 TinyMCE: views: use media setting to get post ID
Also fix dependency declarations and confusing variable names.

Props rhurling.
Fixes #33096.

Built from https://develop.svn.wordpress.org/trunk@33426


git-svn-id: http://core.svn.wordpress.org/trunk@33393 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-26 10:11:24 +00:00
Ella Iseulde Van Dorpe
1ab119798c TinyMCE: views: make sure gallery captions update
Part props dmsnell.
Fixes #32779.

Built from https://develop.svn.wordpress.org/trunk@33338


git-svn-id: http://core.svn.wordpress.org/trunk@33310 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-20 23:56:25 +00:00
Ella Iseulde Van Dorpe
00e4f35300 TinyMCE: wpviews: cache iframe heights
Cache iframe heights per instance so it can be reused. This will prevent to content from moving in the editor when undoing or redoing changes.

Fixes #32593.

Built from https://develop.svn.wordpress.org/trunk@32711


git-svn-id: http://core.svn.wordpress.org/trunk@32681 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-08 21:32:27 +00:00
Ella Iseulde Van Dorpe
e9ac7f5164 TinyMCE: views: fix typo in createInstance
This prevented instances from being reused.

Fixes #32591.

Built from https://develop.svn.wordpress.org/trunk@32710


git-svn-id: http://core.svn.wordpress.org/trunk@32680 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-08 19:54:25 +00:00
Andrew Ozz
4f9682f39e TinyMCE wpView: preserve HTML wrapped in shortcodes.
Fixes #32078.
Built from https://develop.svn.wordpress.org/trunk@32678


git-svn-id: http://core.svn.wordpress.org/trunk@32648 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-01 18:09:26 +00:00
Andrew Ozz
60706015e1 Revert editing of video embed parameters in the media modal, [31620] and [31626] for now. Plan on revisiting in 4.3.
Props iseulde. Fixes #31139, fixes #32006.
Built from https://develop.svn.wordpress.org/trunk@32258


git-svn-id: http://core.svn.wordpress.org/trunk@32229 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-21 22:41:26 +00:00
Andrew Ozz
f003efc8aa TinyMCE wpView: ensure contentNode is passed to all callbacks.
Props iseulde. Fixes #31669.
Built from https://develop.svn.wordpress.org/trunk@32255


git-svn-id: http://core.svn.wordpress.org/trunk@32226 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-21 18:36:24 +00:00
Andrew Ozz
541573b378 TinyMCE wpView: resize sandbox iframes on load. Fixes a problem with resizing after all images are loaded.
Props iseulde, mattheu. Fixes #31480.
Built from https://develop.svn.wordpress.org/trunk@32056


git-svn-id: http://core.svn.wordpress.org/trunk@32035 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-06 18:55:28 +00:00
Andrew Ozz
0186bbcb95 TinyMCE wpView:
- Fix editor undo levels.
- Remove views and markers in the DOM before serialization.
- Unbind views before removing them on hide.
- Empty the content in the timeout, so it doesn't render iframes twice.
Props iseulde. Fixes #31669.
Built from https://develop.svn.wordpress.org/trunk@32022


git-svn-id: http://core.svn.wordpress.org/trunk@32001 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-04 23:00:26 +00:00
Andrew Ozz
c545c63606 TinyMCE: always focus the editor after using the floated toolbar.
Props iseulde. Fixes #30619.
Built from https://develop.svn.wordpress.org/trunk@31972


git-svn-id: http://core.svn.wordpress.org/trunk@31951 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-01 21:50:27 +00:00
Andrew Ozz
036f131b14 TinyMCE wpViews: fix typos in the conditional checking which stylesheets to import.
Props mattheu. See #31464.
Built from https://develop.svn.wordpress.org/trunk@31757


git-svn-id: http://core.svn.wordpress.org/trunk@31738 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-12 20:08:27 +00:00
Andrew Ozz
04494a6c32 TinyMCE wpViews: always import the non-default editor styles in the sandbox iframe in views.
Props iseulde, mattheu. Fixes #31464.
Built from https://develop.svn.wordpress.org/trunk@31742


git-svn-id: http://core.svn.wordpress.org/trunk@31723 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-12 01:05:54 +00:00
Andrew Ozz
b5f1514b54 TinyMCE: improve setting of the sandboxing iframe inside a view.
Props mattheu, iseulde. Fixes #31412.
Built from https://develop.svn.wordpress.org/trunk@31740


git-svn-id: http://core.svn.wordpress.org/trunk@31721 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-11 23:53:26 +00:00
Andrew Ozz
cb185ed5bc TinyMCE wpViews: use the real attribute value instead of the cached jQuery data. Fixes updating of the wpView text strings.
Props iseulde. Fixes #31601.
Built from https://develop.svn.wordpress.org/trunk@31731


git-svn-id: http://core.svn.wordpress.org/trunk@31712 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-11 22:40:28 +00:00
Andrew Ozz
6e14ff9234 TinyMCE:
- Abstract the code for creating floating toolbars.
- Introduce `editor.wp` namespace to hold exported methods from our plugins.
- Create the wpView toolbar(s) with the new method. This makes them work the same as the image toolbar: shortcuts, esc key, etc.
Props iseulde. See #30619.
Built from https://develop.svn.wordpress.org/trunk@31725


git-svn-id: http://core.svn.wordpress.org/trunk@31706 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-11 19:12:28 +00:00
Andrew Ozz
15ec9441cb TinyMCE wpView: decode HTML entities before trying to match the wpView text string. Props iseulde. See #31412.
Built from https://develop.svn.wordpress.org/trunk@31689


git-svn-id: http://core.svn.wordpress.org/trunk@31670 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-09 19:09:27 +00:00
Andrew Ozz
f02a17e2a1 TinyMCE wpView: improve unbinding of mutationObserver in nested iframes. Props iseulde. See #31412.
Built from https://develop.svn.wordpress.org/trunk@31667


git-svn-id: http://core.svn.wordpress.org/trunk@31648 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-07 16:53:27 +00:00
Andrew Ozz
36610e072b TinyMCE wpView: revert decoding of HTML entities. Doesn't work in old IE and needs to be more selective. Keep the change from .html() to .text() when getting the content of a node. See #31412.
Built from https://develop.svn.wordpress.org/trunk@31621


git-svn-id: http://core.svn.wordpress.org/trunk@31602 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-05 12:36:28 +00:00
Scott Taylor
cc953717b7 Allow inline editing of width and height parameters while previewing an embed in the media modal:
* Use `wp.shortcode()` instead of manually constructing a shortcode in `views/embed/link`
* Allow a URL to transition to a shortcode (and vice versa) when returning an embed to TinyMCE
* In `WP_Embed`, store the last URL and last set of attributes requested in class properties
* `wp_ajax_parse_embed()`, allow `[embed]`s to have attributes. Return `attr` in the response.

This is a first pass to allow broad testing with recent MCE view changes. 

See #31139.

Built from https://develop.svn.wordpress.org/trunk@31620


git-svn-id: http://core.svn.wordpress.org/trunk@31601 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-05 06:00:26 +00:00
Andrew Ozz
810df170e7 TinyMCE wpView: decode HTML entities before trying to insert view markers. Props iseulde. See #31412.
Built from https://develop.svn.wordpress.org/trunk@31612


git-svn-id: http://core.svn.wordpress.org/trunk@31593 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-04 20:35:27 +00:00
Andrew Ozz
5aae51144d TinyMCE wpView: update the "update" method. Props iseulde. See #31412.
Built from https://develop.svn.wordpress.org/trunk@31586


git-svn-id: http://core.svn.wordpress.org/trunk@31567 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-27 22:29:26 +00:00
Andrew Ozz
a226da32d3 TinyMCE: wpView improvements: introduce getText() and remove() methods, improved getInstance(), better docs. Props iseulde. See #31412.
Built from https://develop.svn.wordpress.org/trunk@31559


git-svn-id: http://core.svn.wordpress.org/trunk@31540 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-26 19:32:24 +00:00
Andrew Ozz
5f27c59f49 TinyMCE: wpView improvements: remove the (obsolete) get/setViewText methods. Update stopping/pausing of multiple ME media players. Props iseulde. See #31412.
Built from https://develop.svn.wordpress.org/trunk@31548


git-svn-id: http://core.svn.wordpress.org/trunk@31529 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-26 00:31:31 +00:00
Andrew Ozz
b799bd8e33 TinyMCE: wpView improvements:
- Better structure, simpler "view" registration, better extensibility.
- Better inline documentation.
- Don't show a placeholder for pasted link until we know the link is "embeddable'.
And many more improvements. Props iseulde. See #31412.
Built from https://develop.svn.wordpress.org/trunk@31546


git-svn-id: http://core.svn.wordpress.org/trunk@31527 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-25 23:13:25 +00:00
Andrew Ozz
0fa4845eec TinyMCE wpView: don't insert nested paragraphs when inserting embeddable URLs. Props iseulde, fixes #29526.
Built from https://develop.svn.wordpress.org/trunk@31485


git-svn-id: http://core.svn.wordpress.org/trunk@31466 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-20 23:17:27 +00:00
Andrew Ozz
5715db82d4 TinyMCE wpView: fire nodeChanged when an embedded iframe is resized so we can adjust the editor height and other UI components. Props iseulde, fixes #30646.
Built from https://develop.svn.wordpress.org/trunk@31466


git-svn-id: http://core.svn.wordpress.org/trunk@31447 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-15 18:19:27 +00:00
Helen Hou-Sandí
fa053ea65b MCE views: Always refresh the view after updating a gallery.
This allows things like caption changes to be synced, as they are tied to the attachment and not the shortcode.

props iseulde.
fixes #31239.

Built from https://develop.svn.wordpress.org/trunk@31343


git-svn-id: http://core.svn.wordpress.org/trunk@31324 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-05 20:12:22 +00:00
Andrew Ozz
d16c8cf1fc TinyMCE: update the wpView toolbar to look the same as the new image toolbar.
Fixes #30561.
Built from https://develop.svn.wordpress.org/trunk@30694


git-svn-id: http://core.svn.wordpress.org/trunk@30684 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-02 00:26:22 +00:00